Skip to content

Commit 81caf92

Browse files
committed
test for #2378
1 parent 44c100c commit 81caf92

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/test/auxiliary/issue2378a.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
enum maybe<T> { just(T), nothing }
2+
3+
impl methods<T:copy> for maybe<T> {
4+
fn [](idx: uint) -> T {
5+
alt self {
6+
just(t) { t }
7+
nothing { fail; }
8+
}
9+
}
10+
}

src/test/auxiliary/issue2378b.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use issue2378a;
2+
3+
import issue2378a::maybe;
4+
import issue2378a::methods;
5+
6+
type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
7+
8+
impl methods<T:copy> for two_maybes<T> {
9+
fn [](idx: uint) -> (T, T) {
10+
(self.a[idx], self.b[idx])
11+
}
12+
}

src/test/run-pass/issue2378c.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// xfail-test -- #2378 unfixed
2+
// aux-build:issue2378a.rs
3+
// aux-build:issue2378b.rs
4+
5+
use issue2378a;
6+
use issue2378b;
7+
8+
import issue2378a::{just, methods};
9+
import issue2378b::{methods};
10+
11+
fn main() {
12+
let x = {a: just(3), b: just(5)};
13+
assert x[0u] == (3, 5);
14+
}

0 commit comments

Comments
 (0)