Add error message for AltPattern in let statements#2009
Merged
Conversation
Collaborator
Author
|
Waiting on #2008. |
CohenArthur
approved these changes
Mar 21, 2023
| @@ -0,0 +1,5 @@ | |||
| fn main() { | |||
| let a | a = 12; | |||
Member
There was a problem hiding this comment.
Interestingly, let (a | a) = 12; is allowed. I'm assuming this is already handled by our GroupedPattern?
| rust_sorry_at (pattern.get_locus (), | ||
| "alternate pattern let statements not supported"); | ||
| rust_error_at (pattern.get_locus (), | ||
| "top-level or-patterns are not allowed in %<let%> bindings"); |
Member
There was a problem hiding this comment.
It's fine to use an error message different from rustc that suits our compiler logic better :) this is not a critic or anything, just something to keep in mind when you think about new errors
Collaborator
Author
|
Member
|
@powerboat9 I'm in favor of merging this once the CI passes :) |
gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Add is_let_top_level parameter. (ASTLoweringPattern::visit): Handle is_let_top_level. * hir/rust-ast-lower-pattern.h (class ASTLoweringPattern): Add is_let_top_level. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Set is_let_top_level. gcc/testsuite/ChangeLog: * rust/compile/let_alt.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
CohenArthur
approved these changes
Apr 21, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes the
rust_sorry_atforAltPatterninletstatements to arust_error_at.