]> git.lizzy.rs Git - rust.git/blob - tests/ui/let_return.rs
Merge pull request #2984 from flip1995/single_char_pattern
[rust.git] / tests / ui / let_return.rs
1
2
3 #![allow(unused)]
4
5 #![warn(let_and_return)]
6
7 fn test() -> i32 {
8     let _y = 0; // no warning
9     let x = 5;
10     x
11 }
12
13 fn test_inner() -> i32 {
14     if true {
15         let x = 5;
16         x
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 test_nowarn_4() -> i32 {
40     // this should technically warn, but not b/c of let_and_return, but b/c of useless type
41     let x: i32 = 5;
42     x
43 }
44
45 fn main() {
46 }