summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/kindck-owned-contains-1.rs
blob: 8adb06ba3d04e0da04775b2e84c544f46077b678 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// run-pass
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]

trait repeat<A> { fn get(&self) -> A; }

impl<A:Clone + 'static> repeat<A> for Box<A> {
    fn get(&self) -> A {
        (**self).clone()
    }
}

fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
    Box::new(v) as Box<dyn repeat<A>+'static> // No
}

pub fn main() {
    let x = 3;
    let y = repeater(Box::new(x));
    assert_eq!(x, y.get());
}