Skip to content

Commit d0f94d9

Browse files
committed
---
yaml --- r: 36316 b: refs/heads/try2 c: 2f83baf h: refs/heads/master v: v3
1 parent 1620a91 commit d0f94d9

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
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: 82017b8416798b4ad46c1b7416611b353374051a
8+
refs/heads/try2: 2f83baf857caca5cb0f8e996b5e9e25ce0fe22cd
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: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,26 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) {
254254

255255
fn ensure_supertraits(ccx: @crate_ctxt,
256256
id: ast::node_id,
257+
sp: codemap::span,
257258
rp: Option<ty::region_variance>,
258259
trait_refs: &[@ast::trait_ref]) {
259-
if ccx.tcx.supertraits.contains_key(local_def(id)) { return; }
260+
let tcx = ccx.tcx;
261+
if tcx.supertraits.contains_key(local_def(id)) { return; }
260262

261263
let instantiated = dvec::DVec();
262264
for trait_refs.each |trait_ref| {
263265
let (did, tpt) = instantiate_trait_ref(ccx, *trait_ref, rp);
266+
if instantiated.any(|other_trait: &InstantiatedTraitRef|
267+
{ (*other_trait).def_id == did }) {
268+
// This means a trait inherited from the same supertrait more
269+
// than once.
270+
tcx.sess.span_err(sp, ~"Duplicate supertrait in trait \
271+
declaration");
272+
return;
273+
}
264274
instantiated.push(InstantiatedTraitRef { def_id: did, tpt: tpt });
265275
}
266-
ccx.tcx.supertraits.insert(local_def(id),
276+
tcx.supertraits.insert(local_def(id),
267277
@dvec::unwrap(move instantiated));
268278
}
269279

@@ -551,7 +561,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
551561
it.id, ty_to_str(tcx, tpt.ty));
552562
write_ty_to_tcx(tcx, it.id, tpt.ty);
553563
ensure_trait_methods(ccx, it.id, tpt.ty);
554-
ensure_supertraits(ccx, it.id, rp, supertraits);
564+
ensure_supertraits(ccx, it.id, it.span, rp, supertraits);
555565
556566
let (_, provided_methods) = split_trait_methods(trait_methods);
557567
let {bounds, _} = mk_substs(ccx, tps, rp);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use cmp::Eq;
2+
3+
trait Hahaha: Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, //~ ERROR Duplicate supertrait in trait declaration
4+
Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq,
5+
Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq,
6+
Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq,
7+
Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq,
8+
Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq, Eq {}
9+
10+
enum Lol = int;
11+
12+
pub impl Lol: Hahaha {
13+
pure fn eq(other: &Lol) -> bool { *self != **other }
14+
pure fn ne(other: &Lol) -> bool { *self == **other }
15+
}
16+
17+
fn main() {
18+
if Lol(2) == Lol(4) {
19+
io::println("2 == 4");
20+
} else {
21+
io::println("2 != 4");
22+
}
23+
}

0 commit comments

Comments
 (0)