From 003fc730e6007b569dedada8cdde7ce362f2f85c Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sun, 7 Oct 2018 00:52:06 +0900 Subject: [PATCH] Fix empty types being inserted to closure cc https://github.com/rust-lang/rust/pull/54229. --- src/items.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/items.rs b/src/items.rs index 17a9e5296921..6a988d6127af 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1816,12 +1816,9 @@ impl Rewrite for ast::FunctionRetTy { } } -fn is_empty_infer(context: &RewriteContext, ty: &ast::Ty) -> bool { +fn is_empty_infer(ty: &ast::Ty, pat_span: Span) -> bool { match ty.node { - ast::TyKind::Infer => { - let original = context.snippet(ty.span); - original != "_" - } + ast::TyKind::Infer => ty.span.hi() == pat_span.hi(), _ => false, } } @@ -1833,7 +1830,7 @@ impl Rewrite for ast::Arg { .pat .rewrite(context, Shape::legacy(shape.width, shape.indent))?; - if !is_empty_infer(context, &*self.ty) { + if !is_empty_infer(&*self.ty, self.pat.span) { if context.config.space_before_colon() { result.push_str(" "); }