mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Change to give a help message
This commit is contained in:
parent
70536d4b4c
commit
c0e3f4b8bb
@ -1657,13 +1657,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
fn report_dead_assign(&self, hir_id: HirId, sp: Span, var: Variable, is_argument: bool) {
|
||||
if let Some(name) = self.should_warn(var) {
|
||||
if is_argument {
|
||||
self.ir.tcx.lint_hir(lint::builtin::UNUSED_ASSIGNMENTS, hir_id, sp,
|
||||
&format!("value passed to `{}` is never read
|
||||
(maybe it is overwritten before being read)", name));
|
||||
self.ir.tcx.struct_span_lint_hir(lint::builtin::UNUSED_ASSIGNMENTS, hir_id, sp,
|
||||
&format!("value passed to `{}` is never read", name))
|
||||
.help("maybe it is overwritten before being read?")
|
||||
.emit();
|
||||
} else {
|
||||
self.ir.tcx.lint_hir(lint::builtin::UNUSED_ASSIGNMENTS, hir_id, sp,
|
||||
&format!("value assigned to `{}` is never read
|
||||
(maybe it is overwritten before being read)", name));
|
||||
self.ir.tcx.struct_span_lint_hir(lint::builtin::UNUSED_ASSIGNMENTS, hir_id, sp,
|
||||
&format!("value assigned to `{}` is never read", name))
|
||||
.help("maybe it is overwritten before being read?")
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ LL | mut hours_are_suns,
|
||||
= note: consider using `_hours_are_suns` instead
|
||||
|
||||
warning: value assigned to `hours_are_suns` is never read
|
||||
(maybe it is overwritten before being read)
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:50:9
|
||||
|
|
||||
LL | hours_are_suns = false;
|
||||
@ -56,6 +55,7 @@ note: lint level defined here
|
||||
LL | #![warn(unused)] // UI tests pass `-A unused` (#43896)
|
||||
| ^^^^^^
|
||||
= note: #[warn(unused_assignments)] implied by #[warn(unused)]
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
warning: unused variable: `fire`
|
||||
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:54:32
|
||||
|
@ -1,5 +1,4 @@
|
||||
error: value assigned to `x` is never read
|
||||
(maybe it is overwritten before being read)
|
||||
--> $DIR/liveness-dead.rs:19:13
|
||||
|
|
||||
LL | let mut x: isize = 3; //~ ERROR: value assigned to `x` is never read
|
||||
@ -10,27 +9,31 @@ note: lint level defined here
|
||||
|
|
||||
LL | #![deny(unused_assignments)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `x` is never read
|
||||
(maybe it is overwritten before being read)
|
||||
--> $DIR/liveness-dead.rs:27:5
|
||||
|
|
||||
LL | x = 4; //~ ERROR: value assigned to `x` is never read
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value passed to `x` is never read
|
||||
(maybe it is overwritten before being read)
|
||||
--> $DIR/liveness-dead.rs:30:11
|
||||
|
|
||||
LL | fn f4(mut x: i32) { //~ ERROR: value passed to `x` is never read
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: value assigned to `x` is never read
|
||||
(maybe it is overwritten before being read)
|
||||
--> $DIR/liveness-dead.rs:37:5
|
||||
|
|
||||
LL | x = 4; //~ ERROR: value assigned to `x` is never read
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -50,7 +50,6 @@ LL | let mut x = 3;
|
||||
= note: consider using `_x` instead
|
||||
|
||||
error: value assigned to `x` is never read
|
||||
(maybe it is overwritten before being read)
|
||||
--> $DIR/liveness-unused.rs:42:5
|
||||
|
|
||||
LL | x += 4;
|
||||
@ -61,6 +60,7 @@ note: lint level defined here
|
||||
|
|
||||
LL | #![deny(unused_assignments)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: variable `z` is assigned to, but never used
|
||||
--> $DIR/liveness-unused.rs:47:13
|
||||
@ -103,11 +103,12 @@ LL | let x;
|
||||
= note: consider using `_x` instead
|
||||
|
||||
error: value assigned to `x` is never read
|
||||
(maybe it is overwritten before being read)
|
||||
--> $DIR/liveness-unused.rs:126:9
|
||||
|
|
||||
LL | x = 0; //~ ERROR value assigned to `x` is never read
|
||||
| ^
|
||||
|
|
||||
= help: maybe it is overwritten before being read?
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user