Skip to content

Commit 451c508

Browse files
authored
Rollup merge of rust-lang#139740 - jieyouxu:known-bug, r=nnethercote
Convert `tests/ui/lint/dead-code/self-assign.rs` to a known-bug test I did a survey pass over `tests/`, and this test seems like the only candidate suitable for conversion into a known-bug test. (Other tests had varying degrees of other issues that known-bug would not be suitable.) r? compiler
2 parents 3975cce + 16334cd commit 451c508

File tree

2 files changed

+20
-54
lines changed

2 files changed

+20
-54
lines changed

tests/ui/lint/dead-code/self-assign.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
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

1020
fn 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;

tests/ui/lint/dead-code/self-assign.stderr

-44
This file was deleted.

0 commit comments

Comments
 (0)