check that def_id is a local closure in InferCtxt::fn_sig
Before we were assuming that *every* `fn_sig` must pertain to a local closure.
This commit is contained in:
parent
b9c766ccc0
commit
00732a31a0
1 changed files with 21 additions and 12 deletions
|
@ -1481,9 +1481,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
/// work during the type-checking of the enclosing function and
|
||||
/// return the closure signature in its partially inferred state.
|
||||
pub fn fn_sig(&self, def_id: DefId) -> ty::PolyFnSig<'tcx> {
|
||||
// Do we have an in-progress set of tables we are inferring?
|
||||
if let Some(tables) = self.in_progress_tables {
|
||||
// Is this a local item?
|
||||
if let Some(id) = self.tcx.hir.as_local_node_id(def_id) {
|
||||
// Is it a local *closure*?
|
||||
if self.tcx.is_closure(def_id) {
|
||||
let hir_id = self.tcx.hir.node_to_hir_id(id);
|
||||
// Is this local closure contained within the tables we are inferring?
|
||||
if tables.borrow().local_id_root == Some(DefId::local(hir_id.owner)) {
|
||||
// if so, extract signature from there.
|
||||
let closure_ty = tables.borrow().node_id_to_type(hir_id);
|
||||
let (closure_def_id, closure_substs) = match closure_ty.sty {
|
||||
ty::TyClosure(closure_def_id, closure_substs) =>
|
||||
|
@ -1497,6 +1504,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
return closure_sig_ty.fn_sig(self.tcx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.tcx.fn_sig(def_id)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue