From 95183ec529e176f033bc074fd4f137c9e203661d Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Tue, 5 Apr 2022 20:33:06 +1000 Subject: [PATCH] Fix dead_code lint --- compiler/rustc_passes/src/dead.rs | 5 +++++ library/core/src/clone.rs | 1 + 2 files changed, 6 insertions(+) diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index c777074df4641..f000ff50362ac 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -268,6 +268,11 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } return true; } + + // ignore generated `DerivedClone` but do not expose this to users. + if Some(trait_of) == self.tcx.get_diagnostic_item(sym::DerivedClone) { + return true; + } } } diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index af0c8aa2ee790..1c8c1f27a62dc 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -178,6 +178,7 @@ pub struct AssertParamIsCopy { reason = "deriving hack, should not be public", issue = "none" )] +#[rustc_diagnostic_item = "DerivedClone"] pub trait DerivedClone: Sized { fn clone(&self) -> Self; }