Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4bd415f

Browse files
committed
Clarify what attribute and derive macros look like.
1 parent 5dea5d7 commit 4bd415f

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,8 @@ impl<'a> Resolver<'a> {
973973
) {
974974
let desc = match binding.macro_kind() {
975975
Some(MacroKind::Bang) => "a function-like macro".to_string(),
976-
Some(kind) => format!("{} {}", kind.article(), kind.descr_expected()),
976+
Some(MacroKind::Attr) => format!("an attribute: `#[{}]`", ident),
977+
Some(MacroKind::Derive) => format!("a derive macro: `#[derive({})]`", ident),
977978
None => {
978979
let res = binding.res();
979980
format!("{} {}", res.article(), res.descr())

src/test/ui/issues/issue-11692-2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: cannot find macro `test` in this scope
44
LL | concat!(test!());
55
| ^^^^
66
|
7-
= note: `test` is in scope, but it is an attribute
7+
= note: `test` is in scope, but it is an attribute: `#[test]`
88

99
error: aborting due to previous error
1010

src/test/ui/macros/issue-88206.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ error: cannot find macro `test` in this scope
1616
LL | test!();
1717
| ^^^^
1818
|
19-
= note: `test` is in scope, but it is an attribute
19+
= note: `test` is in scope, but it is an attribute: `#[test]`
2020

2121
error: cannot find macro `Copy` in this scope
2222
--> $DIR/issue-88206.rs:56:5
2323
|
2424
LL | Copy!();
2525
| ^^^^
2626
|
27-
= note: `Copy` is in scope, but it is a derive macro
27+
= note: `Copy` is in scope, but it is a derive macro: `#[derive(Copy)]`
2828

2929
error: cannot find macro `Box` in this scope
3030
--> $DIR/issue-88206.rs:52:5

src/test/ui/macros/macro-path-prelude-fail-3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | inline!();
99
LL | macro_rules! line {
1010
| ----------------- similarly named macro `line` defined here
1111
|
12-
= note: `inline` is in scope, but it is an attribute
12+
= note: `inline` is in scope, but it is an attribute: `#[inline]`
1313

1414
error: aborting due to previous error
1515

src/test/ui/proc-macro/macro-namespace-reserved-2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ error: cannot find macro `my_macro_attr` in this scope
9494
LL | my_macro_attr!();
9595
| ^^^^^^^^^^^^^
9696
|
97-
= note: `my_macro_attr` is in scope, but it is an attribute
97+
= note: `my_macro_attr` is in scope, but it is an attribute: `#[my_macro_attr]`
9898

9999
error: cannot find macro `MyTrait` in this scope
100100
--> $DIR/macro-namespace-reserved-2.rs:33:5
101101
|
102102
LL | MyTrait!();
103103
| ^^^^^^^
104104
|
105-
= note: `MyTrait` is in scope, but it is a derive macro
105+
= note: `MyTrait` is in scope, but it is a derive macro: `#[derive(MyTrait)]`
106106

107107
error: cannot find attribute `my_macro` in this scope
108108
--> $DIR/macro-namespace-reserved-2.rs:38:3

0 commit comments

Comments
 (0)