Auto merge of #9379 - royrustdev:multi_assignments, r=llogiq
new lint This fixes #6576 If you added a new lint, here's a checklist for things that will be checked during review or continuous integration. - \[x] Followed [lint naming conventions][lint_naming] - \[x] Added passing UI tests (including committed `.stderr` file) - \[x] `cargo test` passes locally - \[x] Executed `cargo dev update_lints` - \[x] Added lint documentation - \[x] Run `cargo dev fmt` --- changelog: add [`multi_assignments`] lint
This commit is contained in:
commit
21f103abcc
8 changed files with 120 additions and 0 deletions
9
tests/ui/multi_assignments.rs
Normal file
9
tests/ui/multi_assignments.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#![warn(clippy::multi_assignments)]
|
||||
fn main() {
|
||||
let (mut a, mut b, mut c, mut d) = ((), (), (), ());
|
||||
a = b = c;
|
||||
a = b = c = d;
|
||||
a = b = { c };
|
||||
a = { b = c };
|
||||
a = (b = c);
|
||||
}
|
||||
40
tests/ui/multi_assignments.stderr
Normal file
40
tests/ui/multi_assignments.stderr
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
error: assignments don't nest intuitively
|
||||
--> $DIR/multi_assignments.rs:4:5
|
||||
|
|
||||
LL | a = b = c;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::multi-assignments` implied by `-D warnings`
|
||||
|
||||
error: assignments don't nest intuitively
|
||||
--> $DIR/multi_assignments.rs:5:5
|
||||
|
|
||||
LL | a = b = c = d;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: assignments don't nest intuitively
|
||||
--> $DIR/multi_assignments.rs:5:9
|
||||
|
|
||||
LL | a = b = c = d;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: assignments don't nest intuitively
|
||||
--> $DIR/multi_assignments.rs:6:5
|
||||
|
|
||||
LL | a = b = { c };
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: assignments don't nest intuitively
|
||||
--> $DIR/multi_assignments.rs:7:5
|
||||
|
|
||||
LL | a = { b = c };
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: assignments don't nest intuitively
|
||||
--> $DIR/multi_assignments.rs:8:5
|
||||
|
|
||||
LL | a = (b = c);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue