diff options
| author | Michael Goulet <michael@errs.io> | 2025-03-13 18:05:00 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-03-15 06:42:48 +0000 |
| commit | b88f85a4106ca0a53a1dab6d605cf56a0cc945ac (patch) | |
| tree | 74a1d91dcf4a109c1d9b897bf9ca5e184d4bc573 /compiler/rustc_mir_transform | |
| parent | 19c84c8812adb7fa0e7540b5de2541a5995e901a (diff) | |
| download | rust-b88f85a4106ca0a53a1dab6d605cf56a0cc945ac.tar.gz rust-b88f85a4106ca0a53a1dab6d605cf56a0cc945ac.zip | |
Stop relying on rustc_type_ir in non-type-system crates
Diffstat (limited to 'compiler/rustc_mir_transform')
4 files changed, 12 insertions, 16 deletions
diff --git a/compiler/rustc_mir_transform/Cargo.toml b/compiler/rustc_mir_transform/Cargo.toml index fb8d0ac5e74..9e4b4534dcc 100644 --- a/compiler/rustc_mir_transform/Cargo.toml +++ b/compiler/rustc_mir_transform/Cargo.toml @@ -26,7 +26,6 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } rustc_trait_selection = { path = "../rustc_trait_selection" } -rustc_type_ir = { path = "../rustc_type_ir" } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tracing = "0.1" # tidy-alphabetical-end diff --git a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs index 7d77fffa83f..29a9133abe9 100644 --- a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs +++ b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs @@ -2,7 +2,7 @@ use std::cell::RefCell; use std::collections::hash_map; use std::rc::Rc; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::Subdiagnostic; use rustc_hir::CRATE_HIR_ID; @@ -25,7 +25,6 @@ use rustc_mir_dataflow::{Analysis, MaybeReachable, ResultsCursor}; use rustc_session::lint::builtin::TAIL_EXPR_DROP_ORDER; use rustc_session::lint::{self}; use rustc_span::{DUMMY_SP, Span, Symbol}; -use rustc_type_ir::data_structures::IndexMap; use tracing::debug; fn place_has_common_prefix<'tcx>(left: &Place<'tcx>, right: &Place<'tcx>) -> bool { @@ -199,7 +198,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body< // and, for each block, the vector of locations. // // We group them per-block because they tend to scheduled in the same drop ladder block. - let mut bid_per_block = IndexMap::default(); + let mut bid_per_block = FxIndexMap::default(); let mut bid_places = UnordSet::new(); let mut ty_dropped_components = UnordMap::default(); @@ -455,8 +454,8 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body< } /// Extract binding names if available for diagnosis -fn collect_user_names(body: &Body<'_>) -> IndexMap<Local, Symbol> { - let mut names = IndexMap::default(); +fn collect_user_names(body: &Body<'_>) -> FxIndexMap<Local, Symbol> { + let mut names = FxIndexMap::default(); for var_debug_info in &body.var_debug_info { if let mir::VarDebugInfoContents::Place(place) = &var_debug_info.value && let Some(local) = place.local_or_deref_local() @@ -470,9 +469,9 @@ fn collect_user_names(body: &Body<'_>) -> IndexMap<Local, Symbol> { /// Assign names for anonymous or temporary values for diagnosis fn assign_observables_names( locals: impl IntoIterator<Item = Local>, - user_names: &IndexMap<Local, Symbol>, -) -> IndexMap<Local, (String, bool)> { - let mut names = IndexMap::default(); + user_names: &FxIndexMap<Local, Symbol>, +) -> FxIndexMap<Local, (String, bool)> { + let mut names = FxIndexMap::default(); let mut assigned_names = FxHashSet::default(); let mut idx = 0u64; let mut fresh_name = || { diff --git a/compiler/rustc_mir_transform/src/match_branches.rs b/compiler/rustc_mir_transform/src/match_branches.rs index 9db37bf5a07..0d9d0368d37 100644 --- a/compiler/rustc_mir_transform/src/match_branches.rs +++ b/compiler/rustc_mir_transform/src/match_branches.rs @@ -5,7 +5,6 @@ use rustc_index::IndexSlice; use rustc_middle::mir::*; use rustc_middle::ty::layout::{IntegerExt, TyAndLayout}; use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt}; -use rustc_type_ir::TyKind::*; use tracing::instrument; use super::simplify::simplify_cfg; @@ -293,13 +292,13 @@ fn can_cast( ) -> bool { let from_scalar = ScalarInt::try_from_uint(src_val.into(), src_layout.size).unwrap(); let v = match src_layout.ty.kind() { - Uint(_) => from_scalar.to_uint(src_layout.size), - Int(_) => from_scalar.to_int(src_layout.size) as u128, + ty::Uint(_) => from_scalar.to_uint(src_layout.size), + ty::Int(_) => from_scalar.to_int(src_layout.size) as u128, _ => unreachable!("invalid int"), }; let size = match *cast_ty.kind() { - Int(t) => Integer::from_int_ty(&tcx, t).size(), - Uint(t) => Integer::from_uint_ty(&tcx, t).size(), + ty::Int(t) => Integer::from_int_ty(&tcx, t).size(), + ty::Uint(t) => Integer::from_uint_ty(&tcx, t).size(), _ => unreachable!("invalid int"), }; let v = size.truncate(v); diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 4ac3a268c9c..231d7c2ef02 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -13,11 +13,10 @@ use rustc_middle::mir::visit::{NonUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::{ - self, CoroutineArgsExt, InstanceKind, ScalarInt, Ty, TyCtxt, TypeVisitableExt, Variance, + self, CoroutineArgsExt, InstanceKind, ScalarInt, Ty, TyCtxt, TypeVisitableExt, Upcast, Variance, }; use rustc_middle::{bug, span_bug}; use rustc_trait_selection::traits::ObligationCtxt; -use rustc_type_ir::Upcast; use crate::util::{self, is_within_packed}; |
