]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/anchors.rs
Rollup merge of #107777 - compiler-errors:derive_const-actually-derive-const, r=fee1...
[rust.git] / tests / rustdoc / anchors.rs
1 // This test ensures that anchors are generated in the right places.
2
3 #![feature(inherent_associated_types)]
4 #![allow(incomplete_features)]
5 #![crate_name = "foo"]
6
7 pub struct Foo;
8
9 // @has 'foo/trait.Bar.html'
10 pub trait Bar {
11     // There should be no anchors here.
12     // @snapshot no_type_anchor - '//*[@id="associatedtype.T"]'
13     type T;
14     // There should be no anchors here.
15     // @snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]'
16     const YOLO: u32;
17
18     // There should be no anchors here.
19     // @snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]'
20     fn foo();
21     // There should be no anchors here.
22     // @snapshot no_trait_method_anchor - '//*[@id="method.bar"]'
23     fn bar() {}
24 }
25
26 // @has 'foo/struct.Foo.html'
27 impl Bar for Foo {
28     // @has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' ''
29     type T = u32;
30     // @has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' ''
31     const YOLO: u32 = 0;
32
33     // @has - '//*[@id="method.foo"]/a[@class="anchor"]' ''
34     fn foo() {}
35     // Same check for provided "bar" method.
36     // @has - '//*[@id="method.bar"]/a[@class="anchor"]' ''
37 }
38
39 impl Foo {
40     // @snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]'
41     // There should be no anchors here.
42     pub const X: i32 = 0;
43     // @snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]'
44     // There should be no anchors here.
45     pub type Y = u32;
46     // @snapshot no_method_anchor - '//*[@id="method.new"]'
47     // There should be no anchors here.
48     pub fn new() -> Self { Self }
49 }