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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-lang-nominated Nominated for discussion during a lang team meeting. 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 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. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants