about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorGurinder Singh <frederick.the.fool@gmail.com>2024-07-07 15:44:55 +0530
committerGurinder Singh <frederick.the.fool@gmail.com>2024-07-07 15:44:55 +0530
commit9da3638c6a90748cc913a3e2e02a74eb851ec48a (patch)
treebfb4bf5a3304d967b383e322069cf5bb356072ea /compiler
parent5c08cc765af9975d4b176f7a377bbf927791e20d (diff)
Move a span_bug under a condition that cx is tainted
Fixes an ICE caused when a with expression is not a struct
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/expr_use_visitor.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs
index c8ab0429ffc..193dbbbcdf4 100644
--- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs
+++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs
@@ -734,7 +734,9 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
                 // struct; however, when EUV is run during typeck, it
                 // may not. This will generate an error earlier in typeck,
                 // so we can just ignore it.
-                span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
+                if self.cx.tainted_by_errors().is_ok() {
+                    span_bug!(with_expr.span, "with expression doesn't evaluate to a struct");
+                }
             }
         }