Skip to content

Commit 003fc73

Browse files
committed
Fix empty types being inserted to closure
cc rust-lang/rust#54229.
1 parent 5a6822c commit 003fc73

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/items.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1816,12 +1816,9 @@ impl Rewrite for ast::FunctionRetTy {
18161816
}
18171817
}
18181818

1819-
fn is_empty_infer(context: &RewriteContext, ty: &ast::Ty) -> bool {
1819+
fn is_empty_infer(ty: &ast::Ty, pat_span: Span) -> bool {
18201820
match ty.node {
1821-
ast::TyKind::Infer => {
1822-
let original = context.snippet(ty.span);
1823-
original != "_"
1824-
}
1821+
ast::TyKind::Infer => ty.span.hi() == pat_span.hi(),
18251822
_ => false,
18261823
}
18271824
}
@@ -1833,7 +1830,7 @@ impl Rewrite for ast::Arg {
18331830
.pat
18341831
.rewrite(context, Shape::legacy(shape.width, shape.indent))?;
18351832

1836-
if !is_empty_infer(context, &*self.ty) {
1833+
if !is_empty_infer(&*self.ty, self.pat.span) {
18371834
if context.config.space_before_colon() {
18381835
result.push_str(" ");
18391836
}

0 commit comments

Comments
 (0)