From b1d08275a9914b59bbad3cf5f80073b8365e9e67 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 20 Apr 2023 18:08:06 -0700 Subject: rustdoc: catch and don't blow up on impl Trait cycles An odd feature of Rust is that `Foo` is invalid, but `Bar` is okay: type Foo<'a, 'b> = Box>>; type Bar<'a, 'b> = impl PartialEq>; To get it right, track every time rustdoc descends into a type alias, so if it shows up twice, it can be write the path instead of infinitely expanding it. --- tests/rustdoc/issue-110629-private-type-cycle.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/rustdoc/issue-110629-private-type-cycle.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/issue-110629-private-type-cycle.rs b/tests/rustdoc/issue-110629-private-type-cycle.rs new file mode 100644 index 00000000000..a4efbb098f7 --- /dev/null +++ b/tests/rustdoc/issue-110629-private-type-cycle.rs @@ -0,0 +1,19 @@ +// compile-flags: --document-private-items + +#![feature(type_alias_impl_trait)] + +type Bar<'a, 'b> = impl PartialEq> + std::fmt::Debug; + +// @has issue_110629_private_type_cycle/type.Bar.html +// @has - '//pre[@class="rust item-decl"]' \ +// "pub(crate) type Bar<'a, 'b> = impl PartialEq> + Debug;" + +fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + i +} + +fn main() { + let meh = 42; + let muh = 42; + assert_eq!(bar(&meh), bar(&muh)); +} -- cgit 1.4.1-3-g733a5