]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/let_return.rs
new lint for "let x = EXPR; x" at the end of functions (fixes #104)
[rust.git] / tests / compile-fail / let_return.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #![deny(let_and_return)]
5
6 fn test() -> i32 {
7     let _y = 0; // no warning
8     let x = 5;   //~NOTE
9     x            //~ERROR:
10 }
11
12 fn test_nowarn_1() -> i32 {
13     let mut x = 5;
14     x += 1;
15     x
16 }
17
18 fn test_nowarn_2() -> i32 {
19     let x = 5;
20     x + 1
21 }
22
23 fn test_nowarn_3() -> (i32, i32) {
24     // this should technically warn, but we do not compare complex patterns
25     let (x, y) = (5, 9);
26     (x, y)
27 }
28
29 fn main() {
30     test();
31     test_nowarn_1();
32     test_nowarn_2();
33     test_nowarn_3();
34 }