diff options
| author | Michael Goulet <michael@errs.io> | 2025-06-17 17:55:06 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-06-25 15:35:16 +0000 |
| commit | 44254c8cd79810fb2ff575d88e75c979bb7f1fc4 (patch) | |
| tree | e2ed4933625cae2a17297c9fa6e63ff7f75fc33f /compiler/rustc_infer | |
| parent | 2801f9aaf9b7580d9b230b532b0700709857cc88 (diff) | |
| download | rust-44254c8cd79810fb2ff575d88e75c979bb7f1fc4.tar.gz rust-44254c8cd79810fb2ff575d88e75c979bb7f1fc4.zip | |
Remove some glob imports from the type system
Diffstat (limited to 'compiler/rustc_infer')
| -rw-r--r-- | compiler/rustc_infer/src/infer/mod.rs | 56 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/outlives/obligations.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/region_constraints/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/resolve.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/traits/mod.rs | 2 |
5 files changed, 40 insertions, 39 deletions
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index e9b58eb959b..c1b486194db 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1,9 +1,6 @@ use std::cell::{Cell, RefCell}; use std::fmt; -pub use BoundRegionConversionTime::*; -pub use RegionVariableOrigin::*; -pub use SubregionOrigin::*; pub use at::DefineOpaqueTypes; use free_regions::RegionRelations; pub use freshen::TypeFreshener; @@ -467,21 +464,19 @@ pub struct FixupError { impl fmt::Display for FixupError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - use TyOrConstInferVar::*; - match self.unresolved { - TyInt(_) => write!( + TyOrConstInferVar::TyInt(_) => write!( f, "cannot determine the type of this integer; \ add a suffix to specify the type explicitly" ), - TyFloat(_) => write!( + TyOrConstInferVar::TyFloat(_) => write!( f, "cannot determine the type of this number; \ add a suffix to specify the type explicitly" ), - Ty(_) => write!(f, "unconstrained type"), - Const(_) => write!(f, "unconstrained const value"), + TyOrConstInferVar::Ty(_) => write!(f, "unconstrained type"), + TyOrConstInferVar::Const(_) => write!(f, "unconstrained const value"), } } } @@ -865,7 +860,10 @@ impl<'tcx> InferCtxt<'tcx> { GenericParamDefKind::Lifetime => { // Create a region inference variable for the given // region parameter definition. - self.next_region_var(RegionParameterDefinition(span, param.name)).into() + self.next_region_var(RegionVariableOrigin::RegionParameterDefinition( + span, param.name, + )) + .into() } GenericParamDefKind::Type { .. } => { // Create a type inference variable for the given @@ -1172,7 +1170,7 @@ impl<'tcx> InferCtxt<'tcx> { let arg: ty::GenericArg<'_> = match bound_var_kind { ty::BoundVariableKind::Ty(_) => self.next_ty_var(span).into(), ty::BoundVariableKind::Region(br) => { - self.next_region_var(BoundRegion(span, br, lbrct)).into() + self.next_region_var(RegionVariableOrigin::BoundRegion(span, br, lbrct)).into() } ty::BoundVariableKind::Const => self.next_const_var(span).into(), }; @@ -1472,15 +1470,15 @@ impl<'tcx> TypeTrace<'tcx> { impl<'tcx> SubregionOrigin<'tcx> { pub fn span(&self) -> Span { match *self { - Subtype(ref a) => a.span(), - RelateObjectBound(a) => a, - RelateParamBound(a, ..) => a, - RelateRegionParamBound(a, _) => a, - Reborrow(a) => a, - ReferenceOutlivesReferent(_, a) => a, - CompareImplItemObligation { span, .. } => span, - AscribeUserTypeProvePredicate(span) => span, - CheckAssociatedTypeBounds { ref parent, .. } => parent.span(), + SubregionOrigin::Subtype(ref a) => a.span(), + SubregionOrigin::RelateObjectBound(a) => a, + SubregionOrigin::RelateParamBound(a, ..) => a, + SubregionOrigin::RelateRegionParamBound(a, _) => a, + SubregionOrigin::Reborrow(a) => a, + SubregionOrigin::ReferenceOutlivesReferent(_, a) => a, + SubregionOrigin::CompareImplItemObligation { span, .. } => span, + SubregionOrigin::AscribeUserTypeProvePredicate(span) => span, + SubregionOrigin::CheckAssociatedTypeBounds { ref parent, .. } => parent.span(), } } @@ -1528,15 +1526,15 @@ impl<'tcx> SubregionOrigin<'tcx> { impl RegionVariableOrigin { pub fn span(&self) -> Span { match *self { - MiscVariable(a) - | PatternRegion(a) - | BorrowRegion(a) - | Autoref(a) - | Coercion(a) - | RegionParameterDefinition(a, ..) - | BoundRegion(a, ..) - | UpvarRegion(_, a) => a, - Nll(..) => bug!("NLL variable used with `span`"), + RegionVariableOrigin::MiscVariable(a) + | RegionVariableOrigin::PatternRegion(a) + | RegionVariableOrigin::BorrowRegion(a) + | RegionVariableOrigin::Autoref(a) + | RegionVariableOrigin::Coercion(a) + | RegionVariableOrigin::RegionParameterDefinition(a, ..) + | RegionVariableOrigin::BoundRegion(a, ..) + | RegionVariableOrigin::UpvarRegion(_, a) => a, + RegionVariableOrigin::Nll(..) => bug!("NLL variable used with `span`"), } } } diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index db937b3e83e..f272052aaa5 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -141,7 +141,7 @@ impl<'tcx> InferCtxt<'tcx> { debug!(?sup_type, ?sub_region, ?cause); let origin = SubregionOrigin::from_obligation_cause(cause, || { - infer::RelateParamBound( + SubregionOrigin::RelateParamBound( cause.span, sup_type, match cause.code().peel_derives() { diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs index 40e2e654b2e..b5bf5211dd6 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs @@ -14,7 +14,7 @@ use tracing::{debug, instrument}; use self::CombineMapType::*; use self::UndoLog::*; -use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin}; +use super::{RegionVariableOrigin, Rollback, SubregionOrigin}; use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot}; use crate::infer::unify_key::{RegionVariableValue, RegionVidKey}; @@ -580,7 +580,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { let a_universe = self.universe(a); let b_universe = self.universe(b); let c_universe = cmp::max(a_universe, b_universe); - let c = self.new_region_var(c_universe, MiscVariable(origin.span())); + let c = self.new_region_var(c_universe, RegionVariableOrigin::MiscVariable(origin.span())); self.combine_map(t).insert(vars, c); self.undo_log.push(AddCombination(t, vars)); let new_r = ty::Region::new_var(tcx, c); diff --git a/compiler/rustc_infer/src/infer/resolve.rs b/compiler/rustc_infer/src/infer/resolve.rs index a95f24b5b95..13df23a39b9 100644 --- a/compiler/rustc_infer/src/infer/resolve.rs +++ b/compiler/rustc_infer/src/infer/resolve.rs @@ -5,6 +5,7 @@ use rustc_middle::ty::{ }; use super::{FixupError, FixupResult, InferCtxt}; +use crate::infer::TyOrConstInferVar; /////////////////////////////////////////////////////////////////////////// // OPPORTUNISTIC VAR RESOLVER @@ -144,13 +145,17 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> { if !t.has_infer() { Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects... } else { - use super::TyOrConstInferVar::*; - let t = self.infcx.shallow_resolve(t); match *t.kind() { - ty::Infer(ty::TyVar(vid)) => Err(FixupError { unresolved: Ty(vid) }), - ty::Infer(ty::IntVar(vid)) => Err(FixupError { unresolved: TyInt(vid) }), - ty::Infer(ty::FloatVar(vid)) => Err(FixupError { unresolved: TyFloat(vid) }), + ty::Infer(ty::TyVar(vid)) => { + Err(FixupError { unresolved: TyOrConstInferVar::Ty(vid) }) + } + ty::Infer(ty::IntVar(vid)) => { + Err(FixupError { unresolved: TyOrConstInferVar::TyInt(vid) }) + } + ty::Infer(ty::FloatVar(vid)) => { + Err(FixupError { unresolved: TyOrConstInferVar::TyFloat(vid) }) + } ty::Infer(_) => { bug!("Unexpected type in full type resolver: {:?}", t); } diff --git a/compiler/rustc_infer/src/traits/mod.rs b/compiler/rustc_infer/src/traits/mod.rs index 6d5ad96e31c..79a4859f286 100644 --- a/compiler/rustc_infer/src/traits/mod.rs +++ b/compiler/rustc_infer/src/traits/mod.rs @@ -20,8 +20,6 @@ use rustc_middle::ty::{self, Ty, TyCtxt, Upcast}; use rustc_span::Span; use thin_vec::ThinVec; -pub use self::ImplSource::*; -pub use self::SelectionError::*; pub use self::engine::{FromSolverError, ScrubbedTraitError, TraitEngine}; pub(crate) use self::project::UndoLog; pub use self::project::{ |
