about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2023-09-20 21:41:29 +0200
committerlcnr <rust@lcnr.de>2023-09-21 08:17:58 +0200
commit8024c69c2985274f8caf8bccdeec92a5632bd8c3 (patch)
treefbe3632c91a91d63f68b6c82cf88eff5aebea1db /compiler
parent8eade3aa71fd3c08de4e8849a91ef9154e83a054 (diff)
downloadrust-8024c69c2985274f8caf8bccdeec92a5632bd8c3.tar.gz
rust-8024c69c2985274f8caf8bccdeec92a5632bd8c3.zip
HACK: avoid hang in structurally_normalize
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_trait_selection/src/traits/structural_normalize.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/structural_normalize.rs b/compiler/rustc_trait_selection/src/traits/structural_normalize.rs
index d3c4dc45923..9d6be768901 100644
--- a/compiler/rustc_trait_selection/src/traits/structural_normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/structural_normalize.rs
@@ -22,9 +22,14 @@ impl<'tcx> StructurallyNormalizeExt<'tcx> for At<'_, 'tcx> {
         assert!(!ty.is_ty_var(), "should have resolved vars before calling");
 
         if self.infcx.next_trait_solver() {
-            while let ty::Alias(ty::Projection | ty::Inherent | ty::Weak, projection_ty) =
-                *ty.kind()
-            {
+            // FIXME(-Ztrait-solver=next): correctly handle
+            // overflow here.
+            for _ in 0..256 {
+                let ty::Alias(ty::Projection | ty::Inherent | ty::Weak, projection_ty) = *ty.kind()
+                else {
+                    break;
+                };
+
                 let new_infer_ty = self.infcx.next_ty_var(TypeVariableOrigin {
                     kind: TypeVariableOriginKind::NormalizeProjectionType,
                     span: self.cause.span,
@@ -49,6 +54,7 @@ impl<'tcx> StructurallyNormalizeExt<'tcx> for At<'_, 'tcx> {
                     break;
                 }
             }
+
             Ok(ty)
         } else {
             Ok(self.normalize(ty).into_value_registering_obligations(self.infcx, fulfill_cx))