Skip to content

Commit d96ba14

Browse files
committed
---
yaml --- r: 23031 b: refs/heads/master c: e656261 h: refs/heads/master i: 23029: 8491354 23027: 90ed91d 23023: 5fabe1a v: v3
1 parent 9e12f8b commit d96ba14

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2e0c1dbd4f281a8451c1e9f276ff088d9be15977
2+
refs/heads/master: e656261ee7ff7cfd301c0d7c31cdc969e3bdbfeb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rustc/middle/ty.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,14 +2654,21 @@ fn store_trait_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) {
26542654

26552655
fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {
26562656
match cx.trait_method_cache.find(id) {
2657-
some(ms) => return ms,
2658-
_ => ()
2657+
// Local traits are supposed to have been added explicitly.
2658+
some(ms) => ms,
2659+
_ => {
2660+
// If the lookup in trait_method_cache fails, assume that the trait
2661+
// method we're trying to look up is in a different crate, and look
2662+
// for it there.
2663+
assert id.crate != ast::local_crate;
2664+
let result = csearch::get_trait_methods(cx, id);
2665+
2666+
// Store the trait method in the local trait_method_cache so that
2667+
// future lookups succeed.
2668+
cx.trait_method_cache.insert(id, result);
2669+
result
2670+
}
26592671
}
2660-
// Local traits are supposed to have been added explicitly.
2661-
assert id.crate != ast::local_crate;
2662-
let result = csearch::get_trait_methods(cx, id);
2663-
cx.trait_method_cache.insert(id, result);
2664-
result
26652672
}
26662673

26672674
fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] {

trunk/src/rustc/middle/typeck/check/method.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ class lookup {
5757
let include_private: bool;
5858

5959
new(fcx: @fn_ctxt,
60-
expr: @ast::expr, //expr for a.b in a.b()
61-
self_expr: @ast::expr, //a in a.b(...)
62-
borrow_lb: ast::node_id, //scope to borrow the expr for
63-
node_id: ast::node_id, //node id where to store type of fn
64-
m_name: ast::ident, //b in a.b(...)
65-
self_ty: ty::t, //type of a in a.b(...)
66-
supplied_tps: ~[ty::t], //Xs in a.b::<Xs>(...)
60+
61+
// In a call `a.b::<X, Y, ...>(...)`:
62+
expr: @ast::expr, // The expression `a.b`.
63+
self_expr: @ast::expr, // The expression `a`.
64+
borrow_lb: ast::node_id, // Scope to borrow the expression `a` for.
65+
node_id: ast::node_id, // The node_id in which to store the type of
66+
// `a.b`.
67+
m_name: ast::ident, // The ident `b`.
68+
self_ty: ty::t, // The type of `a`.
69+
supplied_tps: ~[ty::t], // The list of types X, Y, ... .
6770
include_private: bool) {
6871

6972
self.fcx = fcx;
@@ -87,6 +90,8 @@ class lookup {
8790
ty::get(self.self_ty).struct};
8891

8992
// Determine if there are any inherent methods we can call.
93+
// (An inherent method is one that belongs to no trait, but is
94+
// inherent to a class or impl.)
9095
let optional_inherent_methods;
9196
match get_base_type_def_id(self.fcx.infcx,
9297
self.self_expr.span,
@@ -281,14 +286,14 @@ class lookup {
281286
if ty::type_has_self(m_fty) {
282287
self.tcx().sess.span_err(
283288
self.expr.span,
284-
~"can not call a method that contains a \
285-
self type through a boxed trait");
289+
~"cannot call a method whose type contains a \
290+
self-type through a boxed trait");
286291
}
287292

288293
if (*m.tps).len() > 0u {
289294
self.tcx().sess.span_err(
290295
self.expr.span,
291-
~"can not call a generic method through a \
296+
~"cannot call a generic method through a \
292297
boxed trait");
293298
}
294299

@@ -315,7 +320,7 @@ class lookup {
315320
if m.vis == ast::private && !self.include_private {
316321
self.tcx().sess.span_fatal(
317322
self.expr.span,
318-
~"Call to private method not allowed outside \
323+
~"call to private method not allowed outside \
319324
its defining class");
320325
}
321326

trunk/src/test/compile-fail/private-method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:Call to private method not allowed
1+
// error-pattern:call to private method not allowed
22
class cat {
33
priv {
44
let mut meows : uint;

trunk/src/test/compile-fail/selftype-traittype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ trait add {
33
}
44

55
fn do_add(x: add, y: add) -> add {
6-
x.plus(y) //~ ERROR can not call a method that contains a self type through a boxed trait
6+
x.plus(y) //~ ERROR cannot call a method whose type contains a self-type through a boxed trait
77
}
88

99
fn main() {}

trunk/src/test/compile-fail/trait-test-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ impl of bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
55
fn main() {
66
10.dup::<int>(); //~ ERROR does not take type parameters
77
10.blah::<int, int>(); //~ ERROR incorrect number of type parameters
8-
(10 as bar).dup(); //~ ERROR contains a self type
8+
(10 as bar).dup(); //~ ERROR contains a self-type
99
}

0 commit comments

Comments
 (0)