about summary refs log tree commit diff
path: root/tests/ui/delegation/explicit-paths.rs
blob: 3b0454eb52400851000e18cb45510581321d8a46 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#![feature(fn_delegation)]
#![allow(incomplete_features)]

trait Trait {
    fn foo1(&self, x: i32) -> i32 { x }
    fn foo2(x: i32) -> i32 { x }
}

struct F;
impl Trait for F {}
struct S(F);

pub mod to_reuse {
    pub fn foo3() {}
}

impl F {
    fn foo4(&self) {}
}

mod fn_to_other {
    use super::*;

    reuse Trait::foo1;
    reuse <S as Trait>::foo2;
    reuse to_reuse::foo3;
    reuse S::foo4;
    //~^ ERROR cannot find function `foo4` in `S`
}

mod inherent_impl_assoc_fn_to_other {
    use crate::*;

    impl S {
        reuse Trait::foo1 { self.0 }
        reuse <S as Trait>::foo2;
        reuse to_reuse::foo3;
        reuse F::foo4 { &self.0 }
        //~^ ERROR cannot find function `foo4` in `F`
    }
}

mod trait_impl_assoc_fn_to_other {
    use crate::*;

    impl Trait for S {
        reuse Trait::foo1 { self.0 }
        reuse <F as Trait>::foo2;
        reuse to_reuse::foo3;
        //~^ ERROR method `foo3` is not a member of trait `Trait`
        reuse F::foo4 { &self.0 }
        //~^ ERROR method `foo4` is not a member of trait `Trait`
        //~| ERROR cannot find function `foo4` in `F`
    }
}

mod trait_assoc_fn_to_other {
    use crate::*;

    trait Trait2 : Trait {
        reuse <F as Trait>::foo1 { self }
        //~^ ERROR mismatched types
        reuse <F as Trait>::foo2;
        reuse to_reuse::foo3;
        reuse F::foo4 { &F }
        //~^ ERROR cannot find function `foo4` in `F`
    }
}

mod type_mismatch {
    use crate::*;

    struct S2;
    impl Trait for S {
    //~^ ERROR conflicting implementations of trait `Trait` for type `S`
        reuse <S2 as Trait>::foo1;
        //~^ ERROR mismatched types
        //~| ERROR the trait bound `S2: Trait` is not satisfied
    }
}

fn main() {}