Skip to content

Commit 4dd17bc

Browse files
committed
---
yaml --- r: 152756 b: refs/heads/try2 c: ab24d29 h: refs/heads/master v: v3
1 parent ec4e337 commit 4dd17bc

File tree

7 files changed

+66
-8
lines changed

7 files changed

+66
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 579a1392158a44ecabb36fe586500d862b3e95b7
8+
refs/heads/try2: ab24d29f0d1bb32a6d8913996755972887f5f150
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/resolve.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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() {}

branches/try2/src/test/compile-fail/issue-3907.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
//
@@ -11,13 +11,14 @@
1111
// aux-build:issue_3907.rs
1212
extern crate issue_3907;
1313

14-
type Foo = issue_3907::Foo; //~ ERROR: reference to trait
14+
type Foo = issue_3907::Foo;
1515

1616
struct S {
1717
name: int
1818
}
1919

2020
impl Foo for S { //~ ERROR: `Foo` is not a trait
21+
//~^ NOTE: `type` aliases cannot be used for traits
2122
fn bar() { }
2223
}
2324

branches/try2/src/test/compile-fail/issue-3973.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ impl NewTrait for Point {
3131
fn 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
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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() {}

branches/try2/src/test/compile-fail/issue-5035.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
trait I {}
12-
type K = I; //~ ERROR: reference to trait
12+
type K = I;
1313
impl K for int {} //~ ERROR: `K` is not a trait
14+
//~^ NOTE: `type` aliases cannot be used for traits
1415
fn main() {}

0 commit comments

Comments
 (0)