Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/solver.rs')
| -rw-r--r-- | crates/hir-ty/src/next_solver/solver.rs | 66 |
1 files changed, 24 insertions, 42 deletions
diff --git a/crates/hir-ty/src/next_solver/solver.rs b/crates/hir-ty/src/next_solver/solver.rs index 2457447ee3..487d164f86 100644 --- a/crates/hir-ty/src/next_solver/solver.rs +++ b/crates/hir-ty/src/next_solver/solver.rs @@ -1,29 +1,22 @@ //! Defining `SolverContext` for next-trait-solver. -use hir_def::{AssocItemId, GeneralConstId, TypeAliasId}; +use hir_def::{AssocItemId, GeneralConstId}; use rustc_next_trait_solver::delegate::SolverDelegate; use rustc_type_ir::GenericArgKind; use rustc_type_ir::lang_items::SolverTraitLangItem; use rustc_type_ir::{ - InferCtxtLike, Interner, PredicatePolarity, TypeFlags, TypeVisitableExt, UniverseIndex, - inherent::{IntoKind, SliceLike, Span as _, Term as _, Ty as _}, + InferCtxtLike, Interner, PredicatePolarity, TypeFlags, TypeVisitableExt, + inherent::{IntoKind, Term as _, Ty as _}, solve::{Certainty, NoSolution}, }; -use crate::next_solver::mapping::NextSolverToChalk; use crate::next_solver::{CanonicalVarKind, ImplIdWrapper}; -use crate::{ - TraitRefExt, - db::HirDatabase, - next_solver::{ - ClauseKind, CoercePredicate, PredicateKind, SubtypePredicate, mapping::ChalkToNextSolver, - util::sizedness_fast_path, - }, +use crate::next_solver::{ + ClauseKind, CoercePredicate, PredicateKind, SubtypePredicate, util::sizedness_fast_path, }; use super::{ - Canonical, CanonicalVarValues, Const, DbInterner, ErrorGuaranteed, GenericArg, GenericArgs, - ParamEnv, Predicate, SolverDefId, Span, Ty, UnevaluatedConst, + DbInterner, ErrorGuaranteed, GenericArg, SolverDefId, Span, infer::{DbInternerInferExt, InferCtxt, canonical::instantiate::CanonicalExt}, }; @@ -66,7 +59,7 @@ impl<'db> SolverDelegate for SolverContext<'db> { (SolverContext(infcx), value, vars) } - fn fresh_var_for_kind_with_span(&self, arg: GenericArg<'db>, span: Span) -> GenericArg<'db> { + fn fresh_var_for_kind_with_span(&self, arg: GenericArg<'db>, _span: Span) -> GenericArg<'db> { match arg.kind() { GenericArgKind::Lifetime(_) => self.next_region_var().into(), GenericArgKind::Type(_) => self.next_ty_var().into(), @@ -76,15 +69,15 @@ impl<'db> SolverDelegate for SolverContext<'db> { fn leak_check( &self, - max_input_universe: rustc_type_ir::UniverseIndex, + _max_input_universe: rustc_type_ir::UniverseIndex, ) -> Result<(), NoSolution> { Ok(()) } fn well_formed_goals( &self, - param_env: <Self::Interner as rustc_type_ir::Interner>::ParamEnv, - arg: <Self::Interner as rustc_type_ir::Interner>::Term, + _param_env: <Self::Interner as rustc_type_ir::Interner>::ParamEnv, + _arg: <Self::Interner as rustc_type_ir::Interner>::Term, ) -> Option< Vec< rustc_type_ir::solve::Goal< @@ -123,7 +116,7 @@ impl<'db> SolverDelegate for SolverContext<'db> { fn instantiate_canonical_var( &self, kind: CanonicalVarKind<'db>, - span: <Self::Interner as Interner>::Span, + _span: <Self::Interner as Interner>::Span, var_values: &[GenericArg<'db>], universe_map: impl Fn(rustc_type_ir::UniverseIndex) -> rustc_type_ir::UniverseIndex, ) -> GenericArg<'db> { @@ -132,11 +125,11 @@ impl<'db> SolverDelegate for SolverContext<'db> { fn add_item_bounds_for_hidden_type( &self, - def_id: <Self::Interner as rustc_type_ir::Interner>::DefId, - args: <Self::Interner as rustc_type_ir::Interner>::GenericArgs, - param_env: <Self::Interner as rustc_type_ir::Interner>::ParamEnv, - hidden_ty: <Self::Interner as rustc_type_ir::Interner>::Ty, - goals: &mut Vec< + _def_id: <Self::Interner as rustc_type_ir::Interner>::DefId, + _args: <Self::Interner as rustc_type_ir::Interner>::GenericArgs, + _param_env: <Self::Interner as rustc_type_ir::Interner>::ParamEnv, + _hidden_ty: <Self::Interner as rustc_type_ir::Interner>::Ty, + _goals: &mut Vec< rustc_type_ir::solve::Goal< Self::Interner, <Self::Interner as rustc_type_ir::Interner>::Predicate, @@ -148,21 +141,10 @@ impl<'db> SolverDelegate for SolverContext<'db> { fn fetch_eligible_assoc_item( &self, - goal_trait_ref: rustc_type_ir::TraitRef<Self::Interner>, + _goal_trait_ref: rustc_type_ir::TraitRef<Self::Interner>, trait_assoc_def_id: SolverDefId, impl_id: ImplIdWrapper, ) -> Result<Option<SolverDefId>, ErrorGuaranteed> { - let trait_ = self - .0 - .interner - .db() - .impl_trait(impl_id.0) - // ImplIds for impls where the trait ref can't be resolved should never reach solver - .expect("invalid impl passed to next-solver") - .skip_binder() - .def_id - .0; - let trait_data = trait_.trait_items(self.0.interner.db()); let impl_items = impl_id.0.impl_items(self.0.interner.db()); let id = match trait_assoc_def_id { SolverDefId::TypeAliasId(trait_assoc_id) => { @@ -208,16 +190,16 @@ impl<'db> SolverDelegate for SolverContext<'db> { fn is_transmutable( &self, - dst: <Self::Interner as rustc_type_ir::Interner>::Ty, - src: <Self::Interner as rustc_type_ir::Interner>::Ty, - assume: <Self::Interner as rustc_type_ir::Interner>::Const, + _dst: <Self::Interner as rustc_type_ir::Interner>::Ty, + _src: <Self::Interner as rustc_type_ir::Interner>::Ty, + _assume: <Self::Interner as rustc_type_ir::Interner>::Const, ) -> Result<Certainty, NoSolution> { unimplemented!() } fn evaluate_const( &self, - param_env: <Self::Interner as rustc_type_ir::Interner>::ParamEnv, + _param_env: <Self::Interner as rustc_type_ir::Interner>::ParamEnv, uv: rustc_type_ir::UnevaluatedConst<Self::Interner>, ) -> Option<<Self::Interner as rustc_type_ir::Interner>::Const> { let c = match uv.def { @@ -236,7 +218,7 @@ impl<'db> SolverDelegate for SolverContext<'db> { Self::Interner, <Self::Interner as rustc_type_ir::Interner>::Predicate, >, - span: <Self::Interner as rustc_type_ir::Interner>::Span, + _span: <Self::Interner as rustc_type_ir::Interner>::Span, ) -> Option<Certainty> { if let Some(trait_pred) = goal.predicate.as_trait_clause() { if self.shallow_resolve(trait_pred.self_ty().skip_binder()).is_ty_var() @@ -279,8 +261,8 @@ impl<'db> SolverDelegate for SolverContext<'db> { let pred = goal.predicate.kind(); match pred.no_bound_vars()? { - PredicateKind::Clause(ClauseKind::RegionOutlives(outlives)) => Some(Certainty::Yes), - PredicateKind::Clause(ClauseKind::TypeOutlives(outlives)) => Some(Certainty::Yes), + PredicateKind::Clause(ClauseKind::RegionOutlives(_outlives)) => Some(Certainty::Yes), + PredicateKind::Clause(ClauseKind::TypeOutlives(_outlives)) => Some(Certainty::Yes), PredicateKind::Subtype(SubtypePredicate { a, b, .. }) | PredicateKind::Coerce(CoercePredicate { a, b }) => { if self.shallow_resolve(a).is_ty_var() && self.shallow_resolve(b).is_ty_var() { |