about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-01-25 21:39:59 +0000
committerMichael Goulet <michael@errs.io>2025-02-11 19:24:07 +0000
commitce0c952e968777004fc59f45653be2fda116fee1 (patch)
tree3d0d2b430b533f9a7172a6805f749aa1432c251d
parenta02a982ffc73457caa1849b09da63e84f78541c6 (diff)
downloadrust-ce0c952e968777004fc59f45653be2fda116fee1.tar.gz
rust-ce0c952e968777004fc59f45653be2fda116fee1.zip
Deeply normalize args for implied bounds
-rw-r--r--compiler/rustc_borrowck/src/type_check/free_region_relations.rs2
-rw-r--r--tests/ui/borrowck/implied-bound-from-normalized-arg.rs22
2 files changed, 23 insertions, 1 deletions
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 `<T as Ref<'a>>::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>(_: <T as Ref<'a>>::Assoc) {
+    outlives::<'a, T>();
+}
+
+fn main() {}