@@ -53,10 +53,11 @@ bitflags! {
5353#[ derive( Copy , Clone , Debug , Eq , PartialEq ) ]
5454#[ cfg_attr( feature = "nightly" , derive( Encodable , Decodable , HashStable_Generic ) ) ]
5555pub enum IntegerType {
56- /// Pointer sized integer type, i.e. isize and usize. The field shows signedness, that
57- /// is, `Pointer(true)` is isize.
56+ /// Pointer- sized integer type, i.e. ` isize` and ` usize` . The field shows signedness, e.g.
57+ /// `Pointer(true)` means ` isize` .
5858 Pointer ( bool ) ,
59- /// Fix sized integer type, e.g. i8, u32, i128 The bool field shows signedness, `Fixed(I8, false)` means `u8`
59+ /// Fixed-sized integer type, e.g. `i8`, `u32`, `i128`. The bool field shows signedness, e.g.
60+ /// `Fixed(I8, false)` means `u8`.
6061 Fixed ( Integer , bool ) ,
6162}
6263
@@ -69,7 +70,7 @@ impl IntegerType {
6970 }
7071}
7172
72- /// Represents the repr options provided by the user,
73+ /// Represents the repr options provided by the user.
7374#[ derive( Copy , Clone , Debug , Eq , PartialEq , Default ) ]
7475#[ cfg_attr( feature = "nightly" , derive( Encodable , Decodable , HashStable_Generic ) ) ]
7576pub struct ReprOptions {
@@ -139,7 +140,7 @@ impl ReprOptions {
139140 }
140141
141142 /// Returns `true` if this type is valid for reordering and `-Z randomize-layout`
142- /// was enabled for its declaration crate
143+ /// was enabled for its declaration crate.
143144 pub fn can_randomize_type_layout ( & self ) -> bool {
144145 !self . inhibit_struct_field_reordering_opt ( )
145146 && self . flags . contains ( ReprFlags :: RANDOMIZE_LAYOUT )
@@ -217,7 +218,8 @@ pub enum TargetDataLayoutErrors<'a> {
217218}
218219
219220impl TargetDataLayout {
220- /// Parse data layout from an [llvm data layout string](https://llvm.org/docs/LangRef.html#data-layout)
221+ /// Parse data layout from an
222+ /// [llvm data layout string](https://llvm.org/docs/LangRef.html#data-layout)
221223 ///
222224 /// This function doesn't fill `c_enum_min_size` and it will always be `I32` since it can not be
223225 /// determined from llvm string.
@@ -242,10 +244,11 @@ impl TargetDataLayout {
242244 } ;
243245
244246 // Parse a size string.
245- let size = |s : & ' a str , cause : & ' a str | parse_bits ( s, "size" , cause) . map ( Size :: from_bits) ;
247+ let parse_size =
248+ |s : & ' a str , cause : & ' a str | parse_bits ( s, "size" , cause) . map ( Size :: from_bits) ;
246249
247250 // Parse an alignment string.
248- let align = |s : & [ & ' a str ] , cause : & ' a str | {
251+ let parse_align = |s : & [ & ' a str ] , cause : & ' a str | {
249252 if s. is_empty ( ) {
250253 return Err ( TargetDataLayoutErrors :: MissingAlignment { cause } ) ;
251254 }
@@ -269,22 +272,22 @@ impl TargetDataLayout {
269272 [ p] if p. starts_with ( 'P' ) => {
270273 dl. instruction_address_space = parse_address_space ( & p[ 1 ..] , "P" ) ?
271274 }
272- [ "a" , ref a @ ..] => dl. aggregate_align = align ( a, "a" ) ?,
273- [ "f32" , ref a @ ..] => dl. f32_align = align ( a, "f32" ) ?,
274- [ "f64" , ref a @ ..] => dl. f64_align = align ( a, "f64" ) ?,
275+ [ "a" , ref a @ ..] => dl. aggregate_align = parse_align ( a, "a" ) ?,
276+ [ "f32" , ref a @ ..] => dl. f32_align = parse_align ( a, "f32" ) ?,
277+ [ "f64" , ref a @ ..] => dl. f64_align = parse_align ( a, "f64" ) ?,
275278 // FIXME(erikdesjardins): we should be parsing nonzero address spaces
276279 // this will require replacing TargetDataLayout::{pointer_size,pointer_align}
277280 // with e.g. `fn pointer_size_in(AddressSpace)`
278281 [ p @ "p" , s, ref a @ ..] | [ p @ "p0" , s, ref a @ ..] => {
279- dl. pointer_size = size ( s, p) ?;
280- dl. pointer_align = align ( a, p) ?;
282+ dl. pointer_size = parse_size ( s, p) ?;
283+ dl. pointer_align = parse_align ( a, p) ?;
281284 }
282285 [ s, ref a @ ..] if s. starts_with ( 'i' ) => {
283286 let Ok ( bits) = s[ 1 ..] . parse :: < u64 > ( ) else {
284- size ( & s[ 1 ..] , "i" ) ?; // For the user error.
287+ parse_size ( & s[ 1 ..] , "i" ) ?; // For the user error.
285288 continue ;
286289 } ;
287- let a = align ( a, s) ?;
290+ let a = parse_align ( a, s) ?;
288291 match bits {
289292 1 => dl. i1_align = a,
290293 8 => dl. i8_align = a,
@@ -301,8 +304,8 @@ impl TargetDataLayout {
301304 }
302305 }
303306 [ s, ref a @ ..] if s. starts_with ( 'v' ) => {
304- let v_size = size ( & s[ 1 ..] , "v" ) ?;
305- let a = align ( a, s) ?;
307+ let v_size = parse_size ( & s[ 1 ..] , "v" ) ?;
308+ let a = parse_align ( a, s) ?;
306309 if let Some ( v) = dl. vector_align . iter_mut ( ) . find ( |v| v. 0 == v_size) {
307310 v. 1 = a;
308311 continue ;
@@ -747,7 +750,6 @@ impl Align {
747750/// A pair of alignments, ABI-mandated and preferred.
748751#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
749752#[ cfg_attr( feature = "nightly" , derive( HashStable_Generic ) ) ]
750-
751753pub struct AbiAndPrefAlign {
752754 pub abi : Align ,
753755 pub pref : Align ,
@@ -773,7 +775,6 @@ impl AbiAndPrefAlign {
773775/// Integers, also used for enum discriminants.
774776#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
775777#[ cfg_attr( feature = "nightly" , derive( Encodable , Decodable , HashStable_Generic ) ) ]
776-
777778pub enum Integer {
778779 I8 ,
779780 I16 ,
@@ -937,8 +938,7 @@ impl Primitive {
937938}
938939
939940/// Inclusive wrap-around range of valid values, that is, if
940- /// start > end, it represents `start..=MAX`,
941- /// followed by `0..=end`.
941+ /// start > end, it represents `start..=MAX`, followed by `0..=end`.
942942///
943943/// That is, for an i8 primitive, a range of `254..=2` means following
944944/// sequence:
@@ -970,21 +970,21 @@ impl WrappingRange {
970970
971971 /// Returns `self` with replaced `start`
972972 #[ inline( always) ]
973- pub fn with_start ( mut self , start : u128 ) -> Self {
973+ fn with_start ( mut self , start : u128 ) -> Self {
974974 self . start = start;
975975 self
976976 }
977977
978978 /// Returns `self` with replaced `end`
979979 #[ inline( always) ]
980- pub fn with_end ( mut self , end : u128 ) -> Self {
980+ fn with_end ( mut self , end : u128 ) -> Self {
981981 self . end = end;
982982 self
983983 }
984984
985985 /// Returns `true` if `size` completely fills the range.
986986 #[ inline]
987- pub fn is_full_for ( & self , size : Size ) -> bool {
987+ fn is_full_for ( & self , size : Size ) -> bool {
988988 let max_value = size. unsigned_int_max ( ) ;
989989 debug_assert ! ( self . start <= max_value && self . end <= max_value) ;
990990 self . start == ( self . end . wrapping_add ( 1 ) & max_value)
@@ -1066,15 +1066,17 @@ impl Scalar {
10661066 }
10671067
10681068 #[ inline]
1069- /// Allows the caller to mutate the valid range. This operation will panic if attempted on a union.
1069+ /// Allows the caller to mutate the valid range. This operation will panic if attempted on a
1070+ /// union.
10701071 pub fn valid_range_mut ( & mut self ) -> & mut WrappingRange {
10711072 match self {
10721073 Scalar :: Initialized { valid_range, .. } => valid_range,
10731074 Scalar :: Union { .. } => panic ! ( "cannot change the valid range of a union" ) ,
10741075 }
10751076 }
10761077
1077- /// Returns `true` if all possible numbers are valid, i.e `valid_range` covers the whole layout
1078+ /// Returns `true` if all possible numbers are valid, i.e `valid_range` covers the whole
1079+ /// layout.
10781080 #[ inline]
10791081 pub fn is_always_valid < C : HasDataLayout > ( & self , cx : & C ) -> bool {
10801082 match * self {
@@ -1252,7 +1254,6 @@ impl AddressSpace {
12521254/// in terms of categories of C types there are ABI rules for.
12531255#[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
12541256#[ cfg_attr( feature = "nightly" , derive( HashStable_Generic ) ) ]
1255-
12561257pub enum Abi {
12571258 Uninhabited ,
12581259 Scalar ( Scalar ) ,
@@ -1457,17 +1458,19 @@ impl Niche {
14571458 return None ;
14581459 }
14591460
1460- // Extend the range of valid values being reserved by moving either `v.start` or `v.end` bound.
1461- // Given an eventual `Option<T>`, we try to maximize the chance for `None` to occupy the niche of zero.
1462- // This is accomplished by preferring enums with 2 variants(`count==1`) and always taking the shortest path to niche zero.
1463- // Having `None` in niche zero can enable some special optimizations.
1461+ // Extend the range of valid values being reserved by moving either `v.start` or `v.end`
1462+ // bound. Given an eventual `Option<T>`, we try to maximize the chance for `None` to occupy
1463+ // the niche of zero. This is accomplished by preferring enums with 2 variants(`count==1`)
1464+ // and always taking the shortest path to niche zero. Having `None` in niche zero can
1465+ // enable some special optimizations.
14641466 //
14651467 // Bound selection criteria:
14661468 // 1. Select closest to zero given wrapping semantics.
14671469 // 2. Avoid moving past zero if possible.
14681470 //
1469- // In practice this means that enums with `count > 1` are unlikely to claim niche zero, since they have to fit perfectly.
1470- // If niche zero is already reserved, the selection of bounds are of little interest.
1471+ // In practice this means that enums with `count > 1` are unlikely to claim niche zero,
1472+ // since they have to fit perfectly. If niche zero is already reserved, the selection of
1473+ // bounds are of little interest.
14711474 let move_start = |v : WrappingRange | {
14721475 let start = v. start . wrapping_sub ( count) & max_value;
14731476 Some ( ( start, Scalar :: Initialized { value, valid_range : v. with_start ( start) } ) )
0 commit comments