-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Migration for or patterns #83318
Comments
Mentoring instructionsThere is some existing logic in macros to try and detect cases where a matcher is followed by an illegal character. I think we can build on this logic easily enough. Here is an example function I found when ripgreping around: rust/compiler/rustc_expand/src/mbe/macro_rules.rs Lines 853 to 871 in 3ad1e4d
I think these three lines are roughly where we want to make changes: rust/compiler/rustc_expand/src/mbe/macro_rules.rs Lines 964 to 967 in 3ad1e4d
What this code is currently doing is checking if you have something like |
There is a Zulip thread on or patterns here: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/or.20patterns |
@rustbot claim |
I would like to try this. |
@hi-rustin great! |
I changed the difficulty label from easy to medium, since it's not easy to generate a lint at that place in the rustc code. |
Producing a lint there with
|
@m-ou-se good catch, I forgot about that. I suspect this ICE is... simply not necessary. @hi-rustin have you had a chance to do any exploration here? The other thing is that @m-ou-se pointed out that we probably want to modify the rules for |
I'll give it a try, but at the moment I'm not very familiar with the compiler code and it might be difficult. |
@hi-rustin if it would be helpful, we could schedule some time to chat on Zulip synchronously, presuming our time zones can be made to overlap =) If that would be useful to you, let me know and I'll have contact you via email to schedule a time. |
Thank you for your support! I've written some code that I'll submit later. |
I've created a draft PR, could you please take a look? cc: #83468 |
…matsakis add OR_PATTERNS_BACK_COMPAT lint close rust-lang#83318
As part of the
|
patterns work (tracking issue), we plan to change the meaning of the$x:pat
matcher in macros within the 2021 Edition. The current plan of record is:pat2015
matcher will match legacy patterns, which exclude the|
character.pat2021
matcher will match new patterns, which include the|
character.pat
matcher will be equivalent topat2021
from Rust 2021 forward, and equivalent topat2015
on older editions, since past crater runs (e.g., 1 and 2) found significant and complex breakage from just changingpat
topat2021
uniformly.The goal of this issue is to issue a useful lint that suggests that converting
$x:pat
to$x:pat2015
if converting to Rust 2021 could cause breakage. We don't want to do this for all$x:pat
usages, however, because the vast majority would benefit from being$x:pat2021
.Examples where lint should trigger
Here is an example of a macro that we DO want to convert (source):
Here is another example (source):
The text was updated successfully, but these errors were encountered: