Skip to content

Commit 6b18424

Browse files
varkorfanzier
authored andcommitted
Add more complex example
1 parent 76bcd89 commit 6b18424

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/test/ui/destructuring-assignment/warn-unused-duplication.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@ fn main() {
1010
// However, we emit warnings when this happens, so it is clear that this is happening.
1111
(a, a) = (0, 1); //~ WARN value assigned to `a` is never read
1212
assert_eq!(a, 1);
13+
14+
// We can't always tell when a variable is being assigned to twice, which is why we don't try
15+
// to emit an error, which would be fallible.
16+
let mut x = 1;
17+
(*foo(&mut x), *foo(&mut x)) = (5, 6);
18+
assert_eq!(x, 6);
19+
}
20+
21+
fn foo<'a>(x: &'a mut u32) -> &'a mut u32 {
22+
x
1323
}

0 commit comments

Comments
 (0)