From aa44a259d2227a3fa3ae1f2587da46398902fe7c Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 27 Oct 2024 17:51:59 -0700 Subject: [PATCH] compiler: Use rustc_abi directly in lint and mir_transform --- .../rustc_mir_transform/src/coroutine/by_move_body.rs | 2 +- .../rustc_mir_transform/src/elaborate_box_derefs.rs | 2 +- compiler/rustc_mir_transform/src/large_enums.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs index 2c622b1927e52..36eb435c63a10 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -69,6 +69,7 @@ //! in case precise captures (edition 2021 closure capture rules) caused the inner coroutine //! to split one field capture into two. +use rustc_abi::{FieldIdx, VariantIdx}; use rustc_data_structures::steal::Steal; use rustc_data_structures::unord::UnordMap; use rustc_hir as hir; @@ -80,7 +81,6 @@ use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::{self, dump_mir}; use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::symbol::kw; -use rustc_target::abi::{FieldIdx, VariantIdx}; pub(crate) fn coroutine_by_move_body_def_id<'tcx>( tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs index 57f7a9ef7f5fc..b909dfa132052 100644 --- a/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs +++ b/compiler/rustc_mir_transform/src/elaborate_box_derefs.rs @@ -2,13 +2,13 @@ //! //! Box is not actually a pointer so it is incorrect to dereference it directly. +use rustc_abi::FieldIdx; use rustc_hir::def_id::DefId; use rustc_middle::mir::patch::MirPatch; use rustc_middle::mir::visit::MutVisitor; use rustc_middle::mir::*; use rustc_middle::span_bug; use rustc_middle::ty::{Ty, TyCtxt}; -use rustc_target::abi::FieldIdx; /// Constructs the types used when accessing a Box's pointer fn build_ptr_tys<'tcx>( diff --git a/compiler/rustc_mir_transform/src/large_enums.rs b/compiler/rustc_mir_transform/src/large_enums.rs index 3e263aa406774..4e4966e342587 100644 --- a/compiler/rustc_mir_transform/src/large_enums.rs +++ b/compiler/rustc_mir_transform/src/large_enums.rs @@ -1,10 +1,10 @@ +use rustc_abi::{Endian, HasDataLayout, Integer, Size, TagEncoding, Variants}; use rustc_data_structures::fx::FxHashMap; use rustc_middle::mir::interpret::AllocId; use rustc_middle::mir::*; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, AdtDef, ParamEnv, Ty, TyCtxt}; use rustc_session::Session; -use rustc_target::abi::{HasDataLayout, Size, TagEncoding, Variants}; /// A pass that seeks to optimize unnecessary moves of large enum types, if there is a large /// enough discrepancy between them. @@ -249,8 +249,8 @@ impl EnumSizeOpt { macro_rules! encode_store { ($curr_idx: expr, $endian: expr, $bytes: expr) => { let bytes = match $endian { - rustc_target::abi::Endian::Little => $bytes.to_le_bytes(), - rustc_target::abi::Endian::Big => $bytes.to_be_bytes(), + Endian::Little => $bytes.to_le_bytes(), + Endian::Big => $bytes.to_be_bytes(), }; for (i, b) in bytes.into_iter().enumerate() { data[$curr_idx + i] = b; @@ -263,10 +263,10 @@ impl EnumSizeOpt { target_bytes * adt_def.discriminant_for_variant(tcx, var_idx).val as usize; let sz = layout.size; match ptr_sized_int { - rustc_target::abi::Integer::I32 => { + Integer::I32 => { encode_store!(curr_idx, data_layout.endian, sz.bytes() as u32); } - rustc_target::abi::Integer::I64 => { + Integer::I64 => { encode_store!(curr_idx, data_layout.endian, sz.bytes()); } _ => unreachable!(),