mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
rustc_passes: fix compilation
This commit is contained in:
parent
37e75411dd
commit
0389cc6bcd
@ -48,7 +48,7 @@ use rustc::lint::builtin::CONST_ERR;
|
||||
use rustc::hir::{self, PatKind};
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor};
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitMode};
|
||||
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::cmp::Ordering;
|
||||
@ -100,7 +100,7 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
|
||||
.enter(|infcx| f(&mut euv::ExprUseVisitor::new(self, &infcx)))
|
||||
}
|
||||
|
||||
fn global_expr(&mut self, mode: Mode, expr: &hir::Expr) -> ConstQualif {
|
||||
fn global_expr(&mut self, mode: Mode, expr: &'gcx hir::Expr) -> ConstQualif {
|
||||
assert!(mode != Mode::Var);
|
||||
match self.tcx.const_qualif_map.borrow_mut().entry(expr.id) {
|
||||
Entry::Occupied(entry) => return *entry.get(),
|
||||
@ -132,9 +132,9 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
|
||||
}
|
||||
|
||||
fn fn_like(&mut self,
|
||||
fk: FnKind,
|
||||
fd: &hir::FnDecl,
|
||||
b: &hir::Expr,
|
||||
fk: FnKind<'gcx>,
|
||||
fd: &'gcx hir::FnDecl,
|
||||
b: hir::ExprId,
|
||||
s: Span,
|
||||
fn_id: ast::NodeId)
|
||||
-> ConstQualif {
|
||||
@ -160,7 +160,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
|
||||
};
|
||||
|
||||
let qualif = self.with_mode(mode, |this| {
|
||||
this.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b));
|
||||
let body = this.tcx.map.expr(b);
|
||||
this.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, body));
|
||||
intravisit::walk_fn(this, fk, fd, b, s, fn_id);
|
||||
this.qualif
|
||||
});
|
||||
@ -213,8 +214,12 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
|
||||
Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
debug!("visit_item(item={})", self.tcx.map.node_to_string(i.id));
|
||||
assert_eq!(self.mode, Mode::Var);
|
||||
match i.node {
|
||||
@ -240,7 +245,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, t: &'v hir::TraitItem) {
|
||||
fn visit_trait_item(&mut self, t: &'tcx hir::TraitItem) {
|
||||
match t.node {
|
||||
hir::ConstTraitItem(_, ref default) => {
|
||||
if let Some(ref expr) = *default {
|
||||
@ -253,7 +258,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, i: &'v hir::ImplItem) {
|
||||
fn visit_impl_item(&mut self, i: &'tcx hir::ImplItem) {
|
||||
match i.node {
|
||||
hir::ImplItemKind::Const(_, ref expr) => {
|
||||
self.global_expr(Mode::Const, &expr);
|
||||
@ -263,15 +268,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
fk: FnKind<'v>,
|
||||
fd: &'v hir::FnDecl,
|
||||
b: &'v hir::Expr,
|
||||
fk: FnKind<'tcx>,
|
||||
fd: &'tcx hir::FnDecl,
|
||||
b: hir::ExprId,
|
||||
s: Span,
|
||||
fn_id: ast::NodeId) {
|
||||
self.fn_like(fk, fd, b, s, fn_id);
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, p: &hir::Pat) {
|
||||
fn visit_pat(&mut self, p: &'tcx hir::Pat) {
|
||||
match p.node {
|
||||
PatKind::Lit(ref lit) => {
|
||||
self.global_expr(Mode::Const, &lit);
|
||||
@ -296,7 +301,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_block(&mut self, block: &hir::Block) {
|
||||
fn visit_block(&mut self, block: &'tcx hir::Block) {
|
||||
// Check all statements in the block
|
||||
for stmt in &block.stmts {
|
||||
match stmt.node {
|
||||
@ -315,7 +320,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
intravisit::walk_block(self, block);
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &hir::Expr) {
|
||||
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
|
||||
let mut outer = self.qualif;
|
||||
self.qualif = ConstQualif::empty();
|
||||
|
||||
|
@ -106,7 +106,7 @@ impl<'k> StatCollector<'k> {
|
||||
}
|
||||
|
||||
impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> {
|
||||
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'v>, hir_visit::NestedVisitMode)> {
|
||||
panic!("visit_nested_xxx must be manually implemented in this visitor")
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
||||
fn visit_fn(&mut self,
|
||||
fk: hir_visit::FnKind<'v>,
|
||||
fd: &'v hir::FnDecl,
|
||||
b: &'v hir::Expr,
|
||||
b: hir::ExprId,
|
||||
s: Span,
|
||||
id: NodeId) {
|
||||
self.record("FnDecl", Id::None, fd);
|
||||
|
@ -13,7 +13,7 @@ use rustc::session::Session;
|
||||
|
||||
use rustc::dep_graph::DepNode;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
|
||||
use rustc::hir;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
@ -59,16 +59,20 @@ pub fn check_crate(sess: &Session, map: &Map) {
|
||||
}.as_deep_visitor());
|
||||
}
|
||||
|
||||
impl<'a, 'ast, 'v> Visitor<'v> for CheckLoopVisitor<'a, 'ast> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> {
|
||||
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'ast>, NestedVisitMode)> {
|
||||
Some((&self.hir_map, NestedVisitMode::OnlyBodies))
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'ast hir::Item) {
|
||||
self.with_context(Normal, |v| intravisit::walk_item(v, i));
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, i: &hir::ImplItem) {
|
||||
fn visit_impl_item(&mut self, i: &'ast hir::ImplItem) {
|
||||
self.with_context(Normal, |v| intravisit::walk_impl_item(v, i));
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &hir::Expr) {
|
||||
fn visit_expr(&mut self, e: &'ast hir::Expr) {
|
||||
match e.node {
|
||||
hir::ExprWhile(ref e, ref b, _) => {
|
||||
self.with_context(Loop(LoopKind::WhileLoop), |v| {
|
||||
@ -79,8 +83,8 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckLoopVisitor<'a, 'ast> {
|
||||
hir::ExprLoop(ref b, _, source) => {
|
||||
self.with_context(Loop(LoopKind::Loop(source)), |v| v.visit_block(&b));
|
||||
}
|
||||
hir::ExprClosure(.., ref b, _) => {
|
||||
self.with_context(Closure, |v| v.visit_expr(&b));
|
||||
hir::ExprClosure(.., b, _) => {
|
||||
self.with_context(Closure, |v| v.visit_body(b));
|
||||
}
|
||||
hir::ExprBreak(label, ref opt_expr) => {
|
||||
if opt_expr.is_some() {
|
||||
|
@ -18,7 +18,7 @@ use rustc::ty::{self, TyCtxt, ParameterEnvironment};
|
||||
use rustc::traits::Reveal;
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
|
||||
@ -31,11 +31,15 @@ struct RvalueContext<'a, 'tcx: 'a> {
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for RvalueContext<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
|
||||
Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
fk: intravisit::FnKind<'v>,
|
||||
fd: &'v hir::FnDecl,
|
||||
b: &'v hir::Expr,
|
||||
fk: intravisit::FnKind<'tcx>,
|
||||
fd: &'tcx hir::FnDecl,
|
||||
b: hir::ExprId,
|
||||
s: Span,
|
||||
fn_id: ast::NodeId) {
|
||||
// FIXME (@jroesch) change this to be an inference context
|
||||
@ -46,8 +50,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||
tcx: infcx.tcx,
|
||||
param_env: ¶m_env
|
||||
};
|
||||
let body = infcx.tcx.map.expr(b);
|
||||
let mut euv = euv::ExprUseVisitor::new(&mut delegate, &infcx);
|
||||
euv.walk_fn(fd, b);
|
||||
euv.walk_fn(fd, body);
|
||||
});
|
||||
intravisit::walk_fn(self, fk, fd, b, s, fn_id)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use rustc::util::nodemap::NodeMap;
|
||||
use syntax::ast;
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
|
||||
use rustc::hir;
|
||||
|
||||
use std::cell::RefCell;
|
||||
@ -200,6 +200,10 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
|
||||
}
|
||||
|
||||
impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
||||
fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'ast>, NestedVisitMode)> {
|
||||
Some((&self.ast_map, NestedVisitMode::OnlyBodies))
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, it: &'ast hir::Item) {
|
||||
self.with_item_id_pushed(it.id, |v| intravisit::walk_item(v, it), it.span);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user