1
+ // We want to be able to build this crate with a stable compiler, so no
2
+ // `#![feature]` attributes should be added.
1
3
#![ cfg_attr( feature = "nightly" , feature( step_trait, rustc_attrs, min_specialization) ) ]
2
4
#![ cfg_attr( feature = "nightly" , allow( internal_features) ) ]
3
5
@@ -28,9 +30,6 @@ pub use layout::LayoutCalculator;
28
30
/// instead of implementing everything in `rustc_middle`.
29
31
pub trait HashStableContext { }
30
32
31
- use Integer :: * ;
32
- use Primitive :: * ;
33
-
34
33
bitflags ! {
35
34
#[ derive( Default ) ]
36
35
#[ cfg_attr( feature = "nightly" , derive( Encodable , Decodable , HashStable_Generic ) ) ]
@@ -339,6 +338,7 @@ impl TargetDataLayout {
339
338
340
339
#[ inline]
341
340
pub fn ptr_sized_integer ( & self ) -> Integer {
341
+ use Integer :: * ;
342
342
match self . pointer_size . bits ( ) {
343
343
16 => I16 ,
344
344
32 => I32 ,
@@ -785,6 +785,7 @@ pub enum Integer {
785
785
impl Integer {
786
786
#[ inline]
787
787
pub fn size ( self ) -> Size {
788
+ use Integer :: * ;
788
789
match self {
789
790
I8 => Size :: from_bytes ( 1 ) ,
790
791
I16 => Size :: from_bytes ( 2 ) ,
@@ -805,6 +806,7 @@ impl Integer {
805
806
}
806
807
807
808
pub fn align < C : HasDataLayout > ( self , cx : & C ) -> AbiAndPrefAlign {
809
+ use Integer :: * ;
808
810
let dl = cx. data_layout ( ) ;
809
811
810
812
match self {
@@ -819,6 +821,7 @@ impl Integer {
819
821
/// Returns the largest signed value that can be represented by this Integer.
820
822
#[ inline]
821
823
pub fn signed_max ( self ) -> i128 {
824
+ use Integer :: * ;
822
825
match self {
823
826
I8 => i8:: MAX as i128 ,
824
827
I16 => i16:: MAX as i128 ,
@@ -831,6 +834,7 @@ impl Integer {
831
834
/// Finds the smallest Integer type which can represent the signed value.
832
835
#[ inline]
833
836
pub fn fit_signed ( x : i128 ) -> Integer {
837
+ use Integer :: * ;
834
838
match x {
835
839
-0x0000_0000_0000_0080 ..=0x0000_0000_0000_007f => I8 ,
836
840
-0x0000_0000_0000_8000 ..=0x0000_0000_0000_7fff => I16 ,
@@ -843,6 +847,7 @@ impl Integer {
843
847
/// Finds the smallest Integer type which can represent the unsigned value.
844
848
#[ inline]
845
849
pub fn fit_unsigned ( x : u128 ) -> Integer {
850
+ use Integer :: * ;
846
851
match x {
847
852
0 ..=0x0000_0000_0000_00ff => I8 ,
848
853
0 ..=0x0000_0000_0000_ffff => I16 ,
@@ -854,6 +859,7 @@ impl Integer {
854
859
855
860
/// Finds the smallest integer with the given alignment.
856
861
pub fn for_align < C : HasDataLayout > ( cx : & C , wanted : Align ) -> Option < Integer > {
862
+ use Integer :: * ;
857
863
let dl = cx. data_layout ( ) ;
858
864
859
865
[ I8 , I16 , I32 , I64 , I128 ] . into_iter ( ) . find ( |& candidate| {
@@ -863,6 +869,7 @@ impl Integer {
863
869
864
870
/// Find the largest integer with the given alignment or less.
865
871
pub fn approximate_align < C : HasDataLayout > ( cx : & C , wanted : Align ) -> Integer {
872
+ use Integer :: * ;
866
873
let dl = cx. data_layout ( ) ;
867
874
868
875
// FIXME(eddyb) maybe include I128 in the future, when it works everywhere.
@@ -908,6 +915,7 @@ pub enum Primitive {
908
915
909
916
impl Primitive {
910
917
pub fn size < C : HasDataLayout > ( self , cx : & C ) -> Size {
918
+ use Primitive :: * ;
911
919
let dl = cx. data_layout ( ) ;
912
920
913
921
match self {
@@ -922,6 +930,7 @@ impl Primitive {
922
930
}
923
931
924
932
pub fn align < C : HasDataLayout > ( self , cx : & C ) -> AbiAndPrefAlign {
933
+ use Primitive :: * ;
925
934
let dl = cx. data_layout ( ) ;
926
935
927
936
match self {
@@ -1027,10 +1036,11 @@ pub enum Scalar {
1027
1036
impl Scalar {
1028
1037
#[ inline]
1029
1038
pub fn is_bool ( & self ) -> bool {
1039
+ use Integer :: * ;
1030
1040
matches ! (
1031
1041
self ,
1032
1042
Scalar :: Initialized {
1033
- value: Int ( I8 , false ) ,
1043
+ value: Primitive :: Int ( I8 , false ) ,
1034
1044
valid_range: WrappingRange { start: 0 , end: 1 }
1035
1045
}
1036
1046
)
0 commit comments