Skip to content

Commit 456b039

Browse files
committed
Remove rustc_trivial_field_reads from trait Default
1 parent c215d30 commit 456b039

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

library/core/src/default.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ use crate::ascii::Char as AsciiChar;
105105
#[stable(feature = "rust1", since = "1.0.0")]
106106
#[const_trait]
107107
#[rustc_const_unstable(feature = "const_default", issue = "none")]
108-
#[rustc_trivial_field_reads]
109108
pub trait Default: Sized {
110109
/// Returns the "default value" for a type.
111110
///

src/tools/clippy/clippy_utils/src/hir_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type SpanlessEqCallback<'a> = dyn FnMut(&Expr<'_>, &Expr<'_>) -> bool + 'a;
2626

2727
/// Determines how paths are hashed and compared for equality.
2828
#[derive(Copy, Clone, Debug, Default)]
29-
#[allow(dead_code)]
3029
pub enum PathCheck {
3130
/// Paths must match exactly and are hashed by their exact HIR tree.
3231
///

tests/ui/deriving/deriving-default-enum.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ run-pass
2-
#![allow(dead_code)]
32

43
// nb: does not impl Default
54
#[derive(Debug, PartialEq)]
@@ -9,6 +8,7 @@ struct NotDefault;
98
enum Foo {
109
#[default]
1110
Alpha,
11+
#[allow(dead_code)]
1212
Beta(NotDefault),
1313
}
1414

@@ -17,6 +17,7 @@ enum Foo {
1717
enum MyOption<T> {
1818
#[default]
1919
None,
20+
#[allow(dead_code)]
2021
Some(T),
2122
}
2223

tests/ui/lint/dead-code/unused-struct-derive-default.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ struct Used;
99
#[derive(Default)]
1010
enum E { //~ NOTE variants in this enum
1111
#[default]
12-
A, //~ ERROR variants `A` and `B` are never constructed
13-
//~^ NOTE `E` has a derived impl for the trait `Default`, but this is intentionally ignored during dead code analysis
14-
B,
12+
A,
13+
B, //~ ERROR variant `B` is never constructed
1514
}
1615

1716
// external crate can call T2::default() to construct T2,

tests/ui/lint/dead-code/unused-struct-derive-default.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ note: the lint level is defined here
1010
LL | #![deny(dead_code)]
1111
| ^^^^^^^^^
1212

13-
error: variants `A` and `B` are never constructed
14-
--> $DIR/unused-struct-derive-default.rs:12:5
13+
error: variant `B` is never constructed
14+
--> $DIR/unused-struct-derive-default.rs:13:5
1515
|
1616
LL | enum E {
17-
| - variants in this enum
18-
LL | #[default]
19-
LL | A,
20-
| ^
21-
LL |
17+
| - variant in this enum
18+
...
2219
LL | B,
2320
| ^
24-
|
25-
= note: `E` has a derived impl for the trait `Default`, but this is intentionally ignored during dead code analysis
2621

2722
error: aborting due to 2 previous errors
2823

0 commit comments

Comments
 (0)