rust-lang / wg-cargo-std-aware

Repo for working on "std aware cargo"
133 stars 8 forks source link

duplicate lang item if `#![feature(test)]` is enabled #80

Open skyzh opened 2 years ago

skyzh commented 2 years ago

Minimum reproducible step:

cargo new --lib test-build-std

lib.rs:

#![feature(test)]
extern crate test;

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        let result = 2 + 2;
        assert_eq!(result, 4);
    }
}
cargo build -Zbuild-std --target aarch64-apple-darwin

Then there are a lot of errors in console...

error: duplicate lang item in crate `core` (which `std` depends on): `const_ptr`.
  |
  = note: the lang item is first defined in crate `core` (which `std` depends on)
  = note: first definition in `core` loaded from /Users/skyzh/Work/test-build-std/target/aarch64-apple-darwin/debug/deps/libcore-ba459098a3dc74d8.rmeta
  = note: second definition in `core` loaded from /Users/skyzh/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-dd6de681850a671c.rlib

error: duplicate lang item in crate `core` (which `std` depends on): `mut_ptr`.
  |
  = note: the lang item is first defined in crate `core` (which `std` depends on)
  = note: first definition in `core` loaded from /Users/skyzh/Work/test-build-std/target/aarch64-apple-darwin/debug/deps/libcore-ba459098a3dc74d8.rmeta
  = note: second definition in `core` loaded from /Users/skyzh/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-dd6de681850a671c.rlib

Once feature test is removed, everything compiles...

Thanks for investigating into this!