-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
The span for the code to be replaced needs to contain the )
as well I think
Using the following flags
--force-warn clippy::redundant_pattern_matching
this code:
#![allow(unused_parens)]
fn main() {
macro_rules! x {
() => { None::<i32> };
}
if let Some(_) = x!{} {};
if let Some(_) = (x!{}) {};
}
caused the following diagnostics:
Checking _main v0.1.0 (/tmp/icemaker_global_tempdir.7g1pIyK8d0z5/icemaker_clippyfix_tempdir.epiVn3ak4SM7/_main)
warning: redundant pattern matching, consider using `is_some()`
--> src/main.rs:8:12
|
8 | if let Some(_) = x!{} {};
| -------^^^^^^^------- help: try: `if x!{}.is_some()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
= note: requested on the command line with `--force-warn clippy::redundant-pattern-matching`
warning: redundant pattern matching, consider using `is_some()`
--> src/main.rs:9:12
|
9 | if let Some(_) = (x!{}) {};
| -------^^^^^^^-------- help: try: `if x!{}.is_some()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
warning: `_main` (bin "_main") generated 2 warnings (run `cargo clippy --fix --bin "_main"` to apply 2 suggestions)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.14s
However after applying these diagnostics, the resulting code:
#![allow(unused_parens)]
fn main() {
macro_rules! x {
() => { None::<i32> };
}
if x!{}.is_some() {};
if x!{}.is_some()) {};
}
no longer compiled:
Checking _main v0.1.0 (/tmp/icemaker_global_tempdir.7g1pIyK8d0z5/icemaker_clippyfix_tempdir.epiVn3ak4SM7/_main)
error: mismatched closing delimiter: `)`
--> src/main.rs:3:11
|
3 | fn main() {
| ^ unclosed delimiter
...
9 | if x!{}.is_some()) {};
| ^ mismatched closing delimiter
error: unexpected closing delimiter: `}`
--> src/main.rs:10:1
|
9 | if x!{}.is_some()) {};
| - missing open `(` for this delimiter
10 | }
| ^ unexpected closing delimiter
error: could not compile `_main` (bin "_main") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `_main` (bin "_main" test) due to 2 previous errors
Version:
rustc 1.89.0-nightly (cf423712b 2025-06-05)
binary: rustc
commit-hash: cf423712b9e95e9f6ec84b1ecb3d125e55ac8d56
commit-date: 2025-06-05
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5
Metadata
Metadata
Assignees
Labels
I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied