@@ -10,6 +10,7 @@ use rustc_hashes::Hash64;
10
10
use rustc_index:: IndexVec ;
11
11
use rustc_middle:: bug;
12
12
use rustc_middle:: query:: Providers ;
13
+ use rustc_middle:: traits:: ObligationCause ;
13
14
use rustc_middle:: ty:: layout:: {
14
15
FloatExt , HasTyCtxt , IntegerExt , LayoutCx , LayoutError , LayoutOf , TyAndLayout ,
15
16
} ;
@@ -390,30 +391,31 @@ fn layout_of_uncached<'tcx>(
390
391
391
392
let metadata = if let Some ( metadata_def_id) = tcx. lang_items ( ) . metadata_type ( ) {
392
393
let pointee_metadata = Ty :: new_projection ( tcx, metadata_def_id, [ pointee] ) ;
393
- let metadata_ty =
394
- match tcx . try_normalize_erasing_regions ( cx. typing_env , pointee_metadata) {
395
- Ok ( metadata_ty ) => metadata_ty ,
396
- Err ( mut err ) => {
397
- // Usually `<Ty as Pointee>::Metadata` can't be normalized because
398
- // its struct tail cannot be normalized either, so try to get a
399
- // more descriptive layout error here, which will lead to less confusing
400
- // diagnostics.
401
- //
402
- // We use the raw struct tail function here to get the first tail
403
- // that is an alias, which is likely the cause of the normalization
404
- // error.
405
- match tcx . try_normalize_erasing_regions (
406
- cx . typing_env ,
407
- tcx . struct_tail_raw ( pointee , |ty| ty , || { } ) ,
408
- ) {
409
- Ok ( _ ) => { }
410
- Err ( better_err ) => {
411
- err = better_err ;
412
- }
394
+ let metadata_ty = match tcx
395
+ . try_normalize_erasing_regions ( cx. typing_env , pointee_metadata)
396
+ {
397
+ Ok ( metadata_ty ) => metadata_ty ,
398
+ Err ( mut err ) => {
399
+ // Usually `<Ty as Pointee>::Metadata` can't be normalized because
400
+ // its struct tail cannot be normalized either, so try to get a
401
+ // more descriptive layout error here, which will lead to less confusing
402
+ // diagnostics.
403
+ //
404
+ // We use the raw struct tail function here to get the first tail
405
+ // that is an alias, which is likely the cause of the normalization
406
+ // error.
407
+ match tcx . try_normalize_erasing_regions (
408
+ cx . typing_env ,
409
+ tcx . struct_tail_raw ( pointee , & ObligationCause :: dummy ( ) , |ty| ty , || { } ) ,
410
+ ) {
411
+ Ok ( _ ) => { }
412
+ Err ( better_err ) => {
413
+ err = better_err ;
413
414
}
414
- return Err ( error ( cx, LayoutError :: NormalizationFailure ( pointee, err) ) ) ;
415
415
}
416
- } ;
416
+ return Err ( error ( cx, LayoutError :: NormalizationFailure ( pointee, err) ) ) ;
417
+ }
418
+ } ;
417
419
418
420
let metadata_layout = cx. layout_of ( metadata_ty) ?;
419
421
// If the metadata is a 1-zst, then the pointer is thin.
0 commit comments