1 // Test that dead code warnings are issued for superfluous assignments of
2 // fields or variables to themselves (issue #75356).
4 // ignore-test FIXME(81658, 83171)
7 #![allow(unused_assignments)]
13 //~^ WARNING: useless assignment of variable of type `i32` to itself
16 //~^ WARNING: useless assignment of variable of type `i32` to itself
19 // block expressions don't count as self-assignments
22 struct S<'a> { f: &'a str }
23 let mut s = S { f: "abc" };
25 //~^ WARNING: useless assignment of variable of type `S` to itself
28 //~^ WARNING: useless assignment of field of type `&str` to itself
31 struct N0 { x: Box<i32> }
35 let mut n3 = N3 { n: N2(N1 { n: N0 { x: Box::new(42) } }) };
36 n3.n.0.n.x = n3.n.0.n.x;
37 //~^ WARNING: useless assignment of field of type `Box<i32>` to itself
39 let mut t = (1, ((2, 3, (4, 5)),));
40 t.1.0.2.1 = t.1.0.2.1;
41 //~^ WARNING: useless assignment of field of type `i32` to itself
45 macro_rules! assign_to_y {
51 // self-assignments in macro expansions are not reported either