rust/tests/ui/unit_arg_expressions.rs
2021-01-18 20:18:56 +01:00

36 lines
462 B
Rust

#![warn(clippy::unit_arg)]
#![allow(clippy::no_effect)]
use std::fmt::Debug;
fn foo<T: Debug>(t: T) {
println!("{:?}", t);
}
fn bad() {
foo(if true {
1;
});
foo(match Some(1) {
Some(_) => {
1;
},
None => {
0;
},
});
}
fn ok() {
foo(if true { 1 } else { 0 });
foo(match Some(1) {
Some(_) => 1,
None => 0,
});
}
fn main() {
bad();
ok();
}