Skip to content

drop derive helpers during attribute parsing#153540

Open
scrabsha wants to merge 3 commits intorust-lang:mainfrom
scrabsha:sasha/drop-derive-helpers
Open

drop derive helpers during attribute parsing#153540
scrabsha wants to merge 3 commits intorust-lang:mainfrom
scrabsha:sasha/drop-derive-helpers

Conversation

@scrabsha
Copy link
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
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
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
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
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
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
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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter out derive helper attributes while lowering

6 participants