77//! - `dead_code` lint expansion for self-assignments was implemented in #87129.
88//! - Unfortunately implementation components of #87129 had to be disabled as part of reverts
99//! #86212, #83171 (to revert #81473) to address regressions #81626 and #81658.
10- //! - Consequently, none of the following warnings are emitted .
10+ //! - Re-enabled in current version to properly detect self-assignments .
1111
1212//@ check-pass
1313
14- // Implementation of self-assignment `dead_code` lint expansions disabled due to reverts.
15- //@ known-bug: #75356
16-
1714#![ allow( unused_assignments) ]
1815#![ warn( dead_code) ]
1916
2017fn main ( ) {
2118 let mut x = 0 ;
2219 x = x;
23- // FIXME ~^ WARNING: useless assignment of variable of type `i32` to itself
20+ //~^ WARNING: useless assignment of variable of type `i32` to itself
2421
2522 x = ( x) ;
26- // FIXME ~^ WARNING: useless assignment of variable of type `i32` to itself
23+ //~^ WARNING: useless assignment of variable of type `i32` to itself
2724
2825 x = { x} ;
2926 // block expressions don't count as self-assignments
@@ -32,10 +29,10 @@ fn main() {
3229 struct S < ' a > { f : & ' a str }
3330 let mut s = S { f : "abc" } ;
3431 s = s;
35- // FIXME ~^ WARNING: useless assignment of variable of type `S` to itself
32+ //~^ WARNING: useless assignment of variable of type `S<'_> ` to itself
3633
3734 s. f = s. f ;
38- // FIXME ~^ WARNING: useless assignment of field of type `&str` to itself
35+ //~^ WARNING: useless assignment of field of type `&str` to itself
3936
4037
4138 struct N0 { x : Box < i32 > }
@@ -44,11 +41,11 @@ fn main() {
4441 struct N3 { n : N2 } ;
4542 let mut n3 = N3 { n : N2 ( N1 { n : N0 { x : Box :: new ( 42 ) } } ) } ;
4643 n3. n . 0 . n . x = n3. n . 0 . n . x ;
47- // FIXME ~^ WARNING: useless assignment of field of type `Box<i32>` to itself
44+ //~^ WARNING: useless assignment of field of type `Box<i32>` to itself
4845
4946 let mut t = ( 1 , ( ( 2 , 3 , ( 4 , 5 ) ) , ) ) ;
5047 t. 1 . 0 . 2 . 1 = t. 1 . 0 . 2 . 1 ;
51- // FIXME ~^ WARNING: useless assignment of field of type `i32` to itself
48+ //~^ WARNING: useless assignment of field of type `i32` to itself
5249
5350
5451 let mut y = 0 ;
0 commit comments