Skip to content

Commit

Permalink
Use span of first unexpected lifetime in E0088.
Browse files Browse the repository at this point in the history
  • Loading branch information
ojsheikh committed Nov 17, 2016
1 parent 96b549a commit 92abce2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}",
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/E0088.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn g<'a>() {}
fn main() {
f::<'static>(); //~ ERROR E0088
//~^ unexpected lifetime parameter

g::<'static, 'static>(); //~ ERROR E0088
//~^ unexpected lifetime parameters
}

0 comments on commit 92abce2

Please sign in to comment.