blob: 19e58e32b16eec5ae94f11d2fd0f4c0ac41a1204 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// { dg-additional-options "-w" }
#[lang = "sized"]
pub trait Sized {}
#[lang = "index"]
trait Index<Idx> {
type Output;
fn index(&self, index: Idx) -> &Self::Output;
}
struct Foo(i32, i32);
impl Index<isize> for Foo {
type Output = i32;
fn index(&self, index: isize) -> &i32 {
if index == 0 {
&self.0
} else {
&self.1
}
}
}
fn main() -> i32 {
let a = Foo(1, 2);
let b = a[0];
let c = a[1];
c - b - 1
}
|