Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/next_solver/consts.rs')
-rw-r--r--crates/hir-ty/src/next_solver/consts.rs68
1 files changed, 35 insertions, 33 deletions
diff --git a/crates/hir-ty/src/next_solver/consts.rs b/crates/hir-ty/src/next_solver/consts.rs
index 2fc1fc4f45..926dbdc03d 100644
--- a/crates/hir-ty/src/next_solver/consts.rs
+++ b/crates/hir-ty/src/next_solver/consts.rs
@@ -2,21 +2,20 @@
use std::hash::Hash;
-use hir_def::{ConstParamId, TypeOrConstParamId};
-use intern::{Interned, Symbol};
+use hir_def::ConstParamId;
use macros::{TypeFoldable, TypeVisitable};
-use rustc_ast_ir::{try_visit, visit::VisitorResult};
+use rustc_ast_ir::visit::VisitorResult;
use rustc_type_ir::{
- BoundVar, DebruijnIndex, FlagComputation, Flags, TypeFoldable, TypeSuperFoldable,
- TypeSuperVisitable, TypeVisitable, TypeVisitableExt, WithCachedTypeInfo,
+ BoundVar, BoundVarIndexKind, ConstVid, DebruijnIndex, FlagComputation, Flags, InferConst,
+ TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
+ WithCachedTypeInfo,
inherent::{IntoKind, ParamEnv as _, PlaceholderLike, SliceLike},
relate::Relate,
};
use crate::{
- ConstScalar, MemoryMap,
- interner::InternedWrapperNoDebug,
- next_solver::{ClauseKind, ParamEnv},
+ MemoryMap,
+ next_solver::{ClauseKind, ParamEnv, interner::InternedWrapperNoDebug},
};
use super::{BoundVarKind, DbInterner, ErrorGuaranteed, GenericArgs, Placeholder, Ty};
@@ -51,11 +50,11 @@ impl<'db> Const<'db> {
}
pub fn error(interner: DbInterner<'db>) -> Self {
- Const::new(interner, rustc_type_ir::ConstKind::Error(ErrorGuaranteed))
+ Const::new(interner, ConstKind::Error(ErrorGuaranteed))
}
pub fn new_param(interner: DbInterner<'db>, param: ParamConst) -> Self {
- Const::new(interner, rustc_type_ir::ConstKind::Param(param))
+ Const::new(interner, ConstKind::Param(param))
}
pub fn new_placeholder(interner: DbInterner<'db>, placeholder: PlaceholderConst) -> Self {
@@ -63,7 +62,7 @@ impl<'db> Const<'db> {
}
pub fn new_bound(interner: DbInterner<'db>, index: DebruijnIndex, bound: BoundConst) -> Self {
- Const::new(interner, ConstKind::Bound(index, bound))
+ Const::new(interner, ConstKind::Bound(BoundVarIndexKind::Bound(index), bound))
}
pub fn new_valtree(
@@ -82,7 +81,11 @@ impl<'db> Const<'db> {
}
pub fn is_ct_infer(&self) -> bool {
- matches!(&self.inner().internee, ConstKind::Infer(_))
+ matches!(self.kind(), ConstKind::Infer(_))
+ }
+
+ pub fn is_error(&self) -> bool {
+ matches!(self.kind(), ConstKind::Error(_))
}
pub fn is_trivially_wf(self) -> bool {
@@ -338,28 +341,34 @@ impl<'db> Flags for Const<'db> {
}
impl<'db> rustc_type_ir::inherent::Const<DbInterner<'db>> for Const<'db> {
- fn new_infer(interner: DbInterner<'db>, var: rustc_type_ir::InferConst) -> Self {
+ fn new_infer(interner: DbInterner<'db>, var: InferConst) -> Self {
Const::new(interner, ConstKind::Infer(var))
}
- fn new_var(interner: DbInterner<'db>, var: rustc_type_ir::ConstVid) -> Self {
- Const::new(interner, ConstKind::Infer(rustc_type_ir::InferConst::Var(var)))
+ fn new_var(interner: DbInterner<'db>, var: ConstVid) -> Self {
+ Const::new(interner, ConstKind::Infer(InferConst::Var(var)))
}
- fn new_bound(
- interner: DbInterner<'db>,
- debruijn: rustc_type_ir::DebruijnIndex,
- var: BoundConst,
- ) -> Self {
- Const::new(interner, ConstKind::Bound(debruijn, var))
+ fn new_bound(interner: DbInterner<'db>, debruijn: DebruijnIndex, var: BoundConst) -> Self {
+ Const::new(interner, ConstKind::Bound(BoundVarIndexKind::Bound(debruijn), var))
+ }
+
+ fn new_anon_bound(interner: DbInterner<'db>, debruijn: DebruijnIndex, var: BoundVar) -> Self {
+ Const::new(
+ interner,
+ ConstKind::Bound(BoundVarIndexKind::Bound(debruijn), BoundConst { var }),
+ )
+ }
+
+ fn new_canonical_bound(interner: DbInterner<'db>, var: BoundVar) -> Self {
+ Const::new(interner, ConstKind::Bound(BoundVarIndexKind::Canonical, BoundConst { var }))
}
- fn new_anon_bound(
+ fn new_placeholder(
interner: DbInterner<'db>,
- debruijn: rustc_type_ir::DebruijnIndex,
- var: rustc_type_ir::BoundVar,
+ param: <DbInterner<'db> as rustc_type_ir::Interner>::PlaceholderConst,
) -> Self {
- Const::new(interner, ConstKind::Bound(debruijn, BoundConst { var }))
+ Const::new(interner, ConstKind::Placeholder(param))
}
fn new_unevaluated(
@@ -376,13 +385,6 @@ impl<'db> rustc_type_ir::inherent::Const<DbInterner<'db>> for Const<'db> {
fn new_error(interner: DbInterner<'db>, guar: ErrorGuaranteed) -> Self {
Const::new(interner, ConstKind::Error(guar))
}
-
- fn new_placeholder(
- interner: DbInterner<'db>,
- param: <DbInterner<'db> as rustc_type_ir::Interner>::PlaceholderConst,
- ) -> Self {
- Const::new(interner, ConstKind::Placeholder(param))
- }
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
@@ -425,7 +427,7 @@ impl<'db> PlaceholderLike<DbInterner<'db>> for PlaceholderConst {
impl<'db> Relate<DbInterner<'db>> for ExprConst {
fn relate<R: rustc_type_ir::relate::TypeRelation<DbInterner<'db>>>(
- relation: &mut R,
+ _relation: &mut R,
a: Self,
b: Self,
) -> rustc_type_ir::relate::RelateResult<DbInterner<'db>, Self> {