Skip to content

Commit 2d56512

Browse files
committed
Cleanup of rustup
1 parent 961f183 commit 2d56512

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

clippy_lints/src/temporary_assignment.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ declare_clippy_lint! {
2121
"assignments to temporaries"
2222
}
2323

24-
fn is_temporary(_cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
25-
match &expr.kind {
26-
ExprKind::Struct(..) | ExprKind::Tup(..) => true,
27-
_ => false,
28-
}
24+
fn is_temporary(expr: &Expr<'_>) -> bool {
25+
matches!(&expr.kind, ExprKind::Struct(..) | ExprKind::Tup(..))
2926
}
3027

3128
declare_lint_pass!(TemporaryAssignment => [TEMPORARY_ASSIGNMENT]);
@@ -37,7 +34,7 @@ impl<'tcx> LateLintPass<'tcx> for TemporaryAssignment {
3734
while let ExprKind::Field(f, _) | ExprKind::Index(f, _) = &base.kind {
3835
base = f;
3936
}
40-
if is_temporary(cx, base) && !is_adjusted(cx, base) {
37+
if is_temporary(base) && !is_adjusted(cx, base) {
4138
span_lint(cx, TEMPORARY_ASSIGNMENT, expr.span, "assignment to temporary");
4239
}
4340
}

tests/ui/temporary_assignment.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![warn(clippy::temporary_assignment)]
2-
#![allow(const_item_mutation)]
32

43
use std::ops::{Deref, DerefMut};
54

@@ -54,11 +53,6 @@ fn main() {
5453
ArrayStruct { array: [0] }.array[0] = 1;
5554
(0, 0).0 = 1;
5655

57-
A.0 = 2;
58-
B.field = 2;
59-
C.structure.field = 2;
60-
D.array[0] = 2;
61-
6256
// no error
6357
s.field = 1;
6458
t.0 = 1;

tests/ui/temporary_assignment.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: assignment to temporary
2-
--> $DIR/temporary_assignment.rs:48:5
2+
--> $DIR/temporary_assignment.rs:47:5
33
|
44
LL | Struct { field: 0 }.field = 1;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::temporary-assignment` implied by `-D warnings`
88

99
error: assignment to temporary
10-
--> $DIR/temporary_assignment.rs:49:5
10+
--> $DIR/temporary_assignment.rs:48:5
1111
|
1212
LL | / MultiStruct {
1313
LL | | structure: Struct { field: 0 },
@@ -17,13 +17,13 @@ LL | | .field = 1;
1717
| |______________^
1818

1919
error: assignment to temporary
20-
--> $DIR/temporary_assignment.rs:54:5
20+
--> $DIR/temporary_assignment.rs:53:5
2121
|
2222
LL | ArrayStruct { array: [0] }.array[0] = 1;
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424

2525
error: assignment to temporary
26-
--> $DIR/temporary_assignment.rs:55:5
26+
--> $DIR/temporary_assignment.rs:54:5
2727
|
2828
LL | (0, 0).0 = 1;
2929
| ^^^^^^^^^^^^

0 commit comments

Comments
 (0)