use std::rc::Rc;
use syntax::ast::{self, NodeId};
use syntax::ptr::P;
-use syntax::symbol::keywords;
+use syntax::symbol::{kw, sym};
use syntax_pos::Span;
use crate::hir;
if let FnKind::Method(..) = fk {
let parent = ir.tcx.hir().get_parent_item(id);
if let Some(Node::Item(i)) = ir.tcx.hir().find_by_hir_id(parent) {
- if i.attrs.iter().any(|a| a.check_name("automatically_derived")) {
+ if i.attrs.iter().any(|a| a.check_name(sym::automatically_derived)) {
return;
}
}
let closure_def_id = ir.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
if let Some(upvars) = ir.tcx.upvars(closure_def_id) {
call_caps.extend(upvars.iter().filter_map(|upvar| {
- if let Res::Local(rv) = upvar.res {
+ if upvar.parent.is_none() {
let upvar_ln = ir.add_live_node(UpvarNode(upvar.span));
- Some(CaptureInfo { ln: upvar_ln, var_hid: rv })
+ Some(CaptureInfo { ln: upvar_ln, var_hid: upvar.var_id })
} else {
None
}
}
// live nodes required for interesting control flow:
- hir::ExprKind::If(..) |
hir::ExprKind::Match(..) |
hir::ExprKind::While(..) |
hir::ExprKind::Loop(..) => {
})
}
- hir::ExprKind::If(ref cond, ref then, ref els) => {
- //
- // (cond)
- // |
- // v
- // (expr)
- // / \
- // | |
- // v v
- // (then)(els)
- // | |
- // v v
- // ( succ )
- //
- let else_ln = self.propagate_through_opt_expr(els.as_ref().map(|e| &**e), succ);
- let then_ln = self.propagate_through_expr(&then, succ);
- let ln = self.live_node(expr.hir_id, expr.span);
- self.init_from_succ(ln, else_ln);
- self.merge_from_succ(ln, then_ln, false);
- self.propagate_through_expr(&cond, ln)
- }
-
hir::ExprKind::While(ref cond, ref blk, _) => {
self.propagate_through_loop(expr, WhileLoop(&cond), &blk, succ)
}
}
// no correctness conditions related to liveness
- hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) | hir::ExprKind::If(..) |
+ hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) |
hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) |
hir::ExprKind::Index(..) | hir::ExprKind::Field(..) |
hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) |
let sp = ident.span;
let var = self.variable(hir_id, sp);
// Ignore unused self.
- if ident.name != keywords::SelfLower.name() {
+ if ident.name != kw::SelfLower {
if !self.warn_about_unused(vec![sp], hir_id, entry_ln, var) {
if self.live_on_entry(entry_ln, var).is_none() {
self.report_dead_assign(hir_id, sp, var, true);