- match expr.kind {
- ExprKind::Path(ref qpath) => {
- if_chain! {
- if let QPath::Resolved(None, ref path) = *qpath;
- if path.segments.len() == 1;
- 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);
- then {
- span_note_and_lint(
- self.cx,
- EVAL_ORDER_DEPENDENCE,
- expr.span,
- "unsequenced read of a variable",
- self.write_expr.span,
- "whether read occurs before this write depends on evaluation order"
- );
- }
- }
+ if path_to_local_id(expr, self.var) {
+ // Check that this is a read, not a write.
+ if !is_in_assignment_position(self.cx, expr) {
+ span_lint_and_note(
+ self.cx,
+ EVAL_ORDER_DEPENDENCE,
+ expr.span,
+ &format!("unsequenced read of `{}`", self.cx.tcx.hir().name(self.var)),
+ Some(self.write_expr.span),
+ "whether read occurs before this write depends on evaluation order",
+ );