Skip to content

Commit 161f475

Browse files
committed
Add test case for same_item_push
1 parent 1e8ada3 commit 161f475

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clippy_lints/src/loops.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ForPatternVisitor<'a, 'tcx> {
11141114
| ExprKind::Cast(expr, _)
11151115
| ExprKind::Type(expr, _)
11161116
| ExprKind::AddrOf(_, _, expr)
1117+
| ExprKind::Field(expr, _)
11171118
| ExprKind::Struct(_, _, Some(expr)) => self.visit_expr(expr),
11181119
_ => {
11191120
// Exploration cannot continue ... calculate the hir_id of the current

tests/ui/same_item_push.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,16 @@ fn main() {
7474
for _ in 0..5 {
7575
println!("Same Item Push");
7676
}
77+
78+
struct A {
79+
kind: u32,
80+
}
81+
let mut vec_a: Vec<A> = Vec::new();
82+
for i in 0..30 {
83+
vec_a.push(A{kind: i});
84+
}
85+
let mut vec12: Vec<u8> = Vec::new();
86+
for a in vec_a {
87+
vec12.push(2u8.pow(a.kind));
88+
}
7789
}

0 commit comments

Comments
 (0)