Skip to content

Commit

Permalink
Cross-crate doc inlining test case for elided lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Aug 8, 2020
1 parent 505d157 commit 541fbbb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
11 changes: 11 additions & 0 deletions src/test/rustdoc/auxiliary/elided-lifetime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![crate_name = "bar"]

pub struct Ref<'a>(&'a u32);

pub fn test5(a: &u32) -> Ref {
Ref(a)
}

pub fn test6(a: &u32) -> Ref<'_> {
Ref(a)
}
25 changes: 11 additions & 14 deletions src/test/rustdoc/elided-lifetime.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#![crate_name = "foo"]

// aux-build:elided-lifetime.rs
//
// rust-lang/rust#75225
//
// Since Rust 2018 we encourage writing out <'_> explicitly to make it clear
// that borrowing is occuring. Make sure rustdoc is following the same idiom.

#![crate_name = "foo"]

pub struct Ref<'a>(&'a u32);
type ARef<'a> = Ref<'a>;

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

// Ensure external paths also display elided lifetime
// @has foo/fn.test5.html
// @matches - "Iter</a>&lt;'_"
pub fn test5(a: &Option<u32>) -> std::option::Iter<u32> {
a.iter()
}

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

0 comments on commit 541fbbb

Please sign in to comment.