about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-14 11:09:57 +0100
committerGitHub <noreply@github.com>2024-03-14 11:09:57 +0100
commit7a744af83e8ae17444dd040093ceb5f7e97bf170 (patch)
tree715eda59f3c9b6a4fdd429d324146f71bb46e395
parentfce6e752ab8b5fa3830994adbbf5c4344dac88f9 (diff)
parent71080dd1d45007e9f806bb913cae47531c4dee12 (diff)
Rollup merge of #121899 - shepmaster:dead-code-docs, r=wesleywiser
Document how removing a type's field can be bad and what to do instead

Related to #119645
-rw-r--r--compiler/rustc_lint_defs/src/builtin.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index 20e492dbd8a..f384f66a2c3 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -704,6 +704,20 @@ declare_lint! {
     /// `PhantomData`.
     ///
     /// Otherwise consider removing the unused code.
+    ///
+    /// ### Limitations
+    ///
+    /// Removing fields that are only used for side-effects and never
+    /// read will result in behavioral changes. Examples of this
+    /// include:
+    ///
+    /// - If a field's value performs an action when it is dropped.
+    /// - If a field's type does not implement an auto trait
+    ///   (e.g. `Send`, `Sync`, `Unpin`).
+    ///
+    /// For side-effects from dropping field values, this lint should
+    /// be allowed on those fields. For side-effects from containing
+    /// field types, `PhantomData` should be used.
     pub DEAD_CODE,
     Warn,
     "detect unused, unexported items"