Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not ICE when checking types against foreign fn #60285

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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