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

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
@traviscross traviscross added P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang T-lang Relevant to the language team labels Sep 16, 2026
@tmandry

tmandry commented Sep 16, 2026

Copy link
Copy Markdown
Member

@rfcbot fcp merge lang

@rust-rfcbot

rust-rfcbot commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

@tmandry 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.

@rust-rfcbot rust-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 Sep 16, 2026
@traviscross

Copy link
Copy Markdown
Contributor

Thanks @fmease.

@rfcbot reviewed

@nikomatsakis

This comment was marked as outdated.

@rust-rfcbot rust-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 Sep 23, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

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

@nikomatsakis

Copy link
Copy Markdown
Contributor

@rfcbot reviewed

@traviscross traviscross removed 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 23, 2026
@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Sep 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 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. T-lang Relevant to the language team 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.

7 participants