-
Notifications
You must be signed in to change notification settings - Fork 149
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
Top level or-patterns are not allowed let binding #2569
Conversation
richloc.add_fixit_replace ("use an outer grouped pattern"); | ||
rust_error_at ( | ||
richloc, ErrorCode::E0658, | ||
"top level or-patterns are not allowed for %<let%> bindings"); |
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.
This message and errorcode is according to rustc 1.49.0
, rustc nighly not emit E0658
(An unstable feature was used) as this was unstable feature in rustc 1.49.0.
Should we add the latest verion message, or stick to rustc 1.49.0
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.
We can't use E0658 here, as E0658 refers to the use of unstable features. In 1.49, top level or patterns were considered an unstable feature, which is why the compiler emitted E0658. It's now been stabilized. So the handling here needs to be a little different.
The error in itself does not have an error code. So we cannot have one either.
We then have to decide if we want to implement top level or-patterns (if they are needed by core
or std
, we'll need to implement them, but otherwise no) and go from there.
Furthermore, in Rust 1.49 with nightly features let a | a = 15
is valid, but not in Rust 1.53 when toplevel or-patterns were stabilized. You need to use let (a | a) = 15
.
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 think improving the error message is nice, and we should remove the error code from the error message. Looks good to me apart from this :)
richloc.add_fixit_replace ("use an outer grouped pattern"); | ||
rust_error_at ( | ||
richloc, ErrorCode::E0658, | ||
"top level or-patterns are not allowed for %<let%> bindings"); |
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.
We can't use E0658 here, as E0658 refers to the use of unstable features. In 1.49, top level or patterns were considered an unstable feature, which is why the compiler emitted E0658. It's now been stabilized. So the handling here needs to be a little different.
The error in itself does not have an error code. So we cannot have one either.
We then have to decide if we want to implement top level or-patterns (if they are needed by core
or std
, we'll need to implement them, but otherwise no) and go from there.
Furthermore, in Rust 1.49 with nightly features let a | a = 15
is valid, but not in Rust 1.53 when toplevel or-patterns were stabilized. You need to use let (a | a) = 15
.
a422d57
to
f7de81b
Compare
f7de81b
to
2d22c5e
Compare
gcc/rust/ChangeLog: * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Added richlocation & error code. gcc/testsuite/ChangeLog: * rust/compile/let_alt.rs: Updated comment. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2d22c5e
to
74ccc33
Compare
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.
Looks great!
Top level or-patterns are not allowed let binding -
E0658
rustc 1.49.0
, but not emitted byrustc -nightly
.rustc 1.49.0
, as we are targetingrustc 1.49.0
testsuite.godbolt
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: