Skip to content

Conversation

fmease
Copy link
Member

@fmease fmease commented Aug 17, 2025

Accept code like let _: != loop {}; or let _: fn() -> != || loop {}; (previously: syntax error). Similar to sth. like #51068.

There's no inherent need to update can_begin_type from what I can tell, since macro matcher $ty:ty = already accepts != (edit: this is not true actually, my bad, I don't know what snippet I tested to come to that conclusion) and since no other current direct/transitive callers would 'benefit' from doing that either, so I didn't do it. It's a conservative choice to avoid odd consequences (concrete example: it would widen the follow set of :vis to include !=).

@rustbot

This comment was marked as outdated.

@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 Aug 17, 2025
@fmease
Copy link
Member Author

fmease commented Aug 17, 2025

r? petrochenkov or reassign

@rustbot rustbot assigned petrochenkov and unassigned lcnr Aug 17, 2025

#[cfg(false)] struct W<const X: ! = { loop {} }>;
#[cfg(false)] struct S<const X: != { loop {} }>;
}
Copy link
Member Author

@fmease fmease Aug 17, 2025

Choose a reason for hiding this comment

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

Maybe add this, too:

#![feature(default_field_values)]

struct X<T> {
    w: fn(T) -> ! = |_| loop {},
    s: fn(T) -> != |_| loop {},
}

Doesn't really matter tho.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, let's add this one too.

@fmease fmease 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 Aug 17, 2025
@fmease fmease force-pushed the split-bang-eq-for-never-ascr branch from 5dd2c57 to d1e84da Compare August 17, 2025 19:36
@fmease fmease 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 Aug 17, 2025
// Parse `!`
// Ideally we'd use `eat_bang` here to allow us to parse `!=>` as `! =>`. However,
// `break_and_eat` doesn't "reglue" the split-off `=` with any following `>` (since
// that would likely be super fragile and complex).
Copy link
Contributor

Choose a reason for hiding this comment

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

It will probably work if the support is added to break_two_token_op.

@petrochenkov petrochenkov 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 Aug 18, 2025
@traviscross traviscross added T-lang Relevant to the language team 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 labels Aug 26, 2025
@traviscross
Copy link
Contributor

As this changes the language grammar, this will need a lang FCP. If you could talk a bit about the analysis and motivation here for the nomination, that would be helpful.

This change would allow, e.g.,

let _: fn() -> != || loop {};

to be accepted both syntactically and semantically.

It'd be good for us to find a way to document this in the Reference as well.

cc @rust-lang/lang-docs

(H/t to our lang advisor @ehuss for raising this.)

@traviscross traviscross added the I-lang-radar Items that are on lang's radar and will need eventual work or consideration. label Aug 26, 2025
@fmease
Copy link
Member Author

fmease commented Sep 9, 2025

Sorry for not getting back to you. To be honest, there's no practical motivation. However, I really liked what [@]ehuss wrote in rust-lang/reference#1983, however it's been two weeks since I last read it.

I guess the general question is: Is there a more principled approach to this (not necessarily wrt. the implementation but also how we want to categorize or describe it in the Reference etc.) or do we "want to keep" adding these things in an ad hoc manner. A possible point of contention: It might hurt forward compatibility since it takes away a bit of whitespace sensitivity (Rust is obv. mostly whitespace insensitive but not fully).

@petrochenkov
Copy link
Contributor

petrochenkov commented Sep 9, 2025

The more principled approach is to migrate rustc's parser to the single-character token model with Spacing, which is used by proc macros.
In that model the notion of "multi-character operators" is only relevant in compatibility cases, like parsing tt, otherwise they are just sequences of single-character punctuation with joint spacing, and can be broken up arbitrarily.

Until then we need to consider cases like this as bugs and fix them when they are discovered. That matches what we did in practice in the previous years, all more popular multi-character tokens are already split in the parser when necessary.

@traviscross traviscross removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 10, 2025
@traviscross
Copy link
Contributor

Makes sense. Good enough for me.

@rfcbot fcp merge

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Sep 10, 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.

@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 10, 2025
@tmandry
Copy link
Member

tmandry commented Sep 10, 2025

My understanding from the lang team discussion is that this should be transparent to users at the lexing level and shouldn't limit us in the future (beyond the decision to support parsing this).

@rfcbot reviewed

@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 10, 2025
@rust-rfcbot
Copy link
Collaborator

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

@scottmcm
Copy link
Member

On the same assumption as Tyler,
@rust-rfcbot reviewed

@traviscross traviscross removed the I-lang-nominated Nominated for discussion during a lang team meeting. label Sep 15, 2025
@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Sep 20, 2025
@rust-rfcbot
Copy link
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@traviscross traviscross added the relnotes Marks issues that should be documented in the release notes of the next release. label Sep 21, 2025
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. finished-final-comment-period The final comment period is finished for this PR / Issue. 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. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-lang Relevant to the language team to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants