Skip to content

Commit b88f85a

Browse files
Stop relying on rustc_type_ir in non-type-system crates
1 parent 19c84c8 commit b88f85a

37 files changed

+136
-163
lines changed

Diff for: Cargo.lock

-8
Original file line numberDiff line numberDiff line change
@@ -3440,7 +3440,6 @@ dependencies = [
34403440
"rustc_symbol_mangling",
34413441
"rustc_target",
34423442
"rustc_trait_selection",
3443-
"rustc_type_ir",
34443443
"serde_json",
34453444
"smallvec",
34463445
"tempfile",
@@ -3473,7 +3472,6 @@ dependencies = [
34733472
"rustc_span",
34743473
"rustc_target",
34753474
"rustc_trait_selection",
3476-
"rustc_type_ir",
34773475
"tracing",
34783476
]
34793477

@@ -3736,7 +3734,6 @@ dependencies = [
37363734
"rustc_span",
37373735
"rustc_target",
37383736
"rustc_trait_selection",
3739-
"rustc_type_ir",
37403737
"smallvec",
37413738
"tracing",
37423739
]
@@ -3775,7 +3772,6 @@ dependencies = [
37753772
"rustc_session",
37763773
"rustc_span",
37773774
"rustc_trait_selection",
3778-
"rustc_type_ir",
37793775
"smallvec",
37803776
"tracing",
37813777
]
@@ -3922,7 +3918,6 @@ dependencies = [
39223918
"rustc_span",
39233919
"rustc_target",
39243920
"rustc_trait_selection",
3925-
"rustc_type_ir",
39263921
"smallvec",
39273922
"tracing",
39283923
"unicode-security",
@@ -3998,7 +3993,6 @@ dependencies = [
39983993
"rustc_session",
39993994
"rustc_span",
40003995
"rustc_target",
4001-
"rustc_type_ir",
40023996
"tempfile",
40033997
"tracing",
40043998
]
@@ -4114,7 +4108,6 @@ dependencies = [
41144108
"rustc_span",
41154109
"rustc_target",
41164110
"rustc_trait_selection",
4117-
"rustc_type_ir",
41184111
"smallvec",
41194112
"tracing",
41204113
]
@@ -4538,7 +4531,6 @@ dependencies = [
45384531
"rustc_span",
45394532
"rustc_target",
45404533
"rustc_trait_selection",
4541-
"rustc_type_ir",
45424534
"tracing",
45434535
]
45444536

Diff for: compiler/rustc_codegen_ssa/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ rustc_span = { path = "../rustc_span" }
4040
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
4141
rustc_target = { path = "../rustc_target" }
4242
rustc_trait_selection = { path = "../rustc_trait_selection" }
43-
rustc_type_ir = { path = "../rustc_type_ir" }
4443
serde_json = "1.0.59"
4544
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
4645
tempfile = "3.2"

Diff for: compiler/rustc_codegen_ssa/src/errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use rustc_errors::{
1212
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
1313
};
1414
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
15-
use rustc_middle::ty::Ty;
1615
use rustc_middle::ty::layout::LayoutError;
16+
use rustc_middle::ty::{FloatTy, Ty};
1717
use rustc_span::{Span, Symbol};
18-
use rustc_type_ir::FloatTy;
1918

2019
use crate::assert_module_sources::CguReuse;
2120
use crate::back::command::Command;

Diff for: compiler/rustc_codegen_ssa/src/mir/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
4343
mir::Const::Ty(_, c) => match c.kind() {
4444
// A constant that came from a const generic but was then used as an argument to
4545
// old-style simd_shuffle (passing as argument instead of as a generic param).
46-
rustc_type_ir::ConstKind::Value(cv) => return Ok(Ok(cv.valtree)),
46+
ty::ConstKind::Value(cv) => return Ok(Ok(cv.valtree)),
4747
other => span_bug!(constant.span, "{other:#?}"),
4848
},
4949
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate

Diff for: compiler/rustc_const_eval/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ rustc_session = { path = "../rustc_session" }
2323
rustc_span = { path = "../rustc_span" }
2424
rustc_target = { path = "../rustc_target" }
2525
rustc_trait_selection = { path = "../rustc_trait_selection" }
26-
rustc_type_ir = { path = "../rustc_type_ir" }
2726
tracing = "0.1"
2827
# tidy-alphabetical-end

Diff for: compiler/rustc_const_eval/src/interpret/cast.rs

+14-19
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_middle::ty::adjustment::PointerCoercion;
99
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, TyAndLayout};
1010
use rustc_middle::ty::{self, FloatTy, Ty};
1111
use rustc_middle::{bug, span_bug};
12-
use rustc_type_ir::TyKind::*;
1312
use tracing::trace;
1413

1514
use super::util::ensure_monomorphic_enough;
@@ -182,9 +181,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
182181
src: &ImmTy<'tcx, M::Provenance>,
183182
cast_to: TyAndLayout<'tcx>,
184183
) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> {
185-
use rustc_type_ir::TyKind::*;
186-
187-
let Float(fty) = src.layout.ty.kind() else {
184+
let ty::Float(fty) = src.layout.ty.kind() else {
188185
bug!("FloatToFloat/FloatToInt cast: source type {} is not a float type", src.layout.ty)
189186
};
190187
let val = match fty {
@@ -277,27 +274,27 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
277274
let signed = src_layout.backend_repr.is_signed(); // Also asserts that abi is `Scalar`.
278275

279276
let v = match src_layout.ty.kind() {
280-
Uint(_) | RawPtr(..) | FnPtr(..) => scalar.to_uint(src_layout.size)?,
281-
Int(_) => scalar.to_int(src_layout.size)? as u128, // we will cast back to `i128` below if the sign matters
282-
Bool => scalar.to_bool()?.into(),
283-
Char => scalar.to_char()?.into(),
277+
ty::Uint(_) | ty::RawPtr(..) | ty::FnPtr(..) => scalar.to_uint(src_layout.size)?,
278+
ty::Int(_) => scalar.to_int(src_layout.size)? as u128, // we will cast back to `i128` below if the sign matters
279+
ty::Bool => scalar.to_bool()?.into(),
280+
ty::Char => scalar.to_char()?.into(),
284281
_ => span_bug!(self.cur_span(), "invalid int-like cast from {}", src_layout.ty),
285282
};
286283

287284
interp_ok(match *cast_ty.kind() {
288285
// int -> int
289-
Int(_) | Uint(_) => {
286+
ty::Int(_) | ty::Uint(_) => {
290287
let size = match *cast_ty.kind() {
291-
Int(t) => Integer::from_int_ty(self, t).size(),
292-
Uint(t) => Integer::from_uint_ty(self, t).size(),
288+
ty::Int(t) => Integer::from_int_ty(self, t).size(),
289+
ty::Uint(t) => Integer::from_uint_ty(self, t).size(),
293290
_ => bug!(),
294291
};
295292
let v = size.truncate(v);
296293
Scalar::from_uint(v, size)
297294
}
298295

299296
// signed int -> float
300-
Float(fty) if signed => {
297+
ty::Float(fty) if signed => {
301298
let v = v as i128;
302299
match fty {
303300
FloatTy::F16 => Scalar::from_f16(Half::from_i128(v).value),
@@ -307,15 +304,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
307304
}
308305
}
309306
// unsigned int -> float
310-
Float(fty) => match fty {
307+
ty::Float(fty) => match fty {
311308
FloatTy::F16 => Scalar::from_f16(Half::from_u128(v).value),
312309
FloatTy::F32 => Scalar::from_f32(Single::from_u128(v).value),
313310
FloatTy::F64 => Scalar::from_f64(Double::from_u128(v).value),
314311
FloatTy::F128 => Scalar::from_f128(Quad::from_u128(v).value),
315312
},
316313

317314
// u8 -> char
318-
Char => Scalar::from_u32(u8::try_from(v).unwrap().into()),
315+
ty::Char => Scalar::from_u32(u8::try_from(v).unwrap().into()),
319316

320317
// Casts to bool are not permitted by rustc, no need to handle them here.
321318
_ => span_bug!(self.cur_span(), "invalid int to {} cast", cast_ty),
@@ -332,11 +329,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
332329
+ FloatConvert<Double>
333330
+ FloatConvert<Quad>,
334331
{
335-
use rustc_type_ir::TyKind::*;
336-
337332
match *dest_ty.kind() {
338333
// float -> uint
339-
Uint(t) => {
334+
ty::Uint(t) => {
340335
let size = Integer::from_uint_ty(self, t).size();
341336
// `to_u128` is a saturating cast, which is what we need
342337
// (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
@@ -345,15 +340,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
345340
Scalar::from_uint(v, size)
346341
}
347342
// float -> int
348-
Int(t) => {
343+
ty::Int(t) => {
349344
let size = Integer::from_int_ty(self, t).size();
350345
// `to_i128` is a saturating cast, which is what we need
351346
// (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
352347
let v = f.to_i128(size.bits_usize()).value;
353348
Scalar::from_int(v, size)
354349
}
355350
// float -> float
356-
Float(fty) => match fty {
351+
ty::Float(fty) => match fty {
357352
FloatTy::F16 => {
358353
Scalar::from_f16(self.adjust_nan(f.convert(&mut false).value, &[f]))
359354
}

Diff for: compiler/rustc_hir_analysis/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ rustc_session = { path = "../rustc_session" }
2828
rustc_span = { path = "../rustc_span" }
2929
rustc_target = { path = "../rustc_target" }
3030
rustc_trait_selection = { path = "../rustc_trait_selection" }
31-
rustc_type_ir = { path = "../rustc_type_ir" }
3231
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
3332
tracing = "0.1"
3433
# tidy-alphabetical-end

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ use rustc_middle::ty::error::TypeErrorToStringExt;
2121
use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES};
2222
use rustc_middle::ty::util::{Discr, IntTypeExt};
2323
use rustc_middle::ty::{
24-
AdtDef, BottomUpFolder, GenericArgKind, RegionKind, TypeSuperVisitable, TypeVisitable,
25-
TypeVisitableExt, fold_regions,
24+
AdtDef, BottomUpFolder, GenericArgKind, RegionKind, TypeFoldable, TypeSuperVisitable,
25+
TypeVisitable, TypeVisitableExt, fold_regions,
2626
};
2727
use rustc_session::lint::builtin::UNINHABITED_STATIC;
2828
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
2929
use rustc_trait_selection::error_reporting::traits::on_unimplemented::OnUnimplementedDirective;
3030
use rustc_trait_selection::traits;
3131
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
32-
use rustc_type_ir::TypeFoldable;
3332
use tracing::{debug, instrument};
3433
use ty::TypingMode;
3534
use {rustc_attr_parsing as attr, rustc_hir as hir};

Diff for: compiler/rustc_hir_analysis/src/check/wfcheck.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ use rustc_lint_defs::builtin::SUPERTRAIT_ITEM_SHADOWING_DEFINITION;
1616
use rustc_macros::LintDiagnostic;
1717
use rustc_middle::mir::interpret::ErrorHandled;
1818
use rustc_middle::query::Providers;
19+
use rustc_middle::traits::solve::NoSolution;
1920
use rustc_middle::ty::trait_def::TraitSpecializationKind;
2021
use rustc_middle::ty::{
21-
self, AdtKind, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable,
22-
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, Upcast,
22+
self, AdtKind, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFlags,
23+
TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode,
24+
Upcast,
2325
};
2426
use rustc_middle::{bug, span_bug};
2527
use rustc_session::parse::feature_err;
@@ -34,8 +36,6 @@ use rustc_trait_selection::traits::{
3436
self, FulfillmentError, Obligation, ObligationCause, ObligationCauseCode, ObligationCtxt,
3537
WellFormedLoc,
3638
};
37-
use rustc_type_ir::TypeFlags;
38-
use rustc_type_ir::solve::NoSolution;
3939
use tracing::{debug, instrument};
4040
use {rustc_ast as ast, rustc_hir as hir};
4141

Diff for: compiler/rustc_hir_analysis/src/coherence/builtin.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,16 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
250250
// trait, they *do* satisfy the repr(transparent) rules, and then we assume that everything else
251251
// in the compiler (in particular, all the call ABI logic) will treat them as repr(transparent)
252252
// even if they do not carry that attribute.
253-
use rustc_type_ir::TyKind::*;
254253
match (source.kind(), target.kind()) {
255-
(&Ref(r_a, _, mutbl_a), Ref(r_b, _, mutbl_b)) if r_a == *r_b && mutbl_a == *mutbl_b => {
254+
(&ty::Ref(r_a, _, mutbl_a), ty::Ref(r_b, _, mutbl_b))
255+
if r_a == *r_b && mutbl_a == *mutbl_b =>
256+
{
256257
Ok(())
257258
}
258-
(&RawPtr(_, a_mutbl), &RawPtr(_, b_mutbl)) if a_mutbl == b_mutbl => Ok(()),
259-
(&Adt(def_a, args_a), &Adt(def_b, args_b)) if def_a.is_struct() && def_b.is_struct() => {
259+
(&ty::RawPtr(_, a_mutbl), &ty::RawPtr(_, b_mutbl)) if a_mutbl == b_mutbl => Ok(()),
260+
(&ty::Adt(def_a, args_a), &ty::Adt(def_b, args_b))
261+
if def_a.is_struct() && def_b.is_struct() =>
262+
{
260263
if def_a != def_b {
261264
let source_path = tcx.def_path_str(def_a.did());
262265
let target_path = tcx.def_path_str(def_b.did());

Diff for: compiler/rustc_hir_analysis/src/coherence/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use rustc_errors::struct_span_code_err;
1010
use rustc_hir::LangItem;
1111
use rustc_hir::def_id::{DefId, LocalDefId};
1212
use rustc_middle::query::Providers;
13-
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
13+
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt, elaborate};
1414
use rustc_session::parse::feature_err;
1515
use rustc_span::{ErrorGuaranteed, sym};
16-
use rustc_type_ir::elaborate;
1716
use tracing::debug;
1817

1918
use crate::check::always_applicable;

Diff for: compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use rustc_hir as hir;
33
use rustc_infer::traits::util;
44
use rustc_middle::ty::{
55
self, GenericArgs, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
6-
shift_vars,
6+
Upcast, shift_vars,
77
};
88
use rustc_middle::{bug, span_bug};
99
use rustc_span::Span;
1010
use rustc_span::def_id::{DefId, LocalDefId};
11-
use rustc_type_ir::Upcast;
1211
use tracing::{debug, instrument};
1312

1413
use super::ItemCtxt;

Diff for: compiler/rustc_hir_analysis/src/constrained_generic_params.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use rustc_data_structures::fx::FxHashSet;
22
use rustc_middle::bug;
3-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
3+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitor};
44
use rustc_span::Span;
5-
use rustc_type_ir::TypeFoldable;
65
use tracing::debug;
76

87
#[derive(Clone, PartialEq, Eq, Hash, Debug)]

Diff for: compiler/rustc_hir_analysis/src/delegation.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ use std::assert_matches::debug_assert_matches;
77
use rustc_data_structures::fx::FxHashMap;
88
use rustc_hir::def::DefKind;
99
use rustc_hir::def_id::{DefId, LocalDefId};
10-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable};
10+
use rustc_middle::ty::{
11+
self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
12+
};
1113
use rustc_span::{ErrorGuaranteed, Span};
12-
use rustc_type_ir::TypeVisitableExt;
1314

1415
type RemapTable = FxHashMap<u32, u32>;
1516

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ use rustc_hir::HirId;
88
use rustc_hir::def::{DefKind, Res};
99
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_middle::bug;
11-
use rustc_middle::ty::{self as ty, IsSuggestable, Ty, TyCtxt, Upcast};
11+
use rustc_middle::ty::{
12+
self as ty, IsSuggestable, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
13+
TypeVisitor, Upcast,
14+
};
1215
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
1316
use rustc_trait_selection::traits;
14-
use rustc_type_ir::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
1517
use smallvec::SmallVec;
1618
use tracing::{debug, instrument};
1719

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use rustc_errors::struct_span_code_err;
44
use rustc_hir as hir;
55
use rustc_hir::def::{DefKind, Res};
66
use rustc_lint_defs::builtin::UNUSED_ASSOCIATED_TYPE_BOUNDS;
7+
use rustc_middle::ty::elaborate::ClauseWithSupertraitSpan;
78
use rustc_middle::ty::{
89
self, BottomUpFolder, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable,
910
TypeVisitableExt, Upcast,
1011
};
1112
use rustc_span::{ErrorGuaranteed, Span};
1213
use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility;
1314
use rustc_trait_selection::traits::{self, hir_ty_lowering_dyn_compatibility_violations};
14-
use rustc_type_ir::elaborate::ClauseWithSupertraitSpan;
1515
use smallvec::{SmallVec, smallvec};
1616
use tracing::{debug, instrument};
1717

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use rustc_middle::mir::interpret::LitToConstInput;
3939
use rustc_middle::ty::print::PrintPolyTraitRefExt as _;
4040
use rustc_middle::ty::{
4141
self, Const, GenericArgKind, GenericArgsRef, GenericParamDefKind, ParamEnv, Ty, TyCtxt,
42-
TypeVisitableExt, TypingMode, fold_regions,
42+
TypeVisitableExt, TypingMode, Upcast, fold_regions,
4343
};
4444
use rustc_middle::{bug, span_bug};
4545
use rustc_session::lint::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
@@ -49,7 +49,6 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
4949
use rustc_trait_selection::infer::InferCtxtExt;
5050
use rustc_trait_selection::traits::wf::object_region_bounds;
5151
use rustc_trait_selection::traits::{self, ObligationCtxt};
52-
use rustc_type_ir::Upcast;
5352
use tracing::{debug, instrument};
5453

5554
use self::errors::assoc_kind_str;

Diff for: compiler/rustc_hir_analysis/src/outlives/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_data_structures::fx::FxIndexMap;
2+
use rustc_middle::ty::outlives::{Component, push_outlives_components};
23
use rustc_middle::ty::{self, GenericArg, GenericArgKind, Region, Ty, TyCtxt};
34
use rustc_middle::{bug, span_bug};
45
use rustc_span::Span;
5-
use rustc_type_ir::outlives::{Component, push_outlives_components};
66
use smallvec::smallvec;
77

88
/// Tracks the `T: 'a` or `'a: 'a` predicates that we have inferred

Diff for: compiler/rustc_hir_typeck/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ rustc_middle = { path = "../rustc_middle" }
2323
rustc_session = { path = "../rustc_session" }
2424
rustc_span = { path = "../rustc_span" }
2525
rustc_trait_selection = { path = "../rustc_trait_selection" }
26-
rustc_type_ir = { path = "../rustc_type_ir" }
2726
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2827
tracing = "0.1"
2928
# tidy-alphabetical-end

0 commit comments

Comments
 (0)