@@ -7,7 +7,7 @@ use rustc_middle::bug;
77use rustc_middle:: ty:: { self , Article , FloatTy , IntTy , Ty , TyCtxt , TypeVisitableExt , UintTy } ;
88use rustc_session:: lint;
99use rustc_span:: def_id:: LocalDefId ;
10- use rustc_span:: { Span , Symbol , sym} ;
10+ use rustc_span:: { ErrorGuaranteed , Span , Symbol , sym} ;
1111use rustc_target:: asm:: {
1212 InlineAsmReg , InlineAsmRegClass , InlineAsmRegOrRegClass , InlineAsmType , ModifierInfo ,
1313} ;
@@ -27,6 +27,7 @@ enum NonAsmTypeReason<'tcx> {
2727 InvalidElement ( DefId , Ty < ' tcx > ) ,
2828 NotSizedPtr ( Ty < ' tcx > ) ,
2929 EmptySIMDArray ( Ty < ' tcx > ) ,
30+ Tainted ( ErrorGuaranteed ) ,
3031}
3132
3233impl < ' a , ' tcx > InlineAsmCtxt < ' a , ' tcx > {
@@ -94,11 +95,11 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
9495 }
9596 ty:: Adt ( adt, args) if adt. repr ( ) . simd ( ) => {
9697 if !adt. is_struct ( ) {
97- self . fcx . dcx ( ) . span_delayed_bug (
98+ let guar = self . fcx . dcx ( ) . span_delayed_bug (
9899 span,
99100 format ! ( "repr(simd) should only be used on structs, got {}" , adt. descr( ) ) ,
100101 ) ;
101- return Err ( NonAsmTypeReason :: Invalid ( ty ) ) ;
102+ return Err ( NonAsmTypeReason :: Tainted ( guar ) ) ;
102103 }
103104
104105 let fields = & adt. non_enum_variant ( ) . fields ;
@@ -242,6 +243,9 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
242243 let msg = format ! ( "use of empty SIMD vector `{ty}`" ) ;
243244 self . fcx . dcx ( ) . struct_span_err ( expr. span , msg) . emit ( ) ;
244245 }
246+ NonAsmTypeReason :: Tainted ( _error_guard) => {
247+ // An error has already been reported.
248+ }
245249 }
246250 return None ;
247251 }
0 commit comments