Clarify what attribute and derive macros look like.

This commit is contained in:
Mara Bos 2021-08-22 17:26:19 +02:00
parent 5dea5d7549
commit 4bd415f70a
5 changed files with 8 additions and 7 deletions

View File

@ -973,7 +973,8 @@ fn lookup_import_candidates_from_module<FilterFn>(
) {
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())

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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