public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7958] gccrs: [E0658] top level or-patterns are not allowed let binding
@ 2024-01-16 18:08 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:08 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5c339c29f9aa61a2bb0488ca2b3456b2e5c53480
commit r14-7958-g5c339c29f9aa61a2bb0488ca2b3456b2e5c53480
Author: Muhammad Mahad <mahadtxt@gmail.com>
Date: Fri Aug 18 17:06:02 2023 +0500
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>
Diff:
---
gcc/rust/hir/rust-ast-lower-pattern.cc | 9 ++++++---
gcc/testsuite/rust/compile/let_alt.rs | 2 +-
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 37f00157641..bfb7b71cef2 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 1284627bb72..a2735bdbe77 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 }
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 18:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:08 [gcc r14-7958] gccrs: [E0658] top level or-patterns are not allowed let binding Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).