Skip to content

Commit 541fbbb

Browse files
committed
Cross-crate doc inlining test case for elided lifetime
1 parent 505d157 commit 541fbbb

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![crate_name = "bar"]
2+
3+
pub struct Ref<'a>(&'a u32);
4+
5+
pub fn test5(a: &u32) -> Ref {
6+
Ref(a)
7+
}
8+
9+
pub fn test6(a: &u32) -> Ref<'_> {
10+
Ref(a)
11+
}

src/test/rustdoc/elided-lifetime.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
#![crate_name = "foo"]
2-
1+
// aux-build:elided-lifetime.rs
2+
//
33
// rust-lang/rust#75225
44
//
55
// Since Rust 2018 we encourage writing out <'_> explicitly to make it clear
66
// that borrowing is occuring. Make sure rustdoc is following the same idiom.
77

8+
#![crate_name = "foo"]
9+
810
pub struct Ref<'a>(&'a u32);
911
type ARef<'a> = Ref<'a>;
1012

@@ -32,15 +34,10 @@ pub fn test4(a: &u32) -> ARef<'_> {
3234
Ref(a)
3335
}
3436

35-
// Ensure external paths also display elided lifetime
36-
// @has foo/fn.test5.html
37-
// @matches - "Iter</a>&lt;'_"
38-
pub fn test5(a: &Option<u32>) -> std::option::Iter<u32> {
39-
a.iter()
40-
}
41-
42-
// @has foo/fn.test6.html
43-
// @matches - "Iter</a>&lt;'_"
44-
pub fn test6(a: &Option<u32>) -> std::option::Iter<'_, u32> {
45-
a.iter()
46-
}
37+
// Ensure external paths in inlined docs also display elided lifetime
38+
// @has foo/bar/fn.test5.html
39+
// @matches - "Ref</a>&lt;'_&gt;"
40+
// @has foo/bar/fn.test6.html
41+
// @matches - "Ref</a>&lt;'_&gt;"
42+
#[doc(inline)]
43+
pub extern crate bar;

0 commit comments

Comments
 (0)