diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/single_match.rs')
-rw-r--r-- | src/tools/clippy/tests/ui/single_match.rs | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/src/tools/clippy/tests/ui/single_match.rs b/src/tools/clippy/tests/ui/single_match.rs index d0c9b7b56..1515a7053 100644 --- a/src/tools/clippy/tests/ui/single_match.rs +++ b/src/tools/clippy/tests/ui/single_match.rs @@ -1,6 +1,11 @@ +//@run-rustfix #![warn(clippy::single_match)] -#![allow(clippy::uninlined_format_args)] - +#![allow( + unused, + clippy::uninlined_format_args, + clippy::needless_if, + clippy::redundant_pattern_matching +)] fn dummy() {} fn single_match() { @@ -244,3 +249,64 @@ fn main() { _ => 0, }; } + +fn issue_10808(bar: Option<i32>) { + match bar { + Some(v) => unsafe { + let r = &v as *const i32; + println!("{}", *r); + }, + _ => {}, + } + + match bar { + #[rustfmt::skip] + Some(v) => { + unsafe { + let r = &v as *const i32; + println!("{}", *r); + } + }, + _ => {}, + } +} + +mod issue8634 { + struct SomeError(i32, i32); + + fn foo(x: Result<i32, ()>) { + match x { + Ok(y) => { + println!("Yay! {y}"); + }, + Err(()) => { + // Ignore this error because blah blah blah. + }, + } + } + + fn bar(x: Result<i32, SomeError>) { + match x { + Ok(y) => { + println!("Yay! {y}"); + }, + Err(_) => { + // TODO: Process the error properly. + }, + } + } + + fn block_comment(x: Result<i32, SomeError>) { + match x { + Ok(y) => { + println!("Yay! {y}"); + }, + Err(_) => { + /* + let's make sure that this also + does not lint block comments. + */ + }, + } + } +} |