File tree Expand file tree Collapse file tree 6 files changed +65
-7
lines changed Expand file tree Collapse file tree 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> {
38943894 self . resolve_error ( trait_reference. path . span , msg. as_slice ( ) ) ;
38953895 }
38963896 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+
38993922 }
39003923 }
39013924 }
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
22// file at the top-level directory of this distribution and at
33// http://rust-lang.org/COPYRIGHT.
44//
1111// aux-build:issue_3907.rs
1212extern crate issue_3907;
1313
14- type Foo = issue_3907:: Foo ; //~ ERROR: reference to trait
14+ type Foo = issue_3907:: Foo ;
1515
1616struct S {
1717 name : int
1818}
1919
2020impl Foo for S { //~ ERROR: `Foo` is not a trait
21+ //~^ NOTE: `type` aliases cannot be used for traits
2122 fn bar ( ) { }
2223}
2324
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ impl NewTrait for Point {
3131fn main ( ) {
3232 let p = Point :: new ( 0.0 , 0.0 ) ;
3333 //~^ 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`
3635 println ! ( "{}" , p. a( ) ) ;
3736}
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 99// except according to those terms.
1010
1111trait I { }
12- type K = I ; //~ ERROR: reference to trait
12+ type K = I ;
1313impl K for int { } //~ ERROR: `K` is not a trait
14+ //~^ NOTE: `type` aliases cannot be used for traits
1415fn main ( ) { }
You can’t perform that action at this time.
0 commit comments