From ce0c952e968777004fc59f45653be2fda116fee1 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 25 Jan 2025 21:39:59 +0000 Subject: [PATCH] Deeply normalize args for implied bounds --- .../src/type_check/free_region_relations.rs | 2 +- .../implied-bound-from-normalized-arg.rs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/ui/borrowck/implied-bound-from-normalized-arg.rs diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index 2bac084c964..a7f8d9c2884 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -264,7 +264,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { } let TypeOpOutput { output: norm_ty, constraints: constraints_normalize, .. } = param_env - .and(type_op::normalize::Normalize { value: ty }) + .and(DeeplyNormalize { value: ty }) .fully_perform(self.infcx, span) .unwrap_or_else(|guar| TypeOpOutput { output: Ty::new_error(self.infcx.tcx, guar), diff --git a/tests/ui/borrowck/implied-bound-from-normalized-arg.rs b/tests/ui/borrowck/implied-bound-from-normalized-arg.rs new file mode 100644 index 00000000000..4e9a4953c6b --- /dev/null +++ b/tests/ui/borrowck/implied-bound-from-normalized-arg.rs @@ -0,0 +1,22 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +// Make sure that we can normalize `>::Assoc` to `&'a T` and get +// its implied bounds. + +trait Ref<'a> { + type Assoc; +} +impl<'a, T> Ref<'a> for T where T: 'a { + type Assoc = &'a T; +} + +fn outlives<'a, T: 'a>() {} + +fn test<'a, T>(_: >::Assoc) { + outlives::<'a, T>(); +} + +fn main() {}