Skip to content

rustc_attr_parsing: use a try {} in or_malformed#155829

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
scrabsha:push-kwlqypwmnpul
Apr 27, 2026
Merged

rustc_attr_parsing: use a try {} in or_malformed#155829
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
scrabsha:push-kwlqypwmnpul

Conversation

@scrabsha
Copy link
Copy Markdown
Contributor

This replace the (|| { Some($($code)*) })() with a nice and clean try { $($code)* } block. try {} is unstable but widely used within the compiler (and in a few places in rustc_attr_parsing), so I would argue it's ok to use it here too?

To the best of my knowledge, there is no instance of IIFE (aka the poor man's try {}) in rustc_attribute_parsing. Happy to be proven wrong though :)

r? mejrs

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 26, 2026
@scrabsha scrabsha marked this pull request as ready for review April 26, 2026 15:28
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 26, 2026

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred to diagnostic attributes.

cc @mejrs

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 26, 2026
@mejrs
Copy link
Copy Markdown
Contributor

mejrs commented Apr 26, 2026

It was originally a try block, see #151558 (comment) This seems fine with me, will review later

@mejrs
Copy link
Copy Markdown
Contributor

mejrs commented Apr 26, 2026

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 26, 2026

📌 Commit a7330f4 has been approved by mejrs

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 Apr 26, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 26, 2026
rustc_attr_parsing: use a `try {}` in `or_malformed`
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 26, 2026
rustc_attr_parsing: use a `try {}` in `or_malformed`
rust-bors Bot pushed a commit that referenced this pull request Apr 26, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #149624 (Fix requires_lto targets needing lto set in cargo)
 - #152443 (NVPTX: Drop support for old architectures and old ISAs)
 - #155317 (`std::io::Take`: Clarify & optimize `BorrowedBuf::set_init` usage.)
 - #155588 (Implement more traits for FRTs)
 - #155682 (Add boxing suggestions for `impl Trait` return type mismatches)
 - #155770 (Avoid misleading closure return type note)
 - #155818 (Convert attribute `FinalizeFn` to fn pointer)
 - #155829 (rustc_attr_parsing: use a `try {}` in `or_malformed`)
 - #155835 (couple of `crate_name` cleanups)
rust-bors Bot pushed a commit that referenced this pull request Apr 27, 2026
Rollup of 12 pull requests

Successful merges:

 - #149624 (Fix requires_lto targets needing lto set in cargo)
 - #155317 (`std::io::Take`: Clarify & optimize `BorrowedBuf::set_init` usage.)
 - #155579 (Make Rcs and Arcs use pointer comparison for unsized types)
 - #155588 (Implement more traits for FRTs)
 - #155708 (Fix heap overflow in slice::join caused by misbehaving Borrow)
 - #155778 (Avoid Vec allocation in TyCtxt::mk_place_elem)
 - #151014 (std: sys: process: uefi: Add program searching)
 - #155682 (Add boxing suggestions for `impl Trait` return type mismatches)
 - #155770 (Avoid misleading closure return type note)
 - #155818 (Convert attribute `FinalizeFn` to fn pointer)
 - #155829 (rustc_attr_parsing: use a `try {}` in `or_malformed`)
 - #155835 (couple of `crate_name` cleanups)
@rust-bors rust-bors Bot merged commit c0e4189 into rust-lang:main Apr 27, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 27, 2026
rust-timer added a commit that referenced this pull request Apr 27, 2026
Rollup merge of #155829 - scrabsha:push-kwlqypwmnpul, r=mejrs

rustc_attr_parsing: use a `try {}` in `or_malformed`
@scrabsha scrabsha deleted the push-kwlqypwmnpul branch April 27, 2026 07:30
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.

3 participants