Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/librustc_typeck/check/method/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,17 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {

if num_supplied_types > 0 && num_supplied_types != num_method_types {
if num_method_types == 0 {
span_err!(self.tcx.sess, self.span, E0035,
"does not take type parameters");
struct_span_err!(self.tcx.sess, self.span, E0035,
"does not take type parameters")
.span_label(self.span, &format!("called with unneeded type parameters"))
.emit();
} else {
span_err!(self.tcx.sess, self.span, E0036,
"incorrect number of type parameters given for this method: \
expected {}, found {}",
num_method_types, num_supplied_types);
struct_span_err!(self.tcx.sess, self.span, E0036,
"incorrect number of type parameters given for this method: expected {}, found {}",
num_method_types, num_supplied_types)
.span_label(self.span, &format!("Passed {} type argument(s), expected {}",
num_supplied_types, num_method_types))
.emit();
}
supplied_method_types = vec![self.tcx.types.err; num_method_types];
}
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/E0035.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ impl Test {
fn main() {
let x = Test;
x.method::<i32>(); //~ ERROR E0035
//~| NOTE called with unneeded type parameters
}
1 change: 1 addition & 0 deletions src/test/compile-fail/E0036.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ fn main() {
let x = Test;
let v = &[0];
x.method::<i32, i32>(v); //~ ERROR E0036
//~| NOTE Passed 2 type arguments, expected 1
}