rustc_mir: fix compilation
This commit is contained in:
parent
8e754736dc
commit
8f6bb85b98
2 changed files with 11 additions and 5 deletions
|
|
@ -736,7 +736,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
let body_id = match cx.tcx.map.find(closure_expr_id) {
|
||||
Some(map::NodeExpr(expr)) => {
|
||||
match expr.node {
|
||||
hir::ExprClosure(.., ref body, _) => body.id,
|
||||
hir::ExprClosure(.., body_id, _) => body_id.node_id(),
|
||||
_ => {
|
||||
span_bug!(expr.span, "closure expr is not a closure expr");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use rustc::traits::Reveal;
|
|||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor};
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitMode};
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
|
|
@ -144,6 +144,10 @@ impl<'a, 'gcx> BuildMir<'a, 'gcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
|
||||
Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
|
||||
}
|
||||
|
||||
// Const and static items.
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
|
|
@ -210,7 +214,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
|||
fn visit_fn(&mut self,
|
||||
fk: FnKind<'tcx>,
|
||||
decl: &'tcx hir::FnDecl,
|
||||
body: &'tcx hir::Expr,
|
||||
body_id: hir::ExprId,
|
||||
span: Span,
|
||||
id: ast::NodeId) {
|
||||
// fetch the fully liberated fn signature (that is, all bound
|
||||
|
|
@ -223,7 +227,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
|||
};
|
||||
|
||||
let (abi, implicit_argument) = if let FnKind::Closure(..) = fk {
|
||||
(Abi::Rust, Some((closure_self_ty(self.tcx, id, body.id), None)))
|
||||
(Abi::Rust, Some((closure_self_ty(self.tcx, id, body_id.node_id()), None)))
|
||||
} else {
|
||||
let def_id = self.tcx.map.local_def_id(id);
|
||||
(self.tcx.item_type(def_id).fn_abi(), None)
|
||||
|
|
@ -237,12 +241,14 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
|||
(fn_sig.inputs[index], Some(&*arg.pat))
|
||||
});
|
||||
|
||||
let body = self.tcx.map.expr(body_id);
|
||||
|
||||
let arguments = implicit_argument.into_iter().chain(explicit_arguments);
|
||||
self.cx(MirSource::Fn(id)).build(|cx| {
|
||||
build::construct_fn(cx, id, arguments, abi, fn_sig.output, body)
|
||||
});
|
||||
|
||||
intravisit::walk_fn(self, fk, decl, body, span, id);
|
||||
intravisit::walk_fn(self, fk, decl, body_id, span, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue