Open
Description
Given the following code:
fn main() {
bitflags! {
struct Flags: u32 {
const A = 0b00000001;
}
}
}
The current output is:
error: cannot find macro `bitflags` in this scope
--> src/main.rs:2:5
|
2 | bitflags! {
| ^^^^^^^^
|
= note: consider importing this macro:
bitflags::bitflags
= note: `bitflags` is in scope, but it is a crate, not a macro
The output should include an actionable help that tells novice users what to do in a way that can be copy/pasted, instead of just specifying which macro to use. Modeling after the error message of a missing type, the missing macro message should look like this (in green):
help: consider importing this macro
|
1 | use bitflags::bitflags;
|
Same for Derive macros
The same should also be done for the derive macros, e.g. instead of this:
error: cannot find derive macro `Bytenum` in this scope
--> src/main.rs:4:10
|
4 | #[derive(Bytenum, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
| ^^^^^^^
|
= help: consider importing this derive macro:
bytenum::Bytenum
the help message should be
= help: consider importing this derive macro:
|
1 | use bytenum::Bytenum;
|
Relevant code
See also the code that generates the message above: compiler/rustc_resolve/src/diagnostics.rs