Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/lib.rs')
-rw-r--r--crates/hir-ty/src/lib.rs53
1 files changed, 23 insertions, 30 deletions
diff --git a/crates/hir-ty/src/lib.rs b/crates/hir-ty/src/lib.rs
index e6b8329ca8..d004b5e3ef 100644
--- a/crates/hir-ty/src/lib.rs
+++ b/crates/hir-ty/src/lib.rs
@@ -62,7 +62,7 @@ use std::{hash::Hash, ops::ControlFlow};
use hir_def::{
CallableDefId, ExpressionStoreOwnerId, GenericDefId, TypeAliasId, TypeOrConstParamId,
- TypeParamId, hir::generics::GenericParams, resolver::TypeNs, type_ref::Rawness,
+ TypeParamId, resolver::TypeNs, type_ref::Rawness,
};
use hir_expand::name::Name;
use indexmap::{IndexMap, map::Entry};
@@ -84,7 +84,7 @@ use crate::{
lower::SupertraitsInfo,
next_solver::{
AliasTy, Binder, BoundConst, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, Canonical,
- CanonicalVarKind, CanonicalVars, ClauseKind, Const, ConstKind, DbInterner, FnSig,
+ CanonicalVarKind, CanonicalVarKinds, ClauseKind, Const, ConstKind, DbInterner, FnSig,
GenericArgs, PolyFnSig, Predicate, Region, RegionKind, TraitRef, Ty, TyKind, Tys, abi,
},
};
@@ -92,10 +92,8 @@ use crate::{
pub use autoderef::autoderef;
pub use infer::{
Adjust, Adjustment, AutoBorrow, BindingMode, InferenceDiagnostic, InferenceResult,
- InferenceTyDiagnosticSource, OverloadedDeref, PointerCast,
- cast::CastError,
- closure::analysis::{CaptureKind, CapturedItem},
- could_coerce, could_unify, could_unify_deeply, infer_query_with_inspect,
+ InferenceTyDiagnosticSource, OverloadedDeref, PointerCast, cast::CastError, could_coerce,
+ could_unify, could_unify_deeply, infer_query_with_inspect,
};
pub use lower::{
GenericPredicates, ImplTraits, LifetimeElisionKind, TyDefId, TyLoweringContext, ValueTyDefId,
@@ -109,6 +107,16 @@ pub use utils::{
is_fn_unsafe_to_call, target_feature_is_safe_in_target,
};
+pub mod closure_analysis {
+ pub use crate::infer::{
+ CaptureInfo, CaptureSourceStack, CapturedPlace, ClosureData, UpvarCapture,
+ closure::analysis::{
+ BorrowKind,
+ expr_use_visitor::{FakeReadCause, Place, PlaceBase, Projection, ProjectionKind},
+ },
+ };
+}
+
/// A constant can have reference to other things. Memory map job is holding
/// the necessary bits of memory of the const eval session to keep the constant
/// meaningful.
@@ -197,7 +205,7 @@ pub fn param_idx(db: &dyn HirDatabase, id: TypeOrConstParamId) -> Option<usize>
generics::generics(db, id.parent).type_or_const_param_idx(id)
}
-#[derive(Debug, Copy, Clone, Eq)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum FnAbi {
Aapcs,
AapcsUnwind,
@@ -239,21 +247,6 @@ pub enum FnAbi {
Unknown,
}
-impl PartialEq for FnAbi {
- fn eq(&self, _other: &Self) -> bool {
- // FIXME: Proper equality breaks `coercion::two_closures_lub` test
- true
- }
-}
-
-impl Hash for FnAbi {
- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
- // Required because of the FIXME above and due to us implementing `Eq`, without this
- // we would break the `Hash` + `Eq` contract
- core::mem::discriminant(&Self::Unknown).hash(state);
- }
-}
-
impl FnAbi {
#[rustfmt::skip]
pub fn from_symbol(s: &Symbol) -> FnAbi {
@@ -435,7 +428,7 @@ where
ConstKind::Error(_) => {
let var = rustc_type_ir::BoundVar::from_usize(self.vars.len());
self.vars.push(CanonicalVarKind::Const(rustc_type_ir::UniverseIndex::ZERO));
- Ok(Const::new_bound(self.interner, self.binder, BoundConst { var }))
+ Ok(Const::new_bound(self.interner, self.binder, BoundConst::new(var)))
}
ConstKind::Infer(_) => error(),
ConstKind::Bound(BoundVarIndexKind::Bound(index), _) if index > self.binder => {
@@ -479,7 +472,7 @@ where
Canonical {
value,
max_universe: rustc_type_ir::UniverseIndex::ZERO,
- variables: CanonicalVars::new_from_slice(&error_replacer.vars),
+ var_kinds: CanonicalVarKinds::new_from_slice(&error_replacer.vars),
}
}
@@ -495,10 +488,7 @@ pub fn associated_type_shorthand_candidates(
TypeNs::GenericParam(param) => (def, param),
TypeNs::SelfType(impl_) => {
let impl_trait = db.impl_trait(impl_)?.skip_binder().def_id.0;
- let param = TypeParamId::from_unchecked(TypeOrConstParamId {
- parent: impl_trait.into(),
- local_id: GenericParams::SELF_PARAM_ID_IN_SELF,
- });
+ let param = TypeParamId::trait_self(impl_trait);
(impl_trait.into(), param)
}
_ => return None,
@@ -554,8 +544,11 @@ pub fn callable_sig_from_fn_trait<'db>(
let trait_ref = TraitRef::new_from_args(table.interner(), fn_once_trait.into(), args);
let projection = Ty::new_alias(
table.interner(),
- rustc_type_ir::AliasTyKind::Projection,
- AliasTy::new_from_args(table.interner(), output_assoc_type.into(), args),
+ AliasTy::new_from_args(
+ table.interner(),
+ rustc_type_ir::Projection { def_id: output_assoc_type.into() },
+ args,
+ ),
);
let pred = Predicate::upcast_from(trait_ref, table.interner());