Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bc9ccee

Browse files
authored
Rollup merge of rust-lang#128404 - compiler-errors:revert-dead-code-changes, r=pnkfelix
Revert recent changes to dead code analysis This is a revert to recent changes to dead code analysis, namely: * efdf219 Rollup merge of rust-lang#128104 - mu001999-contrib:fix/128053, r=petrochenkov * a70dc29 Rollup merge of rust-lang#127017 - mu001999-contrib:dead/enhance, r=pnkfelix * 31fe962 Rollup merge of rust-lang#127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix * 2724aea Rollup merge of rust-lang#126618 - mu001999-contrib:dead/enhance, r=pnkfelix * 977c5fd Rollup merge of rust-lang#126315 - mu001999-contrib:fix/126289, r=petrochenkov * 13314df Rollup merge of rust-lang#125572 - mu001999-contrib:dead/enhance, r=pnkfelix There is an additional change stacked on top, which suppresses false-negatives that were masked by this work. I believe the functions that are touched in that code are legitimately unused functions and the types are not reachable since this `AnonPipe` type is not publically reachable -- please correct me if I'm wrong cc `@NobodyXu` who added these in #rust-lang#127153. Some of these reverts (rust-lang#126315 and rust-lang#126618) are only included because it makes the revert apply cleanly, and I think these changes were only done to fix follow-ups from the other PRs? I apologize for the size of the PR and the churn that it has on the codebase (and for reverting `@mu001999's` work here), but I'm putting this PR up because I am concerned that we're making ad-hoc changes to fix bugs that are fallout of these PRs, and I'd like to see these changes reimplemented in a way that's more separable from the existing dead code pass. I am happy to review any code to reapply these changes in a more separable way. cc `@mu001999` r? `@pnkfelix` Fixes rust-lang#128272 Fixes rust-lang#126169
2 parents 44ccae1 + b1a5e07 commit bc9ccee

File tree

63 files changed

+164
-662
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+164
-662
lines changed

compiler/rustc_passes/src/dead.rs

Lines changed: 71 additions & 143 deletions
Large diffs are not rendered by default.

library/core/src/default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ use crate::ascii::Char as AsciiChar;
103103
/// ```
104104
#[cfg_attr(not(test), rustc_diagnostic_item = "Default")]
105105
#[stable(feature = "rust1", since = "1.0.0")]
106+
#[cfg_attr(not(bootstrap), rustc_trivial_field_reads)]
106107
pub trait Default: Sized {
107108
/// Returns the "default value" for a type.
108109
///

library/std/src/sys/pal/unix/pipe.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
4747
}
4848

4949
impl AnonPipe {
50+
#[allow(dead_code)]
51+
// FIXME: This function seems legitimately unused.
5052
pub fn try_clone(&self) -> io::Result<Self> {
5153
self.0.duplicate().map(Self)
5254
}
@@ -85,6 +87,8 @@ impl AnonPipe {
8587
self.0.is_write_vectored()
8688
}
8789

90+
#[allow(dead_code)]
91+
// FIXME: This function seems legitimately unused.
8892
pub fn as_file_desc(&self) -> &FileDesc {
8993
&self.0
9094
}

tests/codegen-units/item-collection/generic-impl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ impl<T> Struct<T> {
2222
}
2323
}
2424

25-
pub struct _LifeTimeOnly<'a> {
25+
pub struct LifeTimeOnly<'a> {
2626
_a: &'a u32,
2727
}
2828

29-
impl<'a> _LifeTimeOnly<'a> {
30-
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::foo
29+
impl<'a> LifeTimeOnly<'a> {
30+
//~ MONO_ITEM fn LifeTimeOnly::<'_>::foo
3131
pub fn foo(&self) {}
32-
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::bar
32+
//~ MONO_ITEM fn LifeTimeOnly::<'_>::bar
3333
pub fn bar(&'a self) {}
34-
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::baz
34+
//~ MONO_ITEM fn LifeTimeOnly::<'_>::baz
3535
pub fn baz<'b>(&'b self) {}
3636

3737
pub fn non_instantiated<T>(&self) {}

tests/codegen-units/item-collection/overloaded-operators.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,44 @@
55

66
use std::ops::{Add, Deref, Index, IndexMut};
77

8-
pub struct _Indexable {
8+
pub struct Indexable {
99
data: [u8; 3],
1010
}
1111

12-
impl Index<usize> for _Indexable {
12+
impl Index<usize> for Indexable {
1313
type Output = u8;
1414

15-
//~ MONO_ITEM fn <_Indexable as std::ops::Index<usize>>::index
15+
//~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index
1616
fn index(&self, index: usize) -> &Self::Output {
1717
if index >= 3 { &self.data[0] } else { &self.data[index] }
1818
}
1919
}
2020

21-
impl IndexMut<usize> for _Indexable {
22-
//~ MONO_ITEM fn <_Indexable as std::ops::IndexMut<usize>>::index_mut
21+
impl IndexMut<usize> for Indexable {
22+
//~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut
2323
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
2424
if index >= 3 { &mut self.data[0] } else { &mut self.data[index] }
2525
}
2626
}
2727

28-
//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::eq
29-
//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::ne
28+
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq
29+
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne
3030
#[derive(PartialEq)]
31-
pub struct _Equatable(u32);
31+
pub struct Equatable(u32);
3232

33-
impl Add<u32> for _Equatable {
33+
impl Add<u32> for Equatable {
3434
type Output = u32;
3535

36-
//~ MONO_ITEM fn <_Equatable as std::ops::Add<u32>>::add
36+
//~ MONO_ITEM fn <Equatable as std::ops::Add<u32>>::add
3737
fn add(self, rhs: u32) -> u32 {
3838
self.0 + rhs
3939
}
4040
}
4141

42-
impl Deref for _Equatable {
42+
impl Deref for Equatable {
4343
type Target = u32;
4444

45-
//~ MONO_ITEM fn <_Equatable as std::ops::Deref>::deref
45+
//~ MONO_ITEM fn <Equatable as std::ops::Deref>::deref
4646
fn deref(&self) -> &Self::Target {
4747
&self.0
4848
}

tests/ui-fulldeps/deriving-global.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,18 @@ mod submod {
1717
// if any of these are implemented without global calls for any
1818
// function calls, then being in a submodule will (correctly)
1919
// cause errors about unrecognised module `std` (or `extra`)
20-
#[allow(dead_code)]
2120
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, Encodable, Decodable)]
2221
enum A {
2322
A1(usize),
2423
A2(isize),
2524
}
2625

27-
#[allow(dead_code)]
2826
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, Encodable, Decodable)]
2927
struct B {
3028
x: usize,
3129
y: isize,
3230
}
3331

34-
#[allow(dead_code)]
3532
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, Encodable, Decodable)]
3633
struct C(usize, isize);
3734
}

tests/ui-fulldeps/deriving-hygiene.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub const s: u8 = 1;
2020
pub const state: u8 = 1;
2121
pub const cmp: u8 = 1;
2222

23-
#[allow(dead_code)]
2423
#[derive(Ord, Eq, PartialOrd, PartialEq, Debug, Decodable, Encodable, Hash)]
2524
struct Foo {}
2625

tests/ui/coherence/re-rebalance-coherence.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
extern crate re_rebalance_coherence_lib as lib;
55
use lib::*;
66

7-
#[allow(dead_code)]
87
struct Oracle;
98
impl Backend for Oracle {}
109
impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {}

tests/ui/const-generics/cross_crate_complex.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ async fn foo() {
1111
async_in_foo(async_out_foo::<4>().await).await;
1212
}
1313

14-
#[allow(dead_code)]
1514
struct Faz<const N: usize>;
1615

1716
impl<const N: usize> Foo<N> for Faz<N> {}

tests/ui/const-generics/defaults/repr-c-issue-82792.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
//@ run-pass
44

5-
#[allow(dead_code)]
65
#[repr(C)]
76
pub struct Loaf<T: Sized, const N: usize = 1> {
87
head: [T; N],

0 commit comments

Comments
 (0)