Skip to content

Commit c60a4d9

Browse files
author
Alexander Glusker
committed
review patch issue-6116
1 parent 5587fd9 commit c60a4d9

File tree

7 files changed

+41
-7
lines changed

7 files changed

+41
-7
lines changed

src/closures.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_ast::ast::StmtKind;
12
use rustc_ast::{ast, ptr};
23
use rustc_span::Span;
34
use thin_vec::thin_vec;
@@ -119,13 +120,8 @@ fn get_inner_expr<'a>(
119120
expr
120121
}
121122

122-
fn iter_stmts_without_empty(
123-
stmts: &thin_vec::ThinVec<ast::Stmt>,
124-
) -> impl Iterator<Item = &ast::Stmt> {
125-
stmts.iter().filter(|x| match x.kind {
126-
crate::ast::StmtKind::Empty => false,
127-
_ => true,
128-
})
123+
fn iter_stmts_without_empty(stmts: &[ast::Stmt]) -> impl Iterator<Item = &ast::Stmt> {
124+
stmts.iter().filter(|x| !matches!(x.kind, StmtKind::Empty))
129125
}
130126

131127
// Figure out if a block is necessary.

tests/source/issue-6116/main2.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn bar() -> fn(i32) -> i32 {
2+
|a| {
3+
;
4+
a;
5+
b
6+
}
7+
}
8+

tests/source/issue-6116/main3.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn foo() -> fn(i32) -> i32 {
2+
|a| {
3+
;
4+
;
5+
;;;;
6+
a
7+
}
8+
}

tests/source/issue-6116/main4.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn foo() -> fn(i32) -> i32 {
2+
|a| {
3+
/*comment before empty statement */;
4+
a
5+
}
6+
}
7+

tests/target/issue-6116/main2.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn bar() -> fn(i32) -> i32 {
2+
|a| {
3+
a;
4+
b
5+
}
6+
}

tests/target/issue-6116/main3.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn foo() -> fn(i32) -> i32 {
2+
|a| a
3+
}

tests/target/issue-6116/main4.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn foo() -> fn(i32) -> i32 {
2+
|a| {
3+
/*comment before empty statement */
4+
a
5+
}
6+
}

0 commit comments

Comments
 (0)