about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOmer Sheikh <ojsheikh@gmail.com>2016-11-16 20:56:57 -0500
committerOmer Sheikh <ojsheikh@gmail.com>2016-11-16 20:56:57 -0500
commit92abce2addffb8394406fda764e83e81ebd29d08 (patch)
treebc817718dbd23c22634582a7404dbd6fcda409dc
parent96b549a2ee6d309d22f909d285c63b3346be3c4e (diff)
downloadrust-92abce2addffb8394406fda764e83e81ebd29d08.tar.gz
rust-92abce2addffb8394406fda764e83e81ebd29d08.zip
Use span of first unexpected lifetime in E0088.
-rw-r--r--src/librustc_typeck/check/mod.rs10
-rw-r--r--src/test/compile-fail/E0088.rs2
2 files changed, 3 insertions, 9 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index f76d356e045..fe6dbe96a96 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 724398ada52..9ec09603224 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
 }