Skip to content

Commit 0bbcc15

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 d35e059 + 1b8d475 commit 0bbcc15

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

crates/ide-db/src/imports/merge_imports.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ fn recursive_normalize(use_tree: &ast::UseTree, style: NormalizationStyle) -> Op
405405
} else {
406406
ted::replace_with_many(subtree.syntax(), elements);
407407
}
408+
// Silence unused assignment warning on `modified`.
409+
let _ = modified;
408410
modified = true;
409411
} else {
410412
modified |= recursive_normalize(&subtree, NormalizationStyle::Default).is_some();

crates/test-fixture/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ impl ChangeFixture {
383383
}
384384
}
385385

386+
let _ = file_id;
387+
386388
let root = match current_source_root_kind {
387389
SourceRootKind::Local => SourceRoot::new_local(mem::take(&mut file_set)),
388390
SourceRootKind::Library => SourceRoot::new_library(mem::take(&mut file_set)),

0 commit comments

Comments
 (0)