@@ -12,7 +12,6 @@ use rustc_middle::mir::interpret::Scalar;
1212use rustc_middle:: mir:: { self , Const } ;
1313use rustc_middle:: thir:: { FieldPat , Pat , PatKind , PatRange , PatRangeBoundary } ;
1414use rustc_middle:: ty:: layout:: IntegerExt ;
15- use rustc_middle:: ty:: TypeVisitableExt ;
1615use rustc_middle:: ty:: { self , OpaqueTypeKey , Ty , TyCtxt , VariantDef } ;
1716use rustc_span:: ErrorGuaranteed ;
1817use 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