Skip to content

Commit f403c92

Browse files
Rollup merge of rust-lang#140559 - rperier:type-ir-to-type-middle, r=compiler-errors
Removing rustc_type_ir in the rustc_infer codebase cc rust-lang#138449 This is a second refactoring of rustc_type_ir to use rustc_middle instead, this time that's for rustc_infer
2 parents cd789a2 + 6970813 commit f403c92

File tree

12 files changed

+31
-33
lines changed

12 files changed

+31
-33
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4515,6 +4515,7 @@ dependencies = [
45154515
"rustc_session",
45164516
"rustc_span",
45174517
"rustc_transmute",
4518+
"rustc_type_ir",
45184519
"smallvec",
45194520
"thin-vec",
45204521
"tracing",

compiler/rustc_infer/src/infer/context.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,28 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
121121
self.enter_forall(value, f)
122122
}
123123

124-
fn equate_ty_vids_raw(&self, a: rustc_type_ir::TyVid, b: rustc_type_ir::TyVid) {
124+
fn equate_ty_vids_raw(&self, a: ty::TyVid, b: ty::TyVid) {
125125
self.inner.borrow_mut().type_variables().equate(a, b);
126126
}
127127

128-
fn equate_int_vids_raw(&self, a: rustc_type_ir::IntVid, b: rustc_type_ir::IntVid) {
128+
fn equate_int_vids_raw(&self, a: ty::IntVid, b: ty::IntVid) {
129129
self.inner.borrow_mut().int_unification_table().union(a, b);
130130
}
131131

132-
fn equate_float_vids_raw(&self, a: rustc_type_ir::FloatVid, b: rustc_type_ir::FloatVid) {
132+
fn equate_float_vids_raw(&self, a: ty::FloatVid, b: ty::FloatVid) {
133133
self.inner.borrow_mut().float_unification_table().union(a, b);
134134
}
135135

136-
fn equate_const_vids_raw(&self, a: rustc_type_ir::ConstVid, b: rustc_type_ir::ConstVid) {
136+
fn equate_const_vids_raw(&self, a: ty::ConstVid, b: ty::ConstVid) {
137137
self.inner.borrow_mut().const_unification_table().union(a, b);
138138
}
139139

140140
fn instantiate_ty_var_raw<R: PredicateEmittingRelation<Self>>(
141141
&self,
142142
relation: &mut R,
143143
target_is_expected: bool,
144-
target_vid: rustc_type_ir::TyVid,
145-
instantiation_variance: rustc_type_ir::Variance,
144+
target_vid: ty::TyVid,
145+
instantiation_variance: ty::Variance,
146146
source_ty: Ty<'tcx>,
147147
) -> RelateResult<'tcx, ()> {
148148
self.instantiate_ty_var(
@@ -154,27 +154,19 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
154154
)
155155
}
156156

157-
fn instantiate_int_var_raw(
158-
&self,
159-
vid: rustc_type_ir::IntVid,
160-
value: rustc_type_ir::IntVarValue,
161-
) {
157+
fn instantiate_int_var_raw(&self, vid: ty::IntVid, value: ty::IntVarValue) {
162158
self.inner.borrow_mut().int_unification_table().union_value(vid, value);
163159
}
164160

165-
fn instantiate_float_var_raw(
166-
&self,
167-
vid: rustc_type_ir::FloatVid,
168-
value: rustc_type_ir::FloatVarValue,
169-
) {
161+
fn instantiate_float_var_raw(&self, vid: ty::FloatVid, value: ty::FloatVarValue) {
170162
self.inner.borrow_mut().float_unification_table().union_value(vid, value);
171163
}
172164

173165
fn instantiate_const_var_raw<R: PredicateEmittingRelation<Self>>(
174166
&self,
175167
relation: &mut R,
176168
target_is_expected: bool,
177-
target_vid: rustc_type_ir::ConstVid,
169+
target_vid: ty::ConstVid,
178170
source_ct: ty::Const<'tcx>,
179171
) -> RelateResult<'tcx, ()> {
180172
self.instantiate_const_var(relation, target_is_expected, target_vid, source_ct)

compiler/rustc_infer/src/infer/outlives/obligations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ use rustc_data_structures::undo_log::UndoLogs;
6363
use rustc_middle::bug;
6464
use rustc_middle::mir::ConstraintCategory;
6565
use rustc_middle::traits::query::NoSolution;
66+
use rustc_middle::ty::outlives::{Component, push_outlives_components};
6667
use rustc_middle::ty::{
6768
self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesPredicate, Region, Ty, TyCtxt,
6869
TypeFoldable as _, TypeVisitableExt,
6970
};
70-
use rustc_type_ir::outlives::{Component, push_outlives_components};
7171
use smallvec::smallvec;
7272
use tracing::{debug, instrument};
7373

compiler/rustc_infer/src/infer/outlives/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::assert_matches::assert_matches;
22

3+
use rustc_middle::ty::outlives::{Component, compute_alias_components_recursive};
34
use rustc_middle::ty::{self, OutlivesPredicate, Ty, TyCtxt};
4-
use rustc_type_ir::outlives::{Component, compute_alias_components_recursive};
55
use smallvec::smallvec;
66
use tracing::{debug, instrument, trace};
77

compiler/rustc_infer/src/infer/relate/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
//! (except for some relations used for diagnostics and heuristics in the compiler).
33
//! As well as the implementation of `Relate` for interned things (`Ty`/`Const`/etc).
44
5-
pub use rustc_middle::ty::relate::RelateResult;
6-
pub use rustc_type_ir::relate::combine::PredicateEmittingRelation;
7-
pub use rustc_type_ir::relate::*;
5+
pub use rustc_middle::ty::relate::combine::PredicateEmittingRelation;
6+
pub use rustc_middle::ty::relate::{RelateResult, *};
87

98
mod generalize;
109
mod higher_ranked;

compiler/rustc_infer/src/infer/relate/type_relating.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use rustc_middle::ty::relate::combine::{super_combine_consts, super_combine_tys}
33
use rustc_middle::ty::relate::{
44
Relate, RelateResult, TypeRelation, relate_args_invariantly, relate_args_with_variances,
55
};
6-
use rustc_middle::ty::{self, Ty, TyCtxt, TyVar};
6+
use rustc_middle::ty::{self, DelayedSet, Ty, TyCtxt, TyVar};
77
use rustc_span::Span;
8-
use rustc_type_ir::data_structures::DelayedSet;
98
use tracing::{debug, instrument};
109

1110
use crate::infer::BoundRegionConversionTime::HigherRankedType;

compiler/rustc_infer/src/infer/resolve.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use rustc_middle::bug;
22
use rustc_middle::ty::{
3-
self, Const, FallibleTypeFolder, InferConst, Ty, TyCtxt, TypeFoldable, TypeFolder,
3+
self, Const, DelayedMap, FallibleTypeFolder, InferConst, Ty, TyCtxt, TypeFoldable, TypeFolder,
44
TypeSuperFoldable, TypeVisitableExt,
55
};
6-
use rustc_type_ir::data_structures::DelayedMap;
76

87
use super::{FixupError, FixupResult, InferCtxt};
98

compiler/rustc_infer/src/infer/snapshot/fudge.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use std::ops::Range;
33
use rustc_data_structures::{snapshot_vec as sv, unify as ut};
44
use rustc_middle::ty::{
55
self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid, TypeFoldable, TypeFolder,
6-
TypeSuperFoldable,
6+
TypeSuperFoldable, TypeVisitableExt,
77
};
8-
use rustc_type_ir::TypeVisitableExt;
98
use tracing::instrument;
109
use ut::UnifyKey;
1110

compiler/rustc_infer/src/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_data_structures::fx::FxHashSet;
2+
pub use rustc_middle::ty::elaborate::*;
23
use rustc_middle::ty::{self, TyCtxt};
34
use rustc_span::{Ident, Span};
4-
pub use rustc_type_ir::elaborate::*;
55

66
use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation};
77

compiler/rustc_middle/src/ty/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,17 @@ use rustc_session::lint::LintBuffer;
5151
pub use rustc_session::lint::RegisteredTools;
5252
use rustc_span::hygiene::MacroKind;
5353
use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol, kw, sym};
54-
pub use rustc_type_ir::data_structures::DelayedSet;
54+
pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet};
55+
#[allow(
56+
hidden_glob_reexports,
57+
rustc::usage_of_type_ir_inherent,
58+
rustc::non_glob_import_of_type_ir_inherent
59+
)]
60+
use rustc_type_ir::inherent;
5561
pub use rustc_type_ir::relate::VarianceDiagInfo;
5662
pub use rustc_type_ir::*;
63+
#[allow(hidden_glob_reexports, unused_imports)]
64+
use rustc_type_ir::{InferCtxtLike, Interner};
5765
use tracing::{debug, instrument};
5866
pub use vtable::*;
5967
use {rustc_ast as ast, rustc_attr_data_structures as attr, rustc_hir as hir};

compiler/rustc_trait_selection/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ rustc_parse_format = { path = "../rustc_parse_format" }
2020
rustc_session = { path = "../rustc_session" }
2121
rustc_span = { path = "../rustc_span" }
2222
rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] }
23+
rustc_type_ir = { path = "../rustc_type_ir" }
2324
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2425
thin-vec = "0.2"
2526
tracing = "0.1"

compiler/rustc_trait_selection/src/solve/delegate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
156156
fn register_hidden_type_in_storage(
157157
&self,
158158
opaque_type_key: ty::OpaqueTypeKey<'tcx>,
159-
hidden_ty: <Self::Interner as ty::Interner>::Ty,
160-
span: <Self::Interner as ty::Interner>::Span,
161-
) -> Option<<Self::Interner as ty::Interner>::Ty> {
159+
hidden_ty: <Self::Interner as rustc_type_ir::Interner>::Ty,
160+
span: <Self::Interner as rustc_type_ir::Interner>::Span,
161+
) -> Option<<Self::Interner as rustc_type_ir::Interner>::Ty> {
162162
self.0.register_hidden_type_in_storage(
163163
opaque_type_key,
164164
ty::OpaqueHiddenType { span, ty: hidden_ty },

0 commit comments

Comments
 (0)