Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how removing a type's field can be bad and what to do instead #121899

Merged
merged 1 commit into from Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Expand Up @@ -702,6 +702,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"
Expand Down