derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

`cargo test` fails in package named "core"

Open abau opened this issue 3 years ago • 1 comments

In the following project,

  • Cargo.toml:
[workspace]
members = ["core"]
  • core/Cargo.toml:
[package]
name = "core"
version = "0.1.0"
edition = "2021"

[dependencies]
derive_more = "0.99"
  • core/src/lib.rs:
use derive_more::Add;

#[derive(Add)]
pub struct Foo(u32);

... cargo check works fine, but cargo test gives:

error[E0433]: failed to resolve: could not find `ops` in `core`
 --> /home/xxx/core/src/lib.rs:3:10
  |
3 | #[derive(Add)]
  |          ^^^ could not find `ops` in `core`
  |
  = note: this error originates in the derive macro `Add` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.

cargo test works fine if package is not named core.

abau avatar Dec 31 '21 19:12 abau

If you know a way to fix this, feel free to make a PR. Otherwise, maybe just don't call your crate the same as one from the standard library?

JelteF avatar Jan 01 '22 13:01 JelteF

@JelteF we can fix this by referring ::derive_more::core in the expansion rather than just ::core. A little bit more of hygiene.

tyranron avatar Dec 22 '23 12:12 tyranron