use syntax::ast;
use syntax::codemap::Span;
use rustc_front::hir;
-use rustc_front::visit;
-use rustc_front::visit::{FnKind, Visitor};
+use rustc_front::intravisit;
+use rustc_front::intravisit::{FnKind, Visitor};
#[derive(Copy, Clone)]
struct UnsafeContext {
self.unsafe_context = UnsafeContext::new(SafeContext)
}
- visit::walk_fn(self, fn_kind, fn_decl, block, span);
+ intravisit::walk_fn(self, fn_kind, fn_decl, block, span);
self.unsafe_context = old_unsafe_context
}
fn visit_block(&mut self, block: &hir::Block) {
let old_unsafe_context = self.unsafe_context;
match block.rules {
- hir::DefaultBlock => {}
hir::UnsafeBlock(source) => {
// By default only the outermost `unsafe` block is
// "used" and so nested unsafe blocks are pointless
self.unsafe_context.push_unsafe_count =
self.unsafe_context.push_unsafe_count.checked_sub(1).unwrap();
}
+ hir::DefaultBlock | hir::PushUnstableBlock | hir:: PopUnstableBlock => {}
}
- visit::walk_block(self, block);
+ intravisit::walk_block(self, block);
self.unsafe_context = old_unsafe_context
}
}
}
hir::ExprCall(ref base, _) => {
- let base_type = self.tcx.node_id_to_type(base.id);
+ let base_type = self.tcx.expr_ty_adjusted(base);
debug!("effect: call case, base type is {:?}",
base_type);
if type_is_unsafe_function(base_type) {
}
}
hir::ExprUnary(hir::UnDeref, ref base) => {
- let base_type = self.tcx.node_id_to_type(base.id);
+ let base_type = self.tcx.expr_ty_adjusted(base);
debug!("effect: unary case, base type is {:?}",
base_type);
if let ty::TyRawPtr(_) = base_type.sty {
_ => {}
}
- visit::walk_expr(self, expr);
+ intravisit::walk_expr(self, expr);
}
}
unsafe_context: UnsafeContext::new(SafeContext),
};
- visit::walk_crate(&mut visitor, tcx.map.krate());
+ tcx.map.krate().visit_all_items(&mut visitor);
}