提交 8bad0311 编写于 作者: K Kevin Butler

librustc_typeck: give more information when supplied wrong number of type-params for methods

上级 5b4986fa
...@@ -351,7 +351,8 @@ fn instantiate_method_substs(&mut self, ...@@ -351,7 +351,8 @@ fn instantiate_method_substs(&mut self,
method_types); method_types);
} else if num_supplied_types != num_method_types { } else if num_supplied_types != num_method_types {
span_err!(self.tcx().sess, self.span, E0036, span_err!(self.tcx().sess, self.span, E0036,
"incorrect number of type parameters given for this method"); "incorrect number of type parameters given for this method: expected {}, found {}",
num_method_types, num_supplied_types);
final_substs.types.replace( final_substs.types.replace(
subst::FnSpace, subst::FnSpace,
vec![self.tcx().types.err; num_method_types]); vec![self.tcx().types.err; num_method_types]);
......
...@@ -16,7 +16,8 @@ impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} } ...@@ -16,7 +16,8 @@ impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} }
fn main() { fn main() {
10.dup::<i32>(); //~ ERROR does not take type parameters 10.dup::<i32>(); //~ ERROR does not take type parameters
10.blah::<i32, i32>(); //~ ERROR incorrect number of type parameters 10.blah::<i32, i32>();
//~^ ERROR incorrect number of type parameters given for this method: expected 1, found 2
(box 10 as Box<bar>).dup(); (box 10 as Box<bar>).dup();
//~^ ERROR E0038 //~^ ERROR E0038
//~| ERROR E0038 //~| ERROR E0038
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册