]> git.proxmox.com Git - rustc.git/blame - src/test/rustdoc/intra-link-self.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / test / rustdoc / intra-link-self.rs
CommitLineData
8faf50e0
XL
1#![crate_name = "foo"]
2
72b1a166
FG
3// ignore-tidy-linelength
4
8faf50e0
XL
5// @has foo/index.html '//a/@href' '../foo/struct.Foo.html#method.new'
6// @has foo/struct.Foo.html '//a/@href' '../foo/struct.Foo.html#method.new'
7
8/// Use [`new`] to create a new instance.
9///
10/// [`new`]: Self::new
11pub struct Foo;
12
13impl Foo {
14 pub fn new() -> Self {
15 unimplemented!()
16 }
17}
18
19// @has foo/index.html '//a/@href' '../foo/struct.Bar.html#method.new2'
20// @has foo/struct.Bar.html '//a/@href' '../foo/struct.Bar.html#method.new2'
21
22/// Use [`new2`] to create a new instance.
23///
24/// [`new2`]: Self::new2
25pub struct Bar;
26
27impl Bar {
28 pub fn new2() -> Self {
29 unimplemented!()
30 }
31}
72b1a166
FG
32
33pub struct MyStruct {
34 // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#structfield.struct_field'
35
36 /// [`struct_field`]
37 ///
38 /// [`struct_field`]: Self::struct_field
39 pub struct_field: u8,
40}
41
42pub enum MyEnum {
43 // @has foo/enum.MyEnum.html '//a/@href' '../foo/enum.MyEnum.html#variant.EnumVariant'
44
45 /// [`EnumVariant`]
46 ///
47 /// [`EnumVariant`]: Self::EnumVariant
48 EnumVariant,
49}
50
51pub union MyUnion {
52 // @has foo/union.MyUnion.html '//a/@href' '../foo/union.MyUnion.html#structfield.union_field'
53
54 /// [`union_field`]
55 ///
56 /// [`union_field`]: Self::union_field
57 pub union_field: f32,
58}
59
60pub trait MyTrait {
61 // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#associatedtype.AssoType'
62
63 /// [`AssoType`]
64 ///
65 /// [`AssoType`]: Self::AssoType
66 type AssoType;
67
68 // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#associatedconstant.ASSO_CONST'
69
70 /// [`ASSO_CONST`]
71 ///
72 /// [`ASSO_CONST`]: Self::ASSO_CONST
73 const ASSO_CONST: i32 = 1;
74
75 // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#method.asso_fn'
76
77 /// [`asso_fn`]
78 ///
79 /// [`asso_fn`]: Self::asso_fn
80 fn asso_fn() {}
81}
82
83impl MyStruct {
84 // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.for_impl'
85
86 /// [`for_impl`]
87 ///
88 /// [`for_impl`]: Self::for_impl
89 pub fn for_impl() {
90 unimplemented!()
91 }
92}
93
94impl MyTrait for MyStruct {
95 // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedtype.AssoType'
96
97 /// [`AssoType`]
98 ///
99 /// [`AssoType`]: Self::AssoType
100 type AssoType = u32;
101
102 // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedconstant.ASSO_CONST'
103
104 /// [`ASSO_CONST`]
105 ///
106 /// [`ASSO_CONST`]: Self::ASSO_CONST
107 const ASSO_CONST: i32 = 10;
108
109 // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.asso_fn'
110
111 /// [`asso_fn`]
112 ///
113 /// [`asso_fn`]: Self::asso_fn
114 fn asso_fn() {
115 unimplemented!()
116 }
117}