From f79fa636bfc99bf24d8df5124d26fbbab04b5f8c Mon Sep 17 00:00:00 2001 From: Adwin White Date: Fri, 24 Jul 2026 16:08:58 +0800 Subject: [PATCH] add missing resolving vars --- .../query/type_op/implied_outlives_bounds.rs | 1 + ..._outlives_bounds_not_resolving_vars_ice.rs | 19 ++++++++++++ ...lives_bounds_not_resolving_vars_ice.stderr | 29 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.rs create mode 100644 tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.stderr diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs index a98f8b9a9af88..e55f87c6076e6 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs @@ -95,6 +95,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>( continue; } + let arg = ocx.infcx.resolve_vars_if_possible(arg); // From the full set of obligations, just filter down to the region relationships. for obligation in wf::unnormalized_obligations(ocx.infcx, param_env, arg, DUMMY_SP, CRATE_DEF_ID) diff --git a/tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.rs b/tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.rs new file mode 100644 index 0000000000000..a1e60c38fbbc8 --- /dev/null +++ b/tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.rs @@ -0,0 +1,19 @@ +//@ compile-flags: -Znext-solver + +// Regression test for https://github.com/rust-lang/rust-clippy/issues/17439 + +#![feature(inherent_associated_types)] + +struct Foo(T); + +impl<'a> Foo { + type Assoc = &'a (); +} + +fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} +//~^ ERROR: higher-ranked subtype error +//~| ERROR: higher-ranked subtype error +//~| ERROR: lifetime bound not satisfied [E0478] +//~| ERROR: lifetime bound not satisfied [E0478] + +fn main() {} diff --git a/tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.stderr b/tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.stderr new file mode 100644 index 0000000000000..6a79474f60915 --- /dev/null +++ b/tests/ui/traits/next-solver/implied_outlives_bounds_not_resolving_vars_ice.stderr @@ -0,0 +1,29 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/implied_outlives_bounds_not_resolving_vars_ice.rs:13:11 + | +LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0478]: lifetime bound not satisfied + --> $DIR/implied_outlives_bounds_not_resolving_vars_ice.rs:13:11 + | +LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: higher-ranked subtype error + --> $DIR/implied_outlives_bounds_not_resolving_vars_ice.rs:13:1 + | +LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: higher-ranked subtype error + --> $DIR/implied_outlives_bounds_not_resolving_vars_ice.rs:13:8 + | +LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} + | ^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0478`.