-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Open
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-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
Given the following code:
macro_rules! negative {
($e:expr) => { $e < 0 }
}
fn main() {
negative!(1 as i32);
}
The current output is:
warning: unused comparison that must be used
--> src/main.rs:2:22
|
2 | ($e:expr) => { $e < 0 }
| ^^^^^^ the comparison produces a value
...
6 | negative!(1 as i32);
| ------------------- in this macro invocation
|
= note: `#[warn(unused_must_use)]` on by default
= note: this warning originates in the macro `negative` (in Nightly builds, run with -Z macro-backtrace for more info)
help: use `let _ = ...` to ignore the resulting value
|
2 | ($e:expr) => { let _ = $e < 0 }
| +++++++
However, this does make it worse:
The following errors were reported:
error: macro expansion ends with an incomplete expression: expected one of `.`, `;`, `?`, `else`, or an operator
--> src/main.rs:2:36
|
2 | ($e:expr) => { let _ = $e < 0 }
| ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-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.