foo/jump-to-def-assoc-items.rs
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
// This test ensures that patterns also get a link generated.
//@ compile-flags: -Zunstable-options --generate-link-to-definition
#![crate_name = "foo"]
//@ has 'src/foo/jump-to-def-assoc-items.rs.html'
pub trait Trait {
type T;
}
pub trait Another {
type T;
const X: u32;
}
pub struct Foo;
impl Foo {
pub fn new() -> Self { Foo }
}
pub struct C;
impl C {
pub fn wat() {}
}
pub struct Bar;
impl Trait for Bar {
type T = Foo;
}
impl Another for Bar {
type T = C;
const X: u32 = 12;
}
pub fn bar() {
//@ has - '//a[@href="#19"]' 'new'
<Bar as Trait>::T::new();
//@ has - '//a[@href="#25"]' 'wat'
<Bar as Another>::T::wat();
match 12u32 {
<Bar as Another>::X => {}
_ => {}
}
}
pub struct Far {
x: <Bar as Trait>::T,
}