Skip to content

Commit 5a48521

Browse files
committed
mbe: Modify error message to mention "function-like invocation"
1 parent 20909d7 commit 5a48521

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

compiler/rustc_expand/src/mbe/diagnostics.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ pub(super) fn failed_to_match_macro(
5959
let Some(BestFailure { token, msg: label, remaining_matcher, .. }) = tracker.best_failure
6060
else {
6161
if attr_args.is_none() && !rules.iter().any(|rule| matches!(rule, MacroRule::Func { .. })) {
62-
let mut err = psess.dcx().struct_span_err(sp, "invoked macro has no invocation rules");
62+
let msg = format!("macro has no rules for function-like invocation `{name}!`");
63+
let mut err = psess.dcx().struct_span_err(sp, msg);
6364
if !def_head_span.is_dummy() {
64-
err.span_label(def_head_span, "this macro has no rules to invoke");
65+
let msg = "this macro has no rules for function-like invocation";
66+
err.span_label(def_head_span, msg);
6567
}
6668
return (sp, err.emit());
6769
}

tests/ui/macros/macro-rules-attr-error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ fn main() {
1111
#[local_attr]
1212
struct S;
1313

14-
local_attr!(arg); //~ ERROR: invoked macro has no invocation rules
14+
local_attr!(arg); //~ ERROR: macro has no rules for function-like invocation
1515
}

tests/ui/macros/macro-rules-attr-error.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ LL | #[local_attr]
99
|
1010
= note: this error originates in the attribute macro `local_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

12-
error: invoked macro has no invocation rules
12+
error: macro has no rules for function-like invocation `local_attr!`
1313
--> $DIR/macro-rules-attr-error.rs:14:5
1414
|
1515
LL | macro_rules! local_attr {
16-
| ----------------------- this macro has no rules to invoke
16+
| ----------------------- this macro has no rules for function-like invocation
1717
...
1818
LL | local_attr!(arg);
1919
| ^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)