Skip to content

Commit 8f6bb85

Browse files
committed
rustc_mir: fix compilation
1 parent 8e75473 commit 8f6bb85

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/librustc_mir/hair/cx/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
736736
let body_id = match cx.tcx.map.find(closure_expr_id) {
737737
Some(map::NodeExpr(expr)) => {
738738
match expr.node {
739-
hir::ExprClosure(.., ref body, _) => body.id,
739+
hir::ExprClosure(.., body_id, _) => body_id.node_id(),
740740
_ => {
741741
span_bug!(expr.span, "closure expr is not a closure expr");
742742
}

src/librustc_mir/mir_map.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc::traits::Reveal;
3030
use rustc::ty::{self, Ty, TyCtxt};
3131
use rustc::ty::subst::Substs;
3232
use rustc::hir;
33-
use rustc::hir::intravisit::{self, FnKind, Visitor};
33+
use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitMode};
3434
use syntax::abi::Abi;
3535
use syntax::ast;
3636
use syntax_pos::Span;
@@ -144,6 +144,10 @@ impl<'a, 'gcx> BuildMir<'a, 'gcx> {
144144
}
145145

146146
impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
147+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
148+
Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
149+
}
150+
147151
// Const and static items.
148152
fn visit_item(&mut self, item: &'tcx hir::Item) {
149153
match item.node {
@@ -210,7 +214,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
210214
fn visit_fn(&mut self,
211215
fk: FnKind<'tcx>,
212216
decl: &'tcx hir::FnDecl,
213-
body: &'tcx hir::Expr,
217+
body_id: hir::ExprId,
214218
span: Span,
215219
id: ast::NodeId) {
216220
// fetch the fully liberated fn signature (that is, all bound
@@ -223,7 +227,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
223227
};
224228

225229
let (abi, implicit_argument) = if let FnKind::Closure(..) = fk {
226-
(Abi::Rust, Some((closure_self_ty(self.tcx, id, body.id), None)))
230+
(Abi::Rust, Some((closure_self_ty(self.tcx, id, body_id.node_id()), None)))
227231
} else {
228232
let def_id = self.tcx.map.local_def_id(id);
229233
(self.tcx.item_type(def_id).fn_abi(), None)
@@ -237,12 +241,14 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
237241
(fn_sig.inputs[index], Some(&*arg.pat))
238242
});
239243

244+
let body = self.tcx.map.expr(body_id);
245+
240246
let arguments = implicit_argument.into_iter().chain(explicit_arguments);
241247
self.cx(MirSource::Fn(id)).build(|cx| {
242248
build::construct_fn(cx, id, arguments, abi, fn_sig.output, body)
243249
});
244250

245-
intravisit::walk_fn(self, fk, decl, body, span, id);
251+
intravisit::walk_fn(self, fk, decl, body_id, span, id);
246252
}
247253
}
248254

0 commit comments

Comments
 (0)