File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
librustc/middle/typeck/check Expand file tree Collapse file tree 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,
32083208 ty_param_count, ty_substs_len) ) ;
32093209 fcx. infcx ( ) . next_ty_vars ( ty_param_count)
32103210 } 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+ } ;
32113215 fcx. ccx . tcx . sess . span_err
32123216 ( span,
32133217 fmt ! ( "not enough type parameters provided: expected %u, found %u" ,
32143218 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+ }
32153224 fcx. infcx ( ) . next_ty_vars ( ty_param_count)
32163225 } else {
32173226 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