Skip to content

Commit

Permalink
Exit early if expected type is not an adt
Browse files Browse the repository at this point in the history
  • Loading branch information
tmandry committed Oct 13, 2021
1 parent 156c922 commit a8558e9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return false;
}
let pin_did = self.tcx.lang_items().pin_type();
// This guards the `unwrap` and `mk_box` below.
if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() {
return false;
}
match expected.kind() {
ty::Adt(def, _) if Some(def.did) != pin_did => return false,
// This guards the `unwrap` and `mk_box` below.
_ if pin_did.is_none() || self.tcx.lang_items().owned_box().is_none() => return false,
_ => {}
ty::Adt(def, _) if Some(def.did) == pin_did => (),
_ => return false,
}
let box_found = self.tcx.mk_box(found);
let pin_box_found = self.tcx.mk_lang_item(box_found, LangItem::Pin).unwrap();
Expand Down

0 comments on commit a8558e9

Please sign in to comment.