-
Notifications
You must be signed in to change notification settings - Fork 13.3k
never patterns: Document behavior of never patterns with macros-by-example #119622
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
} | ||
|
||
macro_rules! detect_pat { | ||
($p:pat) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, weren't the pat macro metavar matchers adjusted for editions >= 2021? Please make an //edition:2021
version of this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh shoot well spotted that does have a different behavior. Still backwards-compatible, but a bit inconsistent :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I checked on the playground, this is backwards-compatible. And in fact the assymetry of ! | true
vs true | !
in edition 2021 can't be changed
30b4242
to
49bc67f
Compare
49bc67f
to
d9e47be
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me after nit
d9e47be
to
718a433
Compare
@bors r=compiler-errors |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#119151 (Hide foreign `#[doc(hidden)]` paths in import suggestions) - rust-lang#119350 (Imply outlives-bounds on lazy type aliases) - rust-lang#119354 (Make `negative_bounds` internal & fix some of its issues) - rust-lang#119506 (Use `resolutions(()).effective_visiblities` to avoid cycle errors in `report_object_error`) - rust-lang#119554 (Fix scoping for let chains in match guards) - rust-lang#119563 (Check yield terminator's resume type in borrowck) - rust-lang#119589 (cstore: Remove unnecessary locking from `CrateMetadata`) - rust-lang#119622 (never patterns: Document behavior of never patterns with macros-by-example) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119622 - Nadrieril:never_patterns_macros, r=compiler-errors never patterns: Document behavior of never patterns with macros-by-example `never_patterns` makes `!` parse as a pattern so I was worried about breaking macros-by-example matching. Turns out we're fine because the cases that now match `$p:pat` used to error in the past. The only tricky case is `!` by itself, which backwards-compatibly doesn't match `$p:pat`. I have no idea why tho, I didn't think of that when I was implementing parsing 😅. This adds tests so we don't regress the current behavior. r? `@compiler-errors`
never_patterns
makes!
parse as a pattern so I was worried about breaking macros-by-example matching. Turns out we're fine because the cases that now match$p:pat
used to error in the past. The only tricky case is!
by itself, which backwards-compatibly doesn't match$p:pat
. I have no idea why tho, I didn't think of that when I was implementing parsing 😅.This adds tests so we don't regress the current behavior.
r? @compiler-errors