Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/infer/mod.rs')
-rw-r--r--crates/hir-ty/src/next_solver/infer/mod.rs71
1 files changed, 28 insertions, 43 deletions
diff --git a/crates/hir-ty/src/next_solver/infer/mod.rs b/crates/hir-ty/src/next_solver/infer/mod.rs
index e1a46fa069..36c6c48c5a 100644
--- a/crates/hir-ty/src/next_solver/infer/mod.rs
+++ b/crates/hir-ty/src/next_solver/infer/mod.rs
@@ -6,32 +6,23 @@ use std::ops::Range;
use std::sync::Arc;
pub use BoundRegionConversionTime::*;
-pub use at::DefineOpaqueTypes;
-use ena::undo_log::UndoLogs;
use ena::unify as ut;
use hir_def::GenericParamId;
use hir_def::lang_item::LangItem;
-use intern::Symbol;
use opaque_types::{OpaqueHiddenType, OpaqueTypeStorage};
-use region_constraints::{
- GenericKind, RegionConstraintCollector, RegionConstraintStorage, UndoLog, VarInfos, VerifyBound,
-};
-pub use relate::StructurallyRelateAliases;
-pub use relate::combine::PredicateEmittingRelation;
-use rustc_hash::{FxHashMap, FxHashSet};
+use region_constraints::{RegionConstraintCollector, RegionConstraintStorage};
use rustc_next_trait_solver::solve::SolverDelegateEvalExt;
use rustc_pattern_analysis::Captures;
+use rustc_type_ir::TypeFoldable;
use rustc_type_ir::error::{ExpectedFound, TypeError};
use rustc_type_ir::inherent::{
- Const as _, GenericArg as _, GenericArgs as _, IntoKind, ParamEnv as _, SliceLike, Term as _,
- Ty as _,
+ Const as _, GenericArg as _, GenericArgs as _, IntoKind, SliceLike, Term as _, Ty as _,
};
use rustc_type_ir::{
- BoundVar, ClosureKind, ConstVid, FloatTy, FloatVarValue, FloatVid, GenericArgKind, InferConst,
- InferTy, IntTy, IntVarValue, IntVid, OutlivesPredicate, RegionVid, TyVid, UniverseIndex,
+ ClosureKind, ConstVid, FloatVarValue, FloatVid, GenericArgKind, InferConst, InferTy,
+ IntVarValue, IntVid, OutlivesPredicate, RegionVid, TyVid, UniverseIndex,
};
use rustc_type_ir::{TermKind, TypeVisitableExt};
-use rustc_type_ir::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use snapshot::undo_log::InferCtxtUndoLogs;
use tracing::{debug, instrument};
use traits::{ObligationCause, PredicateObligations};
@@ -39,19 +30,17 @@ use type_variable::TypeVariableOrigin;
use unify_key::{ConstVariableOrigin, ConstVariableValue, ConstVidKey};
use crate::next_solver::fold::BoundVarReplacerDelegate;
-use crate::next_solver::infer::opaque_types::table::OpaqueTypeStorageEntries;
use crate::next_solver::infer::select::EvaluationResult;
use crate::next_solver::infer::traits::PredicateObligation;
use crate::next_solver::obligation_ctxt::ObligationCtxt;
use crate::next_solver::{BoundConst, BoundRegion, BoundTy, BoundVarKind, Goal, SolverContext};
-use super::generics::GenericParamDef;
use super::{
- AliasTerm, Binder, BoundRegionKind, CanonicalQueryInput, CanonicalVarValues, Const, ConstKind,
- DbInterner, ErrorGuaranteed, FxIndexMap, GenericArg, GenericArgs, OpaqueTypeKey, ParamEnv,
- PlaceholderRegion, PolyCoercePredicate, PolyExistentialProjection, PolyExistentialTraitRef,
- PolyFnSig, PolyRegionOutlivesPredicate, PolySubtypePredicate, Predicate, Region, SolverDefId,
- SubtypePredicate, Term, TraitPredicate, TraitRef, Ty, TyKind, TypingMode,
+ AliasTerm, Binder, CanonicalQueryInput, CanonicalVarValues, Const, ConstKind, DbInterner,
+ ErrorGuaranteed, GenericArg, GenericArgs, OpaqueTypeKey, ParamEnv, PolyCoercePredicate,
+ PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyRegionOutlivesPredicate,
+ PolySubtypePredicate, Region, SolverDefId, SubtypePredicate, Term, TraitRef, Ty, TyKind,
+ TypingMode,
};
pub mod at;
@@ -82,8 +71,6 @@ pub struct InferOk<'db, T> {
}
pub type InferResult<'db, T> = Result<InferOk<'db, T>, TypeError<DbInterner<'db>>>;
-pub(crate) type FixupResult<T> = Result<T, FixupError>; // "fixup result"
-
pub(crate) type UnificationTable<'a, 'db, T> = ut::UnificationTable<
ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'db>>,
>;
@@ -440,6 +427,7 @@ impl<'db> InferCtxt<'db> {
/// check::<&'_ T>();
/// }
/// ```
+ #[expect(dead_code, reason = "this is used in rustc")]
fn predicate_must_hold_considering_regions(
&self,
obligation: &PredicateObligation<'db>,
@@ -452,14 +440,13 @@ impl<'db> InferCtxt<'db> {
/// not entirely accurate if inference variables are involved.
///
/// This version ignores all outlives constraints.
+ #[expect(dead_code, reason = "this is used in rustc")]
fn predicate_must_hold_modulo_regions(&self, obligation: &PredicateObligation<'db>) -> bool {
self.evaluate_obligation(obligation).must_apply_modulo_regions()
}
/// Evaluate a given predicate, capturing overflow and propagating it back.
fn evaluate_obligation(&self, obligation: &PredicateObligation<'db>) -> EvaluationResult {
- let param_env = obligation.param_env;
-
self.probe(|snapshot| {
let mut ocx = ObligationCtxt::new(self);
ocx.register_obligation(obligation.clone());
@@ -583,16 +570,16 @@ impl<'db> InferCtxt<'db> {
self.enter_forall(predicate, |SubtypePredicate { a_is_expected, a, b }| {
if a_is_expected {
- Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b))
+ Ok(self.at(cause, param_env).sub(a, b))
} else {
- Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a))
+ Ok(self.at(cause, param_env).sup(b, a))
}
})
}
pub fn region_outlives_predicate(
&self,
- cause: &traits::ObligationCause,
+ _cause: &traits::ObligationCause,
predicate: PolyRegionOutlivesPredicate<'db>,
) {
self.enter_forall(predicate, |OutlivesPredicate(r_a, r_b)| {
@@ -632,7 +619,7 @@ impl<'db> InferCtxt<'db> {
}
pub fn next_const_var(&self) -> Const<'db> {
- self.next_const_var_with_origin(ConstVariableOrigin { param_def_id: None })
+ self.next_const_var_with_origin(ConstVariableOrigin {})
}
pub fn next_const_vid(&self) -> ConstVid {
@@ -640,7 +627,7 @@ impl<'db> InferCtxt<'db> {
.borrow_mut()
.const_unification_table()
.new_key(ConstVariableValue::Unknown {
- origin: ConstVariableOrigin { param_def_id: None },
+ origin: ConstVariableOrigin {},
universe: self.universe(),
})
.vid
@@ -657,7 +644,7 @@ impl<'db> InferCtxt<'db> {
}
pub fn next_const_var_in_universe(&self, universe: UniverseIndex) -> Const<'db> {
- let origin = ConstVariableOrigin { param_def_id: None };
+ let origin = ConstVariableOrigin {};
let vid = self
.inner
.borrow_mut()
@@ -738,7 +725,7 @@ impl<'db> InferCtxt<'db> {
self.next_region_var_in_universe(universe)
}
- fn var_for_def(&self, id: GenericParamId, name: &Symbol) -> GenericArg<'db> {
+ fn var_for_def(&self, id: GenericParamId) -> GenericArg<'db> {
match id {
GenericParamId::LifetimeParamId(_) => {
// Create a region inference variable for the given
@@ -763,7 +750,7 @@ impl<'db> InferCtxt<'db> {
Ty::new_var(self.interner, ty_var_id).into()
}
GenericParamId::ConstParamId(_) => {
- let origin = ConstVariableOrigin { param_def_id: None };
+ let origin = ConstVariableOrigin {};
let const_var_id = self
.inner
.borrow_mut()
@@ -778,9 +765,7 @@ impl<'db> InferCtxt<'db> {
/// Given a set of generics defined on a type or impl, returns the generic parameters mapping
/// each type/region parameter to a fresh inference variable.
pub fn fresh_args_for_item(&self, def_id: SolverDefId) -> GenericArgs<'db> {
- GenericArgs::for_item(self.interner, def_id, |name, index, kind, _| {
- self.var_for_def(kind, name)
- })
+ GenericArgs::for_item(self.interner, def_id, |_index, kind, _| self.var_for_def(kind))
}
/// Like `fresh_args_for_item()`, but first uses the args from `first`.
@@ -789,8 +774,8 @@ impl<'db> InferCtxt<'db> {
def_id: SolverDefId,
first: impl IntoIterator<Item = GenericArg<'db>>,
) -> GenericArgs<'db> {
- GenericArgs::fill_rest(self.interner, def_id, first, |name, index, kind, _| {
- self.var_for_def(kind, name)
+ GenericArgs::fill_rest(self.interner, def_id, first, |_index, kind, _| {
+ self.var_for_def(kind)
})
}
@@ -828,8 +813,8 @@ impl<'db> InferCtxt<'db> {
defining_opaque_types_and_generators.contains(&id.into())
}
TypingMode::Coherence | TypingMode::PostAnalysis => false,
- TypingMode::Borrowck { defining_opaque_types } => unimplemented!(),
- TypingMode::PostBorrowckAnalysis { defined_opaque_types } => unimplemented!(),
+ TypingMode::Borrowck { defining_opaque_types: _ } => unimplemented!(),
+ TypingMode::PostBorrowckAnalysis { defined_opaque_types: _ } => unimplemented!(),
}
}
@@ -998,7 +983,7 @@ impl<'db> InferCtxt<'db> {
// use [`InferCtxt::enter_forall`] instead.
pub fn instantiate_binder_with_fresh_vars<T>(
&self,
- lbrct: BoundRegionConversionTime,
+ _lbrct: BoundRegionConversionTime,
value: Binder<'db, T>,
) -> T
where
@@ -1014,7 +999,7 @@ impl<'db> InferCtxt<'db> {
for bound_var_kind in bound_vars {
let arg: GenericArg<'db> = match bound_var_kind {
BoundVarKind::Ty(_) => self.next_ty_var().into(),
- BoundVarKind::Region(br) => self.next_region_var().into(),
+ BoundVarKind::Region(_) => self.next_region_var().into(),
BoundVarKind::Const => self.next_const_var().into(),
};
args.push(arg);
@@ -1070,7 +1055,7 @@ impl<'db> InferCtxt<'db> {
#[inline]
pub fn is_ty_infer_var_definitely_unchanged<'a>(
&'a self,
- ) -> (impl Fn(TyOrConstInferVar) -> bool + Captures<'db> + 'a) {
+ ) -> impl Fn(TyOrConstInferVar) -> bool + Captures<'db> + 'a {
// This hoists the borrow/release out of the loop body.
let inner = self.inner.try_borrow();