about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits/normalize.rs
diff options
context:
space:
mode:
authorBoxy <rust@boxyuwu.dev>2025-04-28 03:53:41 +0100
committerBoxy <rust@boxyuwu.dev>2025-04-29 18:55:21 +0100
commitc31794d6d372e9f5cb575a8ee5618347d3686f89 (patch)
tree2afa9673a6049e53ad9e0436f9ed3adafb2a3dfc /compiler/rustc_trait_selection/src/traits/normalize.rs
parente3e432d4d65a55e6db167598e96db2bcb163e316 (diff)
downloadrust-c31794d6d372e9f5cb575a8ee5618347d3686f89.tar.gz
rust-c31794d6d372e9f5cb575a8ee5618347d3686f89.zip
confusings
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/normalize.rs')
-rw-r--r--compiler/rustc_trait_selection/src/traits/normalize.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs
index 7551ac5aa97..afa72a79848 100644
--- a/compiler/rustc_trait_selection/src/traits/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/normalize.rs
@@ -260,11 +260,14 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
             }
 
             ty::Projection if !data.has_escaping_bound_vars() => {
-                // This branch is *mostly* just an optimization: when we don't
-                // have escaping bound vars, we don't need to replace them with
-                // placeholders (see branch below). *Also*, we know that we can
-                // register an obligation to *later* project, since we know
-                // there won't be bound vars there.
+                // When we don't have escaping bound vars we can normalize ambig aliases
+                // to inference variables (done in `normalize_projection_ty`). This would
+                // be wrong if there were escaping bound vars as even if we instantiated
+                // the bound vars with placeholders, we wouldn't be able to map them back
+                // after normalization succeeded.
+                //
+                // Also, as an optimization: when we don't have escaping bound vars, we don't
+                // need to replace them with placeholders (see branch below).
                 let data = data.fold_with(self);
                 let normalized_ty = project::normalize_projection_ty(
                     self.selcx,