Skip to content

Commit 333ca90

Browse files
committed
Use less rustc_type_ir in the compiler codebase
This commit does the following: - Replaces use of rustc_type_ir by rustc_middle in rustc_infer. - The DelayedMap type is exposed by rustc_middle so everything can be accessed through rustc_middle in a coherent manner. - API-layer traits, like InferCtxtLike, Interner or inherent::* must be accessed via rustc_type_ir, not rustc_middle::ty. For this reason these are not reexported by rustc_middle::ty. - Replaces use of ty::Interner by rustc_type_ir::Interner in rustc_trait_selection
1 parent 0e517d3 commit 333ca90

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
@@ -4494,6 +4494,7 @@ dependencies = [
44944494
"rustc_session",
44954495
"rustc_span",
44964496
"rustc_transmute",
4497+
"rustc_type_ir",
44974498
"smallvec",
44984499
"thin-vec",
44994500
"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
@@ -50,9 +50,17 @@ use rustc_session::lint::LintBuffer;
5050
pub use rustc_session::lint::RegisteredTools;
5151
use rustc_span::hygiene::MacroKind;
5252
use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol, kw, sym};
53-
pub use rustc_type_ir::data_structures::DelayedSet;
53+
pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet};
54+
#[allow(
55+
hidden_glob_reexports,
56+
rustc::usage_of_type_ir_inherent,
57+
rustc::non_glob_import_of_type_ir_inherent
58+
)]
59+
use rustc_type_ir::inherent;
5460
pub use rustc_type_ir::relate::VarianceDiagInfo;
5561
pub use rustc_type_ir::*;
62+
#[allow(hidden_glob_reexports, unused_imports)]
63+
use rustc_type_ir::{InferCtxtLike, Interner};
5664
use tracing::{debug, instrument};
5765
pub use vtable::*;
5866
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
@@ -16,6 +16,7 @@ rustc_hir = { path = "../rustc_hir" }
1616
rustc_infer = { path = "../rustc_infer" }
1717
rustc_macros = { path = "../rustc_macros" }
1818
rustc_middle = { path = "../rustc_middle" }
19+
rustc_type_ir = { path = "../rustc_type_ir" }
1920
rustc_next_trait_solver = { path = "../rustc_next_trait_solver" }
2021
rustc_parse_format = { path = "../rustc_parse_format" }
2122
rustc_session = { path = "../rustc_session" }

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)