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 ) ) ]
@@ -342,6 +341,7 @@ impl TargetDataLayout {
342
341
343
342
#[ inline]
344
343
pub fn ptr_sized_integer ( & self ) -> Integer {
344
+ use Integer :: * ;
345
345
match self . pointer_size . bits ( ) {
346
346
16 => I16 ,
347
347
32 => I32 ,
@@ -786,6 +786,7 @@ pub enum Integer {
786
786
impl Integer {
787
787
#[ inline]
788
788
pub fn size ( self ) -> Size {
789
+ use Integer :: * ;
789
790
match self {
790
791
I8 => Size :: from_bytes ( 1 ) ,
791
792
I16 => Size :: from_bytes ( 2 ) ,
@@ -806,6 +807,7 @@ impl Integer {
806
807
}
807
808
808
809
pub fn align < C : HasDataLayout > ( self , cx : & C ) -> AbiAndPrefAlign {
810
+ use Integer :: * ;
809
811
let dl = cx. data_layout ( ) ;
810
812
811
813
match self {
@@ -820,6 +822,7 @@ impl Integer {
820
822
/// Returns the largest signed value that can be represented by this Integer.
821
823
#[ inline]
822
824
pub fn signed_max ( self ) -> i128 {
825
+ use Integer :: * ;
823
826
match self {
824
827
I8 => i8:: MAX as i128 ,
825
828
I16 => i16:: MAX as i128 ,
@@ -832,6 +835,7 @@ impl Integer {
832
835
/// Finds the smallest Integer type which can represent the signed value.
833
836
#[ inline]
834
837
pub fn fit_signed ( x : i128 ) -> Integer {
838
+ use Integer :: * ;
835
839
match x {
836
840
-0x0000_0000_0000_0080 ..=0x0000_0000_0000_007f => I8 ,
837
841
-0x0000_0000_0000_8000 ..=0x0000_0000_0000_7fff => I16 ,
@@ -844,6 +848,7 @@ impl Integer {
844
848
/// Finds the smallest Integer type which can represent the unsigned value.
845
849
#[ inline]
846
850
pub fn fit_unsigned ( x : u128 ) -> Integer {
851
+ use Integer :: * ;
847
852
match x {
848
853
0 ..=0x0000_0000_0000_00ff => I8 ,
849
854
0 ..=0x0000_0000_0000_ffff => I16 ,
@@ -855,6 +860,7 @@ impl Integer {
855
860
856
861
/// Finds the smallest integer with the given alignment.
857
862
pub fn for_align < C : HasDataLayout > ( cx : & C , wanted : Align ) -> Option < Integer > {
863
+ use Integer :: * ;
858
864
let dl = cx. data_layout ( ) ;
859
865
860
866
[ I8 , I16 , I32 , I64 , I128 ] . into_iter ( ) . find ( |& candidate| {
@@ -864,6 +870,7 @@ impl Integer {
864
870
865
871
/// Find the largest integer with the given alignment or less.
866
872
pub fn approximate_align < C : HasDataLayout > ( cx : & C , wanted : Align ) -> Integer {
873
+ use Integer :: * ;
867
874
let dl = cx. data_layout ( ) ;
868
875
869
876
// FIXME(eddyb) maybe include I128 in the future, when it works everywhere.
@@ -909,6 +916,7 @@ pub enum Primitive {
909
916
910
917
impl Primitive {
911
918
pub fn size < C : HasDataLayout > ( self , cx : & C ) -> Size {
919
+ use Primitive :: * ;
912
920
let dl = cx. data_layout ( ) ;
913
921
914
922
match self {
@@ -923,6 +931,7 @@ impl Primitive {
923
931
}
924
932
925
933
pub fn align < C : HasDataLayout > ( self , cx : & C ) -> AbiAndPrefAlign {
934
+ use Primitive :: * ;
926
935
let dl = cx. data_layout ( ) ;
927
936
928
937
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