Skip to content

Commit

Permalink
Rollup merge of rust-lang#37835 - ojsheikh:E0088, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0088 to new error format

Fixes rust-lang#35226 which is part of rust-lang#35233. Is based on rust-lang#36208 from @yossi-k.

r? @jonathandturner
  • Loading branch information
GuillaumeGomez committed Nov 20, 2016
2 parents 224f2ce + 92abce2 commit e8673ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4436,19 +4436,20 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
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()));
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 e8673ff

Please sign in to comment.