From 2b38399920ad97cc9db61e50549fd4af54d4b38d Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Wed, 5 May 2021 14:44:32 -0500 Subject: [PATCH] Improve eval_order_dependence output --- clippy_lints/src/eval_order_dependence.rs | 2 +- tests/ui/eval_order_dependence.stderr | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/eval_order_dependence.rs b/clippy_lints/src/eval_order_dependence.rs index 762f64fe37a..8815ca27494 100644 --- a/clippy_lints/src/eval_order_dependence.rs +++ b/clippy_lints/src/eval_order_dependence.rs @@ -305,7 +305,7 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { self.cx, EVAL_ORDER_DEPENDENCE, expr.span, - "unsequenced read of a variable", + &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", ); diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index 8f4fa2228f7..cf4adbdfa24 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -1,4 +1,4 @@ -error: unsequenced read of a variable +error: unsequenced read of `x` --> $DIR/eval_order_dependence.rs:15:9 | LL | } + x; @@ -11,7 +11,7 @@ note: whether read occurs before this write depends on evaluation order LL | x = 1; | ^^^^^ -error: unsequenced read of a variable +error: unsequenced read of `x` --> $DIR/eval_order_dependence.rs:18:5 | LL | x += { @@ -23,7 +23,7 @@ note: whether read occurs before this write depends on evaluation order LL | x = 20; | ^^^^^^ -error: unsequenced read of a variable +error: unsequenced read of `x` --> $DIR/eval_order_dependence.rs:31:12 | LL | a: x, @@ -35,7 +35,7 @@ note: whether read occurs before this write depends on evaluation order LL | x = 6; | ^^^^^ -error: unsequenced read of a variable +error: unsequenced read of `x` --> $DIR/eval_order_dependence.rs:40:9 | LL | x += {