Skip to content

Commit 3b99d73

Browse files
committed
Unglob rustc_abi imports
1 parent 5ead745 commit 3b99d73

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

compiler/rustc_abi/src/layout.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
use super::*;
21
use std::fmt::Write;
32
use std::{borrow::Borrow, cmp, iter, ops::Bound};
43

5-
#[cfg(feature = "randomize")]
6-
use rand::{seq::SliceRandom, SeedableRng};
7-
#[cfg(feature = "randomize")]
8-
use rand_xoshiro::Xoshiro128StarStar;
9-
104
use tracing::debug;
115

6+
use crate::{
7+
Abi, AbiAndPrefAlign, Align, FieldIdx, FieldsShape, IndexSlice, IndexVec, Integer, Layout,
8+
LayoutS, Niche, NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding,
9+
TargetDataLayout, VariantIdx, Variants, WrappingRange, FIRST_VARIANT,
10+
};
1211
pub trait LayoutCalculator {
1312
type TargetDataLayoutRef: Borrow<TargetDataLayout>;
1413

@@ -587,7 +586,7 @@ pub trait LayoutCalculator {
587586

588587
let tag_mask = ity.size().unsigned_int_max();
589588
let tag = Scalar::Initialized {
590-
value: Int(ity, signed),
589+
value: Primitive::Int(ity, signed),
591590
valid_range: WrappingRange {
592591
start: (min as u128 & tag_mask),
593592
end: (max as u128 & tag_mask),
@@ -873,9 +872,12 @@ fn univariant(
873872
if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
874873
#[cfg(feature = "randomize")]
875874
{
875+
use rand::{seq::SliceRandom, SeedableRng};
876876
// `ReprOptions.layout_seed` is a deterministic seed we can use to randomize field
877877
// ordering.
878-
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed.as_u64());
878+
let mut rng = rand_xoshiro::Xoshiro128StarStar::seed_from_u64(
879+
repr.field_shuffle_seed.as_u64(),
880+
);
879881

880882
// Shuffle the ordering of the fields.
881883
optimizing.shuffle(&mut rng);

compiler/rustc_abi/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// We want to be able to build this crate with a stable compiler, so no
2+
// `#![feature]` attributes should be added.
13
#![cfg_attr(feature = "nightly", feature(step_trait, rustc_attrs, min_specialization))]
24
#![cfg_attr(feature = "nightly", allow(internal_features))]
35

@@ -28,9 +30,6 @@ pub use layout::LayoutCalculator;
2830
/// instead of implementing everything in `rustc_middle`.
2931
pub trait HashStableContext {}
3032

31-
use Integer::*;
32-
use Primitive::*;
33-
3433
bitflags! {
3534
#[derive(Default)]
3635
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_Generic))]
@@ -342,6 +341,7 @@ impl TargetDataLayout {
342341

343342
#[inline]
344343
pub fn ptr_sized_integer(&self) -> Integer {
344+
use Integer::*;
345345
match self.pointer_size.bits() {
346346
16 => I16,
347347
32 => I32,
@@ -786,6 +786,7 @@ pub enum Integer {
786786
impl Integer {
787787
#[inline]
788788
pub fn size(self) -> Size {
789+
use Integer::*;
789790
match self {
790791
I8 => Size::from_bytes(1),
791792
I16 => Size::from_bytes(2),
@@ -806,6 +807,7 @@ impl Integer {
806807
}
807808

808809
pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAndPrefAlign {
810+
use Integer::*;
809811
let dl = cx.data_layout();
810812

811813
match self {
@@ -820,6 +822,7 @@ impl Integer {
820822
/// Returns the largest signed value that can be represented by this Integer.
821823
#[inline]
822824
pub fn signed_max(self) -> i128 {
825+
use Integer::*;
823826
match self {
824827
I8 => i8::MAX as i128,
825828
I16 => i16::MAX as i128,
@@ -832,6 +835,7 @@ impl Integer {
832835
/// Finds the smallest Integer type which can represent the signed value.
833836
#[inline]
834837
pub fn fit_signed(x: i128) -> Integer {
838+
use Integer::*;
835839
match x {
836840
-0x0000_0000_0000_0080..=0x0000_0000_0000_007f => I8,
837841
-0x0000_0000_0000_8000..=0x0000_0000_0000_7fff => I16,
@@ -844,6 +848,7 @@ impl Integer {
844848
/// Finds the smallest Integer type which can represent the unsigned value.
845849
#[inline]
846850
pub fn fit_unsigned(x: u128) -> Integer {
851+
use Integer::*;
847852
match x {
848853
0..=0x0000_0000_0000_00ff => I8,
849854
0..=0x0000_0000_0000_ffff => I16,
@@ -855,6 +860,7 @@ impl Integer {
855860

856861
/// Finds the smallest integer with the given alignment.
857862
pub fn for_align<C: HasDataLayout>(cx: &C, wanted: Align) -> Option<Integer> {
863+
use Integer::*;
858864
let dl = cx.data_layout();
859865

860866
[I8, I16, I32, I64, I128].into_iter().find(|&candidate| {
@@ -864,6 +870,7 @@ impl Integer {
864870

865871
/// Find the largest integer with the given alignment or less.
866872
pub fn approximate_align<C: HasDataLayout>(cx: &C, wanted: Align) -> Integer {
873+
use Integer::*;
867874
let dl = cx.data_layout();
868875

869876
// FIXME(eddyb) maybe include I128 in the future, when it works everywhere.
@@ -909,6 +916,7 @@ pub enum Primitive {
909916

910917
impl Primitive {
911918
pub fn size<C: HasDataLayout>(self, cx: &C) -> Size {
919+
use Primitive::*;
912920
let dl = cx.data_layout();
913921

914922
match self {
@@ -923,6 +931,7 @@ impl Primitive {
923931
}
924932

925933
pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAndPrefAlign {
934+
use Primitive::*;
926935
let dl = cx.data_layout();
927936

928937
match self {
@@ -1027,10 +1036,11 @@ pub enum Scalar {
10271036
impl Scalar {
10281037
#[inline]
10291038
pub fn is_bool(&self) -> bool {
1039+
use Integer::*;
10301040
matches!(
10311041
self,
10321042
Scalar::Initialized {
1033-
value: Int(I8, false),
1043+
value: Primitive::Int(I8, false),
10341044
valid_range: WrappingRange { start: 0, end: 1 }
10351045
}
10361046
)

0 commit comments

Comments
 (0)