Skip to content

Commit 610d169

Browse files
committed
Auto merge of #22767 - pnkfelix:issue-22265, r=nikomatsakis
Avoid `cat_expr Erred` notes when already in error state. Also, to ensure we do not let the dropck get skipped, ICE if `cat_expr` errors when *not* in error state. This is not known to be a breaking change (i.e. I do not know of a current case that causes the new ICE to be exercised). Fix #22265
2 parents 4db0b32 + 92bc3ea commit 610d169

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/librustc_typeck/check/regionck.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,12 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
554554
expr.span);
555555
}
556556
Err(..) => {
557-
rcx.fcx.tcx().sess.span_note(expr.span,
558-
"cat_expr_unadjusted Errd during dtor check");
557+
let tcx = rcx.fcx.tcx();
558+
if tcx.sess.has_errors() {
559+
// cannot run dropck; okay b/c in error state anyway.
560+
} else {
561+
tcx.sess.span_bug(expr.span, "cat_expr_unadjusted Errd");
562+
}
559563
}
560564
}
561565
}
@@ -571,8 +575,12 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
571575
check_safety_of_rvalue_destructor_if_necessary(rcx, head_cmt, expr.span);
572576
}
573577
Err(..) => {
574-
rcx.fcx.tcx().sess.span_note(expr.span,
575-
"cat_expr Errd during dtor check");
578+
let tcx = rcx.fcx.tcx();
579+
if tcx.sess.has_errors() {
580+
// cannot run dropck; okay b/c in error state anyway.
581+
} else {
582+
tcx.sess.span_bug(expr.span, "cat_expr Errd");
583+
}
576584
}
577585
}
578586

0 commit comments

Comments
 (0)