Repository: rust
Issue: invalid suggestions when the name could not be resolved in derive macro output
Labels: A-diagnostics,T-compiler

### Code

```Rust
// 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

```

### Rust Version

```Shell
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_