-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #75237 - nbdd0121:rustdoc, r=jyn514
Display elided lifetime for non-reference type in doc In edition 2018 we encourage writing `<'_>` explicitly, so rustdoc should display like such as well. Fixes #75225 ~~Somehow when I run the compiled rustdoc using `cargo +stage2 doc` on other crates, it correctly produces `<'_>`, but I couldn't get the std doc to do the same with `./x.py doc --stage 2`. Might this be related to the recent change to x.py about how the doc is built?~~
- Loading branch information
Showing
5 changed files
with
78 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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>; | ||
|
||
// @has foo/fn.test1.html | ||
// @matches - "Ref</a><'_>" | ||
pub fn test1(a: &u32) -> Ref { | ||
Ref(a) | ||
} | ||
|
||
// @has foo/fn.test2.html | ||
// @matches - "Ref</a><'_>" | ||
pub fn test2(a: &u32) -> Ref<'_> { | ||
Ref(a) | ||
} | ||
|
||
// @has foo/fn.test3.html | ||
// @matches - "Ref</a><'_>" | ||
pub fn test3(a: &u32) -> ARef { | ||
Ref(a) | ||
} | ||
|
||
// @has foo/fn.test4.html | ||
// @matches - "Ref</a><'_>" | ||
pub fn test4(a: &u32) -> ARef<'_> { | ||
Ref(a) | ||
} | ||
|
||
// Ensure external paths in inlined docs also display elided lifetime | ||
// @has foo/bar/fn.test5.html | ||
// @matches - "Ref</a><'_>" | ||
// @has foo/bar/fn.test6.html | ||
// @matches - "Ref</a><'_>" | ||
#[doc(inline)] | ||
pub extern crate bar; |