Skip to content

Commit e8861c8

Browse files
committed
Add semicolon_if_nothing_returned test for let-else stmts
1 parent 93f13d5 commit e8861c8

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

tests/ui/semicolon_if_nothing_returned.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(clippy::semicolon_if_nothing_returned)]
22
#![allow(clippy::redundant_closure)]
33
#![feature(label_break_value)]
4+
#![feature(let_else)]
45

56
fn get_unit() {}
67

@@ -110,3 +111,12 @@ fn macro_with_semicolon() {
110111
}
111112
repro!();
112113
}
114+
115+
fn function_returning_option() -> Option<i32> {
116+
Some(1)
117+
}
118+
119+
// No warning
120+
fn let_else_stmts() {
121+
let Some(x) = function_returning_option() else { return; };
122+
}

tests/ui/semicolon_if_nothing_returned.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: consider adding a `;` to the last statement for consistent formatting
2-
--> $DIR/semicolon_if_nothing_returned.rs:9:5
2+
--> $DIR/semicolon_if_nothing_returned.rs:10:5
33
|
44
LL | println!("Hello")
55
| ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");`
66
|
77
= note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings`
88

99
error: consider adding a `;` to the last statement for consistent formatting
10-
--> $DIR/semicolon_if_nothing_returned.rs:13:5
10+
--> $DIR/semicolon_if_nothing_returned.rs:14:5
1111
|
1212
LL | get_unit()
1313
| ^^^^^^^^^^ help: add a `;` here: `get_unit();`
1414

1515
error: consider adding a `;` to the last statement for consistent formatting
16-
--> $DIR/semicolon_if_nothing_returned.rs:18:5
16+
--> $DIR/semicolon_if_nothing_returned.rs:19:5
1717
|
1818
LL | y = x + 1
1919
| ^^^^^^^^^ help: add a `;` here: `y = x + 1;`
2020

2121
error: consider adding a `;` to the last statement for consistent formatting
22-
--> $DIR/semicolon_if_nothing_returned.rs:24:9
22+
--> $DIR/semicolon_if_nothing_returned.rs:25:9
2323
|
2424
LL | hello()
2525
| ^^^^^^^ help: add a `;` here: `hello();`
2626

2727
error: consider adding a `;` to the last statement for consistent formatting
28-
--> $DIR/semicolon_if_nothing_returned.rs:35:9
28+
--> $DIR/semicolon_if_nothing_returned.rs:36:9
2929
|
3030
LL | ptr::drop_in_place(s.as_mut_ptr())
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());`

0 commit comments

Comments
 (0)