]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/elided-lifetime.rs
Update snap from `1.0.1` to `1.1.0`
[rust.git] / tests / rustdoc / elided-lifetime.rs
1 // aux-build:elided-lifetime.rs
2 //
3 // rust-lang/rust#75225
4 //
5 // Since Rust 2018 we encourage writing out <'_> explicitly to make it clear
6 // that borrowing is occurring. Make sure rustdoc is following the same idiom.
7
8 #![crate_name = "foo"]
9
10 pub struct Ref<'a>(&'a u32);
11 type ARef<'a> = Ref<'a>;
12
13 // @has foo/fn.test1.html
14 // @matchesraw - "Ref</a>&lt;'_&gt;"
15 pub fn test1(a: &u32) -> Ref {
16     Ref(a)
17 }
18
19 // @has foo/fn.test2.html
20 // @matchesraw - "Ref</a>&lt;'_&gt;"
21 pub fn test2(a: &u32) -> Ref<'_> {
22     Ref(a)
23 }
24
25 // @has foo/fn.test3.html
26 // @matchesraw - "Ref</a>&lt;'_&gt;"
27 pub fn test3(a: &u32) -> ARef {
28     Ref(a)
29 }
30
31 // @has foo/fn.test4.html
32 // @matchesraw - "Ref</a>&lt;'_&gt;"
33 pub fn test4(a: &u32) -> ARef<'_> {
34     Ref(a)
35 }
36
37 // Ensure external paths in inlined docs also display elided lifetime
38 // @has foo/bar/fn.test5.html
39 // @matchesraw - "Ref</a>&lt;'_&gt;"
40 // @has foo/bar/fn.test6.html
41 // @matchesraw - "Ref</a>&lt;'_&gt;"
42 #[doc(inline)]
43 pub extern crate bar;