From 17ec134fa421dd152df12063e45afe355e585d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Mon, 8 Jan 2024 22:31:50 +0100 Subject: [PATCH] Update tests --- .../auxiliary/default-generic-args.rs | 9 ++++-- .../auxiliary/u_default_generic_args.rs | 1 + .../inline_cross/default-generic-args.rs | 32 ++++++++++++------- 3 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 tests/rustdoc/inline_cross/auxiliary/u_default_generic_args.rs diff --git a/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs index 1e31f18927e..c2c94817fad 100644 --- a/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs +++ b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs @@ -40,6 +40,11 @@ pub struct Multi(A, B); pub type M0 = Multi; -pub trait Trait<'a, T = &'a ()> {} +pub trait Trait0<'a, T = &'a ()> {} +pub type D0 = dyn for<'a> Trait0<'a>; -pub type F = dyn for<'a> Trait<'a>; +// Regression test for issue #119529. +pub trait Trait1 {} +pub type D1 = dyn Trait1; +pub type D2 = dyn Trait1<(), K>; +pub type D3 = dyn Trait1; diff --git a/tests/rustdoc/inline_cross/auxiliary/u_default_generic_args.rs b/tests/rustdoc/inline_cross/auxiliary/u_default_generic_args.rs new file mode 100644 index 00000000000..a742dd7d865 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/u_default_generic_args.rs @@ -0,0 +1 @@ +pub use default_generic_args::*; diff --git a/tests/rustdoc/inline_cross/default-generic-args.rs b/tests/rustdoc/inline_cross/default-generic-args.rs index c9a87a19901..775bf041532 100644 --- a/tests/rustdoc/inline_cross/default-generic-args.rs +++ b/tests/rustdoc/inline_cross/default-generic-args.rs @@ -79,15 +79,14 @@ pub use default_generic_args::P1; pub use default_generic_args::P2; // @has user/type.A0.html -// Ensure that we elide generic arguments that are alpha-equivalent to their respective -// generic parameter (modulo substs) (#1): -// @has - '//*[@class="rust item-decl"]//code' "Alpha" +// @has - '//*[@class="rust item-decl"]//code' "Alpha;" pub use default_generic_args::A0; // @has user/type.A1.html -// Ensure that we elide generic arguments that are alpha-equivalent to their respective -// generic parameter (modulo substs) (#1): -// @has - '//*[@class="rust item-decl"]//code' "Alpha" +// Demonstrates that we currently don't elide generic arguments that are alpha-equivalent to their +// respective generic parameter (after instantiation) for perf reasons (it would require us to +// create an inference context). +// @has - '//*[@class="rust item-decl"]//code' "Alpha fn(_: &'arbitrary ())>" pub use default_generic_args::A1; // @has user/type.M0.html @@ -97,8 +96,19 @@ pub use default_generic_args::A1; // @has - '//*[@class="rust item-decl"]//code' "Multi" pub use default_generic_args::M0; -// @has user/type.F.html -// FIXME: Ideally, we would elide `&'a ()` but `'a` is an escaping bound var which we can't reason -// about at the moment since we don't keep track of bound vars. -// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a> Trait<'a, &'a ()>" -pub use default_generic_args::F; +// @has user/type.D0.html +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a> Trait0<'a>" +pub use default_generic_args::D0; + +// Regression test for issue #119529. +// Check that we correctly elide def ty&const args inside trait object types. + +// @has user/type.D1.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Trait1" +pub use default_generic_args::D1; +// @has user/type.D2.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Trait1<(), K>" +pub use default_generic_args::D2; +// @has user/type.D3.html +// @has - '//*[@class="rust item-decl"]//code' "dyn Trait1;" +pub use default_generic_args::D3;