| 1 |
// { dg-additional-options "-w" } |
| 2 |
#[lang = "sized"] |
| 3 |
pub trait Sized {} |
| 4 |
|
| 5 |
trait Get { |
| 6 |
type Value; |
| 7 |
fn get(&self) -> &<Self as Get>::Value; |
| 8 |
} |
| 9 |
|
| 10 |
struct Struct { |
| 11 |
x: isize, |
| 12 |
} |
| 13 |
|
| 14 |
impl Get for Struct { |
| 15 |
type Value = isize; |
| 16 |
fn get(&self) -> &isize { |
| 17 |
&self.x |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
trait Grab { |
| 22 |
type U; |
| 23 |
fn grab(&self) -> &<Self as Grab>::U; |
| 24 |
} |
| 25 |
|
| 26 |
impl<T: Get> Grab for T { |
| 27 |
type U = <T as Get>::Value; |
| 28 |
fn grab(&self) -> &<T as Get>::Value { |
| 29 |
self.get() |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
fn main() { |
| 34 |
let s = Struct { x: 100 }; |
| 35 |
let a = s.grab(); |
| 36 |
} |