Skip to content

Commit 680f8b8

Browse files
authored
Rollup merge of rust-lang#111863 - compiler-errors:check-more-mir, r=b-naber
Don't skip mir typeck if body has errors Comment says: ``` // if verifier failed, don't do further checks to avoid ICEs ``` But there are no ICEs to be found. The comment is quite old, so perhaps something fixed it... maybe because the MIR typechecker is delaying span bugs rather than panicking via eager bugs? IDK I'm generally inclined to fix the ICEs themselves that were to arise from this, rather than just totally skipping large parts of the compiler that have impacts on downstream logic (namely, our opaque type results are affected). Anyways, this happens on the error path, so it shouldn't really matter. Fixes this hack: https://github.com/rust-lang/rust/pull/111853/files#r1201501540
2 parents d09ee57 + b1387e7 commit 680f8b8

File tree

1 file changed

+9
-27
lines changed
  • compiler/rustc_borrowck/src/type_check

1 file changed

+9
-27
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+9-27
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,10 @@ pub(crate) fn type_check<'mir, 'tcx>(
183183
&mut borrowck_context,
184184
);
185185

186-
let errors_reported = {
187-
let mut verifier = TypeVerifier::new(&mut checker, promoted);
188-
verifier.visit_body(&body);
189-
verifier.errors_reported
190-
};
191-
192-
if !errors_reported {
193-
// if verifier failed, don't do further checks to avoid ICEs
194-
checker.typeck_mir(body);
195-
}
186+
let mut verifier = TypeVerifier::new(&mut checker, promoted);
187+
verifier.visit_body(&body);
196188

189+
checker.typeck_mir(body);
197190
checker.equate_inputs_and_outputs(&body, universal_regions, &normalized_inputs_and_output);
198191
checker.check_signature_annotation(&body);
199192

@@ -294,7 +287,6 @@ struct TypeVerifier<'a, 'b, 'tcx> {
294287
cx: &'a mut TypeChecker<'b, 'tcx>,
295288
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
296289
last_span: Span,
297-
errors_reported: bool,
298290
}
299291

300292
impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
@@ -383,13 +375,11 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
383375
};
384376
};
385377

386-
if !self.errors_reported {
387-
let promoted_body = &self.promoted[promoted];
388-
self.sanitize_promoted(promoted_body, location);
378+
let promoted_body = &self.promoted[promoted];
379+
self.sanitize_promoted(promoted_body, location);
389380

390-
let promoted_ty = promoted_body.return_ty();
391-
check_err(self, promoted_body, ty, promoted_ty);
392-
}
381+
let promoted_ty = promoted_body.return_ty();
382+
check_err(self, promoted_body, ty, promoted_ty);
393383
} else {
394384
self.cx.ascribe_user_type(
395385
constant.literal.ty(),
@@ -483,9 +473,6 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
483473
for local_decl in &body.local_decls {
484474
self.sanitize_type(local_decl, local_decl.ty);
485475
}
486-
if self.errors_reported {
487-
return;
488-
}
489476
self.super_body(body);
490477
}
491478
}
@@ -495,7 +482,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
495482
cx: &'a mut TypeChecker<'b, 'tcx>,
496483
promoted: &'b IndexSlice<Promoted, Body<'tcx>>,
497484
) -> Self {
498-
TypeVerifier { promoted, last_span: cx.body.span, cx, errors_reported: false }
485+
TypeVerifier { promoted, last_span: cx.body.span, cx }
499486
}
500487

501488
fn body(&self) -> &Body<'tcx> {
@@ -529,7 +516,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
529516
for elem in place.projection.iter() {
530517
if place_ty.variant_index.is_none() {
531518
if let Err(guar) = place_ty.ty.error_reported() {
532-
assert!(self.errors_reported);
533519
return PlaceTy::from_ty(self.tcx().ty_error(guar));
534520
}
535521
}
@@ -593,10 +579,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
593579

594580
self.visit_body(&promoted_body);
595581

596-
if !self.errors_reported {
597-
// if verifier failed, don't do further checks to avoid ICEs
598-
self.cx.typeck_mir(promoted_body);
599-
}
582+
self.cx.typeck_mir(promoted_body);
600583

601584
self.cx.body = parent_body;
602585
// Merge the outlives constraints back in, at the given location.
@@ -762,7 +745,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
762745
}
763746

764747
fn error(&mut self) -> Ty<'tcx> {
765-
self.errors_reported = true;
766748
self.tcx().ty_error_misc()
767749
}
768750

0 commit comments

Comments
 (0)