]> git.proxmox.com Git - rustc.git/blame - src/test/ui/destructuring-assignment/warn-unused-duplication.rs
New upstream version 1.59.0+dfsg1
[rustc.git] / src / test / ui / destructuring-assignment / warn-unused-duplication.rs
CommitLineData
29967ef6
XL
1// run-pass
2
29967ef6
XL
3#![warn(unused_assignments)]
4
5fn main() {
6 let mut a;
7 // Assignment occurs left-to-right.
8 // However, we emit warnings when this happens, so it is clear that this is happening.
9 (a, a) = (0, 1); //~ WARN value assigned to `a` is never read
10 assert_eq!(a, 1);
11
12 // We can't always tell when a variable is being assigned to twice, which is why we don't try
13 // to emit an error, which would be fallible.
14 let mut x = 1;
15 (*foo(&mut x), *foo(&mut x)) = (5, 6);
16 assert_eq!(x, 6);
17}
18
19fn foo<'a>(x: &'a mut u32) -> &'a mut u32 {
20 x
21}