Skip to content

Commit

Permalink
Rollup merge of rust-lang#36103 - zjhmale:fix-E0089, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0089 to new error format

Fixes rust-lang#35227.
Part of rust-lang#35233.

r? @jonathandturner
  • Loading branch information
GuillaumeGomez authored Aug 30, 2016
2 parents eb33044 + 01083ba commit 9a3cfe9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4427,14 +4427,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// use inference variables instead of the provided types.
*segment = None;
} else if !(can_omit && types.len() == 0) && types.len() < required_len {
let qualifier =
if type_defs.len() != required_len { "at least " } else { "" };
span_err!(self.tcx.sess, span, E0089,
"too few type parameters provided: \
expected {}{}, found {}",
qualifier,
count(required_len),
count(types.len()));
let adjust = |len| if len > 1 { "parameters" } else { "parameter" };
let required_param_str = adjust(required_len);
let actual_param_str = adjust(types.len());
struct_span_err!(self.tcx.sess, span, E0089,
"too few type parameters provided: \
expected {} {}, found {} {}",
count(required_len),
required_param_str,
count(types.len()),
actual_param_str)
.span_label(span, &format!("expected {} type {}", required_len, required_param_str))
.emit();
}

if !bindings.is_empty() {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0089.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
fn foo<T, U>() {}

fn main() {
foo::<f64>(); //~ ERROR E0089
foo::<f64>();
//~^ ERROR E0089
//~| NOTE expected 2 type parameters
}

0 comments on commit 9a3cfe9

Please sign in to comment.