Suppress unreachable_code lint in derive(PartialEq, Clone)#154910
Suppress unreachable_code lint in derive(PartialEq, Clone)#154910rust-bors[bot] merged 3 commits intorust-lang:mainfrom
unreachable_code lint in derive(PartialEq, Clone)#154910Conversation
|
Changes to the code generated for builtin derived traits. cc @nnethercote |
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
I was going to say that some people may forbid the lint, but fortunately that doesn't seems to be the case. |
There was a problem hiding this comment.
I'm surprised by the diff on deriving-all-codegen.stdout. The code looks like it goes to some effort to only produce #[allow(unreachable_code)] on types where it's needed (those involving !) and yet the output has that attribute on the derived clone for every type.
What I was expecting: all the existing examples in deriving-all-codegen.stdout would be unchanged, and there would be some new types added that contain ! and have unreachable_code in their output.
|
@Urgau There are people who The |
|
@nnethercote the macros don't have access to type information, so they can't know if a type contains |
|
I see. Is it worth going to the effort to check if there are any fields? You could just slap |
2272c28 to
b15273b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@nnethercote I think I did the check originally thinking it could be more precise (and thus useful), but in the state I ended up in it was indeed somewhat useless. I simplified code by just indeed always adding the |
This comment has been minimized.
This comment has been minimized.
b15273b to
f5a59d1
Compare
|
Makes sense. Is the forbid(unused) issue a showstopper for this? |
|
These derived impls all have |
Yes... with this change |
This is relevant for `derive(Clone, PartialEq)` on adts with fields of type never.
f5a59d1 to
ddf9d4c
Compare
I'm not sure disabling all lints is a good idea, and it's definitely not something I want to work on right now. However disabling unreachable code specifically seems simple enough. I updated the code to do that instead of adding |
|
@bors r+ rollup |
…uwer Rollup of 15 pull requests Successful merges: - #153995 (Use convergent attribute to funcs for GPU targets) - #154184 (stabilize s390x vector registers) - #151898 (constify DoubleEndedIterator) - #154235 (remove unnecessary variables and delimiter check) - #154473 (move borrow checker tests) - #154745 (Replace span_look_ahead with span_followed_by) - #154778 (make field representing types invariant over the base type) - #154867 (Fix private fields diagnostics and improve error messages) - #154879 (Don't store `pattern_ty` in `TestableCase`) - #154910 (Suppress `unreachable_code` lint in `derive(PartialEq, Clone)`) - #154923 (Fix ICE in next-solver dyn-compatibility check) - #154934 (Add getters for `rustc_pattern_analysis::constructor::Slice` fields) - #154938 (match exhaustiveness: Show the guard exhaustivity note only when it's the guards alone that cause non-exhaustiveness) - #154961 (Use derived impl for `GappedRange` subdiagnostic) - #154980 (rustc-dev-guide subtree update)
|
@nnethercote thanks a lot for your review! it turned a lot better indeed :) |
…uwer Rollup of 15 pull requests Successful merges: - rust-lang/rust#153995 (Use convergent attribute to funcs for GPU targets) - rust-lang/rust#154184 (stabilize s390x vector registers) - rust-lang/rust#151898 (constify DoubleEndedIterator) - rust-lang/rust#154235 (remove unnecessary variables and delimiter check) - rust-lang/rust#154473 (move borrow checker tests) - rust-lang/rust#154745 (Replace span_look_ahead with span_followed_by) - rust-lang/rust#154778 (make field representing types invariant over the base type) - rust-lang/rust#154867 (Fix private fields diagnostics and improve error messages) - rust-lang/rust#154879 (Don't store `pattern_ty` in `TestableCase`) - rust-lang/rust#154910 (Suppress `unreachable_code` lint in `derive(PartialEq, Clone)`) - rust-lang/rust#154923 (Fix ICE in next-solver dyn-compatibility check) - rust-lang/rust#154934 (Add getters for `rustc_pattern_analysis::constructor::Slice` fields) - rust-lang/rust#154938 (match exhaustiveness: Show the guard exhaustivity note only when it's the guards alone that cause non-exhaustiveness) - rust-lang/rust#154961 (Use derived impl for `GappedRange` subdiagnostic) - rust-lang/rust#154980 (rustc-dev-guide subtree update)
Resolves #154900