diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-04-26 03:50:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-26 03:50:25 +0200 |
| commit | 66645340edcb706453c8647f4c42063f73e7e9ed (patch) | |
| tree | 3847b4a4020990dd4229f50d0f304e2107fa7370 | |
| parent | 3a907cee97e9e2b7bc7f5947028e05b3133123ad (diff) | |
| parent | 6b190d6de5e34bcb3e66d088dd0503c6810d357b (diff) | |
| download | rust-66645340edcb706453c8647f4c42063f73e7e9ed.tar.gz rust-66645340edcb706453c8647f4c42063f73e7e9ed.zip | |
Rollup merge of #60285 - estebank:icent, r=varkor
Do not ICE when checking types against foreign fn Fix #60275.
| -rw-r--r-- | src/librustc_typeck/check/op.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 78ce0bf9cc1..d1ca0578093 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -443,13 +443,16 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ) -> bool /* did we suggest to call a function because of missing parenthesis? */ { err.span_label(span, ty.to_string()); if let FnDef(def_id, _) = ty.sty { + let source_map = self.tcx.sess.source_map(); + let hir_id = match self.tcx.hir().as_local_hir_id(def_id) { + Some(hir_id) => hir_id, + None => return false, + }; if self.tcx.has_typeck_tables(def_id) == false { return false; } - let source_map = self.tcx.sess.source_map(); - let hir_id = &self.tcx.hir().as_local_hir_id(def_id).unwrap(); let fn_sig = { - match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(*hir_id) { + match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(hir_id) { Some(f) => f.clone(), None => { bug!("No fn-sig entry for def_id={:?}", def_id); @@ -458,11 +461,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; let other_ty = if let FnDef(def_id, _) = other_ty.sty { + let hir_id = match self.tcx.hir().as_local_hir_id(def_id) { + Some(hir_id) => hir_id, + None => return false, + }; if self.tcx.has_typeck_tables(def_id) == false { return false; } - let hir_id = &self.tcx.hir().as_local_hir_id(def_id).unwrap(); - match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(*hir_id) { + match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(hir_id) { Some(f) => f.clone().output(), None => { bug!("No fn-sig entry for def_id={:?}", def_id); |
