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.
5
11
6
12
//@ check-pass
13
+
14
+ // Implementation of self-assignment `dead_code` lint expansions disabled due to reverts.
15
+ //@ known-bug: #75356
16
+
7
17
#![ allow( unused_assignments) ]
8
18
#![ warn( dead_code) ]
9
19
10
20
fn main ( ) {
11
21
let mut x = 0 ;
12
22
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
14
24
15
25
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
17
27
18
28
x = { x} ;
19
29
// block expressions don't count as self-assignments
@@ -22,10 +32,10 @@ fn main() {
22
32
struct S < ' a > { f : & ' a str }
23
33
let mut s = S { f : "abc" } ;
24
34
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
26
36
27
37
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
29
39
30
40
31
41
struct N0 { x : Box < i32 > }
@@ -34,11 +44,11 @@ fn main() {
34
44
struct N3 { n : N2 } ;
35
45
let mut n3 = N3 { n : N2 ( N1 { n : N0 { x : Box :: new ( 42 ) } } ) } ;
36
46
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
38
48
39
49
let mut t = ( 1 , ( ( 2 , 3 , ( 4 , 5 ) ) , ) ) ;
40
50
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
42
52
43
53
44
54
let mut y = 0 ;
0 commit comments