Skip to content

Commit 006f641

Browse files
committed
---
yaml --- r: 40410 b: refs/heads/dist-snap c: 82017b8 h: refs/heads/master v: v3
1 parent 177a52c commit 006f641

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
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: f9ca0c89d8d91a71d14a980037f3d7e555667515
10+
refs/heads/dist-snap: 82017b8416798b4ad46c1b7416611b353374051a
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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/dist-snap/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)