@@ -267,6 +267,9 @@ impl TargetDataLayout {
267267 [ "a" , ref a @ ..] => dl. aggregate_align = align ( a, "a" ) ?,
268268 [ "f32" , ref a @ ..] => dl. f32_align = align ( a, "f32" ) ?,
269269 [ "f64" , ref a @ ..] => dl. f64_align = align ( a, "f64" ) ?,
270+ // FIXME(erikdesjardins): we should be parsing nonzero address spaces
271+ // this will require replacing TargetDataLayout::{pointer_size,pointer_align}
272+ // with e.g. `fn pointer_size_in(AddressSpace)`
270273 [ p @ "p" , s, ref a @ ..] | [ p @ "p0" , s, ref a @ ..] => {
271274 dl. pointer_size = size ( s, p) ?;
272275 dl. pointer_align = align ( a, p) ?;
@@ -861,7 +864,7 @@ pub enum Primitive {
861864 Int ( Integer , bool ) ,
862865 F32 ,
863866 F64 ,
864- Pointer ,
867+ Pointer ( AddressSpace ) ,
865868}
866869
867870impl Primitive {
@@ -872,7 +875,10 @@ impl Primitive {
872875 Int ( i, _) => i. size ( ) ,
873876 F32 => Size :: from_bits ( 32 ) ,
874877 F64 => Size :: from_bits ( 64 ) ,
875- Pointer => dl. pointer_size ,
878+ // FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
879+ // different address spaces can have different sizes
880+ // (but TargetDataLayout doesn't currently parse that part of the DL string)
881+ Pointer ( _) => dl. pointer_size ,
876882 }
877883 }
878884
@@ -883,14 +889,12 @@ impl Primitive {
883889 Int ( i, _) => i. align ( dl) ,
884890 F32 => dl. f32_align ,
885891 F64 => dl. f64_align ,
886- Pointer => dl. pointer_align ,
892+ // FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
893+ // different address spaces can have different alignments
894+ // (but TargetDataLayout doesn't currently parse that part of the DL string)
895+ Pointer ( _) => dl. pointer_align ,
887896 }
888897 }
889-
890- #[ inline]
891- pub fn is_ptr ( self ) -> bool {
892- matches ! ( self , Pointer )
893- }
894898}
895899
896900/// Inclusive wrap-around range of valid values, that is, if
@@ -1176,7 +1180,8 @@ impl FieldsShape {
11761180/// An identifier that specifies the address space that some operation
11771181/// should operate on. Special address spaces have an effect on code generation,
11781182/// depending on the target and the address spaces it implements.
1179- #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord ) ]
1183+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
1184+ #[ cfg_attr( feature = "nightly" , derive( HashStable_Generic ) ) ]
11801185pub struct AddressSpace ( pub u32 ) ;
11811186
11821187impl AddressSpace {
@@ -1456,7 +1461,6 @@ pub struct PointeeInfo {
14561461 pub size : Size ,
14571462 pub align : Align ,
14581463 pub safe : Option < PointerKind > ,
1459- pub address_space : AddressSpace ,
14601464}
14611465
14621466/// Used in `might_permit_raw_init` to indicate the kind of initialisation
0 commit comments