about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-08-09 09:41:23 +0000
committerMichael Goulet <michael@errs.io>2022-08-09 09:41:28 +0000
commitca7e3c4a83e2adddf74d9a45301a84024ce1f730 (patch)
tree5d83f6be57d1b5be23157c9df71969154d32dfea /compiler/rustc_trait_selection/src
parent6f18f0a9d4548bc87afff1e4c0fe9081c35002c2 (diff)
downloadrust-ca7e3c4a83e2adddf74d9a45301a84024ce1f730.tar.gz
rust-ca7e3c4a83e2adddf74d9a45301a84024ce1f730.zip
Keep going if normalized projection has unevaluated consts in QueryNormalizer
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/traits/query/normalize.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
index 449d7a7b47b..b5e5f14064f 100644
--- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
@@ -194,7 +194,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
         // wait to fold the substs.
 
         // Wrap this in a closure so we don't accidentally return from the outer function
-        let res = (|| match *ty.kind() {
+        let mut res = (|| match *ty.kind() {
             // This is really important. While we *can* handle this, this has
             // severe performance implications for large opaque types with
             // late-bound regions. See `issue-88862` benchmark.
@@ -317,6 +317,13 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
 
             _ => ty.try_super_fold_with(self),
         })()?;
+
+        // `tcx.normalize_projection_ty` may normalize to a type that still has
+        // unevaluated consts, so keep normalizing here if that's the case.
+        if res != ty && res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) {
+            res = res.try_super_fold_with(self)?;
+        }
+
         self.cache.insert(ty, res);
         Ok(res)
     }