summaryrefslogtreecommitdiffstats
path: root/src/test/ui/self/arbitrary_self_types_nested.rs
blob: 680196fbb92f644573259277bc92ade071f64398 (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
32
33
34
35
36
// run-pass

use {
    std::{
        rc::Rc,
        sync::Arc,
    },
};

#[derive(Default)]
struct Ty;

trait Trait {
    fn receive_trait(self: &Arc<Rc<Box<Self>>>) -> u32;
}

const TRAIT_MAGIC: u32 = 42;
const INHERENT_MAGIC: u32 = 1995;

impl Trait for Ty {
    fn receive_trait(self: &Arc<Rc<Box<Self>>>) -> u32 {
        TRAIT_MAGIC
    }
}

impl Ty {
    fn receive_inherent(self: &Arc<Rc<Box<Self>>>) -> u32 {
        INHERENT_MAGIC
    }
}

fn main() {
    let ty = <Arc<Rc<Box<Ty>>>>::default();
    assert_eq!(TRAIT_MAGIC, ty.receive_trait());
    assert_eq!(INHERENT_MAGIC, ty.receive_inherent());
}