1- // Test that dead code warnings are issued for superfluous assignments of
2- // fields or variables to themselves (issue #75356).
3-
4- //@ ignore-test FIXME(81658, 83171)
1+ //! Test that dead code warnings are issued for superfluous assignments of fields or variables to
2+ //! themselves (issue #75356).
3+ //!
4+ //! # History of this test (to aid relanding of a fixed version of #81473)
5+ //!
6+ //! - Original lint request was about self-assignments not triggering sth like `dead_code`.
7+ //! - `dead_code` lint expansion for self-assignments was implemented in #87129.
8+ //! - Unfortunately implementation components of #87129 had to be disabled as part of reverts
9+ //! #86212, #83171 (to revert #81473) to address regressions #81626 and #81658.
10+ //! - Consequently, none of the following warnings are emitted.
511
612//@ check-pass
13+
14+ // Implementation of self-assignment `dead_code` lint expansions disabled due to reverts.
15+ //@ known-bug: #75356
16+
717#![allow(unused_assignments)]
818#![warn(dead_code)]
919
1020fn main() {
1121 let mut x = 0;
1222 x = x;
13- //~^ WARNING: useless assignment of variable of type `i32` to itself
23+ // FIXME ~^ WARNING: useless assignment of variable of type `i32` to itself
1424
1525 x = (x);
16- //~^ WARNING: useless assignment of variable of type `i32` to itself
26+ // FIXME ~^ WARNING: useless assignment of variable of type `i32` to itself
1727
1828 x = {x};
1929 // block expressions don't count as self-assignments
@@ -22,10 +32,10 @@ fn main() {
2232 struct S<'a> { f: &'a str }
2333 let mut s = S { f: "abc" };
2434 s = s;
25- //~^ WARNING: useless assignment of variable of type `S` to itself
35+ // FIXME ~^ WARNING: useless assignment of variable of type `S` to itself
2636
2737 s.f = s.f;
28- //~^ WARNING: useless assignment of field of type `&str` to itself
38+ // FIXME ~^ WARNING: useless assignment of field of type `&str` to itself
2939
3040
3141 struct N0 { x: Box<i32> }
@@ -34,11 +44,11 @@ fn main() {
3444 struct N3 { n: N2 };
3545 let mut n3 = N3 { n: N2(N1 { n: N0 { x: Box::new(42) } }) };
3646 n3.n.0.n.x = n3.n.0.n.x;
37- //~^ WARNING: useless assignment of field of type `Box<i32>` to itself
47+ // FIXME ~^ WARNING: useless assignment of field of type `Box<i32>` to itself
3848
3949 let mut t = (1, ((2, 3, (4, 5)),));
4050 t.1.0.2.1 = t.1.0.2.1;
41- //~^ WARNING: useless assignment of field of type `i32` to itself
51+ // FIXME ~^ WARNING: useless assignment of field of type `i32` to itself
4252
4353
4454 let mut y = 0;
0 commit comments