about summary refs log tree commit diff
path: root/tests/ui/privacy/ufc-method-call.rs
blob: 525d9a9eee904f5d7188c2fda6f0de3de598a2fd (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
//! This test used to report that the method call cannot
//! call the private method `Foo<A>::foo`, even though the user
//! explicitly selected `Foo<B>::foo`. This is because we only
//! looked for methods of the right name, without properly checking
//! the `Self` type

//@ revisions: same_name different_name

pub mod test {
    pub struct A;
    pub struct B;
    pub struct Foo<T>(T);

    impl Foo<A> {
        fn foo() {}
    }

    impl Foo<B> {
        #[cfg(same_name)]
        fn foo() {}
        #[cfg(different_name)]
        fn bar() {}
    }
}

fn main() {
    test::Foo::<test::B>::foo();
    //[same_name]~^ ERROR associated function `foo` is private
    //[different_name]~^^ ERROR no function or associated item named `foo` found for struct `Foo<B>`
}