Skip to content

Mark PartialEq as #[rustc_trivial_field_reads] #143487

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

GrigorenkoPV
Copy link
Contributor

@GrigorenkoPV GrigorenkoPV commented Jul 5, 2025

Closes #134588

Probably needs a crater run

@rustbot
Copy link
Collaborator

rustbot commented Jul 5, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 5, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@fmease
Copy link
Member

fmease commented Jul 5, 2025

Probably needs a crater run

I'm pretty sure you'd have to bump dead_code to deny-by-default but only for struct fields (somehow), otherwise it wouldn't get caught by crater (additional warnings don't make a run fail IINM) unless you're only interested in crates that deny/forbid dead_code.

@rustbot
Copy link
Collaborator

rustbot commented Jul 6, 2025

Some changes occurred in exhaustiveness checking

cc @Nadrieril

@rust-log-analyzer

This comment has been minimized.

@fee1-dead
Copy link
Member

This seems like another contentious thing. I'd recommend getting some discussion first (see also #134588 (comment)), maybe on T-lang Zulip.

I wouldn't mind if we use an allow-by-default lint for this, but at present it doesn't look like a trivial change. Maybe incorporate to clippy is another option?

@fee1-dead fee1-dead added S-waiting-on-concerns Status: Awaiting concerns to be addressed by the author and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

@rust-log-analyzer

This comment has been minimized.

@GrigorenkoPV GrigorenkoPV force-pushed the lints/partial-eq-is-dead branch from 69ccdf5 to c0a2f46 Compare July 7, 2025 14:47
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
normalized stderr:
warning: field `0` is never read
##[warning]  --> $DIR/mutually-recursive-types.rs:16:14
   |
LL |     Children(Box<List>),
   |     -------- ^^^^^^^^^
   |     |
   |     field in this variant
   |
   = note: `Tree` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
LL -     Children(Box<List>),
LL +     Children(()),
   |

warning: field `0` is never read
##[warning]  --> $DIR/mutually-recursive-types.rs:17:10
   |
LL |     Leaf(Colour),
   |     ---- ^^^^^^
   |     |
   |     field in this variant
   |
   = note: `Tree` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
LL -     Leaf(Colour),
LL +     Leaf(()),
   |

warning: fields `0` and `1` are never read
##[warning]  --> $DIR/mutually-recursive-types.rs:22:10
   |
LL |     Cons(Box<Tree>, Box<List>),
   |     ---- ^^^^^^^^^  ^^^^^^^^^
   |     |
   |     fields in this variant
   |
   = note: `List` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
   |
LL -     Cons(Box<Tree>, Box<List>),
LL +     Cons((), ()),
   |

warning: fields `0` and `1` are never read
##[warning]  --> $DIR/mutually-recursive-types.rs:28:10
   |
LL |     Kons(isize, Box<SmallList>),
   |     ---- ^^^^^  ^^^^^^^^^^^^^^
   |     |
   |     fields in this variant
   |
   = note: `SmallList` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
   |
LL -     Kons(isize, Box<SmallList>),
LL +     Kons((), ()),
   |

warning: 4 warnings emitted


---
To only update this specific test, also pass `--test-args type/mutually-recursive-types.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/type/mutually-recursive-types.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "-O" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/type/mutually-recursive-types/a" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
warning: field `0` is never read
##[warning]  --> /checkout/tests/ui/type/mutually-recursive-types.rs:16:14
   |
LL |     Children(Box<List>),
   |     -------- ^^^^^^^^^
   |     |
   |     field in this variant
   |
   = note: `Tree` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
LL -     Children(Box<List>),
LL +     Children(()),
   |

warning: field `0` is never read
##[warning]  --> /checkout/tests/ui/type/mutually-recursive-types.rs:17:10
   |
LL |     Leaf(Colour),
   |     ---- ^^^^^^
   |     |
   |     field in this variant
   |
   = note: `Tree` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
LL -     Leaf(Colour),
LL +     Leaf(()),
   |

warning: fields `0` and `1` are never read
##[warning]  --> /checkout/tests/ui/type/mutually-recursive-types.rs:22:10
   |
LL |     Cons(Box<Tree>, Box<List>),
   |     ---- ^^^^^^^^^  ^^^^^^^^^
   |     |
   |     fields in this variant
   |
   = note: `List` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
   |
LL -     Cons(Box<Tree>, Box<List>),
LL +     Cons((), ()),
   |

warning: fields `0` and `1` are never read
##[warning]  --> /checkout/tests/ui/type/mutually-recursive-types.rs:28:10
   |
LL |     Kons(isize, Box<SmallList>),
   |     ---- ^^^^^  ^^^^^^^^^^^^^^
   |     |
   |     fields in this variant
   |
   = note: `SmallList` has derived impls for the traits `PartialEq` and `Debug`, but these are intentionally ignored during dead code analysis
help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
   |
LL -     Kons(isize, Box<SmallList>),
LL +     Kons((), ()),
   |

warning: 4 warnings emitted
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-concerns Status: Awaiting concerns to be addressed by the author T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

derive(PartialEq) should not prevent "field is never read" warnings
5 participants