From 5d08a54141c180e2a6907f5e10c939864e0328a0 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Tue, 25 Jun 2024 23:29:44 +0800 Subject: [PATCH] Detect unused structs which derived Default --- alloc/src/sync/tests.rs | 2 +- core/src/default.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/alloc/src/sync/tests.rs b/alloc/src/sync/tests.rs index 49eae718c1690..1b123aa58f205 100644 --- a/alloc/src/sync/tests.rs +++ b/alloc/src/sync/tests.rs @@ -396,7 +396,7 @@ fn show_arc() { // Make sure deriving works with Arc #[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)] -struct Foo { +struct _Foo { inner: Arc, } diff --git a/core/src/default.rs b/core/src/default.rs index 4524b352ec817..5cacedcb241a5 100644 --- a/core/src/default.rs +++ b/core/src/default.rs @@ -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. ///