Skip to content

Port #[should_panic] to the new attribute parsing infrastructure #143808

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 2 commits into
base: master
Choose a base branch
from

Conversation

JonathanBrouwer
Copy link
Contributor

Ports #[should_panic] to the new attribute parsing infrastructure for #131229 (comment)

r? @jdonszelmann

@rustbot
Copy link
Collaborator

rustbot commented Jul 11, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@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 Jul 11, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 11, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

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

cc @jdonszelmann

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 11, 2025
@@ -1,4 +1,3 @@
//@ check-pass
Copy link
Contributor Author

@JonathanBrouwer JonathanBrouwer Jul 11, 2025

Choose a reason for hiding this comment

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

This is a breaking change! Malformed should_panic attributes have had the following warning since 2016:

warning: argument must be of the form: `expected = "error message"`
 --> src/main.rs:5:1
  |
5 | #[should_panic(expected = "foo", bar)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: errors in this attribute were erroneously allowed and will become a hard error in a future release

This PR makes this an error.

As discussed in #142838 (comment), we can make breaking changes as long as we do a crater run. So this PR needs a crater run.

Copy link
Contributor Author

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

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

This issue is currently NOT solved by this PR.
We can do this in a future PR or now, but we should decide whether this should be a warning or error:
#143799

@bors
Copy link
Collaborator

bors commented Jul 12, 2025

☔ The latest upstream changes (presumably #143810) made this pull request unmergeable. Please resolve the merge conflicts.

@JonathanBrouwer
Copy link
Contributor Author

^ Rebased on #143796
@rustbot ready

I'd propose to do #143799 in a separate PR, as I think it's more likely to fail crater than the change in this PR

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 13, 2025
@bors
Copy link
Collaborator

bors commented Jul 14, 2025

☔ The latest upstream changes (presumably #143779) made this pull request unmergeable. Please resolve the merge conflicts.

@JonathanBrouwer JonathanBrouwer force-pushed the should_panic_parser branch 2 times, most recently from bee8d3d to 4b68dc9 Compare July 15, 2025 11:59
@bors
Copy link
Collaborator

bors commented Jul 17, 2025

☔ The latest upstream changes (presumably #144044) made this pull request unmergeable. Please resolve the merge conflicts.

@jdonszelmann
Copy link
Contributor

@bors try

@bors
Copy link
Collaborator

bors commented Jul 17, 2025

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout should_panic_parser (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self should_panic_parser --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging compiler/rustc_passes/src/check_attr.rs
Auto-merging compiler/rustc_parse/src/validate_attr.rs
Auto-merging compiler/rustc_hir/src/hir.rs
Auto-merging compiler/rustc_builtin_macros/src/test.rs
CONFLICT (content): Merge conflict in compiler/rustc_builtin_macros/src/test.rs
Auto-merging compiler/rustc_attr_parsing/src/context.rs
Auto-merging compiler/rustc_attr_data_structures/src/encode_cross_crate.rs
Auto-merging compiler/rustc_attr_data_structures/src/attributes.rs
Automatic merge failed; fix conflicts and then commit the result.

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
@jdonszelmann
Copy link
Contributor

@bors try

bors added a commit that referenced this pull request Jul 17, 2025
Port `#[should_panic]` to the new attribute parsing infrastructure

Ports `#[should_panic]` to the new attribute parsing infrastructure for #131229 (comment)

r? `@jdonszelmann`
@craterbot craterbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 21, 2025
@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Jul 21, 2025

Crater analysis:

  • One crate uses the invalid #[should_panic("Expecting char. Identifier found")]
  • One crate used the invalid #[should_panic()]
  • One crate uses the invalid #[should_panic()]
  • I'm a little confused on this one, it does not seem like the kind of error that would be spurious, but also completely unrelated to the PR

So 3 regressions, the rest is all spurious.

@jdonszelmann I think calling in the lang team for a decision is next?

@jdonszelmann
Copy link
Contributor

@rust-lang/lang ?

@traviscross traviscross added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 25, 2025
@traviscross
Copy link
Contributor

If we could please make PRs to the three affected crates, that'd be good, as it's something the team might ask to see.

Otherwise, this sounds right to me, so let's...

@rfcbot fcp merge

cc @rust-lang/lang-docs

@traviscross

This comment was marked as duplicate.

@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Jul 25, 2025

@traviscross
I've submitted the PRs:
cre-chan/MCIR#1
KijitoraFinch/Fuchu#5
masaimahapa/rust-simple-die#1

@traviscross

This comment was marked as duplicate.

@traviscross traviscross added the T-lang Relevant to the language team label Jul 25, 2025
@traviscross

This comment was marked as duplicate.

@rfcbot
Copy link
Collaborator

rfcbot commented Jul 25, 2025

Team member @traviscross has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jul 25, 2025
@joshtriplett
Copy link
Member

This seems fine, and I'm checking my box here.

I'm wondering, though: how difficult is it, in the new attribute parsing infrastructure, be to accept and ignore should_panic() and treat it as equivalent to should_panic?

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jul 27, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Jul 27, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@JonathanBrouwer
Copy link
Contributor Author

@joshtriplett
This is very easy to do, if this is desired

@traviscross
Copy link
Contributor

Thanks. We'll discuss with the nomination.

For our notes, the applicable Reference text: "The should_panic attribute".

@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Aug 2, 2025
@traviscross
Copy link
Contributor

We talked about this after the meeting, and we weren't motivated to change what is here and under FCP.

@traviscross traviscross added the I-lang-radar Items that are on lang's radar and will need eventual work or consideration. label Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants