Skip to content

Commit a8558e9

Browse files
committed
Exit early if expected type is not an adt
1 parent 156c922 commit a8558e9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
364364
return false;
365365
}
366366
let pin_did = self.tcx.lang_items().pin_type();
367+
// This guards the `unwrap` and `mk_box` below.
368+
if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() {
369+
return false;
370+
}
367371
match expected.kind() {
368-
ty::Adt(def, _) if Some(def.did) != pin_did => return false,
369-
// This guards the `unwrap` and `mk_box` below.
370-
_ if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() => return false,
371-
_ => {}
372+
ty::Adt(def, _) if Some(def.did) == pin_did => (),
373+
_ => return false,
372374
}
373375
let box_found = self.tcx.mk_box(found);
374376
let pin_box_found = self.tcx.mk_lang_item(box_found, LangItem::Pin).unwrap();

0 commit comments

Comments
 (0)