-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
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
Using the following flags
--force-warn clippy::match_ref_pats
this code:
// check-pass
const FOO: &&&u32 = &&&42;
fn main() {
match unimplemented!() {
&&&42 => {
match unimplemented!() {
&&&42 => {},
FOO => {},
_ => {},
}
},
FOO => {
match unimplemented!() {
&&&42 => {},
FOO => {},
_ => {},
}
},
_ => {
match unimplemented!() {
&_ => {},
&&&42 => {
match unimplemented!() {
&&&42 => {},
FOO => {},
_ => {},
}
},
_ => {},
}
},
}
}caused the following diagnostics:
Checking _17cf102309ba325072c67c53efe4fb5e2d923828 v0.1.0 (/tmp/icemaker_global_tempdir.f0JXFBTcO4io/icemaker_clippyfix_tempdir.AjJtkmFC5tvf/_17cf102309ba325072c67c53efe4fb5e2d923828)
warning: you don't need to add `&` to all patterns
--> src/main.rs:22:5
|
22 | / match unimplemented!() {
23 | | &_ => {},
24 | | &&&42 => {
25 | | match unimplemented!() {
... |
31 | | _ => {},
32 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_ref_pats
= note: requested on the command line with `--force-warn clippy::match-ref-pats`
help: instead of prefixing all patterns with `&`, you can dereference the expression
|
22 ~ match *unimplemented!() {
23 ~ _ => {},
24 ~ &&42 => {
|
warning: `_17cf102309ba325072c67c53efe4fb5e2d923828` (bin "_17cf102309ba325072c67c53efe4fb5e2d923828") generated 1 warning (run `cargo clippy --fix --bin "_17cf102309ba325072c67c53efe4fb5e2d923828"` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.44s
However after applying these diagnostics, the resulting code:
// check-pass
const FOO: &&&u32 = &&&42;
fn main() {
match unimplemented!() {
&&&42 => {
match unimplemented!() {
&&&42 => {},
FOO => {},
_ => {},
}
},
FOO => {
match unimplemented!() {
&&&42 => {},
FOO => {},
_ => {},
}
},
_ => {
match *unimplemented!() {
_ => {},
&&42 => {
match unimplemented!() {
&&&42 => {},
FOO => {},
_ => {},
}
},
_ => {},
}
},
}
}no longer compiled:
Checking _17cf102309ba325072c67c53efe4fb5e2d923828 v0.1.0 (/tmp/icemaker_global_tempdir.f0JXFBTcO4io/icemaker_clippyfix_tempdir.AjJtkmFC5tvf/_17cf102309ba325072c67c53efe4fb5e2d923828)
error[E0614]: type `!` cannot be dereferenced
--> src/main.rs:22:11
|
22 | match *unimplemented!() {
| ^^^^^^^^^^^^^^^^^ can't be dereferenced
For more information about this error, try `rustc --explain E0614`.
error: could not compile `_17cf102309ba325072c67c53efe4fb5e2d923828` (bin "_17cf102309ba325072c67c53efe4fb5e2d923828") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_17cf102309ba325072c67c53efe4fb5e2d923828` (bin "_17cf102309ba325072c67c53efe4fb5e2d923828" test) due to 1 previous error
Version:
rustc 1.90.0-nightly (cc0a5b730 2025-07-31)
binary: rustc
commit-hash: cc0a5b73053c62a3df5f84b3ee85079c9b65fa87
commit-date: 2025-07-31
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
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