]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/is_unit_expr.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / is_unit_expr.rs
CommitLineData
abe05a73
XL
1
2
ea8adc8c
XL
3#![warn(unit_expr)]
4#[allow(unused_variables)]
5
6fn main() {
7 // lint should note removing the semicolon from "baz"
8 let x = {
9 "foo";
10 "baz";
11 };
12
13
14 // lint should ignore false positive.
15 let y = if true {
16 "foo"
17 } else {
18 return;
19 };
20
21 // lint should note removing semicolon from "bar"
22 let z = if true {
23 "foo";
24 } else {
25 "bar";
26 };
27
28
29 let a1 = Some(5);
30
31 // lint should ignore false positive
32 let a2 = match a1 {
33 Some(x) => x,
34 _ => {
35 return;
36 },
37 };
38
39 // lint should note removing the semicolon after `x;`
40 let a3 = match a1 {
41 Some(x) => {
42 x;
43 },
44 _ => {
45 0;
46 },
47 };
abe05a73
XL
48
49 loop {
50 let a2 = match a1 {
51 Some(x) => x,
52 _ => {
53 break;
54 },
55 };
56 let a2 = match a1 {
57 Some(x) => x,
58 _ => {
59 continue;
60 },
61 };
62 }
63}
64
65pub fn foo() -> i32 {
66 let a2 = match None {
67 Some(x) => x,
68 _ => {
69 return 42;
70 },
71 };
72 55
ea8adc8c 73}