Skip to content

Syntactically reject leading parenthesized precise capturing lists in bare trait object types ((use<…>)+) - #162652

Open
fmease wants to merge 1 commit into
rust-lang:mainfrom
fmease:reject-bare-obj-paren-use
Open

Syntactically reject leading parenthesized precise capturing lists in bare trait object types ((use<…>)+)#162652
fmease wants to merge 1 commit into
rust-lang:mainfrom
fmease:reject-bare-obj-paren-use

Conversation

@fmease

@fmease fmease commented Sep 11, 2026

Copy link
Copy Markdown
Member

Follow-up to #162269. Addresses fmease/rasur#7 (item 6).

(No LLM was or will be used by me during the entire creation process of this PR)

@fmease fmease added I-lang-nominated Nominated for discussion during a lang team meeting. I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination labels Sep 11, 2026
@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 Sep 11, 2026
@rustbot

rustbot commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

r? @adwinwhite

rustbot has assigned @adwinwhite.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, parser
  • compiler, parser expanded to 76 candidates
  • Random selection from 21 candidates

@fmease

fmease commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

This is so niche that it does not need a crater run IMO and it might not even require an FCP.

@fmease fmease changed the title Syntactically reject parenthesized precise capturing lists in bare trait object types ((use<…>)+) Syntactically reject leading parenthesized precise capturing lists in bare trait object types ((use<…>)+) Sep 11, 2026
@fmease
fmease force-pushed the reject-bare-obj-paren-use branch from 1c3974f to b41ef23 Compare September 11, 2026 16:25
@fmease

fmease commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Context for T-lang:

We generally only support parenthesizing trait bounds, not however any other kind of bound (namely, outlives-bounds and use-bounds) and as it stands there would be no use in generalizing this part of the grammar. So we allow bounds like (Trait), (for<'a> path::to::Trait<'a>) and (Fn() -> i32) but we don't allow ('a) or (use<N>)...

...Well, when precise capturing lists were introduced & stabilized, something was overlooked: While we correctly reject bare trait object types1 like Trait + (use<T>) (where the use-bound doesn't come first) before this PR we would incorrectly syntactically accept bare trait object types like (use<T>) + Trait or (use<>)+ (where the use-bounds come first).

Note that all of this only concerns the grammar of Rust as use-bounds are semantically invalid in trait object types anyway. This is just part of my ongoing efforts to deep clean Rust's grammar + rustc's parser.

Arguably this is super niche and thus I actually think that merging this w/o a T-lang FCP would be fine but I wanted to at least inform you of this.

The Reference doesn't need updating as it already conforms to what I expect & propose here. See also TraitObjectType, Bound etc.

Footnotes

  1. Which are syntactically legal in all editions by the way; they're merely semantically illegal in Rust >=2021.

@fmease
fmease force-pushed the reject-bare-obj-paren-use branch from b41ef23 to fc6fa6d Compare September 11, 2026 16:51
@fmease fmease added waived-reference-pr This language change does not need a Reference PR. S-waiting-on-t-lang Status: Awaiting decision from T-lang labels Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-easy-decision Issue: The decision needed by the team is conjectured to be easy; this does not imply nomination I-lang-nominated Nominated for discussion during a lang team meeting. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-t-lang Status: Awaiting decision from T-lang T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. waived-reference-pr This language change does not need a Reference PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants