Open
Description
library/alloc/src/ffi/c_str.rs
has:
#[cfg(not(test))]
#[stable(feature = "box_from_c_str", since = "1.17.0")]
impl From<&CStr> for Box<CStr> {
As far as I can tell, #[cfg(not(test))]
is a workaround for something like #87534, as evidenced by error messages like:
note: the crate `alloc` is compiled multiple times, possibly with different configurations
alloc
is being compiled a second time as part of tests, and the two compilations are conflicting.
-
This workaround shouldn't be necessary.
-
This should be much better documented, so it doesn't send people on multi-hour debugging adventures when they try to write new trait impls in
alloc
.
Metadata
Metadata
Assignees
Labels
Area: Documentation for any part of the project, including the compiler, standard library, and toolsCategory: This is a bug.Call for partcipation: This issues needs some investigation to determine current statusRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Add `#[cfg(not(test))]` to some impls to work around rust-lang#135100
Add `#[cfg(not(test))]` to some impls to work around rust-lang#135100
bjorn3 commentedon Jan 4, 2025
This is also necessary for all lang item definitions outside of libcore. For libcore it isn't necessary because all "unit" tests have been moved into a separate crate in
library/core/tests
(core_tests). For liballoc and libstd some are inlibrary/alloc/tests
andlibrary/std/tests
, but others are in liballoc and libstd directly because they are testing non-public functions and accessing non-public fields.By the way the current construction also has other issues. We are depending on cargo compiling the libcore that is a direct dependency with the exact same flags and rustc version as the one libtest from the sysroot depends on to avoid getting an error about duplicate lang items. With rustbuild in practice this works fine, but I haven't been able to exactly match the flags in cg_clif's test suite. As such I had to patch core_tests to be an entirely separate cargo package which doesn't depend on libcore and I can't run liballoc's and libstd's test suite at all.
Add `#[cfg(not(test))]` to some impls to work around rust-lang#135100
Add `#[cfg(not(test))]` to some impls to work around rust-lang#135100
Add `#[cfg(not(test))]` to some impls to work around rust-lang#135100
Add `#[cfg(not(test))]` to some impls to work around rust-lang#135100
Add `#[cfg(not(test))]` to some impls to work around rust-lang#135100
86 remaining items