/// shorthand.
///
/// **Example:**
- /// ```rust
+ /// ```rust,no_run
+ /// # fn b() -> bool { true }
+ /// # fn c() -> bool { true }
/// let a = b() || panic!() || c();
/// // `c()` is dead, `panic!()` is only called if `b()` returns `false`
/// let x = (a, b, c, panic!());
if let ExprKind::Path(ref qpath) = lhs.node {
if let QPath::Resolved(_, ref path) = *qpath {
if path.segments.len() == 1 {
- if let def::Def::Local(var) = cx.tables.qpath_def(qpath, lhs.hir_id) {
+ if let def::Res::Local(var) = cx.tables.qpath_res(qpath, lhs.hir_id) {
let mut visitor = ReadVisitor {
cx,
var,
}
}
-struct DivergenceVisitor<'a, 'tcx: 'a> {
+struct DivergenceVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
}
let map = &vis.cx.tcx.hir();
let mut cur_id = vis.write_expr.hir_id;
loop {
- let parent_id = map.get_parent_node_by_hir_id(cur_id);
+ let parent_id = map.get_parent_node(cur_id);
if parent_id == cur_id {
break;
}
- let parent_node = match map.find_by_hir_id(parent_id) {
+ let parent_node = match map.find(parent_id) {
Some(parent) => parent,
None => break,
};
}
/// A visitor that looks for reads from a variable.
-struct ReadVisitor<'a, 'tcx: 'a> {
+struct ReadVisitor<'a, 'tcx> {
cx: &'a LateContext<'a, 'tcx>,
/// The ID of the variable we're looking for.
var: HirId,
if_chain! {
if let QPath::Resolved(None, ref path) = *qpath;
if path.segments.len() == 1;
- if let def::Def::Local(local_id) = self.cx.tables.qpath_def(qpath, expr.hir_id);
+ if let def::Res::Local(local_id) = self.cx.tables.qpath_res(qpath, expr.hir_id);
if local_id == self.var;
// Check that this is a read, not a write.
if !is_in_assignment_position(self.cx, expr);