@@ -115,12 +115,17 @@ fn check_transmute<'tcx>(
115115 && let SizeSkeleton :: Known ( size_to, _) = sk_to
116116 && size_to == Pointer ( tcx. data_layout . instruction_address_space ) . size ( & tcx)
117117 {
118- struct_span_code_err ! ( tcx. sess. dcx( ) , span( ) , E0591 , "can't transmute zero-sized type" )
119- . with_note ( format ! ( "source type: {from}" ) )
120- . with_note ( format ! ( "target type: {to}" ) )
121- . with_help ( "cast with `as` to a pointer instead" )
122- . emit ( ) ;
123- return Ok ( ( ) ) ;
118+ let err = struct_span_code_err ! (
119+ tcx. sess. dcx( ) ,
120+ span( ) ,
121+ E0591 ,
122+ "can't transmute zero-sized type"
123+ )
124+ . with_note ( format ! ( "source type: {from}" ) )
125+ . with_note ( format ! ( "target type: {to}" ) )
126+ . with_help ( "cast with `as` to a pointer instead" )
127+ . emit ( ) ;
128+ return Err ( err) ;
124129 }
125130 }
126131
@@ -150,7 +155,7 @@ pub(crate) fn check_transmutes(tcx: TyCtxt<'_>, owner: LocalDefId) -> Result<(),
150155 let typing_env = ty:: TypingEnv :: post_analysis ( tcx, owner) ;
151156 let mut result = Ok ( ( ) ) ;
152157 for & ( from, to, hir_id) in & typeck_results. transmutes_to_check {
153- result = check_transmute ( tcx, typing_env, from, to, hir_id) ;
158+ result = result . and ( check_transmute ( tcx, typing_env, from, to, hir_id) ) ;
154159 }
155160 result
156161}
0 commit comments