Skip to content

Commit c72ee98

Browse files
committed
Auto merge of #142390 - cjgillot:mir-liveness, r=davidtwco
Perform unused assignment and unused variables lints on MIR. Rebase of rust-lang/rust#101500 Fixes rust-lang/rust#51003. The first commit moves detection of uninhabited types from the current liveness pass to MIR building. In order to keep the same level of diagnostics, I had to instrument MIR a little more: - keep for which original local a guard local is created; - store in the `VarBindingForm` the list of introducer places and whether this was a shorthand pattern. I am not very proud of the handling of self-assignments. The proposed scheme is in two parts: first detect probable self-assignments, by pattern matching on MIR, and second treat them specially during dataflow analysis. I welcome ideas. Please review carefully the changes in tests. There are many small changes to behaviour, and I'm not sure all of them are desirable.
2 parents 982ce7b + 5f4398a commit c72ee98

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

tests/ui/needless_match.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![warn(clippy::needless_match)]
22
#![allow(clippy::manual_map)]
33
#![allow(dead_code)]
4-
4+
#![allow(unused)]
55
#[derive(Clone, Copy)]
66
enum Simple {
77
A,

tests/ui/needless_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![warn(clippy::needless_match)]
22
#![allow(clippy::manual_map)]
33
#![allow(dead_code)]
4-
4+
#![allow(unused)]
55
#[derive(Clone, Copy)]
66
enum Simple {
77
A,

tests/ui/useless_conversion.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![deny(clippy::useless_conversion)]
2-
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
2+
#![allow(clippy::needless_if, clippy::unnecessary_wraps, unused)]
33
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
44
#![allow(static_mut_refs)]
55

tests/ui/useless_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![deny(clippy::useless_conversion)]
2-
#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
2+
#![allow(clippy::needless_if, clippy::unnecessary_wraps, unused)]
33
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
44
#![allow(static_mut_refs)]
55

0 commit comments

Comments
 (0)