You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Show an actionable help text to add a "use ..." on error "cannot find macro" #102601
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 macro `bitflags` in this scope
--> src/main.rs:5:5
|
5 | bitflags! {
| ^^^^^^^^
|
= note: `bitflags` is in scope, but it is a crate, not a macro
help: consider importing this macro
|
4 + use bitflags::bitflags;
|
error: cannot find derive macro `Serialize` in this scope
--> src/main.rs:1:10
|
1 | #[derive(Serialize)]
| ^^^^^^^^^
|
note: `Serialize` is a trait, not a derive macro
--> /playground/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/markup5ever-0.12.1/serialize.rs:36:1
|
36 | pub trait Serialize {
| ^^^^^^^^^^^^^^^^^^^
note: `Serialize` is a trait, not a derive macro
--> /playground/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/markup5ever-0.11.0/serialize.rs:36:1
|
36 | pub trait Serialize {
| ^^^^^^^^^^^^^^^^^^^
note: `Serialize` is a trait, not a derive macro
--> /playground/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rkyv-0.8.18/src/traits.rs:262:1
|
262 | pub trait Serialize<S: Fallible + ?Sized>: Archive {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `Serialize` is a trait, not a derive macro
--> /playground/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde_core-1.0.229/src/ser/mod.rs:234:1
|
234 | pub trait Serialize {
| ^^^^^^^^^^^^^^^^^^^
= help: consider implementing `Serialize` for your type manually
help: consider importing one of these derive macros
|
1 + use noop_proc_macro::Serialize;
|
1 + use rkyv::Serialize;
|
1 + use rkyv_derive::Serialize;
|
1 + use serde::Serialize;
|
= and 1 other candidate
We could probably clean up the case where there are multiple traits and derives with the same name to be less verbose. It would make sense to not even mention existing traits if importing the derives are suggested. But that's besides the point, the original report is now fixed.
Activity
chenyukang commentedon Oct 3, 2022
@rustbot claim
togami2864 commentedon Oct 10, 2022
@rustbot claim
nyurik commentedon Mar 15, 2023
Apparently the derive macros also have this shortcoming, added an example above
estebank commentedon Sep 3, 2026
Current output:
We could probably clean up the case where there are multiple traits and derives with the same name to be less verbose. It would make sense to not even mention existing traits if importing the derives are suggested. But that's besides the point, the original report is now fixed.