Skip to content

Commit 1e67915

Browse files
committed
Move rustc_middle::MaxUniverse to rustc_infer.
Because `rust_infer` is the only crate that uses it.
1 parent 006c85d commit 1e67915

File tree

3 files changed

+41
-42
lines changed

3 files changed

+41
-42
lines changed

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use rustc_hir::def_id::DefId;
66
use rustc_middle::bug;
77
use rustc_middle::ty::error::TypeError;
88
use rustc_middle::ty::{
9-
self, AliasRelationDirection, InferConst, MaxUniverse, Term, Ty, TyCtxt, TypeVisitable,
10-
TypeVisitableExt, TypingMode,
9+
self, AliasRelationDirection, InferConst, Term, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
10+
TypeVisitableExt, TypeVisitor, TypingMode,
1111
};
1212
use rustc_span::Span;
1313
use tracing::{debug, instrument, warn};
@@ -290,6 +290,45 @@ impl<'tcx> InferCtxt<'tcx> {
290290
}
291291
}
292292

293+
/// Finds the max universe present
294+
struct MaxUniverse {
295+
max_universe: ty::UniverseIndex,
296+
}
297+
298+
impl MaxUniverse {
299+
fn new() -> Self {
300+
MaxUniverse { max_universe: ty::UniverseIndex::ROOT }
301+
}
302+
303+
fn max_universe(self) -> ty::UniverseIndex {
304+
self.max_universe
305+
}
306+
}
307+
308+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxUniverse {
309+
fn visit_ty(&mut self, t: Ty<'tcx>) {
310+
if let ty::Placeholder(placeholder) = t.kind() {
311+
self.max_universe = self.max_universe.max(placeholder.universe);
312+
}
313+
314+
t.super_visit_with(self)
315+
}
316+
317+
fn visit_const(&mut self, c: ty::Const<'tcx>) {
318+
if let ty::ConstKind::Placeholder(placeholder) = c.kind() {
319+
self.max_universe = self.max_universe.max(placeholder.universe);
320+
}
321+
322+
c.super_visit_with(self)
323+
}
324+
325+
fn visit_region(&mut self, r: ty::Region<'tcx>) {
326+
if let ty::RePlaceholder(placeholder) = r.kind() {
327+
self.max_universe = self.max_universe.max(placeholder.universe);
328+
}
329+
}
330+
}
331+
293332
/// The "generalizer" is used when handling inference variables.
294333
///
295334
/// The basic strategy for handling a constraint like `?A <: B` is to

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ pub use self::typeck_results::{
109109
CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity,
110110
Rust2024IncompatiblePatInfo, TypeckResults, UserType, UserTypeAnnotationIndex, UserTypeKind,
111111
};
112-
pub use self::visit::*;
113112
use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
114113
use crate::metadata::ModChild;
115114
use crate::middle::privacy::EffectiveVisibilities;

compiler/rustc_middle/src/ty/visit.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -212,42 +212,3 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for LateBoundRegionsCollector {
212212
}
213213
}
214214
}
215-
216-
/// Finds the max universe present
217-
pub struct MaxUniverse {
218-
max_universe: ty::UniverseIndex,
219-
}
220-
221-
impl MaxUniverse {
222-
pub fn new() -> Self {
223-
MaxUniverse { max_universe: ty::UniverseIndex::ROOT }
224-
}
225-
226-
pub fn max_universe(self) -> ty::UniverseIndex {
227-
self.max_universe
228-
}
229-
}
230-
231-
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxUniverse {
232-
fn visit_ty(&mut self, t: Ty<'tcx>) {
233-
if let ty::Placeholder(placeholder) = t.kind() {
234-
self.max_universe = self.max_universe.max(placeholder.universe);
235-
}
236-
237-
t.super_visit_with(self)
238-
}
239-
240-
fn visit_const(&mut self, c: ty::consts::Const<'tcx>) {
241-
if let ty::ConstKind::Placeholder(placeholder) = c.kind() {
242-
self.max_universe = self.max_universe.max(placeholder.universe);
243-
}
244-
245-
c.super_visit_with(self)
246-
}
247-
248-
fn visit_region(&mut self, r: ty::Region<'tcx>) {
249-
if let ty::RePlaceholder(placeholder) = r.kind() {
250-
self.max_universe = self.max_universe.max(placeholder.universe);
251-
}
252-
}
253-
}

0 commit comments

Comments
 (0)