Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo test fails in package named "core" #180

Closed
abau opened this issue Dec 31, 2021 · 2 comments · Fixed by #327
Closed

cargo test fails in package named "core" #180

abau opened this issue Dec 31, 2021 · 2 comments · Fixed by #327
Assignees
Milestone

Comments

@abau
Copy link

abau commented Dec 31, 2021

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 abau changed the title cargo test fails in when package is named "core" cargo test fails in package named "core" Dec 31, 2021
@JelteF
Copy link
Owner

JelteF commented Jan 1, 2022

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 JelteF closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2023
@tyranron tyranron added this to the 1.0.0 milestone Dec 22, 2023
@tyranron tyranron self-assigned this Dec 22, 2023
@tyranron
Copy link
Collaborator

tyranron commented Dec 22, 2023

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

@tyranron tyranron reopened this Dec 22, 2023
tyranron added a commit that referenced this issue Dec 26, 2023
## Synopsis

See #180 (comment)
for details.

At the moment, compilation fails in a local crate `core` is present in
workspace or some another crate is renamed as `core`.




## Solution

Use `::derive_more::core` instead of `::core` in macro expansions.




Co-authored-by: Jelte Fennema-Nio <github-tech@jeltef.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants