From 05d19fba27d2e53c64ea8ec488dca4fec7f2b984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 20 Aug 2018 16:16:17 -0700 Subject: [PATCH] Point at the trait argument when using unboxed closure --- src/libsyntax/parse/parser.rs | 15 ++++++++------- .../unboxed-closure-sugar-wrong-trait.stderr | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b1e2e69863d97..c80187ba77ee0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1079,12 +1079,13 @@ impl<'a> Parser<'a> { self.parse_seq_to_before_tokens(&[ket], sep, TokenExpectType::Expect, f) } - fn parse_seq_to_before_tokens(&mut self, - kets: &[&token::Token], - sep: SeqSep, - expect: TokenExpectType, - mut f: F) - -> PResult<'a, Vec> + fn parse_seq_to_before_tokens( + &mut self, + kets: &[&token::Token], + sep: SeqSep, + expect: TokenExpectType, + mut f: F, + ) -> PResult<'a, Vec> where F: FnMut(&mut Parser<'a>) -> PResult<'a, T> { let mut first: bool = true; @@ -2058,12 +2059,12 @@ impl<'a> Parser<'a> { TokenExpectType::Expect, |p| p.parse_ty())?; self.bump(); // `)` + let span = lo.to(self.prev_span); let output = if self.eat(&token::RArrow) { Some(self.parse_ty_common(false, false)?) } else { None }; - let span = lo.to(self.prev_span); ParenthesisedArgs { inputs, output, span }.into() }; diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr index 5d8c86f5a5809..91f57cbd468a8 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr @@ -2,7 +2,7 @@ error[E0244]: wrong number of type arguments: expected 0, found 1 --> $DIR/unboxed-closure-sugar-wrong-trait.rs:15:13 | LL | fn f isize>(x: F) {} - | ^^^^^^^^^^^^^^^^ unexpected type argument + | ^^^^^^^ unexpected type argument error[E0220]: associated type `Output` not found for `Trait` --> $DIR/unboxed-closure-sugar-wrong-trait.rs:15:24