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
This commit is contained in:
Matthias Krüger 2024-03-14 11:09:57 +01:00 committed by GitHub
commit 7a744af83e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"