aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-08-18 17:06:02 +0500
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:04:30 +0100
commit5c339c29f9aa61a2bb0488ca2b3456b2e5c53480 (patch)
tree620f6affe8c9a7f1a2d5ebe782cb32290a6634c4
parentc00624a6c8b9a08b10674abff7826ac990e9248a (diff)
downloadgcc-5c339c29f9aa61a2bb0488ca2b3456b2e5c53480.zip
gcc-5c339c29f9aa61a2bb0488ca2b3456b2e5c53480.tar.gz
gcc-5c339c29f9aa61a2bb0488ca2b3456b2e5c53480.tar.bz2
gccrs: [E0658] top level or-patterns are not allowed let binding
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>
-rw-r--r--gcc/rust/hir/rust-ast-lower-pattern.cc9
-rw-r--r--gcc/testsuite/rust/compile/let_alt.rs2
2 files changed, 7 insertions, 4 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-pattern.cc b/gcc/rust/hir/rust-ast-lower-pattern.cc
index 37f0015..bfb7b71 100644
--- a/gcc/rust/hir/rust-ast-lower-pattern.cc
+++ b/gcc/rust/hir/rust-ast-lower-pattern.cc
@@ -333,9 +333,12 @@ ASTLoweringPattern::visit (AST::AltPattern &pattern)
= new HIR::AltPattern (mapping, std::move (alts), pattern.get_locus ());
if (is_let_top_level)
- rust_error_at (pattern.get_locus (),
- "top level alternate patterns are not allowed for %<let%> "
- "bindings - use an outer grouped pattern");
+ {
+ rich_location richloc (line_table, pattern.get_locus ());
+ richloc.add_fixit_replace ("use an outer grouped pattern");
+ rust_error_at (
+ richloc, "top level or-patterns are not allowed for %<let%> bindings");
+ }
}
} // namespace HIR
diff --git a/gcc/testsuite/rust/compile/let_alt.rs b/gcc/testsuite/rust/compile/let_alt.rs
index 1284627..a2735bd 100644
--- a/gcc/testsuite/rust/compile/let_alt.rs
+++ b/gcc/testsuite/rust/compile/let_alt.rs
@@ -1,4 +1,4 @@
fn main() {
let _a | _a = 12;
- // { dg-error "top level alternate patterns are not allowed" "" { target *-*-* } .-1 }
+ // { dg-error "top level or-patterns are not allowed for .let. bindings" "" { target *-*-* } .-1 }
}