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