Skip to content

Commit 5bce4c7

Browse files
committed
Unglob rustc_abi imports
1 parent c545019 commit 5bce4c7

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),
@@ -872,9 +871,12 @@ fn univariant(
872871
if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
873872
#[cfg(feature = "randomize")]
874873
{
874+
use rand::{seq::SliceRandom, SeedableRng};
875875
// `ReprOptions.layout_seed` is a deterministic seed that we can use to
876876
// randomize field ordering with
877-
let mut rng = Xoshiro128StarStar::seed_from_u64(repr.field_shuffle_seed.as_u64());
877+
let mut rng = rand_xoshiro::Xoshiro128StarStar::seed_from_u64(
878+
repr.field_shuffle_seed.as_u64(),
879+
);
878880

879881
// Shuffle the ordering of the fields
880882
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))]
@@ -339,6 +338,7 @@ impl TargetDataLayout {
339338

340339
#[inline]
341340
pub fn ptr_sized_integer(&self) -> Integer {
341+
use Integer::*;
342342
match self.pointer_size.bits() {
343343
16 => I16,
344344
32 => I32,
@@ -785,6 +785,7 @@ pub enum Integer {
785785
impl Integer {
786786
#[inline]
787787
pub fn size(self) -> Size {
788+
use Integer::*;
788789
match self {
789790
I8 => Size::from_bytes(1),
790791
I16 => Size::from_bytes(2),
@@ -805,6 +806,7 @@ impl Integer {
805806
}
806807

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

810812
match self {
@@ -819,6 +821,7 @@ impl Integer {
819821
/// Returns the largest signed value that can be represented by this Integer.
820822
#[inline]
821823
pub fn signed_max(self) -> i128 {
824+
use Integer::*;
822825
match self {
823826
I8 => i8::MAX as i128,
824827
I16 => i16::MAX as i128,
@@ -831,6 +834,7 @@ impl Integer {
831834
/// Finds the smallest Integer type which can represent the signed value.
832835
#[inline]
833836
pub fn fit_signed(x: i128) -> Integer {
837+
use Integer::*;
834838
match x {
835839
-0x0000_0000_0000_0080..=0x0000_0000_0000_007f => I8,
836840
-0x0000_0000_0000_8000..=0x0000_0000_0000_7fff => I16,
@@ -843,6 +847,7 @@ impl Integer {
843847
/// Finds the smallest Integer type which can represent the unsigned value.
844848
#[inline]
845849
pub fn fit_unsigned(x: u128) -> Integer {
850+
use Integer::*;
846851
match x {
847852
0..=0x0000_0000_0000_00ff => I8,
848853
0..=0x0000_0000_0000_ffff => I16,
@@ -854,6 +859,7 @@ impl Integer {
854859

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

859865
[I8, I16, I32, I64, I128].into_iter().find(|&candidate| {
@@ -863,6 +869,7 @@ impl Integer {
863869

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

868875
// FIXME(eddyb) maybe include I128 in the future, when it works everywhere.
@@ -908,6 +915,7 @@ pub enum Primitive {
908915

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

913921
match self {
@@ -922,6 +930,7 @@ impl Primitive {
922930
}
923931

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

927936
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)