diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2021-09-30 03:33:12 +0000 |
|---|---|---|
| committer | Tyler Mandry <tmandry@gmail.com> | 2021-10-13 23:26:01 +0000 |
| commit | a8558e9efabc6640e8c1b1c353e62c233624f616 (patch) | |
| tree | b30059d5af55d00bee8162b0a4d703aaa01a87de | |
| parent | 156c9222f52acb1a842ffc2d6e814fca8937cbf0 (diff) | |
| download | rust-a8558e9efabc6640e8c1b1c353e62c233624f616.tar.gz rust-a8558e9efabc6640e8c1b1c353e62c233624f616.zip | |
Exit early if expected type is not an adt
| -rw-r--r-- | compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs index 7fe841c3815..339c46616a5 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs @@ -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(); |
