diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.rs b/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.rs new file mode 100644 index 000000000..55a8c2621 --- /dev/null +++ b/src/tools/clippy/tests/ui/pattern_type_mismatch/mutability.rs @@ -0,0 +1,49 @@ +#![allow(clippy::all)] +#![warn(clippy::pattern_type_mismatch)] + +fn main() {} + +fn should_lint() { + let value = &Some(23); + match value { + Some(_) => (), + _ => (), + } + + let value = &mut Some(23); + match value { + Some(_) => (), + _ => (), + } +} + +fn should_not_lint() { + let value = &Some(23); + match value { + &Some(_) => (), + _ => (), + } + match *value { + Some(_) => (), + _ => (), + } + + let value = &mut Some(23); + match value { + &mut Some(_) => (), + _ => (), + } + match *value { + Some(_) => (), + _ => (), + } + + const FOO: &str = "foo"; + + fn foo(s: &str) -> i32 { + match s { + FOO => 1, + _ => 0, + } + } +} |