`impl ... for Box<CoreType>` in alloc should not require `#[cfg(not(test))]`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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 https://github.com/rust-lang/rust/issues/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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read library/alloc/src/ffi/c_str.rs and the surrounding #[cfg(not(test))] impl; then trace how alloc is compiled during tests and compare the issue-87534 behavior. Done means the impl no longer needs the workaround and the multi-configuration failure is either resolved or documented clearly for new alloc trait implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100