Skip to content

drop derive helpers during attribute parsing#153540

Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
scrabsha:sasha/drop-derive-helpers
Mar 23, 2026
Merged

drop derive helpers during attribute parsing#153540
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
scrabsha:sasha/drop-derive-helpers

Conversation

@scrabsha
Copy link
Copy Markdown
Contributor

@scrabsha scrabsha commented Mar 7, 2026

fixes #153102.

first two commits (7db3f6e, 0033b31) move attribute target checks from rustc_passes to rustc_attr_parsing. last commit (38f62ee) actually fixes the issue.

the diagnostics slightly regressed and i'm not super happy about it, but i doubt there's much we can do to avoid that.

r? @jdonszelmann
r? @JonathanBrouwer

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 7, 2026

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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 Mar 7, 2026
@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch from 38f62ee to 676a6d9 Compare March 8, 2026 10:29
@rustbot rustbot 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 Mar 8, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 8, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch from 676a6d9 to 88e1141 Compare March 12, 2026 21:55
@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 Mar 12, 2026
@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch from 88e1141 to 3b5896d Compare March 12, 2026 22:06
@rust-bors

This comment has been minimized.

@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch from 3b5896d to 0dfbffd Compare March 17, 2026 20:47
@rustbot

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer self-assigned this Mar 20, 2026
@rustbot rustbot 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 Mar 20, 2026
@rust-bors

This comment has been minimized.

@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch from 0dfbffd to a01ee9d Compare March 20, 2026 22:38
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch 2 times, most recently from da15086 to 54402b6 Compare March 21, 2026 23:19
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 21, 2026

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.

@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 Mar 21, 2026
@scrabsha
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rust-log-analyzer

This comment has been minimized.

@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch from 54402b6 to 443cce5 Compare March 21, 2026 23:25
@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
PR_CI_JOB set; skipping tidy
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
---

9    |
10 LL | union U {
11    | ^^^^^^^
-    = note: add `#[derive(Debug)]` to `U` or manually `impl Debug for U`
+    = note: manually `impl Debug for U`
13 
14 error[E0369]: binary operation `==` cannot be applied to type `U`
15   --> $DIR/union-no-derive-suggestion.rs:22:15


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args union/union-no-derive-suggestion.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
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/union/union-no-derive-suggestion.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)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/union/union-no-derive-suggestion" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0277]: `U` doesn't implement `Debug`
##[error]  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:19:15
   |
LL |     println!("{u:?}"); //~ ERROR `U` doesn't implement `Debug`
   |               ^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
help: the trait `Debug` is not implemented for `U`
  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:5:1
   |
LL | union U { //~ HELP consider annotating `U` with `#[derive(Clone)]`
   | ^^^^^^^
   = note: manually `impl Debug for U`

error[E0369]: binary operation `==` cannot be applied to type `U`
##[error]  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:22:15
   |
LL |     let _ = u == U { a: 0 }; //~ ERROR binary operation `==` cannot be applied to type `U`
   |             - ^^ ---------- U
   |             |
   |             U
   |
note: an implementation of `PartialEq` might be missing for `U`
  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:5:1
   |
LL | union U { //~ HELP consider annotating `U` with `#[derive(Clone)]`
   | ^^^^^^^ must implement `PartialEq`
note: the trait `PartialEq` must be implemented
  --> /rustc/FAKE_PREFIX/library/core/src/cmp.rs:251:0

error[E0369]: binary operation `<` cannot be applied to type `U`
##[error]  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:25:15
   |
LL |     let _ = u < U { a: 1 }; //~ ERROR binary operation `<` cannot be applied to type `U`
   |             - ^ ---------- U
   |             |
   |             U
   |
note: an implementation of `PartialOrd` might be missing for `U`
  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:5:1
   |
LL | union U { //~ HELP consider annotating `U` with `#[derive(Clone)]`
   | ^^^^^^^ must implement `PartialOrd`
note: the trait `PartialOrd` must be implemented
  --> /rustc/FAKE_PREFIX/library/core/src/cmp.rs:1367:0

error[E0277]: the trait bound `U: Default` is not satisfied
##[error]  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:28:16
   |
LL |     let _: U = Default::default(); //~ ERROR the trait bound `U: Default` is not satisfied
   |                ^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `Default` is not implemented for `U`
  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:5:1
   |
LL | union U { //~ HELP consider annotating `U` with `#[derive(Clone)]`
   | ^^^^^^^

error[E0277]: the trait bound `U: Hash` is not satisfied
##[error]  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:31:27
   |
LL |     std::hash::Hash::hash(&u, &mut h); //~ ERROR the trait bound `U: Hash` is not satisfied
   |     --------------------- ^^ unsatisfied trait bound
   |     |
   |     required by a bound introduced by this call
   |
help: the trait `Hash` is not implemented for `U`
  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:5:1
   |
LL | union U { //~ HELP consider annotating `U` with `#[derive(Clone)]`
   | ^^^^^^^

error[E0277]: the trait bound `U: Clone` is not satisfied
##[error]  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:34:9
   |
LL |     x::<U>(); //~ ERROR the trait bound `U: Clone` is not satisfied
   |         ^ the trait `Clone` is not implemented for `U`
   |
note: required by a bound in `x`
  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:13:9
   |
LL | fn x<T: Clone>() {}
   |         ^^^^^ required by this bound in `x`
help: consider annotating `U` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | union U { //~ HELP consider annotating `U` with `#[derive(Clone)]`
   |

error[E0277]: the trait bound `U: Copy` is not satisfied
##[error]  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:36:9
   |
LL |     y::<U>(); //~ ERROR the trait bound `U: Copy` is not satisfied
   |         ^ the trait `Copy` is not implemented for `U`
   |
note: required by a bound in `y`
  --> /checkout/tests/ui/union/union-no-derive-suggestion.rs:14:9
   |
LL | fn y<T: Copy>() {}
   |         ^^^^ required by this bound in `y`
help: consider annotating `U` with `#[derive(Copy)]`
   |
LL + #[derive(Copy)]
LL | union U { //~ HELP consider annotating `U` with `#[derive(Clone)]`
   |

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0277, E0369.

@scrabsha scrabsha force-pushed the sasha/drop-derive-helpers branch from 443cce5 to 29e9273 Compare March 22, 2026 07:59
@jdonszelmann
Copy link
Copy Markdown
Contributor

very good! Gave it a final pass, not entirely thrilled by the source map code but it's much better than the alternative I think.

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 23, 2026

📌 Commit 29e9273 has been approved by jdonszelmann

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Mar 23, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 23, 2026
…, r=jdonszelmann

drop derive helpers during attribute parsing
rust-bors bot pushed a commit that referenced this pull request Mar 23, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #154241 (`rust-analyzer` subtree update)
 - #153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - #154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - #153069 ([BPF] add target feature allows-misaligned-mem-access)
 - #154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - #154191 (refactor RangeFromIter overflow-checks impl)
 - #154207 (Refactor query loading)
 - #153540 (drop derive helpers during attribute parsing)
 - #154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - #154161 (On E0277 tweak help when single type impls traits)
 - #154218 (interpret/validity: remove unreachable error kind)
 - #154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - #154228 (Improve inline assembly error messages)
@rust-bors rust-bors bot merged commit 37d76a5 into rust-lang:main Mar 23, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 23, 2026
@scrabsha scrabsha deleted the sasha/drop-derive-helpers branch March 24, 2026 18:36
github-actions bot pushed a commit to rust-lang/stdarch that referenced this pull request Mar 26, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#154241 (`rust-analyzer` subtree update)
 - rust-lang/rust#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - rust-lang/rust#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - rust-lang/rust#153069 ([BPF] add target feature allows-misaligned-mem-access)
 - rust-lang/rust#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - rust-lang/rust#154191 (refactor RangeFromIter overflow-checks impl)
 - rust-lang/rust#154207 (Refactor query loading)
 - rust-lang/rust#153540 (drop derive helpers during attribute parsing)
 - rust-lang/rust#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - rust-lang/rust#154161 (On E0277 tweak help when single type impls traits)
 - rust-lang/rust#154218 (interpret/validity: remove unreachable error kind)
 - rust-lang/rust#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - rust-lang/rust#154228 (Improve inline assembly error messages)
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Mar 26, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#154241 (`rust-analyzer` subtree update)
 - rust-lang/rust#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - rust-lang/rust#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - rust-lang/rust#153069 ([BPF] add target feature allows-misaligned-mem-access)
 - rust-lang/rust#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - rust-lang/rust#154191 (refactor RangeFromIter overflow-checks impl)
 - rust-lang/rust#154207 (Refactor query loading)
 - rust-lang/rust#153540 (drop derive helpers during attribute parsing)
 - rust-lang/rust#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - rust-lang/rust#154161 (On E0277 tweak help when single type impls traits)
 - rust-lang/rust#154218 (interpret/validity: remove unreachable error kind)
 - rust-lang/rust#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - rust-lang/rust#154228 (Improve inline assembly error messages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) 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

Development

Successfully merging this pull request may close these issues.

Filter out derive helper attributes while lowering

6 participants