Skip to content

Commit 8e75473

Browse files
committed
rustc_const_eval: fix compilation
1 parent f55482e commit 8e75473

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/librustc_const_eval/check_match.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc::ty::{self, TyCtxt};
2929
use rustc_errors::DiagnosticBuilder;
3030

3131
use rustc::hir::def::*;
32-
use rustc::hir::intravisit::{self, Visitor, FnKind};
32+
use rustc::hir::intravisit::{self, Visitor, FnKind, NestedVisitMode};
3333
use rustc::hir::print::pat_to_string;
3434
use rustc::hir::{self, Pat, PatKind};
3535

@@ -41,29 +41,29 @@ use syntax_pos::Span;
4141

4242
struct OuterVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> }
4343

44-
impl<'a, 'v, 'tcx> Visitor<'v> for OuterVisitor<'a, 'tcx> {
45-
fn visit_expr(&mut self, _expr: &hir::Expr) {
44+
impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
45+
fn visit_expr(&mut self, _expr: &'tcx hir::Expr) {
4646
return // const, static and N in [T; N] - shouldn't contain anything
4747
}
4848

49-
fn visit_trait_item(&mut self, item: &hir::TraitItem) {
49+
fn visit_trait_item(&mut self, item: &'tcx hir::TraitItem) {
5050
if let hir::ConstTraitItem(..) = item.node {
5151
return // nothing worth match checking in a constant
5252
} else {
5353
intravisit::walk_trait_item(self, item);
5454
}
5555
}
5656

57-
fn visit_impl_item(&mut self, item: &hir::ImplItem) {
57+
fn visit_impl_item(&mut self, item: &'tcx hir::ImplItem) {
5858
if let hir::ImplItemKind::Const(..) = item.node {
5959
return // nothing worth match checking in a constant
6060
} else {
6161
intravisit::walk_impl_item(self, item);
6262
}
6363
}
6464

65-
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v hir::FnDecl,
66-
b: &'v hir::Expr, s: Span, id: ast::NodeId) {
65+
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
66+
b: hir::ExprId, s: Span, id: ast::NodeId) {
6767
if let FnKind::Closure(..) = fk {
6868
span_bug!(s, "check_match: closure outside of function")
6969
}
@@ -90,8 +90,12 @@ struct MatchVisitor<'a, 'tcx: 'a> {
9090
param_env: &'a ty::ParameterEnvironment<'tcx>
9191
}
9292

93-
impl<'a, 'tcx, 'v> Visitor<'v> for MatchVisitor<'a, 'tcx> {
94-
fn visit_expr(&mut self, ex: &hir::Expr) {
93+
impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> {
94+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
95+
Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
96+
}
97+
98+
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
9599
intravisit::walk_expr(self, ex);
96100

97101
match ex.node {
@@ -102,7 +106,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchVisitor<'a, 'tcx> {
102106
}
103107
}
104108

105-
fn visit_local(&mut self, loc: &hir::Local) {
109+
fn visit_local(&mut self, loc: &'tcx hir::Local) {
106110
intravisit::walk_local(self, loc);
107111

108112
self.check_irrefutable(&loc.pat, false);
@@ -111,8 +115,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchVisitor<'a, 'tcx> {
111115
self.check_patterns(false, slice::ref_slice(&loc.pat));
112116
}
113117

114-
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v hir::FnDecl,
115-
b: &'v hir::Expr, s: Span, n: ast::NodeId) {
118+
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
119+
b: hir::ExprId, s: Span, n: ast::NodeId) {
116120
intravisit::walk_fn(self, fk, fd, b, s, n);
117121

118122
for input in &fd.inputs {

src/librustc_const_eval/eval.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,11 +868,12 @@ pub fn eval_const_expr_partial<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
868868
Struct(_) => signal!(e, UnimplementedConstVal("tuple struct constructors")),
869869
callee => signal!(e, CallOn(callee)),
870870
};
871-
let (decl, result) = if let Some(fn_like) = lookup_const_fn_by_id(tcx, did) {
871+
let (decl, body_id) = if let Some(fn_like) = lookup_const_fn_by_id(tcx, did) {
872872
(fn_like.decl(), fn_like.body())
873873
} else {
874874
signal!(e, NonConstPath)
875875
};
876+
let result = tcx.map.expr(body_id);
876877
assert_eq!(decl.inputs.len(), args.len());
877878

878879
let mut call_args = DefIdMap();

0 commit comments

Comments
 (0)