-
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
syntax: Treat error literals in more principled way #61615
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
✌️ @matklad can now approve this pull request |
Than maybe there shouldn't be an error literal token, and just an error token? |
Well, maybe yes in theory, but it may be more convenient to make that token a literal due to various circumstances.
|
not sure about #61615 (comment), but r=me |
Added a test for #61615 (comment). |
📌 Commit 2af47fa has been approved by |
syntax: Treat error literals in more principled way Free them from their character literal origins. I actually tried to remove `LitKind::Err` entirely (by converting it into `ExprKind::Err` immediately), and it caused no diagnostic regressions in the test suite. However, I'd still want to use error literals as general purpose error tokens some day, so I kept them. The downside of having `LitKind::Err` in addition to `ExprKind::Err` is that every time you want to do something with `ExprKind::Err` you need to make sure that `ExprKind::Lit(LitKind::Err)` is treated in the same way. Fortunately, this usually happens automatically because both literals and errors are "leaf" expressions, however this PR does fix a couple of inconsistencies between them. Addresses rust-lang#60679 (comment) in a way
syntax: Treat error literals in more principled way Free them from their character literal origins. I actually tried to remove `LitKind::Err` entirely (by converting it into `ExprKind::Err` immediately), and it caused no diagnostic regressions in the test suite. However, I'd still want to use error literals as general purpose error tokens some day, so I kept them. The downside of having `LitKind::Err` in addition to `ExprKind::Err` is that every time you want to do something with `ExprKind::Err` you need to make sure that `ExprKind::Lit(LitKind::Err)` is treated in the same way. Fortunately, this usually happens automatically because both literals and errors are "leaf" expressions, however this PR does fix a couple of inconsistencies between them. Addresses rust-lang#60679 (comment) in a way
syntax: Treat error literals in more principled way Free them from their character literal origins. I actually tried to remove `LitKind::Err` entirely (by converting it into `ExprKind::Err` immediately), and it caused no diagnostic regressions in the test suite. However, I'd still want to use error literals as general purpose error tokens some day, so I kept them. The downside of having `LitKind::Err` in addition to `ExprKind::Err` is that every time you want to do something with `ExprKind::Err` you need to make sure that `ExprKind::Lit(LitKind::Err)` is treated in the same way. Fortunately, this usually happens automatically because both literals and errors are "leaf" expressions, however this PR does fix a couple of inconsistencies between them. Addresses rust-lang#60679 (comment) in a way
syntax: Treat error literals in more principled way Free them from their character literal origins. I actually tried to remove `LitKind::Err` entirely (by converting it into `ExprKind::Err` immediately), and it caused no diagnostic regressions in the test suite. However, I'd still want to use error literals as general purpose error tokens some day, so I kept them. The downside of having `LitKind::Err` in addition to `ExprKind::Err` is that every time you want to do something with `ExprKind::Err` you need to make sure that `ExprKind::Lit(LitKind::Err)` is treated in the same way. Fortunately, this usually happens automatically because both literals and errors are "leaf" expressions, however this PR does fix a couple of inconsistencies between them. Addresses rust-lang#60679 (comment) in a way
Rollup of 7 pull requests Successful merges: - #61223 (Document tuple's Ord behavior as sequential) - #61615 (syntax: Treat error literals in more principled way) - #61616 (parser: Remove `Deref` impl from `Parser`) - #61621 (Clarify when we run steps with ONLY_HOSTS) - #61627 (Add regression test for #61452.) - #61641 (Revert "Make LocalAnalizer visitor iterate instead of recurse") - #61647 (Use stable wrappers in f32/f64::signum) Failed merges: r? @ghost
Free them from their character literal origins.
I actually tried to remove
LitKind::Err
entirely (by converting it intoExprKind::Err
immediately), and it caused no diagnostic regressions in the test suite.However, I'd still want to use error literals as general purpose error tokens some day, so I kept them.
The downside of having
LitKind::Err
in addition toExprKind::Err
is that every time you want to do something withExprKind::Err
you need to make sure thatExprKind::Lit(LitKind::Err)
is treated in the same way.Fortunately, this usually happens automatically because both literals and errors are "leaf" expressions, however this PR does fix a couple of inconsistencies between them.
Addresses #60679 (comment) in a way