generalize let_and_return for any block (closes #340)

This commit is contained in:
Georg Brandl 2015-09-20 13:57:27 +02:00
parent 56b9682624
commit 7cc291d02e
2 changed files with 16 additions and 7 deletions

View file

@ -1,5 +1,6 @@
#![feature(plugin)]
#![plugin(clippy)]
#![allow(unused)]
#![deny(let_and_return)]
@ -9,6 +10,15 @@ fn test() -> i32 {
x //~ERROR returning the result of a let binding
}
fn test_inner() -> i32 {
if true {
let x = 5;
x //~ERROR returning the result of a let binding
} else {
0
}
}
fn test_nowarn_1() -> i32 {
let mut x = 5;
x += 1;
@ -27,8 +37,4 @@ fn test_nowarn_3() -> (i32, i32) {
}
fn main() {
test();
test_nowarn_1();
test_nowarn_2();
test_nowarn_3();
}