Skip to content

Commit 1620a91

Browse files
committed
---
yaml --- r: 36315 b: refs/heads/try2 c: 82017b8 h: refs/heads/master i: 36313: 1191e2b 36311: b5fe0c9 v: v3
1 parent d7665b0 commit 1620a91

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
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: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f9ca0c89d8d91a71d14a980037f3d7e555667515
8+
refs/heads/try2: 82017b8416798b4ad46c1b7416611b353374051a
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/src/librustc/middle/typeck/collect.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,27 @@ fn compare_impl_method(tcx: ty::ctxt,
296296
// implementable by an `&const self` method (the impl assumes less
297297
// than the trait provides).
298298
if impl_m.self_ty != trait_m.self_ty {
299-
tcx.sess.span_err(
300-
cm.span,
301-
fmt!("method `%s`'s self type does \
302-
not match the trait method's \
303-
self type", tcx.sess.str_of(impl_m.ident)));
299+
if impl_m.self_ty == ast::sty_static {
300+
// Needs to be a fatal error because otherwise,
301+
// method::transform_self_type_for_method ICEs
302+
tcx.sess.span_fatal(cm.span,
303+
fmt!("method `%s` is declared as \
304+
static in its impl, but not in \
305+
its trait", tcx.sess.str_of(impl_m.ident)));
306+
}
307+
else if trait_m.self_ty == ast::sty_static {
308+
tcx.sess.span_fatal(cm.span,
309+
fmt!("method `%s` is declared as \
310+
static in its trait, but not in \
311+
its impl", tcx.sess.str_of(impl_m.ident)));
312+
}
313+
else {
314+
tcx.sess.span_err(
315+
cm.span,
316+
fmt!("method `%s`'s self type does \
317+
not match the trait method's \
318+
self type", tcx.sess.str_of(impl_m.ident)));
319+
}
304320
}
305321

306322
if impl_m.tps.len() != trait_m.tps.len() {
@@ -348,9 +364,6 @@ fn compare_impl_method(tcx: ty::ctxt,
348364
pluralize(trait_param_bounds.len(), ~"bound")));
349365
return;
350366
}
351-
// tjc: I'm mildly worried that there's something I'm
352-
// not checking that require_same_types doesn't catch,
353-
// but I can't figure out what.
354367
}
355368
356369
// Replace any references to the self region in the self type with
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
struct Bike {
2+
name: ~str,
3+
}
4+
5+
trait BikeMethods {
6+
fn woops(&const self) -> ~str;
7+
}
8+
9+
pub impl Bike : BikeMethods {
10+
static fn woops(&const self) -> ~str { ~"foo" }
11+
//~^ ERROR method `woops` is declared as static in its impl, but not in its trait
12+
}
13+
14+
pub fn main() {
15+
}

branches/try2/src/test/compile-fail/staticness-mismatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ trait foo {
44
}
55

66
impl int: foo {
7-
fn bar() {} //~ ERROR self type does not match the trait method's
7+
fn bar() {} //~ ERROR method `bar` is declared as static in its trait, but not in its impl
88
}
99

1010
fn main() {}

0 commit comments

Comments
 (0)