-
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
Make edition dependent :expr
macro fragment act like the edition-dependent :pat
fragment does
#126700
Merged
Merged
Make edition dependent :expr
macro fragment act like the edition-dependent :pat
fragment does
#126700
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
//@ edition:2021 | ||
|
||
#[macro_export] | ||
macro_rules! m { | ||
($expr:expr) => { | ||
compile_error!("did not expect an expression to be parsed"); | ||
}; | ||
(const { }) => {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@ compile-flags: --edition=2024 -Zunstable-options | ||
//@ aux-build:expr_2021_implicit.rs | ||
|
||
//@ check-pass | ||
|
||
extern crate expr_2021_implicit; | ||
|
||
// Makes sure that a `:expr` fragment matcher defined in a edition 2021 crate | ||
// still parses like an `expr_2021` fragment matcher in a 2024 user crate. | ||
expr_2021_implicit::m!(const {}); | ||
|
||
fn main() {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
unrelated -- but I wonder if we can come up with a more descriptive name.
expr_2021
gives me the vibe that its new to 2021 (i.e. >=2021) not legacy to 2021 (i.e. <=2021).I quite like
PatParam
andPatWithOr
naming scheme since it makes it less about edition and more about what it's parsing.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.
Yeah, that would be awesome. I couldn't come up with a good succinct name yet, it's kinda hard lol ngl and the grammar may still change, too (cc #126697). Note that we're already tracking this under Unresolved Questions in #123742.
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.
I agree the
_2021
suffix's meaning is non-obvious, and even after learning what it means it I keep having trouble remembering the meaning.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.
I have been thinking about a good name for a while now because I often get confused when reading the code a week later.
However, I think expr_2021 is one of the best names we can choose. If we update the documentation to explain that expr_2021 includes all features up to the 2021 edition, and expr includes all features of the current edition (up to 2024 in this case), it would be clear.
This approach can be applied retroactively as well. We do not have an expr_2018 because there were no changes in the semantics of expr at that time.
Do you think your concern can be addressed by updating the documentation to clearly explain this way of thinking?
I am also considering that if we give another name without referencing the edition, and if expr keeps changing in the next edition, keeping track of and explaining all the different expr types will be a mess, in my opinion.
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.
Maybe we can use the year as a suffix for saying "the moment in was introduced", that would mean we would have
Expr2015
andExpr2024
; that would follow "the vibe that its new to 2024".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.
Just to confirm, are we agreeing that Expr2021 would include all features up to the 2021 edition, and Expr would continue to represent the current edition's features?
Or are you proposing a slightly different idea from what we are currently implementing?
By the way, I am happy with either approach, but I think it is important for users that we clearly indicate the edition where the expr_* is necessary to maintain old behavior.