-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
macro_rules! delegate {
($method:ident) => {
<Self>::$method(8)
}
}
struct Bar;
impl Bar {
fn foo(a: u8, b: u8) {
}
fn bar() {
delegate!(foo);
}
}
Current output
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> src/main.rs:3:9
|
3 | <Self>::$method(8)
| ^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
...
14 | delegate!(foo);
| -------------- in this macro invocation
|
note: associated function defined here
--> src/main.rs:10:8
|
10 | fn foo(a: u8, b: u8) {
| ^^^ -----
= note: this error originates in the macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the argument
|
3 - <Self>::$method(8)
3 + <Self>::<Self>::$method(8, /* u8 */)
|
Desired output
Should not add the extra ::<Self>
in the suggestion.
Rationale and extra context
<Self>::<Self>
is not valid Rust :)
Other cases
Rust Version
1.88.0-nightly (2025-04-29 74509131e85a97353c67)
Anything else?
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.