Skip to content

Commit d034ab0

Browse files
committed
Apply reviewed suggestions
1 parent fc53c59 commit d034ab0

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

crates/hir-ty/src/infer/coerce.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,16 @@ impl InferenceTable<'_> {
278278

279279
// If we are coercing into an ATPIT, coerce into its proxy inference var, instead.
280280
let mut to_ty = to_ty;
281-
let mut _to = None;
281+
let _to;
282282
if let Some(atpit_table) = &self.atpit_coercion_table {
283283
if let TyKind::OpaqueType(opaque_ty_id, _) = to_ty.kind(Interner) {
284284
if !matches!(
285285
from_ty.kind(Interner),
286286
TyKind::InferenceVar(..) | TyKind::OpaqueType(..)
287287
) {
288288
if let Some(ty) = atpit_table.get(opaque_ty_id) {
289-
_to = Some(ty.clone());
290-
to_ty = _to.as_ref().unwrap();
289+
_to = ty.clone();
290+
to_ty = &_to;
291291
}
292292
}
293293
}

crates/hir-ty/src/lower.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,9 @@ impl<'a> TyLoweringContext<'a> {
301301
TypeRef::ImplTrait(bounds) => {
302302
match &self.impl_trait_mode {
303303
ImplTraitLoweringState::Opaque(opaque_type_data) => {
304-
let (origin, krate) = match self.resolver.generic_def() {
305-
Some(GenericDefId::FunctionId(f)) => {
306-
(Either::Left(f), f.krate(self.db.upcast()))
307-
}
308-
Some(GenericDefId::TypeAliasId(a)) => {
309-
(Either::Right(a), a.krate(self.db.upcast()))
310-
}
304+
let origin = match self.resolver.generic_def() {
305+
Some(GenericDefId::FunctionId(it)) => Either::Left(it),
306+
Some(GenericDefId::TypeAliasId(it)) => Either::Right(it),
311307
_ => panic!(
312308
"opaque impl trait lowering must be in function or type alias"
313309
),
@@ -330,7 +326,7 @@ impl<'a> TyLoweringContext<'a> {
330326
// away instead of two.
331327
let actual_opaque_type_data = self
332328
.with_debruijn(DebruijnIndex::INNERMOST, |ctx| {
333-
ctx.lower_impl_trait(bounds, krate)
329+
ctx.lower_impl_trait(bounds, self.resolver.krate())
334330
});
335331
opaque_type_data.borrow_mut()[idx] = actual_opaque_type_data;
336332

0 commit comments

Comments
 (0)