Skip to content

Commit

Permalink
Update E0088 to new format, remove E0090
Browse files Browse the repository at this point in the history
  • Loading branch information
Yossi Konstantinovsky committed Sep 8, 2016
1 parent 13c4e32 commit abb8576
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4324,20 +4324,27 @@ 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[lifetime_defs.len()].span;
span_err!(self.tcx.sess, span, E0088,
"too many lifetime parameters provided: \
expected {}, found {}",
count(lifetime_defs.len()),
count(lifetimes.len()));
} else if lifetimes.len() > 0 && lifetimes.len() < lifetime_defs.len() {
span_err!(self.tcx.sess, span, E0090,
"too few lifetime parameters provided: \
expected {}, found {}",
count(lifetime_defs.len()),
count(lifetimes.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,
});

struct_span_err!(self.tcx.sess, span, E0088,
"too many lifetime parameters provided: \
expected {}, found {}",
count(lifetime_defs.len()),
count(lifetimes.len()))
.span_label(span, &format!("unexpected lifetime parameter{}",
match lifetimes.len() { 1 => "", _ => "s" }))
.emit();
}

// The case where there is not enough lifetime parameters is not checked,
// because this is not possible - a function never takes lifetime parameters.
// See discussion for Pull Request 36208.

// Check provided type parameters.
let type_defs = segment.map_or(&[][..], |(_, generics)| {
if generics.parent.is_none() {
Expand Down
5 changes: 5 additions & 0 deletions src/test/compile-fail/E0088.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
// except according to those terms.

fn f() {}
fn g<'a>() {}

fn main() {
f::<'static>(); //~ ERROR E0088
//~^ unexpected lifetime parameter

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

0 comments on commit abb8576

Please sign in to comment.