Unnamed repository; edit this file 'description' to name the repository.
Apply reviewed suggestions
Shoyu Vanilla 2024-03-18
parent fc53c59 · commit d034ab0
-rw-r--r--crates/hir-ty/src/infer/coerce.rs6
-rw-r--r--crates/hir-ty/src/lower.rs12
2 files changed, 7 insertions, 11 deletions
diff --git a/crates/hir-ty/src/infer/coerce.rs b/crates/hir-ty/src/infer/coerce.rs
index fba37dbcff..cfbbc9dd6c 100644
--- a/crates/hir-ty/src/infer/coerce.rs
+++ b/crates/hir-ty/src/infer/coerce.rs
@@ -278,7 +278,7 @@ impl InferenceTable<'_> {
// If we are coercing into an ATPIT, coerce into its proxy inference var, instead.
let mut to_ty = to_ty;
- let mut _to = None;
+ let _to;
if let Some(atpit_table) = &self.atpit_coercion_table {
if let TyKind::OpaqueType(opaque_ty_id, _) = to_ty.kind(Interner) {
if !matches!(
@@ -286,8 +286,8 @@ impl InferenceTable<'_> {
TyKind::InferenceVar(..) | TyKind::OpaqueType(..)
) {
if let Some(ty) = atpit_table.get(opaque_ty_id) {
- _to = Some(ty.clone());
- to_ty = _to.as_ref().unwrap();
+ _to = ty.clone();
+ to_ty = &_to;
}
}
}
diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs
index d65fd4a71c..bcc4784eae 100644
--- a/crates/hir-ty/src/lower.rs
+++ b/crates/hir-ty/src/lower.rs
@@ -301,13 +301,9 @@ impl<'a> TyLoweringContext<'a> {
TypeRef::ImplTrait(bounds) => {
match &self.impl_trait_mode {
ImplTraitLoweringState::Opaque(opaque_type_data) => {
- let (origin, krate) = match self.resolver.generic_def() {
- Some(GenericDefId::FunctionId(f)) => {
- (Either::Left(f), f.krate(self.db.upcast()))
- }
- Some(GenericDefId::TypeAliasId(a)) => {
- (Either::Right(a), a.krate(self.db.upcast()))
- }
+ let origin = match self.resolver.generic_def() {
+ Some(GenericDefId::FunctionId(it)) => Either::Left(it),
+ Some(GenericDefId::TypeAliasId(it)) => Either::Right(it),
_ => panic!(
"opaque impl trait lowering must be in function or type alias"
),
@@ -330,7 +326,7 @@ impl<'a> TyLoweringContext<'a> {
// away instead of two.
let actual_opaque_type_data = self
.with_debruijn(DebruijnIndex::INNERMOST, |ctx| {
- ctx.lower_impl_trait(bounds, krate)
+ ctx.lower_impl_trait(bounds, self.resolver.krate())
});
opaque_type_data.borrow_mut()[idx] = actual_opaque_type_data;