File tree 2 files changed +31
-0
lines changed
librustc/middle/typeck/check
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -3208,10 +3208,19 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
3208
3208
ty_param_count, ty_substs_len) ) ;
3209
3209
fcx. infcx ( ) . next_ty_vars ( ty_param_count)
3210
3210
} else if ty_substs_len < ty_param_count {
3211
+ let is_static_method = match fcx. ccx . tcx . def_map . find ( & node_id) {
3212
+ Some ( & ast:: def_static_method( * ) ) => true ,
3213
+ _ => false
3214
+ } ;
3211
3215
fcx. ccx . tcx . sess . span_err
3212
3216
( span,
3213
3217
fmt ! ( "not enough type parameters provided: expected %u, found %u" ,
3214
3218
ty_param_count, ty_substs_len) ) ;
3219
+ if is_static_method {
3220
+ fcx. ccx . tcx . sess . span_note
3221
+ ( span, "Static methods have an extra implicit type parameter -- \
3222
+ did you omit the type parameter for the `Self` type?") ;
3223
+ }
3215
3224
fcx. infcx ( ) . next_ty_vars ( ty_param_count)
3216
3225
} else {
3217
3226
pth. types . map ( |aty| fcx. to_ty ( aty) )
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ pub trait Nummy {
12
+ fn from_inty < T > ( ) -> Self ;
13
+ }
14
+
15
+ impl Nummy for float {
16
+ fn from_inty < T > ( ) -> float { 0.0 }
17
+ }
18
+
19
+ fn main ( ) {
20
+ let _1: float = Nummy :: from_inty :: < int > ( ) ; //~ ERROR not enough type
21
+ //~^ NOTE Static methods have an extra implicit type parameter
22
+ }
You can’t perform that action at this time.
0 commit comments