diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-08-22 17:41:22 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-08-23 16:57:59 +0200 |
| commit | a13c66e0a522957591b04237ccc72b411671fc9c (patch) | |
| tree | 2d34bb00f61fe254062c00dd175e15d15bda1a3a | |
| parent | 4bd415f70a7af9a64a700772ece354829a777a50 (diff) | |
| download | rust-a13c66e0a522957591b04237ccc72b411671fc9c.tar.gz rust-a13c66e0a522957591b04237ccc72b411671fc9c.zip | |
Don't confuse the user with notes about tool modules.
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr | 8 |
2 files changed, 5 insertions, 13 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index a9e499c9a71..7b3da373fc9 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -971,14 +971,14 @@ impl<'a> Resolver<'a> { false, ident.span, ) { - let desc = match binding.macro_kind() { + let res = binding.res(); + let desc = match res.macro_kind() { Some(MacroKind::Bang) => "a function-like macro".to_string(), Some(MacroKind::Attr) => format!("an attribute: `#[{}]`", ident), Some(MacroKind::Derive) => format!("a derive macro: `#[derive({})]`", ident), - None => { - let res = binding.res(); - format!("{} {}", res.article(), res.descr()) - } + // Don't confuse the user with tool modules. + None if res == Res::ToolMod => continue, + None => format!("{} {}", res.article(), res.descr()), }; if let crate::NameBindingKind::Import { import, .. } = binding.kind { if !import.span.is_dummy() { diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr index 6e875eebb46..71fd5f1d44a 100644 --- a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr +++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr @@ -3,32 +3,24 @@ error: cannot find derive macro `rustfmt` in this scope | LL | #[derive(rustfmt)] | ^^^^^^^ - | - = note: `rustfmt` is in scope, but it is a tool module error: cannot find derive macro `rustfmt` in this scope --> $DIR/tool-attributes-misplaced-1.rs:4:10 | LL | #[derive(rustfmt)] | ^^^^^^^ - | - = note: `rustfmt` is in scope, but it is a tool module error: cannot find attribute `rustfmt` in this scope --> $DIR/tool-attributes-misplaced-1.rs:9:3 | LL | #[rustfmt] | ^^^^^^^ - | - = note: `rustfmt` is in scope, but it is a tool module error: cannot find macro `rustfmt` in this scope --> $DIR/tool-attributes-misplaced-1.rs:15:5 | LL | rustfmt!(); | ^^^^^^^ - | - = note: `rustfmt` is in scope, but it is a tool module error[E0573]: expected type, found tool module `rustfmt` --> $DIR/tool-attributes-misplaced-1.rs:1:10 |
