Skip to content

Commit 4fe8e38

Browse files
committed
---
yaml --- r: 119004 b: refs/heads/auto c: 579a139 h: refs/heads/master v: v3
1 parent 0c02c46 commit 4fe8e38

File tree

10 files changed

+113
-13
lines changed

10 files changed

+113
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 575710f6cee318e2806b4563eb2887c1f03aaa18
16+
refs/heads/auto: 579a1392158a44ecabb36fe586500d862b3e95b7
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,6 +4021,9 @@ impl<'a> Resolver<'a> {
40214021

40224022
this.with_current_self_type(self_type, |this| {
40234023
for method in methods.iter() {
4024+
// If this is a trait impl, ensure the method exists in trait
4025+
this.check_trait_method(&**method);
4026+
40244027
// We also need a new scope for the method-specific type parameters.
40254028
this.resolve_method(MethodRibKind(id, Provided(method.id)),
40264029
&**method);
@@ -4030,6 +4033,21 @@ impl<'a> Resolver<'a> {
40304033
});
40314034
}
40324035

4036+
fn check_trait_method(&self, method: &Method) {
4037+
// If there is a TraitRef in scope for an impl, then the method must be in the trait.
4038+
for &(did, ref trait_ref) in self.current_trait_ref.iter() {
4039+
let method_name = method.ident.name;
4040+
4041+
if self.method_map.borrow().find(&(method_name, did)).is_none() {
4042+
let path_str = self.path_idents_to_str(&trait_ref.path);
4043+
self.resolve_error(method.span,
4044+
format!("method `{}` is not a member of trait `{}`",
4045+
token::get_name(method_name),
4046+
path_str).as_slice());
4047+
}
4048+
}
4049+
}
4050+
40334051
fn resolve_module(&mut self, module: &Mod, _span: Span,
40344052
_name: Ident, id: NodeId) {
40354053
// Write the implementations in scope into the module metadata.

branches/auto/src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,8 @@ fn check_impl_methods_against_trait(ccx: &CrateCtxt,
784784
&impl_trait_ref.substs);
785785
}
786786
None => {
787-
tcx.sess.span_err(
787+
// This is span_bug as it should have already been caught in resolve.
788+
tcx.sess.span_bug(
788789
impl_method.span,
789790
format!(
790791
"method `{}` is not a member of trait `{}`",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2012-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+
use x = m::f; //~ ERROR unresolved import `m::f`. There is no `f` in `m`
12+
13+
mod m {}
14+
15+
fn main() {}

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,30 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-test
12-
13-
use std::io;
14-
1511
struct Point {
1612
x: f64,
1713
y: f64,
1814
}
1915

20-
impl ToStr for Point { //~ ERROR implements a method not defined in the trait
16+
trait NewTrait {
17+
fn a(&self) -> String;
18+
}
19+
20+
impl NewTrait for Point {
2121
fn new(x: f64, y: f64) -> Point {
22+
//~^ ERROR method `new` is not a member of trait `NewTrait`
2223
Point { x: x, y: y }
2324
}
2425

25-
fn to_str(&self) -> String {
26+
fn a(&self) -> String {
2627
format!("({}, {})", self.x, self.y)
2728
}
2829
}
2930

3031
fn main() {
3132
let p = Point::new(0.0, 0.0);
32-
println!("{}", p.to_str());
33+
//~^ ERROR unresolved name `Point::new`
34+
//~^^ ERROR unresolved name
35+
//~^^^ ERROR use of undeclared module `Point`
36+
println!("{}", p.a());
3337
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2012 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+
use zoo::fly; //~ ERROR: function `fly` is private
12+
13+
mod zoo {
14+
fn fly() {}
15+
}
16+
17+
18+
fn main() {
19+
fly();
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2012 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+
// issue #516
12+
13+
fn main() {
14+
let x = true;
15+
let y = 1;
16+
let z = x + y;
17+
//~^ ERROR binary operation `+` cannot be applied to type `bool`
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2012 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+
// error-pattern:quux
12+
fn my_err(s: String) -> ! { println!("{}", s); fail!("quux"); }
13+
fn main() { 3u == my_err("bye".to_string()); }

branches/auto/src/test/run-pass/deriving-meta-multiple.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212
use std::hash::hash;
1313

14-
// testing mulptiple separate deriving attributes
15-
#[deriving(PartialEq)]
16-
#[deriving(Clone)]
17-
#[deriving(Hash)]
14+
#[deriving(PartialEq, Clone, Hash)]
1815
struct Foo {
1916
bar: uint,
2017
baz: int
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2012 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 fn main() {
12+
let i = box 100;
13+
assert_eq!(*i, 100);
14+
}

0 commit comments

Comments
 (0)