invalid suggestions when the name could not be resolved in derive macro output
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
// cargo new banana
// cd banana
// cargo add rkyv@0.8.8
// cat src/main.rs
#[derive(rkyv::bytecheck::CheckBytes)]
#[repr(u8)]
enum Fruit { Apple, Banana }
fn main() {
println!("Hello, world!");
}
Current output
error[E0433]: failed to resolve: could not find `bytecheck` in the list of imported crates
--> src/main.rs:1:10
|
1 | #[derive(rkyv::bytecheck::CheckBytes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `bytecheck` in the list of imported crates
|
= note: this error originates in the derive macro `rkyv::bytecheck::CheckBytes` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this crate
|
1 + use rkyv::bytecheck;
|
error[E0433]: failed to resolve: could not find `bytecheck` in the list of imported crates
--> src/main.rs:1:10
|
1 | #[derive(rkyv::bytecheck::CheckBytes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `bytecheck` in the list of imported crates
|
= note: this error originates in the derive macro `rkyv::bytecheck::CheckBytes` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this crate
|
1 + use rkyv::rancor;
|
and then after adding use rkyv::bytecheck:
error[E0433]: failed to resolve: could not find `bytecheck` in the list of imported crates
--> src/main.rs:3:10
|
3 | #[derive(rkyv::bytecheck::CheckBytes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `bytecheck` in the list of imported crates
|
= note: this error originates in the derive macro `rkyv::bytecheck::CheckBytes` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these crates
|
1 + use crate::bytecheck;
|
1 + use rkyv::bytecheck;
|
error[E0433]: failed to resolve: could not find `bytecheck` in the list of imported crates
--> src/main.rs:3:10
|
3 | #[derive(rkyv::bytecheck::CheckBytes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `bytecheck` in the list of imported crates
|
= note: this error originates in the derive macro `rkyv::bytecheck::CheckBytes` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these crates
|
1 + use crate::bytecheck::rancor;
|
1 + use rkyv::rancor;
|
warning: unused import: `rkyv::bytecheck`
--> src/main.rs:1:5
|
1 | use rkyv::bytecheck;
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
Desired output
Perhaps in this case use-ing crates should not be suggested. What's even weirder is the compiler suggesting an import of rancor which is unrelated to the error!
Rationale and extra context
It looks like for this derive macro to be usable the crate must be made available as a proper crate (i.e. --extern or extern crate.)
Other cases
Rust Version
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
and
rustc 1.84.0-nightly (b19329a37 2024-11-21)
binary: rustc
commit-hash: b19329a37cedf2027517ae22c87cf201f93d776e
commit-date: 2024-11-21
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.4
Anything else?
No response
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
Start by reproducing the reported diagnostics with the supplied Rust 1.81.0 example and the rkyv derive macro. Trace the compiler's import suggestions for unresolved names in derive macro output; done means unrelated crate imports such as bytecheck or rancor are no longer suggested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100