File tree 6 files changed +65
-7
lines changed
6 files changed +65
-7
lines changed Original file line number Diff line number Diff line change @@ -3894,8 +3894,31 @@ impl<'a> Resolver<'a> {
3894
3894
self . resolve_error ( trait_reference. path . span , msg. as_slice ( ) ) ;
3895
3895
}
3896
3896
Some ( def) => {
3897
- debug ! ( "(resolving trait) found trait def: {:?}" , def) ;
3898
- self . record_def ( trait_reference. ref_id , def) ;
3897
+ match def {
3898
+ ( DefTrait ( _) , _) => {
3899
+ debug ! ( "(resolving trait) found trait def: {:?}" , def) ;
3900
+ self . record_def ( trait_reference. ref_id , def) ;
3901
+ }
3902
+ ( def, _) => {
3903
+ self . resolve_error ( trait_reference. path . span ,
3904
+ format ! ( "`{}` is not a trait" ,
3905
+ self . path_idents_to_str(
3906
+ & trait_reference. path) ) ) ;
3907
+
3908
+ // If it's a typedef, give a note
3909
+ match def {
3910
+ DefTy ( _) => {
3911
+ self . session . span_note (
3912
+ trait_reference. path . span ,
3913
+ format ! ( "`type` aliases cannot \
3914
+ be used for traits")
3915
+ . as_slice ( ) ) ;
3916
+ }
3917
+ _ => { }
3918
+ }
3919
+ }
3920
+ }
3921
+
3899
3922
}
3900
3923
}
3901
3924
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2013-2014 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
+ // aux-build:issue_3907.rs
12
+ extern crate issue_3907;
13
+
14
+ type Foo = issue_3907:: Foo ; //~ ERROR: reference to trait
15
+
16
+ struct S {
17
+ name : int
18
+ }
19
+
20
+ fn main ( ) { }
Original file line number Diff line number Diff line change 1
- // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
11
11
// aux-build:issue_3907.rs
12
12
extern crate issue_3907;
13
13
14
- type Foo = issue_3907:: Foo ; //~ ERROR: reference to trait
14
+ type Foo = issue_3907:: Foo ;
15
15
16
16
struct S {
17
17
name : int
18
18
}
19
19
20
20
impl Foo for S { //~ ERROR: `Foo` is not a trait
21
+ //~^ NOTE: `type` aliases cannot be used for traits
21
22
fn bar ( ) { }
22
23
}
23
24
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ impl NewTrait for Point {
31
31
fn main ( ) {
32
32
let p = Point :: new ( 0.0 , 0.0 ) ;
33
33
//~^ ERROR unresolved name `Point::new`
34
- //~^^ ERROR unresolved name
35
- //~^^^ ERROR use of undeclared module `Point`
34
+ //~^^ ERROR failed to resolve. Use of undeclared module `Point`
36
35
println ! ( "{}" , p. a( ) ) ;
37
36
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2013-2014 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
+ trait I { }
12
+ type K = I ; //~ ERROR: reference to trait
13
+
14
+ fn main ( ) { }
Original file line number Diff line number Diff line change 9
9
// except according to those terms.
10
10
11
11
trait I { }
12
- type K = I ; //~ ERROR: reference to trait
12
+ type K = I ;
13
13
impl K for int { } //~ ERROR: `K` is not a trait
14
+ //~^ NOTE: `type` aliases cannot be used for traits
14
15
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments