Skip to content

Revert recent changes to dead code analysis #128404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 71 additions & 143 deletions compiler/rustc_passes/src/dead.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions library/core/src/default.rs
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ use crate::ascii::Char as AsciiChar;
/// ```
#[cfg_attr(not(test), rustc_diagnostic_item = "Default")]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(bootstrap), rustc_trivial_field_reads)]
pub trait Default: Sized {
/// Returns the "default value" for a type.
///
4 changes: 4 additions & 0 deletions library/std/src/sys/pal/unix/pipe.rs
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
}

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

#[allow(dead_code)]
// FIXME: This function seems legitimately unused.
pub fn as_file_desc(&self) -> &FileDesc {
&self.0
}
4 changes: 0 additions & 4 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
@@ -31,10 +31,6 @@ pub struct Std {
}

impl Std {
pub fn new(target: TargetSelection) -> Self {
Self::new_with_build_kind(target, None)
}

pub fn new_with_build_kind(target: TargetSelection, kind: Option<Kind>) -> Self {
Self { target, crates: vec![], override_build_kind: kind }
}
10 changes: 5 additions & 5 deletions tests/codegen-units/item-collection/generic-impl.rs
Original file line number Diff line number Diff line change
@@ -22,16 +22,16 @@ impl<T> Struct<T> {
}
}

pub struct _LifeTimeOnly<'a> {
pub struct LifeTimeOnly<'a> {
_a: &'a u32,
}

impl<'a> _LifeTimeOnly<'a> {
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::foo
impl<'a> LifeTimeOnly<'a> {
//~ MONO_ITEM fn LifeTimeOnly::<'_>::foo
pub fn foo(&self) {}
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::bar
//~ MONO_ITEM fn LifeTimeOnly::<'_>::bar
pub fn bar(&'a self) {}
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::baz
//~ MONO_ITEM fn LifeTimeOnly::<'_>::baz
pub fn baz<'b>(&'b self) {}

pub fn non_instantiated<T>(&self) {}
24 changes: 12 additions & 12 deletions tests/codegen-units/item-collection/overloaded-operators.rs
Original file line number Diff line number Diff line change
@@ -5,44 +5,44 @@

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

pub struct _Indexable {
pub struct Indexable {
data: [u8; 3],
}

impl Index<usize> for _Indexable {
impl Index<usize> for Indexable {
type Output = u8;

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

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

//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::eq
//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::ne
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne
#[derive(PartialEq)]
pub struct _Equatable(u32);
pub struct Equatable(u32);

impl Add<u32> for _Equatable {
impl Add<u32> for Equatable {
type Output = u32;

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

impl Deref for _Equatable {
impl Deref for Equatable {
type Target = u32;

//~ MONO_ITEM fn <_Equatable as std::ops::Deref>::deref
//~ MONO_ITEM fn <Equatable as std::ops::Deref>::deref
fn deref(&self) -> &Self::Target {
&self.0
}
1 change: 0 additions & 1 deletion tests/ui/coherence/re-rebalance-coherence.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
extern crate re_rebalance_coherence_lib as lib;
use lib::*;

#[allow(dead_code)]
struct Oracle;
impl Backend for Oracle {}
impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {}
1 change: 0 additions & 1 deletion tests/ui/const-generics/cross_crate_complex.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ async fn foo() {
async_in_foo(async_out_foo::<4>().await).await;
}

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

impl<const N: usize> Foo<N> for Faz<N> {}
1 change: 0 additions & 1 deletion tests/ui/const-generics/defaults/repr-c-issue-82792.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

//@ run-pass

#[allow(dead_code)]
#[repr(C)]
pub struct Loaf<T: Sized, const N: usize = 1> {
head: [T; N],
Original file line number Diff line number Diff line change
@@ -16,8 +16,7 @@ impl BlockCipher for BarCipher {
const BLOCK_SIZE: usize = 32;
}

#[allow(dead_code)]
pub struct Block<C>(C);
pub struct Block<C>(#[allow(dead_code)] C);

pub fn test<C: BlockCipher, const M: usize>()
where
1 change: 0 additions & 1 deletion tests/ui/const-generics/issues/issue-86535-2.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ pub trait Foo {
[(); Self::ASSOC_C]:;
}

#[allow(dead_code)]
struct Bar<const N: &'static ()>;
impl<const N: &'static ()> Foo for Bar<N> {
const ASSOC_C: usize = 3;
1 change: 0 additions & 1 deletion tests/ui/const-generics/issues/issue-86535.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
#![feature(adt_const_params, unsized_const_params, generic_const_exprs)]
#![allow(incomplete_features, unused_variables)]

#[allow(dead_code)]
struct F<const S: &'static str>;
impl<const S: &'static str> X for F<{ S }> {
const W: usize = 3;
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@

use std::mem::MaybeUninit;

#[allow(dead_code)]
#[repr(transparent)]
pub struct MaybeUninitWrapper<const N: usize>(MaybeUninit<[u64; N]>);

4 changes: 0 additions & 4 deletions tests/ui/generic-associated-types/missing-bounds.fixed
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

use std::ops::Add;

#[allow(dead_code)]
struct A<B>(B);

impl<B> Add for A<B> where B: Add<Output = B> {
@@ -13,7 +12,6 @@ impl<B> Add for A<B> where B: Add<Output = B> {
}
}

#[allow(dead_code)]
struct C<B>(B);

impl<B: Add<Output = B>> Add for C<B> {
@@ -24,7 +22,6 @@ impl<B: Add<Output = B>> Add for C<B> {
}
}

#[allow(dead_code)]
struct D<B>(B);

impl<B: std::ops::Add<Output = B>> Add for D<B> {
@@ -35,7 +32,6 @@ impl<B: std::ops::Add<Output = B>> Add for D<B> {
}
}

#[allow(dead_code)]
struct E<B>(B);

impl<B: Add<Output = B>> Add for E<B> where B: Add<Output = B> {
4 changes: 0 additions & 4 deletions tests/ui/generic-associated-types/missing-bounds.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

use std::ops::Add;

#[allow(dead_code)]
struct A<B>(B);

impl<B> Add for A<B> where B: Add {
@@ -13,7 +12,6 @@ impl<B> Add for A<B> where B: Add {
}
}

#[allow(dead_code)]
struct C<B>(B);

impl<B: Add> Add for C<B> {
@@ -24,7 +22,6 @@ impl<B: Add> Add for C<B> {
}
}

#[allow(dead_code)]
struct D<B>(B);

impl<B> Add for D<B> {
@@ -35,7 +32,6 @@ impl<B> Add for D<B> {
}
}

#[allow(dead_code)]
struct E<B>(B);

impl<B: Add> Add for E<B> where <B as Add>::Output = B {
18 changes: 9 additions & 9 deletions tests/ui/generic-associated-types/missing-bounds.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: equality constraints are not yet supported in `where` clauses
--> $DIR/missing-bounds.rs:41:33
--> $DIR/missing-bounds.rs:37:33
|
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
| ^^^^^^^^^^^^^^^^^^^^^^ not supported
@@ -11,7 +11,7 @@ LL | impl<B: Add> Add for E<B> where B: Add<Output = B> {
| ~~~~~~~~~~~~~~~~~~

error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:12:11
--> $DIR/missing-bounds.rs:11:11
|
LL | impl<B> Add for A<B> where B: Add {
| - expected this type parameter
@@ -24,14 +24,14 @@ LL | A(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
help: the type constructed contains `<B as Add>::Output` due to the type of the argument passed
--> $DIR/missing-bounds.rs:12:9
--> $DIR/missing-bounds.rs:11:9
|
LL | A(self.0 + rhs.0)
| ^^--------------^
| |
| this argument influences the type of `A`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:6:8
--> $DIR/missing-bounds.rs:5:8
|
LL | struct A<B>(B);
| ^
@@ -41,7 +41,7 @@ LL | impl<B> Add for A<B> where B: Add<Output = B> {
| ++++++++++++

error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:23:14
--> $DIR/missing-bounds.rs:21:14
|
LL | impl<B: Add> Add for C<B> {
| - expected this type parameter
@@ -54,7 +54,7 @@ LL | Self(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:17:8
--> $DIR/missing-bounds.rs:15:8
|
LL | struct C<B>(B);
| ^
@@ -64,7 +64,7 @@ LL | impl<B: Add<Output = B>> Add for C<B> {
| ++++++++++++

error[E0369]: cannot add `B` to `B`
--> $DIR/missing-bounds.rs:34:21
--> $DIR/missing-bounds.rs:31:21
|
LL | Self(self.0 + rhs.0)
| ------ ^ ----- B
@@ -77,7 +77,7 @@ LL | impl<B: std::ops::Add<Output = B>> Add for D<B> {
| +++++++++++++++++++++++++++

error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:46:14
--> $DIR/missing-bounds.rs:42:14
|
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
| - expected this type parameter
@@ -90,7 +90,7 @@ LL | Self(self.0 + rhs.0)
= note: expected type parameter `B`
found associated type `<B as Add>::Output`
note: tuple struct defined here
--> $DIR/missing-bounds.rs:39:8
--> $DIR/missing-bounds.rs:35:8
|
LL | struct E<B>(B);
| ^
2 changes: 0 additions & 2 deletions tests/ui/impl-trait/extra-impl-in-trait-impl.fixed
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ run-rustfix

#[allow(dead_code)]
struct S<T>(T);
#[allow(dead_code)]
struct S2;

impl<T: Default> Default for S<T> {
2 changes: 0 additions & 2 deletions tests/ui/impl-trait/extra-impl-in-trait-impl.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ run-rustfix

#[allow(dead_code)]
struct S<T>(T);
#[allow(dead_code)]
struct S2;

impl<T: Default> impl Default for S<T> {
8 changes: 4 additions & 4 deletions tests/ui/impl-trait/extra-impl-in-trait-impl.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: unexpected `impl` keyword
--> $DIR/extra-impl-in-trait-impl.rs:8:18
--> $DIR/extra-impl-in-trait-impl.rs:6:18
|
LL | impl<T: Default> impl Default for S<T> {
| ^^^^^ help: remove the extra `impl`
|
note: this is parsed as an `impl Trait` type, but a trait is expected at this position
--> $DIR/extra-impl-in-trait-impl.rs:8:18
--> $DIR/extra-impl-in-trait-impl.rs:6:18
|
LL | impl<T: Default> impl Default for S<T> {
| ^^^^^^^^^^^^

error: unexpected `impl` keyword
--> $DIR/extra-impl-in-trait-impl.rs:14:6
--> $DIR/extra-impl-in-trait-impl.rs:12:6
|
LL | impl impl Default for S2 {
| ^^^^^ help: remove the extra `impl`
|
note: this is parsed as an `impl Trait` type, but a trait is expected at this position
--> $DIR/extra-impl-in-trait-impl.rs:14:6
--> $DIR/extra-impl-in-trait-impl.rs:12:6
|
LL | impl impl Default for S2 {
| ^^^^^^^^^^^^
1 change: 0 additions & 1 deletion tests/ui/issues/issue-5708.rs
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ pub trait MyTrait<T> {
fn dummy(&self, t: T) -> T { panic!() }
}

#[allow(dead_code)]
pub struct MyContainer<'a, T:'a> {
foos: Vec<&'a (dyn MyTrait<T>+'a)> ,
}
33 changes: 0 additions & 33 deletions tests/ui/lint/dead-code/allow-unconstructed-pub-struct.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/lint/dead-code/issue-59003.rs
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@

#![deny(dead_code)]

#[allow(dead_code)]
struct Foo {
#[allow(dead_code)]
inner: u32,
}

5 changes: 3 additions & 2 deletions tests/ui/lint/dead-code/lint-dead-code-1.rs
Original file line number Diff line number Diff line change
@@ -46,10 +46,11 @@ struct SemiUsedStruct;
impl SemiUsedStruct {
fn la_la_la() {}
}
struct StructUsedAsField; //~ ERROR struct `StructUsedAsField` is never constructed
struct StructUsedAsField;
pub struct StructUsedInEnum;
struct StructUsedInGeneric;
pub struct PubStruct2 { //~ ERROR struct `PubStruct2` is never constructed
pub struct PubStruct2 {
#[allow(dead_code)]
struct_used_as_field: *const StructUsedAsField
}

26 changes: 7 additions & 19 deletions tests/ui/lint/dead-code/lint-dead-code-1.stderr
Original file line number Diff line number Diff line change
@@ -22,26 +22,14 @@ error: struct `PrivStruct` is never constructed
LL | struct PrivStruct;
| ^^^^^^^^^^

error: struct `StructUsedAsField` is never constructed
--> $DIR/lint-dead-code-1.rs:49:8
|
LL | struct StructUsedAsField;
| ^^^^^^^^^^^^^^^^^

error: struct `PubStruct2` is never constructed
--> $DIR/lint-dead-code-1.rs:52:12
|
LL | pub struct PubStruct2 {
| ^^^^^^^^^^

error: enum `priv_enum` is never used
--> $DIR/lint-dead-code-1.rs:63:6
--> $DIR/lint-dead-code-1.rs:64:6
|
LL | enum priv_enum { foo2, bar2 }
| ^^^^^^^^^

error: variant `bar3` is never constructed
--> $DIR/lint-dead-code-1.rs:66:5
--> $DIR/lint-dead-code-1.rs:67:5
|
LL | enum used_enum {
| --------- variant in this enum
@@ -50,25 +38,25 @@ LL | bar3
| ^^^^

error: function `priv_fn` is never used
--> $DIR/lint-dead-code-1.rs:87:4
--> $DIR/lint-dead-code-1.rs:88:4
|
LL | fn priv_fn() {
| ^^^^^^^

error: function `foo` is never used
--> $DIR/lint-dead-code-1.rs:92:4
--> $DIR/lint-dead-code-1.rs:93:4
|
LL | fn foo() {
| ^^^

error: function `bar` is never used
--> $DIR/lint-dead-code-1.rs:97:4
--> $DIR/lint-dead-code-1.rs:98:4
|
LL | fn bar() {
| ^^^

error: function `baz` is never used
--> $DIR/lint-dead-code-1.rs:101:4
--> $DIR/lint-dead-code-1.rs:102:4
|
LL | fn baz() -> impl Copy {
| ^^^
@@ -79,5 +67,5 @@ error: struct `Bar` is never constructed
LL | pub struct Bar;
| ^^^

error: aborting due to 12 previous errors
error: aborting due to 10 previous errors

37 changes: 0 additions & 37 deletions tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.rs

This file was deleted.

20 changes: 0 additions & 20 deletions tests/ui/lint/dead-code/lint-unused-adt-appeared-in-pattern.stderr

This file was deleted.

32 changes: 0 additions & 32 deletions tests/ui/lint/dead-code/not-lint-used-adt-appeared-in-pattern.rs

This file was deleted.

35 changes: 0 additions & 35 deletions tests/ui/lint/dead-code/unconstructible-pub-struct.rs

This file was deleted.

14 changes: 0 additions & 14 deletions tests/ui/lint/dead-code/unconstructible-pub-struct.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#![deny(dead_code)]

struct T1; //~ ERROR struct `T1` is never constructed
struct T2; //~ ERROR struct `T2` is never constructed
pub struct T3(i32); //~ ERROR struct `T3` is never constructed
pub struct T4(i32); //~ ERROR field `0` is never read
pub struct T2(i32); //~ ERROR field `0` is never read
struct T3;

trait Trait1 { //~ ERROR trait `Trait1` is never used
const UNUSED: i32;
@@ -12,13 +11,13 @@ trait Trait1 { //~ ERROR trait `Trait1` is never used
}

pub trait Trait2 {
const MAY_USED: i32;
fn may_used(&self) {}
const USED: i32;
fn used(&self) {}
}

pub trait Trait3 {
const MAY_USED: i32;
fn may_used() -> Self;
const USED: i32;
fn construct_self() -> Self;
}

impl Trait1 for T1 {
@@ -31,34 +30,23 @@ impl Trait1 for T1 {
impl Trait1 for T2 {
const UNUSED: i32 = 0;
fn construct_self() -> Self {
Self
T2(0)
}
}

impl Trait2 for T1 {
const MAY_USED: i32 = 0;
const USED: i32 = 0;
}

impl Trait2 for T2 {
const MAY_USED: i32 = 0;
}

impl Trait2 for T3 {
const MAY_USED: i32 = 0;
const USED: i32 = 0;
}

impl Trait3 for T2 {
const MAY_USED: i32 = 0;
fn may_used() -> Self {
impl Trait3 for T3 {
const USED: i32 = 0;
fn construct_self() -> Self {
Self
}
}

impl Trait3 for T4 {
const MAY_USED: i32 = 0;
fn may_used() -> Self {
T4(0)
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -10,33 +10,21 @@ note: the lint level is defined here
LL | #![deny(dead_code)]
| ^^^^^^^^^

error: struct `T2` is never constructed
--> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:4:8
|
LL | struct T2;
| ^^

error: struct `T3` is never constructed
--> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:5:12
|
LL | pub struct T3(i32);
| ^^

error: field `0` is never read
--> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:6:15
--> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:4:15
|
LL | pub struct T4(i32);
LL | pub struct T2(i32);
| -- ^^^
| |
| field in this struct
|
= help: consider removing this field

error: trait `Trait1` is never used
--> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:8:7
--> $DIR/unused-adt-impl-pub-trait-with-assoc-const.rs:7:7
|
LL | trait Trait1 {
| ^^^^^^

error: aborting due to 5 previous errors
error: aborting due to 3 previous errors

20 changes: 0 additions & 20 deletions tests/ui/lint/dead-code/unused-assoc-const.rs

This file was deleted.

16 changes: 0 additions & 16 deletions tests/ui/lint/dead-code/unused-assoc-const.stderr

This file was deleted.

45 changes: 0 additions & 45 deletions tests/ui/lint/dead-code/unused-impl-for-non-adts.rs

This file was deleted.

20 changes: 0 additions & 20 deletions tests/ui/lint/dead-code/unused-impl-for-non-adts.stderr

This file was deleted.

48 changes: 0 additions & 48 deletions tests/ui/lint/dead-code/unused-pub-struct.rs

This file was deleted.

14 changes: 0 additions & 14 deletions tests/ui/lint/dead-code/unused-pub-struct.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui/lint/dead-code/unused-struct-derive-default.rs
Original file line number Diff line number Diff line change
@@ -22,5 +22,4 @@ pub struct T2 {

fn main() {
let _x: Used = Default::default();
let _e: E = Default::default();
}
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ error: struct `T` is never constructed
LL | struct T;
| ^
|
= note: `T` has a derived impl for the trait `Default`, but this is intentionally ignored during dead code analysis
note: the lint level is defined here
--> $DIR/unused-struct-derive-default.rs:1:9
|
11 changes: 0 additions & 11 deletions tests/ui/lint/dead-code/unused-trait-with-assoc-ty.rs

This file was deleted.

20 changes: 0 additions & 20 deletions tests/ui/lint/dead-code/unused-trait-with-assoc-ty.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui/parser/issues/issue-105366.fixed
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ run-rustfix

#[allow(dead_code)]
struct Foo;

impl From<i32> for Foo {
1 change: 0 additions & 1 deletion tests/ui/parser/issues/issue-105366.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ run-rustfix

#[allow(dead_code)]
struct Foo;

fn From<i32> for Foo {
2 changes: 1 addition & 1 deletion tests/ui/parser/issues/issue-105366.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: you might have meant to write `impl` instead of `fn`
--> $DIR/issue-105366.rs:6:1
--> $DIR/issue-105366.rs:5:1
|
LL | fn From<i32> for Foo {
| ^^
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Regression test for issues #100790 and #106439.
//@ run-rustfix

#[allow(dead_code)]
pub struct Example(usize)
pub struct Example(#[allow(dead_code)] usize)
where
(): Sized;
//~^^^ ERROR where clauses are not allowed before tuple struct bodies
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Regression test for issues #100790 and #106439.
//@ run-rustfix

#[allow(dead_code)]
pub struct Example
where
(): Sized,
(usize);
(#[allow(dead_code)] usize);
//~^^^ ERROR where clauses are not allowed before tuple struct bodies

struct _Demo
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: where clauses are not allowed before tuple struct bodies
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:6:1
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:5:1
|
LL | pub struct Example
| ------- while parsing this tuple struct
LL | / where
LL | | (): Sized,
| |______________^ unexpected where clause
LL | (usize);
| ------- the struct body
LL | (#[allow(dead_code)] usize);
| --------------------------- the struct body
|
help: move the body before the where clause
|
LL ~ pub struct Example(usize)
LL ~ pub struct Example(#[allow(dead_code)] usize)
LL | where
LL ~ (): Sized;
|

error: where clauses are not allowed before tuple struct bodies
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:12:1
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:11:1
|
LL | struct _Demo
| ----- while parsing this tuple struct
2 changes: 1 addition & 1 deletion tests/ui/pattern/issue-22546.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ impl<T: ::std::fmt::Display> Foo<T> {
}
}

trait Tr {
trait Tr { //~ WARN trait `Tr` is never used
type U;
}

10 changes: 10 additions & 0 deletions tests/ui/pattern/issue-22546.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: trait `Tr` is never used
--> $DIR/issue-22546.rs:18:7
|
LL | trait Tr {
| ^^
|
= note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

3 changes: 1 addition & 2 deletions tests/ui/pub/pub-ident-struct-4.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-rustfix

#[allow(dead_code)]
pub struct T(String);
pub struct T(#[allow(dead_code)] String);
//~^ ERROR missing `struct` for struct definition

fn main() {}
3 changes: 1 addition & 2 deletions tests/ui/pub/pub-ident-struct-4.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-rustfix

#[allow(dead_code)]
pub T(String);
pub T(#[allow(dead_code)] String);
//~^ ERROR missing `struct` for struct definition

fn main() {}
6 changes: 3 additions & 3 deletions tests/ui/pub/pub-ident-struct-4.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error: missing `struct` for struct definition
--> $DIR/pub-ident-struct-4.rs:4:1
--> $DIR/pub-ident-struct-4.rs:3:1
|
LL | pub T(String);
LL | pub T(#[allow(dead_code)] String);
| ^^^^^
|
help: add `struct` here to parse `T` as a struct
|
LL | pub struct T(String);
LL | pub struct T(#[allow(dead_code)] String);
| ++++++

error: aborting due to 1 previous error
1 change: 0 additions & 1 deletion tests/ui/regions/regions-issue-21422.rs
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@

//@ pretty-expanded FIXME #23616

#[allow(dead_code)]
pub struct P<'a> {
_ptr: *const &'a u8,
}
2 changes: 0 additions & 2 deletions tests/ui/structs-enums/newtype-struct-with-dtor.rs
Original file line number Diff line number Diff line change
@@ -3,10 +3,8 @@
#![allow(unused_variables)]
//@ pretty-expanded FIXME #23616

#[allow(dead_code)]
pub struct Fd(u32);

#[allow(dead_code)]
fn foo(a: u32) {}

impl Drop for Fd {
3 changes: 1 addition & 2 deletions tests/ui/structs-enums/uninstantiable-struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
#[allow(dead_code)]
pub struct Z(&'static Z);
pub struct Z(#[allow(dead_code)] &'static Z);

pub fn main() {}
1 change: 0 additions & 1 deletion tests/ui/suggestions/derive-clone-for-eq.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-rustfix
// https://github.com/rust-lang/rust/issues/79076

#[allow(dead_code)]
#[derive(Clone, Eq)] //~ ERROR [E0277]
pub struct Struct<T: std::clone::Clone>(T);

1 change: 0 additions & 1 deletion tests/ui/suggestions/derive-clone-for-eq.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ run-rustfix
// https://github.com/rust-lang/rust/issues/79076

#[allow(dead_code)]
#[derive(Clone, Eq)] //~ ERROR [E0277]
pub struct Struct<T>(T);

4 changes: 2 additions & 2 deletions tests/ui/suggestions/derive-clone-for-eq.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0277]: the trait bound `T: Clone` is not satisfied
--> $DIR/derive-clone-for-eq.rs:5:17
--> $DIR/derive-clone-for-eq.rs:4:17
|
LL | #[derive(Clone, Eq)]
| ^^ the trait `Clone` is not implemented for `T`, which is required by `Struct<T>: PartialEq`
|
note: required for `Struct<T>` to implement `PartialEq`
--> $DIR/derive-clone-for-eq.rs:8:19
--> $DIR/derive-clone-for-eq.rs:7:19
|
LL | impl<T: Clone, U> PartialEq<U> for Struct<T>
| ----- ^^^^^^^^^^^^ ^^^^^^^^^
2 changes: 0 additions & 2 deletions tests/ui/suggestions/option-content-move.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-rustfix
#[allow(dead_code)]
pub struct LipogramCorpora {
selections: Vec<(char, Option<String>)>,
}
@@ -18,7 +17,6 @@ impl LipogramCorpora {
}
}

#[allow(dead_code)]
pub struct LipogramCorpora2 {
selections: Vec<(char, Result<String, String>)>,
}
2 changes: 0 additions & 2 deletions tests/ui/suggestions/option-content-move.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-rustfix
#[allow(dead_code)]
pub struct LipogramCorpora {
selections: Vec<(char, Option<String>)>,
}
@@ -18,7 +17,6 @@ impl LipogramCorpora {
}
}

#[allow(dead_code)]
pub struct LipogramCorpora2 {
selections: Vec<(char, Result<String, String>)>,
}
4 changes: 2 additions & 2 deletions tests/ui/suggestions/option-content-move.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0507]: cannot move out of `selection.1` which is behind a shared reference
--> $DIR/option-content-move.rs:11:20
--> $DIR/option-content-move.rs:10:20
|
LL | if selection.1.unwrap().contains(selection.0) {
| ^^^^^^^^^^^ -------- `selection.1` moved due to this method call
@@ -19,7 +19,7 @@ LL | if selection.1.clone().unwrap().contains(selection.0) {
| ++++++++

error[E0507]: cannot move out of `selection.1` which is behind a shared reference
--> $DIR/option-content-move.rs:30:20
--> $DIR/option-content-move.rs:28:20
|
LL | if selection.1.unwrap().contains(selection.0) {
| ^^^^^^^^^^^ -------- `selection.1` moved due to this method call
1 change: 0 additions & 1 deletion tests/ui/traits/object/generics.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ pub trait Trait2<A> {
fn doit(&self) -> A;
}

#[allow(dead_code)]
pub struct Impl<A1, A2, A3> {
m1: marker::PhantomData<(A1,A2,A3)>,
/*