Skip to content

Commit 7a744af

Browse files
authored
Rollup merge of rust-lang#121899 - shepmaster:dead-code-docs, r=wesleywiser
Document how removing a type's field can be bad and what to do instead Related to rust-lang#119645
2 parents fce6e75 + 71080dd commit 7a744af

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
@@ -704,6 +704,20 @@ declare_lint! {
704704
/// `PhantomData`.
705705
///
706706
/// Otherwise consider removing the unused code.
707+
///
708+
/// ### Limitations
709+
///
710+
/// Removing fields that are only used for side-effects and never
711+
/// read will result in behavioral changes. Examples of this
712+
/// include:
713+
///
714+
/// - If a field's value performs an action when it is dropped.
715+
/// - If a field's type does not implement an auto trait
716+
/// (e.g. `Send`, `Sync`, `Unpin`).
717+
///
718+
/// For side-effects from dropping field values, this lint should
719+
/// be allowed on those fields. For side-effects from containing
720+
/// field types, `PhantomData` should be used.
707721
pub DEAD_CODE,
708722
Warn,
709723
"detect unused, unexported items"

0 commit comments

Comments
 (0)