]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/check-source-code-urls-to-def.rs
Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk
[rust.git] / tests / rustdoc / check-source-code-urls-to-def.rs
1 // compile-flags: -Zunstable-options --generate-link-to-definition
2 // aux-build:source_code.rs
3 // build-aux-docs
4
5 #![feature(rustdoc_internals)]
6
7 #![crate_name = "foo"]
8
9 extern crate source_code;
10
11 // @has 'src/foo/check-source-code-urls-to-def.rs.html'
12
13 // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar'
14 #[path = "auxiliary/source-code-bar.rs"]
15 pub mod bar;
16
17 // @count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5"]' 4
18 use bar::Bar;
19 // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13"]' 'self'
20 // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait'
21 use bar::sub::{self, Trait};
22
23 pub struct Foo;
24
25 impl Foo {
26     fn hello(&self) {}
27 }
28
29 fn babar() {}
30
31 // @has - '//pre[@class="rust"]//a/@href' '/struct.String.html'
32 // @has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html'
33 // @has - '//pre[@class="rust"]//a/@href' '/primitive.str.html'
34 // @count - '//pre[@class="rust"]//a[@href="#23"]' 5
35 // @has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' 'source_code::SourceCode'
36 pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
37     let x = 12;
38     let y: Foo = Foo;
39     let z: Bar = bar::Bar { field: Foo };
40     babar();
41     // @has - '//pre[@class="rust"]//a[@href="#26"]' 'hello'
42     y.hello();
43 }
44
45 // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'bar::sub::Trait'
46 // @has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14"]' 'Trait'
47 pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
48
49 pub trait AnotherTrait {}
50 pub trait WhyNot {}
51
52 // @has - '//pre[@class="rust"]//a[@href="#49"]' 'AnotherTrait'
53 // @has - '//pre[@class="rust"]//a[@href="#50"]' 'WhyNot'
54 pub fn foo3<T, V>(t: &T, v: &V)
55 where
56     T: AnotherTrait,
57     V: WhyNot
58 {}
59
60 pub trait AnotherTrait2 {}
61
62 // @has - '//pre[@class="rust"]//a[@href="#60"]' 'AnotherTrait2'
63 pub fn foo4() {
64     let x: Vec<AnotherTrait2> = Vec::new();
65 }
66
67 // @has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool'
68 #[doc(primitive = "bool")]
69 mod whatever {}