File tree 2 files changed +5
-12
lines changed
2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -970,7 +970,7 @@ fn univariant<
970
970
let mut align = if pack. is_some ( ) { dl. i8_align } else { dl. aggregate_align } ;
971
971
let mut max_repr_align = repr. align ;
972
972
let mut inverse_memory_index: IndexVec < u32 , FieldIdx > = fields. indices ( ) . collect ( ) ;
973
- let optimize = !repr. inhibit_struct_field_reordering_opt ( ) ;
973
+ let optimize = !repr. inhibit_struct_field_reordering ( ) ;
974
974
if optimize && fields. len ( ) > 1 {
975
975
let end = if let StructKind :: MaybeUnsized = kind { fields. len ( ) - 1 } else { fields. len ( ) } ;
976
976
let optimizing = & mut inverse_memory_index. raw [ ..end] ;
Original file line number Diff line number Diff line change @@ -137,23 +137,16 @@ impl ReprOptions {
137
137
self . c ( ) || self . int . is_some ( )
138
138
}
139
139
140
- /// Returns `true` if this `#[repr()]` should inhibit struct field reordering
141
- /// optimizations, such as with `repr(C)`, `repr(packed(1))`, or `repr(<int>)`.
142
- pub fn inhibit_struct_field_reordering_opt ( & self ) -> bool {
143
- if let Some ( pack) = self . pack {
144
- if pack. bytes ( ) == 1 {
145
- return true ;
146
- }
147
- }
148
-
140
+ /// Returns `true` if this `#[repr()]` guarantees a fixed field order,
141
+ /// e.g. `repr(C)` or `repr(<int>)`.
142
+ pub fn inhibit_struct_field_reordering ( & self ) -> bool {
149
143
self . flags . intersects ( ReprFlags :: IS_UNOPTIMISABLE ) || self . int . is_some ( )
150
144
}
151
145
152
146
/// Returns `true` if this type is valid for reordering and `-Z randomize-layout`
153
147
/// was enabled for its declaration crate.
154
148
pub fn can_randomize_type_layout ( & self ) -> bool {
155
- !self . inhibit_struct_field_reordering_opt ( )
156
- && self . flags . contains ( ReprFlags :: RANDOMIZE_LAYOUT )
149
+ !self . inhibit_struct_field_reordering ( ) && self . flags . contains ( ReprFlags :: RANDOMIZE_LAYOUT )
157
150
}
158
151
159
152
/// Returns `true` if this `#[repr()]` should inhibit union ABI optimisations.
You can’t perform that action at this time.
0 commit comments