Skip to content

Commit a13c66e

Browse files
committed
Don't confuse the user with notes about tool modules.
1 parent 4bd415f commit a13c66e

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -971,14 +971,14 @@ impl<'a> Resolver<'a> {
971971
false,
972972
ident.span,
973973
) {
974-
let desc = match binding.macro_kind() {
974+
let res = binding.res();
975+
let desc = match res.macro_kind() {
975976
Some(MacroKind::Bang) => "a function-like macro".to_string(),
976977
Some(MacroKind::Attr) => format!("an attribute: `#[{}]`", ident),
977978
Some(MacroKind::Derive) => format!("a derive macro: `#[derive({})]`", ident),
978-
None => {
979-
let res = binding.res();
980-
format!("{} {}", res.article(), res.descr())
981-
}
979+
// Don't confuse the user with tool modules.
980+
None if res == Res::ToolMod => continue,
981+
None => format!("{} {}", res.article(), res.descr()),
982982
};
983983
if let crate::NameBindingKind::Import { import, .. } = binding.kind {
984984
if !import.span.is_dummy() {

src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,24 @@ error: cannot find derive macro `rustfmt` in this scope
33
|
44
LL | #[derive(rustfmt)]
55
| ^^^^^^^
6-
|
7-
= note: `rustfmt` is in scope, but it is a tool module
86

97
error: cannot find derive macro `rustfmt` in this scope
108
--> $DIR/tool-attributes-misplaced-1.rs:4:10
119
|
1210
LL | #[derive(rustfmt)]
1311
| ^^^^^^^
14-
|
15-
= note: `rustfmt` is in scope, but it is a tool module
1612

1713
error: cannot find attribute `rustfmt` in this scope
1814
--> $DIR/tool-attributes-misplaced-1.rs:9:3
1915
|
2016
LL | #[rustfmt]
2117
| ^^^^^^^
22-
|
23-
= note: `rustfmt` is in scope, but it is a tool module
2418

2519
error: cannot find macro `rustfmt` in this scope
2620
--> $DIR/tool-attributes-misplaced-1.rs:15:5
2721
|
2822
LL | rustfmt!();
2923
| ^^^^^^^
30-
|
31-
= note: `rustfmt` is in scope, but it is a tool module
3224

3325
error[E0573]: expected type, found tool module `rustfmt`
3426
--> $DIR/tool-attributes-misplaced-1.rs:1:10

0 commit comments

Comments
 (0)