From 92abce2addffb8394406fda764e83e81ebd29d08 Mon Sep 17 00:00:00 2001 From: Omer Sheikh Date: Wed, 16 Nov 2016 20:56:57 -0500 Subject: [PATCH] Use span of first unexpected lifetime in E0088. --- src/librustc_typeck/check/mod.rs | 10 ++-------- src/test/compile-fail/E0088.rs | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f76d356e045d..fe6dbe96a96e 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4412,13 +4412,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // Check provided lifetime parameters. let lifetime_defs = segment.map_or(&[][..], |(_, generics)| &generics.regions); if lifetimes.len() > lifetime_defs.len() { - let span = lifetimes[..].into_iter().skip(1).map(|lft| lft.span) - .fold(lifetimes[0].span, |acc, n| Span { - expn_id: acc.expn_id, - lo: acc.lo, - hi: n.hi, - }); - + let span = lifetimes[lifetime_defs.len()].span; struct_span_err!(self.tcx.sess, span, E0088, "too many lifetime parameters provided: \ expected {}, found {}", @@ -4430,7 +4424,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } // The case where there is not enough lifetime parameters is not checked, - // because this is not possible - a function never takes lifetime parameters. + // because this is not possible - a function never takes lifetime parameters. // See discussion for Pull Request 36208. // Check provided type parameters. diff --git a/src/test/compile-fail/E0088.rs b/src/test/compile-fail/E0088.rs index 724398ada521..9ec096032241 100644 --- a/src/test/compile-fail/E0088.rs +++ b/src/test/compile-fail/E0088.rs @@ -14,7 +14,7 @@ fn g<'a>() {} fn main() { f::<'static>(); //~ ERROR E0088 //~^ unexpected lifetime parameter - + g::<'static, 'static>(); //~ ERROR E0088 //~^ unexpected lifetime parameters }