summaryrefslogtreecommitdiffstats
path: root/src/test/ui/traits/alias/import.rs
blob: 802a8f15698f2a8af4b3c8136151fe6b3710020a (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
// run-pass

#![feature(trait_alias)]

mod inner {
    pub trait Foo {
        fn foo(&self);
    }

    pub struct Qux;

    impl Foo for Qux {
        fn foo(&self) {}
    }

    pub trait Bar = Foo;
}

mod two {
    pub trait A {
        fn foo();
    }

    impl A for u8 {
        fn foo() {}
    }
}

// Import only the alias, not the `Foo` trait.
use inner::{Bar, Qux};

// Declaring an alias also brings in aliased methods.
trait Two = two::A;

fn main() {
    let q = Qux;
    q.foo(); // From Bar.

    u8::foo(); // From A.
}