Skip to content

Commit

Permalink
Do not ICE when checking types against foreign fn
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Apr 25, 2019
1 parent e305df1 commit 6b190d6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/librustc_typeck/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 6b190d6

Please sign in to comment.