Syntactically reject equality predicates#153513
Syntactically reject equality predicates#153513fmease wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
[crater only] Syntactically reject equality predicates
|
@craterbot check |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🎉 Experiment
Footnotes
|
|
@craterbot run mode=check-only crates=https://crater-reports.s3.amazonaws.com/pr-153513/retry-regressed-list.txt p=1 |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
This comment has been minimized.
This comment has been minimized.
|
Like Jack, I was skeptical because I thought this would make it harder to introduce these in the future. But since we don't have any macro matchers today that can match over a where clause / bound, it won't do that. @rfcbot fcp merge lang |
|
Team member @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. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
@rfcbot reviewed |
|
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. |
|
The Reference is already correct on this point. cc @rust-lang/lang-docs @rust-lang/fls |
View all comments
Background (History)
Equality predicates have been syntactically valid since PR #39158 / nightly-2017-02-02 / 1.16 (released 2017-03-16, 9 years ago), both forms that is:
$ty = $tyand$ty == $ty. They're not registered as an unstable feature despite having a tracking issue (#20041). Naturally, they don't have a feature gate. Of course, we reject them post-expansion, so they are still semantically invalid.Parser scaffolding for
$ident = $tywas added in RUST-19391 (2014) which was then generalized to$ty = $tyin RUST-20002 (2014) and extended to additionally cover$ty == $tyin RUST-39158 (2017). As mentioned, the last PR also made them grammatical.RUST-87471 (2021) attempted to start impl'ing typeck'ing but it was closed due to concerns: #87471 (comment) (already back in 2017 there were concerns: https://github.com/rust-lang/rust/pull/39158/changes#r97811244).
In 2022, T-lang discussed this feature during a meeting and raised concerns: #20041 (comment). However, they were inclined to accept a restricted form, namely
T::AssocTy = $ty(Tis a (self) ty param or a self ty alias) and<$ty as Trait>::AssocTy = $tysince that's trivial to support in HIR ty lowering (this is still accurate).Change
This renders equality predicates
$ty = $tyand$ty == $tysyntactically invalid again. On stable, they're merely semantically invalid. This is motivated by the fact that=or==?$ty = $tyto$term = $termdue to ambiguities 1 that would require backtracking whereas$typepath = $termwouldn't have that problemI've merely upgraded the semantic hard error to a syntactic hard error, I've intentionally not introduced an unstable feature under which equality predicates become legal.
That's because a hard error is easier to push through procedurally, it's an important first step (we can always turn it into a feature gate error later on) and since this potential feature isn't backed by any official lang experiment.
I don't consider T-lang's message #20041 (comment) from 2022 to be sufficient because it doesn't answer questions like (1.i), (1.ii) or whether code like
T: Trait<A>, <T as Trait<B>>::AssocTy = Ty(A≠B) orT: Trait<'r>, for<'a> <T as Trait<'a>>::AssocTy = Tyshould be legal (which would be more powerful / could lead to typechecking issues, idk) or not assuming we're going with the restricted form ofc (we would need input from T-types).Lang nomination
#153513 (comment)
Footnotes
Code lile
fn f() -> i32 where { 0 }is intentionally legal today but if we had$term = $termthe{ 0 }could then also be the start of an equality predicate like{ 0 } = 0. ↩