Skip to content

Commit 0112270

Browse files
committed
Only abort when the type error would cause issues
1 parent f051185 commit 0112270

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_pattern_analysis/src

1 file changed

+5
-5
lines changed

compiler/rustc_pattern_analysis/src/rustc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_middle::mir::interpret::Scalar;
1212
use rustc_middle::mir::{self, Const};
1313
use rustc_middle::thir::{FieldPat, Pat, PatKind, PatRange, PatRangeBoundary};
1414
use rustc_middle::ty::layout::IntegerExt;
15-
use rustc_middle::ty::TypeVisitableExt;
1615
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt, VariantDef};
1716
use rustc_span::ErrorGuaranteed;
1817
use rustc_span::{Span, DUMMY_SP};
@@ -316,8 +315,6 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
316315
RangeEnd::Included,
317316
)
318317
};
319-
// Abort on type error.
320-
ty.error_reported()?;
321318
// This determines the set of all possible constructors for the type `ty`. For numbers,
322319
// arrays and slices we use ranges and variable-length slices when appropriate.
323320
Ok(match ty.kind() {
@@ -425,8 +422,11 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
425422
| ty::Closure(_, _)
426423
| ty::Coroutine(_, _)
427424
| ty::Alias(_, _)
428-
| ty::Param(_)
429-
| ty::Error(_) => ConstructorSet::Unlistable,
425+
| ty::Param(_) => ConstructorSet::Unlistable,
426+
ty::Error(err) => {
427+
// Abort on type error.
428+
return Err(*err);
429+
}
430430
ty::CoroutineWitness(_, _) | ty::Bound(_, _) | ty::Placeholder(_) | ty::Infer(_) => {
431431
bug!("Encountered unexpected type in `ConstructorSet::for_ty`: {ty:?}")
432432
}

0 commit comments

Comments
 (0)