Rollup merge of #110960 - lukas-code:unused-mut, r=compiler-errors
fix false negative for `unused_mut` fixes https://github.com/rust-lang/rust/issues/110849 We want to avoid double diagnostics for code like this, but only if an error actually occurs: ```rust fn main() { let mut x: (i32, i32); x.0 = 1; } ``` The first commit fixes the lint and the second one removes all the unused `mut`s it found.
This commit is contained in:
commit
34ef13b15b
10 changed files with 34 additions and 17 deletions
|
@ -935,6 +935,7 @@ enum InitializationRequiringAction {
|
|||
PartialAssignment,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RootPlace<'tcx> {
|
||||
place_local: Local,
|
||||
place_projection: &'tcx [PlaceElem<'tcx>],
|
||||
|
@ -1848,11 +1849,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
// is allowed, remove this match arm.
|
||||
ty::Adt(..) | ty::Tuple(..) => {
|
||||
check_parent_of_field(self, location, place_base, span, flow_state);
|
||||
|
||||
// rust-lang/rust#21232, #54499, #54986: during period where we reject
|
||||
// partial initialization, do not complain about unnecessary `mut` on
|
||||
// an attempt to do a partial initialization.
|
||||
self.used_mut.insert(place.local);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
|
@ -1940,6 +1936,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
(prefix, base, span),
|
||||
mpi,
|
||||
);
|
||||
|
||||
// rust-lang/rust#21232, #54499, #54986: during period where we reject
|
||||
// partial initialization, do not complain about unnecessary `mut` on
|
||||
// an attempt to do a partial initialization.
|
||||
this.used_mut.insert(base.local);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ fn append_list(
|
|||
) {
|
||||
let mut p = target_list;
|
||||
loop {
|
||||
let mut r = &mut constraints[p];
|
||||
let r = &mut constraints[p];
|
||||
match r.next_constraint {
|
||||
Some(q) => p = q,
|
||||
None => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue