Skip to content

Commit 71080dd

Browse files
committed
Document how removing a type's field can be bad and what to do instead
Related to #119645
1 parent 3314d5c commit 71080dd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+14
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,20 @@ declare_lint! {
702702
/// `PhantomData`.
703703
///
704704
/// Otherwise consider removing the unused code.
705+
///
706+
/// ### Limitations
707+
///
708+
/// Removing fields that are only used for side-effects and never
709+
/// read will result in behavioral changes. Examples of this
710+
/// include:
711+
///
712+
/// - If a field's value performs an action when it is dropped.
713+
/// - If a field's type does not implement an auto trait
714+
/// (e.g. `Send`, `Sync`, `Unpin`).
715+
///
716+
/// For side-effects from dropping field values, this lint should
717+
/// be allowed on those fields. For side-effects from containing
718+
/// field types, `PhantomData` should be used.
705719
pub DEAD_CODE,
706720
Warn,
707721
"detect unused, unexported items"

0 commit comments

Comments
 (0)