]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/intra-doc/associated-items.rs
2757418bc64e5c4990885be015c95b3813c8771a
[rust.git] / src / test / rustdoc / intra-doc / associated-items.rs
1 #![deny(intra_doc_link_resolution_failure)]
2
3 /// [`std::collections::BTreeMap::into_iter`]
4 /// [`String::from`] is ambiguous as to which `From` impl
5 /// [Vec::into_iter()] uses a disambiguator
6 // @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html#method.into_iter"]' 'std::collections::BTreeMap::into_iter'
7 // @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from"]' 'String::from'
8 // @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.into_iter"]' 'Vec::into_iter'
9 pub fn foo() {}
10
11 /// Link to [MyStruct], [link from struct][MyStruct::method], [MyStruct::clone], [MyStruct::Input]
12 // @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html"]' 'MyStruct'
13 // @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.method"]' 'link from struct'
14 // @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.clone"]' 'MyStruct::clone'
15 // @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#associatedtype.Input"]' 'MyStruct::Input'
16 pub struct MyStruct { foo: () }
17
18 impl Clone for MyStruct {
19     fn clone(&self) -> Self {
20         MyStruct
21     }
22 }
23
24 pub trait T {
25     type Input;
26     fn method(i: Self::Input);
27 }
28
29 impl T for MyStruct {
30     type Input = usize;
31
32     /// [link from method][MyStruct::method] on method
33     // @has 'associated_items/struct.MyStruct.html' '//a[@href="struct.MyStruct.html#method.method"]' 'link from method'
34     fn method(i: usize) {
35     }
36 }
37
38 /// Ambiguity between which trait to use
39 pub trait T1 {
40     fn ambiguous_method();
41 }
42
43 pub trait T2 {
44     fn ambiguous_method();
45 }
46
47 /// Link to [S::ambiguous_method]
48 // FIXME: there is no way to disambiguate these.
49 // Since we have `#[deny(intra_doc_failure)]`, we still know it was one or the other.
50 pub struct S;
51
52 impl T1 for S {
53     fn ambiguous_method() {}
54 }
55
56 impl T2 for S {
57     fn ambiguous_method() {}
58 }
59
60 fn main() {}