mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 17:28:07 +00:00
db3fcf8df7
modify `manual_map_option` uitest because one test case has confliction.
88 lines
1.6 KiB
Rust
88 lines
1.6 KiB
Rust
// run-rustfix
|
|
#![warn(clippy::nop_match)]
|
|
#![allow(clippy::manual_map)]
|
|
#![allow(clippy::question_mark)]
|
|
#![allow(dead_code)]
|
|
|
|
fn func_ret_err<T>(err: T) -> Result<(), T> {
|
|
Err(err)
|
|
}
|
|
|
|
enum SampleEnum {
|
|
A,
|
|
B,
|
|
C,
|
|
}
|
|
|
|
fn useless_prim_type_match(x: i32) -> i32 {
|
|
x
|
|
}
|
|
|
|
fn useless_custom_type_match(se: SampleEnum) -> SampleEnum {
|
|
se
|
|
}
|
|
|
|
// Don't trigger
|
|
fn mingled_custom_type(se: SampleEnum) -> SampleEnum {
|
|
match se {
|
|
SampleEnum::A => SampleEnum::B,
|
|
SampleEnum::B => SampleEnum::C,
|
|
SampleEnum::C => SampleEnum::A,
|
|
}
|
|
}
|
|
|
|
fn option_match() -> Option<i32> {
|
|
Some(1)
|
|
}
|
|
|
|
fn result_match() -> Result<i32, i32> {
|
|
Ok(1)
|
|
}
|
|
|
|
fn result_match_func_call() {
|
|
let _ = func_ret_err(0_i32);
|
|
}
|
|
|
|
fn option_check() -> Option<i32> {
|
|
if let Some(a) = Some(1) { Some(a) } else { None }
|
|
}
|
|
|
|
fn option_check_no_else() -> Option<i32> {
|
|
if let Some(a) = Some(1) {
|
|
return Some(a);
|
|
}
|
|
None
|
|
}
|
|
|
|
fn result_check_no_else() -> Result<(), i32> {
|
|
if let Err(e) = func_ret_err(0_i32) {
|
|
return Err(e);
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn result_check_a() -> Result<(), i32> {
|
|
if let Err(e) = func_ret_err(0_i32) {
|
|
Err(e)
|
|
} else {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
// Don't trigger
|
|
fn result_check_b() -> Result<(), i32> {
|
|
if let Err(e) = Ok(1) { Err(e) } else { Ok(()) }
|
|
}
|
|
|
|
fn result_check_c() -> Result<(), i32> {
|
|
let example = Ok(());
|
|
if let Err(e) = example { Err(e) } else { example }
|
|
}
|
|
|
|
// Don't trigger
|
|
fn result_check_d() -> Result<(), i32> {
|
|
let example = Ok(1);
|
|
if let Err(e) = example { Err(e) } else { Ok(()) }
|
|
}
|
|
|
|
fn main() {}
|