From 4bd415f70a7af9a64a700772ece354829a777a50 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 22 Aug 2021 17:26:19 +0200 Subject: [PATCH] Clarify what attribute and derive macros look like. --- compiler/rustc_resolve/src/diagnostics.rs | 3 ++- src/test/ui/issues/issue-11692-2.stderr | 2 +- src/test/ui/macros/issue-88206.stderr | 4 ++-- src/test/ui/macros/macro-path-prelude-fail-3.stderr | 2 +- src/test/ui/proc-macro/macro-namespace-reserved-2.stderr | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 088596b2cbc..a9e499c9a71 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -973,7 +973,8 @@ fn lookup_import_candidates_from_module( ) { let desc = match binding.macro_kind() { Some(MacroKind::Bang) => "a function-like macro".to_string(), - Some(kind) => format!("{} {}", kind.article(), kind.descr_expected()), + 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()) diff --git a/src/test/ui/issues/issue-11692-2.stderr b/src/test/ui/issues/issue-11692-2.stderr index de705e74026..84746ca2c88 100644 --- a/src/test/ui/issues/issue-11692-2.stderr +++ b/src/test/ui/issues/issue-11692-2.stderr @@ -4,7 +4,7 @@ error: cannot find macro `test` in this scope LL | concat!(test!()); | ^^^^ | - = note: `test` is in scope, but it is an attribute + = note: `test` is in scope, but it is an attribute: `#[test]` error: aborting due to previous error diff --git a/src/test/ui/macros/issue-88206.stderr b/src/test/ui/macros/issue-88206.stderr index 9220c16f6ae..c189fc47357 100644 --- a/src/test/ui/macros/issue-88206.stderr +++ b/src/test/ui/macros/issue-88206.stderr @@ -16,7 +16,7 @@ error: cannot find macro `test` in this scope LL | test!(); | ^^^^ | - = note: `test` is in scope, but it is an attribute + = note: `test` is in scope, but it is an attribute: `#[test]` error: cannot find macro `Copy` in this scope --> $DIR/issue-88206.rs:56:5 @@ -24,7 +24,7 @@ error: cannot find macro `Copy` in this scope LL | Copy!(); | ^^^^ | - = note: `Copy` is in scope, but it is a derive macro + = note: `Copy` is in scope, but it is a derive macro: `#[derive(Copy)]` error: cannot find macro `Box` in this scope --> $DIR/issue-88206.rs:52:5 diff --git a/src/test/ui/macros/macro-path-prelude-fail-3.stderr b/src/test/ui/macros/macro-path-prelude-fail-3.stderr index 0f448f7cab1..70900a6bc81 100644 --- a/src/test/ui/macros/macro-path-prelude-fail-3.stderr +++ b/src/test/ui/macros/macro-path-prelude-fail-3.stderr @@ -9,7 +9,7 @@ LL | inline!(); LL | macro_rules! line { | ----------------- similarly named macro `line` defined here | - = note: `inline` is in scope, but it is an attribute + = note: `inline` is in scope, but it is an attribute: `#[inline]` error: aborting due to previous error diff --git a/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr index 3c7ba5ac9ba..633a6c6a0d3 100644 --- a/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr +++ b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -94,7 +94,7 @@ error: cannot find macro `my_macro_attr` in this scope LL | my_macro_attr!(); | ^^^^^^^^^^^^^ | - = note: `my_macro_attr` is in scope, but it is an attribute + = note: `my_macro_attr` is in scope, but it is an attribute: `#[my_macro_attr]` error: cannot find macro `MyTrait` in this scope --> $DIR/macro-namespace-reserved-2.rs:33:5 @@ -102,7 +102,7 @@ error: cannot find macro `MyTrait` in this scope LL | MyTrait!(); | ^^^^^^^ | - = note: `MyTrait` is in scope, but it is a derive macro + = note: `MyTrait` is in scope, but it is a derive macro: `#[derive(MyTrait)]` error: cannot find attribute `my_macro` in this scope --> $DIR/macro-namespace-reserved-2.rs:38:3