]> git.lizzy.rs Git - rust.git/blob - tests/ui/let_return.rs
rustup and compile-fail -> ui test move
[rust.git] / tests / ui / let_return.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3 #![allow(unused)]
4
5 #![deny(let_and_return)]
6
7 fn test() -> i32 {
8     let _y = 0; // no warning
9     let x = 5;   //~NOTE this expression can be directly returned
10     x            //~ERROR returning the result of a let binding
11 }
12
13 fn test_inner() -> i32 {
14     if true {
15         let x = 5;   //~NOTE this expression can be directly returned
16         x            //~ERROR returning the result of a let binding
17     } else {
18         0
19     }
20 }
21
22 fn test_nowarn_1() -> i32 {
23     let mut x = 5;
24     x += 1;
25     x
26 }
27
28 fn test_nowarn_2() -> i32 {
29     let x = 5;
30     x + 1
31 }
32
33 fn test_nowarn_3() -> (i32, i32) {
34     // this should technically warn, but we do not compare complex patterns
35     let (x, y) = (5, 9);
36     (x, y)
37 }
38
39 fn main() {
40 }