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

Remove attributes from generics in built-in derive macros #132651

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

PonasKovas
Copy link
Contributor

Related issue #132561

Removes all attributes from generics in the expanded implementations of built-in derive macros.

@rustbot
Copy link
Collaborator

rustbot commented Nov 5, 2024

r? @nnethercote

rustbot has assigned @nnethercote.
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. labels Nov 5, 2024
@fmease fmease added the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label Nov 5, 2024
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add regression tests for #132561?

@fmease fmease removed the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label Nov 5, 2024
@fmease fmease self-assigned this Nov 5, 2024
@fmease
Copy link
Member

fmease commented Nov 5, 2024

Note to others: This is consistent with the current behavior for type parameters.

I've thought about the change proposed here and while technically technically speaking it's a breaking change, I don't think it's observable by the user -- apart from affecting the emission of lints

  1. which is mostly(?) excluded from Rust's stability guarantees
  2. which is unreachable/masked anyway due to a bug, cc Lint control attributes (allow/deny/etc) have no effect on lifetime and const parameters #61552

@nnethercote nnethercote removed their assignment Nov 6, 2024
@nnethercote
Copy link
Contributor

@fmease, I'll pass the review to you.

@PonasKovas PonasKovas requested a review from fmease November 6, 2024 17:52
@PonasKovas
Copy link
Contributor Author

@fmease Is there a problem? I don't want to be annoying or rush things, just wondering. My project is partially blocked by this bug, so I'm just not sure if I am to expect a fix (whether this PR, or something else) to be merged in a relatively short time frame, or should I just use a workaround in my project for now?

Again, I don't want to rush anything, just want to know what is the situation 😅

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, one suggestion

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs Outdated Show resolved Hide resolved
.map(|mut param| {
// Remove all attributes, because there might be helper attributes
// from other macros that will not be valid in the expanded implementation.
param.attrs = ThinVec::new();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, we clear the attrs of the param after having cloned the entire param. As a result we clone the attrs only to throw them away. However, avoiding this makes the code more awkward. I've just noticed that we also needlessly clone const parameter defaults. Er, this could be addressed in a separate PR, if need be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the compiler would optimize it away, and writing it like this is easier to read?

Either way, if this whole thing might be significantly changed in the near future by addressing the real bug here (#61552), I don't think it's necessary to do anything about it in this PR

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2024
@PonasKovas PonasKovas requested a review from fmease November 11, 2024 17:29
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 11, 2024
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I forgot to say, could you squash into one commit? Then I'll place it into merge queue.

add a test

add github issue link to description of the test

replace new ThinVec with clear()

Co-authored-by: León Orell Valerian Liehr <[email protected]>
@PonasKovas
Copy link
Contributor Author

@fmease Done

@fmease
Copy link
Member

fmease commented Nov 11, 2024

#132651 (comment)

This is clearly a bug fix and doesn't need T-lang involvement (cc rust-lang/lang-team#290).
Therefore I'll unilaterally approve this PR.

@bors r+

@bors
Copy link
Contributor

bors commented Nov 11, 2024

📌 Commit 7c0a7f7 has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#132651 (Remove attributes from generics in built-in derive macros)
 - rust-lang#132668 (Feature gate yield expressions not in 2024)
 - rust-lang#132771 (test(configure): cover `parse_args` in `src/bootstrap/configure.py`)
 - rust-lang#132895 (Generalize `NonNull::from_raw_parts` per ACP362)
 - rust-lang#132914 (Update grammar in std::cell docs.)
 - rust-lang#132927 (Consolidate type system const evaluation under `traits::evaluate_const`)
 - rust-lang#132935 (Make sure to ignore elided lifetimes when pointing at args for fulfillment errors)
 - rust-lang#132941 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b18ee98 into rust-lang:master Nov 12, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 12, 2024
Rollup merge of rust-lang#132651 - PonasKovas:master, r=fmease

Remove attributes from generics in built-in derive macros

Related issue rust-lang#132561

Removes all attributes from generics in the expanded implementations of built-in derive macros.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants