Skip to content

Commit

Permalink
review patch issue-6116
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Glusker committed Mar 29, 2024
1 parent 5587fd9 commit c60a4d9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/closures.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustc_ast::ast::StmtKind;
use rustc_ast::{ast, ptr};
use rustc_span::Span;
use thin_vec::thin_vec;
Expand Down Expand Up @@ -119,13 +120,8 @@ fn get_inner_expr<'a>(
expr
}

fn iter_stmts_without_empty(
stmts: &thin_vec::ThinVec<ast::Stmt>,
) -> impl Iterator<Item = &ast::Stmt> {
stmts.iter().filter(|x| match x.kind {
crate::ast::StmtKind::Empty => false,
_ => true,
})
fn iter_stmts_without_empty(stmts: &[ast::Stmt]) -> impl Iterator<Item = &ast::Stmt> {
stmts.iter().filter(|x| !matches!(x.kind, StmtKind::Empty))
}

// Figure out if a block is necessary.
Expand Down
8 changes: 8 additions & 0 deletions tests/source/issue-6116/main2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn bar() -> fn(i32) -> i32 {
|a| {
;
a;
b
}
}

8 changes: 8 additions & 0 deletions tests/source/issue-6116/main3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn foo() -> fn(i32) -> i32 {
|a| {
;
;
;;;;
a
}
}
7 changes: 7 additions & 0 deletions tests/source/issue-6116/main4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn foo() -> fn(i32) -> i32 {
|a| {
/*comment before empty statement */;
a
}
}

6 changes: 6 additions & 0 deletions tests/target/issue-6116/main2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn bar() -> fn(i32) -> i32 {
|a| {
a;
b
}
}
3 changes: 3 additions & 0 deletions tests/target/issue-6116/main3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn foo() -> fn(i32) -> i32 {
|a| a
}
6 changes: 6 additions & 0 deletions tests/target/issue-6116/main4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn foo() -> fn(i32) -> i32 {
|a| {
/*comment before empty statement */
a
}
}

0 comments on commit c60a4d9

Please sign in to comment.