2017-09-18 10:47:33 +00:00
|
|
|
|
|
|
|
|
2017-09-03 17:39:28 +00:00
|
|
|
#![warn(unit_expr)]
|
2017-09-03 15:56:34 +00:00
|
|
|
#[allow(unused_variables)]
|
|
|
|
|
|
|
|
fn main() {
|
2017-09-03 20:46:49 +00:00
|
|
|
// lint should note removing the semicolon from "baz"
|
2017-09-03 15:56:34 +00:00
|
|
|
let x = {
|
|
|
|
"foo";
|
|
|
|
"baz";
|
|
|
|
};
|
2017-09-03 20:39:49 +00:00
|
|
|
|
|
|
|
|
2017-09-03 20:46:49 +00:00
|
|
|
// lint should ignore false positive.
|
|
|
|
let y = if true {
|
|
|
|
"foo"
|
|
|
|
} else {
|
2017-09-03 20:39:49 +00:00
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
2017-09-03 20:46:49 +00:00
|
|
|
// lint should note removing semicolon from "bar"
|
|
|
|
let z = if true {
|
2017-09-03 20:39:49 +00:00
|
|
|
"foo";
|
2017-09-03 20:46:49 +00:00
|
|
|
} else {
|
2017-09-03 20:39:49 +00:00
|
|
|
"bar";
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let a1 = Some(5);
|
|
|
|
|
2017-09-03 20:46:49 +00:00
|
|
|
// lint should ignore false positive
|
2017-09-03 20:39:49 +00:00
|
|
|
let a2 = match a1 {
|
|
|
|
Some(x) => x,
|
2017-09-03 20:46:49 +00:00
|
|
|
_ => {
|
|
|
|
return;
|
|
|
|
},
|
2017-09-03 20:39:49 +00:00
|
|
|
};
|
|
|
|
|
2017-09-03 20:46:49 +00:00
|
|
|
// lint should note removing the semicolon after `x;`
|
2017-09-03 20:39:49 +00:00
|
|
|
let a3 = match a1 {
|
2017-09-03 20:46:49 +00:00
|
|
|
Some(x) => {
|
|
|
|
x;
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
0;
|
|
|
|
},
|
2017-09-03 20:39:49 +00:00
|
|
|
};
|
2017-09-05 09:25:20 +00:00
|
|
|
|
|
|
|
loop {
|
|
|
|
let a2 = match a1 {
|
|
|
|
Some(x) => x,
|
|
|
|
_ => {
|
|
|
|
break;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
let a2 = match a1 {
|
|
|
|
Some(x) => x,
|
|
|
|
_ => {
|
|
|
|
continue;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn foo() -> i32 {
|
|
|
|
let a2 = match None {
|
|
|
|
Some(x) => x,
|
|
|
|
_ => {
|
|
|
|
return 42;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
55
|
2017-09-03 15:56:34 +00:00
|
|
|
}
|
2017-10-21 01:26:41 +00:00
|
|
|
|
|
|
|
pub fn issue_2160() {
|
2017-12-01 00:38:29 +00:00
|
|
|
let x1 = {};
|
|
|
|
let x2 = if true {} else {};
|
|
|
|
let x3 = match None { Some(_) => {}, None => {}, };
|
2017-10-21 01:26:41 +00:00
|
|
|
}
|