Skip to content

Commit b95801f

Browse files
committed
Removing use crate::inherent::Ty as _; and adding ty::Ty<I>
1 parent 0c5d075 commit b95801f

File tree

14 files changed

+257
-280
lines changed

14 files changed

+257
-280
lines changed

‎compiler/rustc_next_trait_solver/src/canonical/canonicalizer.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use rustc_type_ir::data_structures::{HashMap, ensure_sufficient_stack};
2-
#[cfg_attr(feature = "nightly", allow(rustc::non_glob_import_of_type_ir_inherent))]
3-
use rustc_type_ir::inherent::Ty as _;
42
use rustc_type_ir::inherent::*;
53
use rustc_type_ir::solve::{Goal, QueryInput};
64
use rustc_type_ir::{
75
self as ty, Canonical, CanonicalParamEnvCacheEntry, CanonicalVarKind, Flags, InferCtxtLike,
8-
Interner, PlaceholderConst, PlaceholderType, Ty, TypeFlags, TypeFoldable, TypeFolder,
6+
Interner, PlaceholderConst, PlaceholderType, TypeFlags, TypeFoldable, TypeFolder,
97
TypeSuperFoldable, TypeVisitableExt,
108
};
119

@@ -80,7 +78,7 @@ pub(super) struct Canonicalizer<'a, D: SolverDelegate<Interner = I>, I: Interner
8078

8179
/// We can simply cache based on the ty itself, because we use
8280
/// `ty::BoundVarIndexKind::Canonical`.
83-
cache: HashMap<Ty<I>, Ty<I>>,
81+
cache: HashMap<ty::Ty<I>, ty::Ty<I>>,
8482
}
8583

8684
impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
@@ -318,7 +316,7 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
318316
(max_universe, self.variables, var_kinds)
319317
}
320318

321-
fn inner_fold_ty(&mut self, t: Ty<I>) -> Ty<I> {
319+
fn inner_fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
322320
let kind = match t.kind() {
323321
ty::Infer(i) => match i {
324322
ty::TyVar(vid) => {
@@ -402,7 +400,7 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
402400

403401
let var = self.get_or_insert_bound_var(t, kind);
404402

405-
I::Ty::new_canonical_bound(self.cx(), var)
403+
Ty::new_canonical_bound(self.cx(), var)
406404
}
407405
}
408406

@@ -477,7 +475,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> TypeFolder<I> for Canonicaliz
477475
Region::new_canonical_bound(self.cx(), var)
478476
}
479477

480-
fn fold_ty(&mut self, t: Ty<I>) -> Ty<I> {
478+
fn fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
481479
if !t.flags().intersects(NEEDS_CANONICAL) {
482480
t
483481
} else if let Some(&ty) = self.cache.get(&t) {

‎compiler/rustc_next_trait_solver/src/coherence.rs‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ use std::fmt::Debug;
22
use std::ops::ControlFlow;
33

44
use derive_where::derive_where;
5-
#[cfg_attr(feature = "nightly", allow(rustc::non_glob_import_of_type_ir_inherent))]
6-
use rustc_type_ir::inherent::Ty as _;
75
use rustc_type_ir::inherent::*;
86
use rustc_type_ir::{
9-
self as ty, InferCtxtLike, Interner, TrivialTypeTraversalImpls, Ty, TypeVisitable,
7+
self as ty, InferCtxtLike, Interner, TrivialTypeTraversalImpls, TypeVisitable,
108
TypeVisitableExt, TypeVisitor,
119
};
1210
use tracing::instrument;
@@ -49,7 +47,7 @@ pub enum Conflict {
4947
pub fn trait_ref_is_knowable<Infcx, I, E>(
5048
infcx: &Infcx,
5149
trait_ref: ty::TraitRef<I>,
52-
mut lazily_normalize_ty: impl FnMut(Ty<I>) -> Result<Ty<I>, E>,
50+
mut lazily_normalize_ty: impl FnMut(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
5351
) -> Result<Result<(), Conflict>, E>
5452
where
5553
Infcx: InferCtxtLike<Interner = I>,
@@ -117,14 +115,14 @@ impl From<bool> for IsFirstInputType {
117115

118116
#[derive_where(Debug; I: Interner, T: Debug)]
119117
pub enum OrphanCheckErr<I: Interner, T> {
120-
NonLocalInputType(Vec<(Ty<I>, IsFirstInputType)>),
118+
NonLocalInputType(Vec<(ty::Ty<I>, IsFirstInputType)>),
121119
UncoveredTyParams(UncoveredTyParams<I, T>),
122120
}
123121

124122
#[derive_where(Debug; I: Interner, T: Debug)]
125123
pub struct UncoveredTyParams<I: Interner, T> {
126124
pub uncovered: T,
127-
pub local_ty: Option<Ty<I>>,
125+
pub local_ty: Option<ty::Ty<I>>,
128126
}
129127

130128
/// Checks whether a trait-ref is potentially implementable by a crate.
@@ -224,8 +222,8 @@ pub fn orphan_check_trait_ref<Infcx, I, E: Debug>(
224222
infcx: &Infcx,
225223
trait_ref: ty::TraitRef<I>,
226224
in_crate: InCrate,
227-
lazily_normalize_ty: impl FnMut(Ty<I>) -> Result<Ty<I>, E>,
228-
) -> Result<Result<(), OrphanCheckErr<I, Ty<I>>>, E>
225+
lazily_normalize_ty: impl FnMut(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
226+
) -> Result<Result<(), OrphanCheckErr<I, ty::Ty<I>>>, E>
229227
where
230228
Infcx: InferCtxtLike<Interner = I>,
231229
I: Interner,
@@ -264,14 +262,14 @@ struct OrphanChecker<'a, Infcx, I: Interner, F> {
264262
lazily_normalize_ty: F,
265263
/// Ignore orphan check failures and exclusively search for the first local type.
266264
search_first_local_ty: bool,
267-
non_local_tys: Vec<(Ty<I>, IsFirstInputType)>,
265+
non_local_tys: Vec<(ty::Ty<I>, IsFirstInputType)>,
268266
}
269267

270268
impl<'a, Infcx, I, F, E> OrphanChecker<'a, Infcx, I, F>
271269
where
272270
Infcx: InferCtxtLike<Interner = I>,
273271
I: Interner,
274-
F: FnOnce(Ty<I>) -> Result<Ty<I>, E>,
272+
F: FnOnce(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
275273
{
276274
fn new(infcx: &'a Infcx, in_crate: InCrate, lazily_normalize_ty: F) -> Self {
277275
OrphanChecker {
@@ -284,12 +282,15 @@ where
284282
}
285283
}
286284

287-
fn found_non_local_ty(&mut self, t: Ty<I>) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
285+
fn found_non_local_ty(&mut self, t: ty::Ty<I>) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
288286
self.non_local_tys.push((t, self.in_self_ty.into()));
289287
ControlFlow::Continue(())
290288
}
291289

292-
fn found_uncovered_ty_param(&mut self, ty: Ty<I>) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
290+
fn found_uncovered_ty_param(
291+
&mut self,
292+
ty: ty::Ty<I>,
293+
) -> ControlFlow<OrphanCheckEarlyExit<I, E>> {
293294
if self.search_first_local_ty {
294295
return ControlFlow::Continue(());
295296
}
@@ -307,23 +308,23 @@ where
307308

308309
enum OrphanCheckEarlyExit<I: Interner, E> {
309310
NormalizationFailure(E),
310-
UncoveredTyParam(Ty<I>),
311-
LocalTy(Ty<I>),
311+
UncoveredTyParam(ty::Ty<I>),
312+
LocalTy(ty::Ty<I>),
312313
}
313314

314315
impl<'a, Infcx, I, F, E> TypeVisitor<I> for OrphanChecker<'a, Infcx, I, F>
315316
where
316317
Infcx: InferCtxtLike<Interner = I>,
317318
I: Interner,
318-
F: FnMut(Ty<I>) -> Result<Ty<I>, E>,
319+
F: FnMut(ty::Ty<I>) -> Result<ty::Ty<I>, E>,
319320
{
320321
type Result = ControlFlow<OrphanCheckEarlyExit<I, E>>;
321322

322323
fn visit_region(&mut self, _r: I::Region) -> Self::Result {
323324
ControlFlow::Continue(())
324325
}
325326

326-
fn visit_ty(&mut self, ty: Ty<I>) -> Self::Result {
327+
fn visit_ty(&mut self, ty: ty::Ty<I>) -> Self::Result {
327328
let ty = self.infcx.shallow_resolve(ty);
328329
let ty = match (self.lazily_normalize_ty)(ty) {
329330
Ok(norm_ty) if norm_ty.is_ty_var() => ty,

‎compiler/rustc_next_trait_solver/src/placeholder.rs‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use core::panic;
22

33
use rustc_type_ir::data_structures::IndexMap;
4-
#[cfg_attr(feature = "nightly", allow(rustc::non_glob_import_of_type_ir_inherent))]
5-
use rustc_type_ir::inherent::Ty as _;
64
use rustc_type_ir::inherent::*;
75
use rustc_type_ir::{
8-
self as ty, InferCtxtLike, Interner, PlaceholderConst, PlaceholderRegion, PlaceholderType, Ty,
6+
self as ty, InferCtxtLike, Interner, PlaceholderConst, PlaceholderRegion, PlaceholderType,
97
TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
108
};
119

@@ -115,7 +113,7 @@ where
115113
}
116114
}
117115

118-
fn fold_ty(&mut self, t: Ty<I>) -> Ty<I> {
116+
fn fold_ty(&mut self, t: ty::Ty<I>) -> ty::Ty<I> {
119117
match t.kind() {
120118
ty::Bound(ty::BoundVarIndexKind::Bound(debruijn), _)
121119
if debruijn.as_usize() + 1
@@ -132,7 +130,7 @@ where
132130
let universe = self.universe_for(debruijn);
133131
let p = PlaceholderType::new(universe, bound_ty);
134132
self.mapped_types.insert(p, bound_ty);
135-
I::Ty::new_placeholder(self.cx(), p)
133+
Ty::new_placeholder(self.cx(), p)
136134
}
137135
_ if t.has_vars_bound_at_or_above(self.current_index) => t.super_fold_with(self),
138136
_ => t,

‎compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ use std::cell::Cell;
66
use std::ops::ControlFlow;
77

88
use derive_where::derive_where;
9-
#[cfg_attr(feature = "nightly", allow(rustc::non_glob_import_of_type_ir_inherent))]
10-
use rustc_type_ir::inherent::Ty as _;
119
use rustc_type_ir::inherent::*;
1210
use rustc_type_ir::lang_items::SolverTraitLangItem;
1311
use rustc_type_ir::search_graph::CandidateHeadUsages;
1412
use rustc_type_ir::solve::Certainty::Maybe;
1513
use rustc_type_ir::solve::{AliasBoundKind, SizedTraitKind};
1614
use rustc_type_ir::{
17-
self as ty, Interner, Ty, TypeFlags, TypeFoldable, TypeFolder, TypeSuperFoldable,
15+
self as ty, Interner, TypeFlags, TypeFoldable, TypeFolder, TypeSuperFoldable,
1816
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, Upcast,
1917
elaborate,
2018
};
@@ -48,11 +46,11 @@ where
4846
D: SolverDelegate<Interner = I>,
4947
I: Interner,
5048
{
51-
fn self_ty(self) -> Ty<I>;
49+
fn self_ty(self) -> ty::Ty<I>;
5250

5351
fn trait_ref(self, cx: I) -> ty::TraitRef<I>;
5452

55-
fn with_replaced_self_ty(self, cx: I, self_ty: Ty<I>) -> Self;
53+
fn with_replaced_self_ty(self, cx: I, self_ty: ty::Ty<I>) -> Self;
5654

5755
fn trait_def_id(self, cx: I) -> I::TraitId;
5856

@@ -685,7 +683,7 @@ where
685683
// hitting another overflow error something. Add a depth parameter needed later.
686684
fn assemble_alias_bound_candidates_recur<G: GoalKind<D>>(
687685
&mut self,
688-
self_ty: Ty<I>,
686+
self_ty: ty::Ty<I>,
689687
goal: Goal<I, G>,
690688
candidates: &mut Vec<Candidate<I>>,
691689
consider_self_bounds: AliasBoundKind,
@@ -1019,13 +1017,13 @@ where
10191017
struct ReplaceOpaque<I: Interner> {
10201018
cx: I,
10211019
alias_ty: ty::AliasTy<I>,
1022-
self_ty: Ty<I>,
1020+
self_ty: ty::Ty<I>,
10231021
}
10241022
impl<I: Interner> TypeFolder<I> for ReplaceOpaque<I> {
10251023
fn cx(&self) -> I {
10261024
self.cx
10271025
}
1028-
fn fold_ty(&mut self, ty: Ty<I>) -> Ty<I> {
1026+
fn fold_ty(&mut self, ty: ty::Ty<I>) -> ty::Ty<I> {
10291027
if let ty::Alias(ty::Opaque, alias_ty) = ty.kind() {
10301028
if alias_ty == self.alias_ty {
10311029
return self.self_ty;
@@ -1282,7 +1280,7 @@ where
12821280
ControlFlow::Continue(())
12831281
}
12841282

1285-
fn visit_ty(&mut self, ty: Ty<I>) -> Self::Result {
1283+
fn visit_ty(&mut self, ty: ty::Ty<I>) -> Self::Result {
12861284
let ty = self.ecx.replace_bound_vars(ty, &mut self.universes);
12871285
let Ok(ty) = self.ecx.structurally_normalize_ty(self.param_env, ty) else {
12881286
return ControlFlow::Break(Err(NoSolution));

0 commit comments

Comments
 (0)