Remove hir-ty/src/next_solver/mapping.rs
This commit is contained in:
parent
6e397d3cd5
commit
617683f8d4
8 changed files with 21 additions and 52 deletions
|
|
@ -277,7 +277,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
|
|||
|
||||
// Interned IDs for solver integration
|
||||
#[salsa::interned]
|
||||
fn intern_impl_trait_id(&self, id: ImplTraitId) -> InternedOpaqueTyId;
|
||||
fn intern_impl_trait_id(&self, id: ImplTraitId<'_>) -> InternedOpaqueTyId;
|
||||
|
||||
#[salsa::interned]
|
||||
fn intern_closure(&self, id: InternedClosure) -> InternedClosureId;
|
||||
|
|
@ -322,7 +322,7 @@ pub struct InternedConstParamId {
|
|||
#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX)]
|
||||
#[derive(PartialOrd, Ord)]
|
||||
pub struct InternedOpaqueTyId {
|
||||
pub loc: ImplTraitId,
|
||||
pub loc: ImplTraitId<'db>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ use crate::{
|
|||
TraitRef, Ty, TyKind, TypingMode,
|
||||
abi::Safety,
|
||||
infer::{DbInternerInferExt, traits::ObligationCause},
|
||||
mapping::ChalkToNextSolver,
|
||||
},
|
||||
primitive,
|
||||
utils::{self, detect_variant_from_bytes},
|
||||
|
|
@ -1126,9 +1125,9 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
|
|||
let datas = db
|
||||
.return_type_impl_traits(func)
|
||||
.expect("impl trait id without data");
|
||||
let data = (*datas).as_ref().map_bound(|rpit| {
|
||||
&rpit.impl_traits[idx.to_nextsolver(interner)].predicates
|
||||
});
|
||||
let data = (*datas)
|
||||
.as_ref()
|
||||
.map_bound(|rpit| &rpit.impl_traits[idx].predicates);
|
||||
let bounds =
|
||||
|| data.iter_instantiated_copied(f.interner, ty.args.as_slice());
|
||||
let mut len = bounds().count();
|
||||
|
|
@ -1358,9 +1357,8 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
|
|||
ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||
let datas =
|
||||
db.return_type_impl_traits(func).expect("impl trait id without data");
|
||||
let data = (*datas).as_ref().map_bound(|rpit| {
|
||||
&rpit.impl_traits[idx.to_nextsolver(interner)].predicates
|
||||
});
|
||||
let data =
|
||||
(*datas).as_ref().map_bound(|rpit| &rpit.impl_traits[idx].predicates);
|
||||
let bounds = data
|
||||
.iter_instantiated_copied(interner, alias_ty.args.as_slice())
|
||||
.collect::<Vec<_>>();
|
||||
|
|
@ -1377,9 +1375,8 @@ impl<'db> HirDisplay<'db> for Ty<'db> {
|
|||
ImplTraitId::TypeAliasImplTrait(alias, idx) => {
|
||||
let datas =
|
||||
db.type_alias_impl_traits(alias).expect("impl trait id without data");
|
||||
let data = (*datas).as_ref().map_bound(|rpit| {
|
||||
&rpit.impl_traits[idx.to_nextsolver(interner)].predicates
|
||||
});
|
||||
let data =
|
||||
(*datas).as_ref().map_bound(|rpit| &rpit.impl_traits[idx].predicates);
|
||||
let bounds = data
|
||||
.iter_instantiated_copied(interner, alias_ty.args.as_slice())
|
||||
.collect::<Vec<_>>();
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ use crate::{
|
|||
abi::Safety,
|
||||
fold::fold_tys,
|
||||
infer::traits::{Obligation, ObligationCause},
|
||||
mapping::ChalkToNextSolver,
|
||||
},
|
||||
traits::FnTrait,
|
||||
utils::TargetFeatureIsSafeInTarget,
|
||||
|
|
@ -1228,9 +1227,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
|
|||
if matches!(mode, ImplTraitReplacingMode::TypeAlias) {
|
||||
// RPITs don't have `tait_coercion_table`, so use inserted inference
|
||||
// vars for them.
|
||||
if let Some(ty) =
|
||||
self.result.type_of_rpit.get(idx.to_nextsolver(self.interner()))
|
||||
{
|
||||
if let Some(ty) = self.result.type_of_rpit.get(idx) {
|
||||
return *ty;
|
||||
}
|
||||
return ty;
|
||||
|
|
@ -1251,10 +1248,9 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
|
|||
let Some(impl_traits) = impl_traits else {
|
||||
return ty;
|
||||
};
|
||||
let bounds = (*impl_traits).as_ref().map_bound(|its| {
|
||||
its.impl_traits[idx.to_nextsolver(self.interner())].predicates.as_slice()
|
||||
});
|
||||
let var = match self.result.type_of_rpit.entry(idx.to_nextsolver(self.interner())) {
|
||||
let bounds =
|
||||
(*impl_traits).as_ref().map_bound(|its| its.impl_traits[idx].predicates.as_slice());
|
||||
let var = match self.result.type_of_rpit.entry(idx) {
|
||||
Entry::Occupied(entry) => return *entry.get(),
|
||||
Entry::Vacant(entry) => *entry.insert(self.table.next_ty_var()),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ use hir_def::{CallableDefId, TypeOrConstParamId, hir::ExprId, type_ref::Rawness}
|
|||
use hir_expand::name::Name;
|
||||
use indexmap::{IndexMap, map::Entry};
|
||||
use intern::{Symbol, sym};
|
||||
use la_arena::Idx;
|
||||
use mir::{MirEvalError, VTableMap};
|
||||
use rustc_hash::{FxBuildHasher, FxHashMap, FxHashSet};
|
||||
use rustc_type_ir::{
|
||||
|
|
@ -332,17 +331,12 @@ impl FnAbi {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub enum ImplTraitId {
|
||||
ReturnTypeImplTrait(hir_def::FunctionId, ImplTraitIdx), // FIXME(next-solver): Should be crate::nextsolver::ImplTraitIdx.
|
||||
TypeAliasImplTrait(hir_def::TypeAliasId, ImplTraitIdx),
|
||||
pub enum ImplTraitId<'db> {
|
||||
ReturnTypeImplTrait(hir_def::FunctionId, next_solver::ImplTraitIdx<'db>),
|
||||
TypeAliasImplTrait(hir_def::TypeAliasId, next_solver::ImplTraitIdx<'db>),
|
||||
AsyncBlockTypeImplTrait(hir_def::DefWithBodyId, ExprId),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Hash)]
|
||||
pub struct ImplTrait {}
|
||||
|
||||
pub type ImplTraitIdx = Idx<ImplTrait>;
|
||||
|
||||
/// 'Canonicalizes' the `t` by replacing any errors with new variables. Also
|
||||
/// ensures there are no unbound variables or inference variables anywhere in
|
||||
/// the `t`.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ pub mod infer;
|
|||
pub(crate) mod inspect;
|
||||
pub mod interner;
|
||||
mod ir_print;
|
||||
pub mod mapping;
|
||||
pub mod normalize;
|
||||
pub mod obligation_ctxt;
|
||||
mod opaques;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ use super::{
|
|||
abi::Safety,
|
||||
fold::{BoundVarReplacer, BoundVarReplacerDelegate, FnMutDelegate},
|
||||
generics::{Generics, generics},
|
||||
mapping::ChalkToNextSolver,
|
||||
region::{
|
||||
BoundRegion, BoundRegionKind, EarlyParamRegion, LateParamRegion, PlaceholderRegion, Region,
|
||||
},
|
||||
|
|
@ -1883,7 +1882,7 @@ impl<'db> Interner for DbInterner<'db> {
|
|||
match impl_trait_id {
|
||||
crate::ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||
let infer = self.db().infer(func.into());
|
||||
EarlyBinder::bind(infer.type_of_rpit[idx.to_nextsolver(self)])
|
||||
EarlyBinder::bind(infer.type_of_rpit[idx])
|
||||
}
|
||||
crate::ImplTraitId::TypeAliasImplTrait(..)
|
||||
| crate::ImplTraitId::AsyncBlockTypeImplTrait(_, _) => {
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
//! Things useful for mapping to/from Chalk and next-trait-solver types.
|
||||
|
||||
use crate::next_solver::interner::DbInterner;
|
||||
|
||||
pub(crate) trait ChalkToNextSolver<'db, Out> {
|
||||
fn to_nextsolver(&self, interner: DbInterner<'db>) -> Out;
|
||||
}
|
||||
|
||||
impl<'db> ChalkToNextSolver<'db, crate::lower::ImplTraitIdx<'db>> for crate::ImplTraitIdx {
|
||||
fn to_nextsolver(&self, _interner: DbInterner<'db>) -> crate::lower::ImplTraitIdx<'db> {
|
||||
crate::lower::ImplTraitIdx::from_raw(self.into_raw())
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,6 @@ use crate::{
|
|||
CoroutineIdWrapper, FnSig, GenericArg, PolyFnSig, Region, TraitRef, TypeAliasIdWrapper,
|
||||
abi::Safety,
|
||||
interner::InternedWrapperNoDebug,
|
||||
mapping::ChalkToNextSolver,
|
||||
util::{CoroutineArgsExt, IntegerTypeExt},
|
||||
},
|
||||
};
|
||||
|
|
@ -533,18 +532,16 @@ impl<'db> Ty<'db> {
|
|||
match db.lookup_intern_impl_trait_id(opaque_ty.def_id.expect_opaque_ty()) {
|
||||
ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||
db.return_type_impl_traits(func).map(|it| {
|
||||
let data = (*it).as_ref().map_bound(|rpit| {
|
||||
&rpit.impl_traits[idx.to_nextsolver(interner)].predicates
|
||||
});
|
||||
let data =
|
||||
(*it).as_ref().map_bound(|rpit| &rpit.impl_traits[idx].predicates);
|
||||
data.iter_instantiated_copied(interner, opaque_ty.args.as_slice())
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
ImplTraitId::TypeAliasImplTrait(alias, idx) => {
|
||||
db.type_alias_impl_traits(alias).map(|it| {
|
||||
let data = (*it).as_ref().map_bound(|rpit| {
|
||||
&rpit.impl_traits[idx.to_nextsolver(interner)].predicates
|
||||
});
|
||||
let data =
|
||||
(*it).as_ref().map_bound(|rpit| &rpit.impl_traits[idx].predicates);
|
||||
data.iter_instantiated_copied(interner, opaque_ty.args.as_slice())
|
||||
.collect()
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue