Skip to content

Commit 0389cc6

Browse files
committed
rustc_passes: fix compilation
1 parent 37e7541 commit 0389cc6

File tree

5 files changed

+50
-32
lines changed

5 files changed

+50
-32
lines changed

src/librustc_passes/consts.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use rustc::lint::builtin::CONST_ERR;
4848
use rustc::hir::{self, PatKind};
4949
use syntax::ast;
5050
use syntax_pos::Span;
51-
use rustc::hir::intravisit::{self, FnKind, Visitor};
51+
use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitMode};
5252

5353
use std::collections::hash_map::Entry;
5454
use std::cmp::Ordering;
@@ -100,7 +100,7 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
100100
.enter(|infcx| f(&mut euv::ExprUseVisitor::new(self, &infcx)))
101101
}
102102

103-
fn global_expr(&mut self, mode: Mode, expr: &hir::Expr) -> ConstQualif {
103+
fn global_expr(&mut self, mode: Mode, expr: &'gcx hir::Expr) -> ConstQualif {
104104
assert!(mode != Mode::Var);
105105
match self.tcx.const_qualif_map.borrow_mut().entry(expr.id) {
106106
Entry::Occupied(entry) => return *entry.get(),
@@ -132,9 +132,9 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
132132
}
133133

134134
fn fn_like(&mut self,
135-
fk: FnKind,
136-
fd: &hir::FnDecl,
137-
b: &hir::Expr,
135+
fk: FnKind<'gcx>,
136+
fd: &'gcx hir::FnDecl,
137+
b: hir::ExprId,
138138
s: Span,
139139
fn_id: ast::NodeId)
140140
-> ConstQualif {
@@ -160,7 +160,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
160160
};
161161

162162
let qualif = self.with_mode(mode, |this| {
163-
this.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b));
163+
let body = this.tcx.map.expr(b);
164+
this.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, body));
164165
intravisit::walk_fn(this, fk, fd, b, s, fn_id);
165166
this.qualif
166167
});
@@ -213,8 +214,12 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
213214
}
214215
}
215216

216-
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
217-
fn visit_item(&mut self, i: &hir::Item) {
217+
impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
218+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
219+
Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
220+
}
221+
222+
fn visit_item(&mut self, i: &'tcx hir::Item) {
218223
debug!("visit_item(item={})", self.tcx.map.node_to_string(i.id));
219224
assert_eq!(self.mode, Mode::Var);
220225
match i.node {
@@ -240,7 +245,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
240245
}
241246
}
242247

243-
fn visit_trait_item(&mut self, t: &'v hir::TraitItem) {
248+
fn visit_trait_item(&mut self, t: &'tcx hir::TraitItem) {
244249
match t.node {
245250
hir::ConstTraitItem(_, ref default) => {
246251
if let Some(ref expr) = *default {
@@ -253,7 +258,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
253258
}
254259
}
255260

256-
fn visit_impl_item(&mut self, i: &'v hir::ImplItem) {
261+
fn visit_impl_item(&mut self, i: &'tcx hir::ImplItem) {
257262
match i.node {
258263
hir::ImplItemKind::Const(_, ref expr) => {
259264
self.global_expr(Mode::Const, &expr);
@@ -263,15 +268,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
263268
}
264269

265270
fn visit_fn(&mut self,
266-
fk: FnKind<'v>,
267-
fd: &'v hir::FnDecl,
268-
b: &'v hir::Expr,
271+
fk: FnKind<'tcx>,
272+
fd: &'tcx hir::FnDecl,
273+
b: hir::ExprId,
269274
s: Span,
270275
fn_id: ast::NodeId) {
271276
self.fn_like(fk, fd, b, s, fn_id);
272277
}
273278

274-
fn visit_pat(&mut self, p: &hir::Pat) {
279+
fn visit_pat(&mut self, p: &'tcx hir::Pat) {
275280
match p.node {
276281
PatKind::Lit(ref lit) => {
277282
self.global_expr(Mode::Const, &lit);
@@ -296,7 +301,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
296301
}
297302
}
298303

299-
fn visit_block(&mut self, block: &hir::Block) {
304+
fn visit_block(&mut self, block: &'tcx hir::Block) {
300305
// Check all statements in the block
301306
for stmt in &block.stmts {
302307
match stmt.node {
@@ -315,7 +320,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
315320
intravisit::walk_block(self, block);
316321
}
317322

318-
fn visit_expr(&mut self, ex: &hir::Expr) {
323+
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
319324
let mut outer = self.qualif;
320325
self.qualif = ConstQualif::empty();
321326

src/librustc_passes/hir_stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'k> StatCollector<'k> {
106106
}
107107

108108
impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
109-
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> {
109+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'v>, hir_visit::NestedVisitMode)> {
110110
panic!("visit_nested_xxx must be manually implemented in this visitor")
111111
}
112112

@@ -172,7 +172,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
172172
fn visit_fn(&mut self,
173173
fk: hir_visit::FnKind<'v>,
174174
fd: &'v hir::FnDecl,
175-
b: &'v hir::Expr,
175+
b: hir::ExprId,
176176
s: Span,
177177
id: NodeId) {
178178
self.record("FnDecl", Id::None, fd);

src/librustc_passes/loops.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc::session::Session;
1313

1414
use rustc::dep_graph::DepNode;
1515
use rustc::hir::map::Map;
16-
use rustc::hir::intravisit::{self, Visitor};
16+
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
1717
use rustc::hir;
1818
use syntax::ast;
1919
use syntax_pos::Span;
@@ -59,16 +59,20 @@ pub fn check_crate(sess: &Session, map: &Map) {
5959
}.as_deep_visitor());
6060
}
6161

62-
impl<'a, 'ast, 'v> Visitor<'v> for CheckLoopVisitor<'a, 'ast> {
63-
fn visit_item(&mut self, i: &hir::Item) {
62+
impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> {
63+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'ast>, NestedVisitMode)> {
64+
Some((&self.hir_map, NestedVisitMode::OnlyBodies))
65+
}
66+
67+
fn visit_item(&mut self, i: &'ast hir::Item) {
6468
self.with_context(Normal, |v| intravisit::walk_item(v, i));
6569
}
6670

67-
fn visit_impl_item(&mut self, i: &hir::ImplItem) {
71+
fn visit_impl_item(&mut self, i: &'ast hir::ImplItem) {
6872
self.with_context(Normal, |v| intravisit::walk_impl_item(v, i));
6973
}
7074

71-
fn visit_expr(&mut self, e: &hir::Expr) {
75+
fn visit_expr(&mut self, e: &'ast hir::Expr) {
7276
match e.node {
7377
hir::ExprWhile(ref e, ref b, _) => {
7478
self.with_context(Loop(LoopKind::WhileLoop), |v| {
@@ -79,8 +83,8 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckLoopVisitor<'a, 'ast> {
7983
hir::ExprLoop(ref b, _, source) => {
8084
self.with_context(Loop(LoopKind::Loop(source)), |v| v.visit_block(&b));
8185
}
82-
hir::ExprClosure(.., ref b, _) => {
83-
self.with_context(Closure, |v| v.visit_expr(&b));
86+
hir::ExprClosure(.., b, _) => {
87+
self.with_context(Closure, |v| v.visit_body(b));
8488
}
8589
hir::ExprBreak(label, ref opt_expr) => {
8690
if opt_expr.is_some() {

src/librustc_passes/rvalues.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::ty::{self, TyCtxt, ParameterEnvironment};
1818
use rustc::traits::Reveal;
1919

2020
use rustc::hir;
21-
use rustc::hir::intravisit::{self, Visitor};
21+
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
2222
use syntax::ast;
2323
use syntax_pos::Span;
2424

@@ -31,11 +31,15 @@ struct RvalueContext<'a, 'tcx: 'a> {
3131
tcx: TyCtxt<'a, 'tcx, 'tcx>,
3232
}
3333

34-
impl<'a, 'tcx, 'v> Visitor<'v> for RvalueContext<'a, 'tcx> {
34+
impl<'a, 'tcx> Visitor<'tcx> for RvalueContext<'a, 'tcx> {
35+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
36+
Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
37+
}
38+
3539
fn visit_fn(&mut self,
36-
fk: intravisit::FnKind<'v>,
37-
fd: &'v hir::FnDecl,
38-
b: &'v hir::Expr,
40+
fk: intravisit::FnKind<'tcx>,
41+
fd: &'tcx hir::FnDecl,
42+
b: hir::ExprId,
3943
s: Span,
4044
fn_id: ast::NodeId) {
4145
// FIXME (@jroesch) change this to be an inference context
@@ -46,8 +50,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for RvalueContext<'a, 'tcx> {
4650
tcx: infcx.tcx,
4751
param_env: &param_env
4852
};
53+
let body = infcx.tcx.map.expr(b);
4954
let mut euv = euv::ExprUseVisitor::new(&mut delegate, &infcx);
50-
euv.walk_fn(fd, b);
55+
euv.walk_fn(fd, body);
5156
});
5257
intravisit::walk_fn(self, fk, fd, b, s, fn_id)
5358
}

src/librustc_passes/static_recursion.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc::util::nodemap::NodeMap;
2020
use syntax::ast;
2121
use syntax::feature_gate::{GateIssue, emit_feature_err};
2222
use syntax_pos::Span;
23-
use rustc::hir::intravisit::{self, Visitor};
23+
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
2424
use rustc::hir;
2525

2626
use std::cell::RefCell;
@@ -200,6 +200,10 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
200200
}
201201

202202
impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
203+
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'ast>, NestedVisitMode)> {
204+
Some((&self.ast_map, NestedVisitMode::OnlyBodies))
205+
}
206+
203207
fn visit_item(&mut self, it: &'ast hir::Item) {
204208
self.with_item_id_pushed(it.id, |v| intravisit::walk_item(v, it), it.span);
205209
}

0 commit comments

Comments
 (0)