@@ -111,19 +111,21 @@ pub(super) fn check<'tcx>(
111111 from_ty_orig, to_ty_orig
112112 ) ,
113113 |diag| {
114- if let ( Some ( from_def) , Some ( to_def) ) = ( from_ty. ty_adt_def ( ) , to_ty. ty_adt_def ( ) )
115- && from_def == to_def
116- {
117- diag. note ( & format ! (
118- "two instances of the same generic type (`{}`) may have different layouts" ,
119- cx. tcx. item_name( from_def. did)
120- ) ) ;
121- } else {
122- if from_ty_orig. peel_refs ( ) != from_ty {
123- diag. note ( & format ! ( "the contained type `{}` has an undefined layout" , from_ty) ) ;
124- }
125- if to_ty_orig. peel_refs ( ) != to_ty {
126- diag. note ( & format ! ( "the contained type `{}` has an undefined layout" , to_ty) ) ;
114+ if_chain ! {
115+ if let ( Some ( from_def) , Some ( to_def) ) = ( from_ty. ty_adt_def( ) , to_ty. ty_adt_def( ) ) ;
116+ if from_def == to_def;
117+ then {
118+ diag. note( & format!(
119+ "two instances of the same generic type (`{}`) may have different layouts" ,
120+ cx. tcx. item_name( from_def. did)
121+ ) ) ;
122+ } else {
123+ if from_ty_orig. peel_refs( ) != from_ty {
124+ diag. note( & format!( "the contained type `{}` has an undefined layout" , from_ty) ) ;
125+ }
126+ if to_ty_orig. peel_refs( ) != to_ty {
127+ diag. note( & format!( "the contained type `{}` has an undefined layout" , to_ty) ) ;
128+ }
127129 }
128130 }
129131 } ,
@@ -279,11 +281,13 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
279281}
280282
281283fn is_zero_sized_ty < ' tcx > ( cx : & LateContext < ' tcx > , ty : Ty < ' tcx > ) -> bool {
282- if let Ok ( ty) = cx. tcx . try_normalize_erasing_regions ( cx. param_env , ty)
283- && let Ok ( layout) = cx. tcx . layout_of ( cx. param_env . and ( ty) )
284- {
285- layout. layout . size . bytes ( ) == 0
286- } else {
287- false
284+ if_chain ! {
285+ if let Ok ( ty) = cx. tcx. try_normalize_erasing_regions( cx. param_env, ty) ;
286+ if let Ok ( layout) = cx. tcx. layout_of( cx. param_env. and( ty) ) ;
287+ then {
288+ layout. layout. size. bytes( ) == 0
289+ } else {
290+ false
291+ }
288292 }
289293}
0 commit comments