about summary refs log tree commit diff
path: root/tests/ui/delegation/self-coercion.rs
blob: 96c1f1b140b14e66d62d5fbc183ec4417a79f90d (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
//@ run-pass

#![feature(fn_delegation)]
#![allow(incomplete_features)]

trait Trait : Sized {
    fn by_value(self) -> i32 { 1 }
    fn by_mut_ref(&mut self) -> i32 { 2 }
    fn by_ref(&self) -> i32 { 3 }
}

struct F;
impl Trait for F {}

struct S(F);

impl Trait for S {
    reuse Trait::{by_value, by_mut_ref, by_ref} { self.0 }
}

fn main() {
    let mut s = S(F);
    assert_eq!(s.by_ref(), 3);
    assert_eq!(s.by_mut_ref(), 2);
    assert_eq!(s.by_value(), 1);
}