From 63c0d9ca51bb471189a0d5529c8ee5491fb4e102 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Fri, 7 Aug 2020 00:48:24 +0100 Subject: Display elided lifetime for non-reference type in doc --- src/test/rustdoc/elided-lifetime.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/rustdoc/elided-lifetime.rs (limited to 'src/test') diff --git a/src/test/rustdoc/elided-lifetime.rs b/src/test/rustdoc/elided-lifetime.rs new file mode 100644 index 00000000000..641866aaf3c --- /dev/null +++ b/src/test/rustdoc/elided-lifetime.rs @@ -0,0 +1,33 @@ +#![crate_name = "foo"] + +// 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. + +pub struct Ref<'a>(&'a u32); +type ARef<'a> = Ref<'a>; + +// @has foo/fn.test1.html +// @matches - "Ref<'_>" +pub fn test1(a: &u32) -> Ref { + Ref(a) +} + +// @has foo/fn.test2.html +// @matches - "Ref<'_>" +pub fn test2(a: &u32) -> Ref<'_> { + Ref(a) +} + +// @has foo/fn.test3.html +// @matches - "Ref<'_>" +pub fn test3(a: &u32) -> ARef { + Ref(a) +} + +// @has foo/fn.test4.html +// @matches - "Ref<'_>" +pub fn test4(a: &u32) -> ARef<'_> { + Ref(a) +} -- cgit 1.4.1-3-g733a5