File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
compiler/rustc_middle/src/mir/interpret Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -384,18 +384,20 @@ impl<'tcx> GlobalAlloc<'tcx> {
384
384
. type_of ( def_id)
385
385
. no_bound_vars ( )
386
386
. expect ( "statics should not have generic parameters" ) ;
387
- let layout = tcx. layout_of ( typing_env. as_query_input ( ty) ) . unwrap ( ) ;
388
- assert ! ( layout. is_sized( ) ) ;
387
+ let layout = tcx. layout_of ( typing_env. as_query_input ( ty) ) ;
388
+ let ( size, mut align) = if let Ok ( layout) = layout {
389
+ assert ! ( layout. is_sized( ) ) ;
390
+ ( layout. size , layout. align . abi )
391
+ } else {
392
+ ( Size :: ZERO , Align :: ONE )
393
+ } ;
389
394
390
395
// Take over-alignment from attributes into account.
391
- let align = match tcx. codegen_fn_attrs ( def_id) . alignment {
392
- Some ( align_from_attribute) => {
393
- Ord :: max ( align_from_attribute, layout. align . abi )
394
- }
395
- None => layout. align . abi ,
396
- } ;
396
+ if let Some ( align_from_attribute) = tcx. codegen_fn_attrs ( def_id) . alignment {
397
+ align = Ord :: max ( align_from_attribute, align) ;
398
+ }
397
399
398
- ( layout . size , align)
400
+ ( size, align)
399
401
}
400
402
}
401
403
GlobalAlloc :: Memory ( alloc) => {
You can’t perform that action at this time.
0 commit comments