-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add &pin (mut|const) T
type position sugar
#130635
Conversation
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
I'm missing a test to make sure that @rustbot author |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
19eb307
to
bd45002
Compare
This comment has been minimized.
This comment has been minimized.
@rustbot author Remember to switch back to S-waiting-on-review when it's rebased and updated |
☔ The latest upstream changes (presumably #130724) made this pull request unmergeable. Please resolve the merge conflicts. |
6988094
to
fefdcc1
Compare
@rustbot ready |
&pin (mut|const) T
sugar&pin (mut|const) T
type position sugar
@rustbot labels +I-lang-nominated +I-lang-easy-decision In Rust 1.41, we broke this program... macro_rules! m {
($x:expr) => { compile_error!("bad") };
($($t:tt)*) => {}
}
m!(&raw const ()); ...even though we didn't end up stabilizing Then we broke this in Rust 1.77: macro_rules! m {
($x:ty) => { compile_error!("bad") };
($($t:tt)*) => {}
}
m!(impl const Sized); (We haven't stabilized macro_rules! m {
($x:ty) => { compile_error!("bad") };
($($t:tt)*) => {}
}
m!(impl async Sized); (We haven't stabilized Now we plan to break this program when this PR lands: macro_rules! m {
($x:ty) => { compile_error!("bad") };
($($t:tt)*) => {}
}
m!(&pin const ()); This breakage is believed to be theoretical-only. Does this sound OK to us? (See this thread for background.) |
The breakage specifically represents an inherent limitation to the "macro follow-set" formulation which is supposed to make us more resilient against breakages due to extensions to the grammar like this. Given two macro matcher arms:
And given tokens like:
On nightly today, I think that's weird, because if this second arm were written like I think this breakage is purely theoretical, though. I would like to hear any suggestions to close this hole and make macros a bit more resilient, but nothing really comes to mind :( |
Given that this changes behavior even without the @rustbot author |
Yes, so we'd also be intending to break: //@ check-pass
macro_rules! m {
($x:expr) => { compile_error!("bad") };
($($t:tt)*) => {}
}
m!(&pin const ()); |
a bit off-topic for the thread but I believe a solution to this would be the following new logic:
What this semantically does is strengthen the "commit to fully matching metavars or error" behavior such that it extends past the end. |
That seems plausible to me. I've filed and nominated... ...for the proposal for that FCW. |
@rustbot labels -I-lang-nominated +T-lang +relnotes We discussed this in the meeting today. We agreed that this seems like theoretical-only breakage and is OK to move forward as far as lang is concerned. We'll mention this in the release notes as it is technically breaking, and in that way we'll help to make this information available to those doing the beta crater runs, just in case anything is found there. Our general sentiment was that anyone using match arms as an oracle to detect what gets parsed in other arms is probably asking for trouble; it's unwise to rely on the subtleties of this, given the limitations of the follow-set behavior with respect to the interaction between arms, and we're interested in better ways to explicitly reserve this space. |
☔ The latest upstream changes (presumably #131205) made this pull request unmergeable. Please resolve the merge conflicts. |
fefdcc1
to
af9492d
Compare
☔ The latest upstream changes (presumably #131275) made this pull request unmergeable. Please resolve the merge conflicts. |
af9492d
to
3aabe1e
Compare
@bors r+ |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#130608 (Implemented `FromStr` for `CString` and `TryFrom<CString>` for `String`) - rust-lang#130635 (Add `&pin (mut|const) T` type position sugar) - rust-lang#130747 (improve error messages for `C-cmse-nonsecure-entry` functions) - rust-lang#131137 (Add 1.82 release notes) - rust-lang#131328 (Remove unnecessary sorts in `rustc_hir_analysis`) - rust-lang#131496 (Stabilise `const_make_ascii`.) - rust-lang#131706 (Fix two const-hacks) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#130635 - eholk:pin-reborrow-sugar, r=compiler-errors Add `&pin (mut|const) T` type position sugar This adds parser support for `&pin mut T` and `&pin const T` references. These are desugared to `Pin<&mut T>` and `Pin<&T>` in the AST lowering phases. This PR currently includes rust-lang#130526 since that one is in the commit queue. Only the most recent commits (bd45002 and following) are new. Tracking: - rust-lang#130494 r? `@compiler-errors`
…er-errors Add `&pin (mut|const) T` type position sugar This adds parser support for `&pin mut T` and `&pin const T` references. These are desugared to `Pin<&mut T>` and `Pin<&T>` in the AST lowering phases. This PR currently includes rust-lang#130526 since that one is in the commit queue. Only the most recent commits (bd45002 and following) are new. Tracking: - rust-lang#130494 r? `@compiler-errors`
This adds parser support for
&pin mut T
and&pin const T
references. These are desugared toPin<&mut T>
andPin<&T>
in the AST lowering phases.This PR currently includes #130526 since that one is in the commit queue. Only the most recent commits (bd45002 and following) are new.
Tracking:
r? @compiler-errors