public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Fix parsing of array expressions.
@ 2023-03-30 6:47 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-30 6:47 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0ddec9f44d6ce81eec7aa62c2d9b13c9094e7857
commit 0ddec9f44d6ce81eec7aa62c2d9b13c9094e7857
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date: Mon Mar 27 11:05:03 2023 -0400
Fix parsing of array expressions.
Array expressions were being eagerly handled
outside of Pratt parsing.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser<ManagedTokenSource>::parse_expr_without_block):
Remove direct array expression handling.
gcc/testsuite/ChangeLog:
* rust/compile/array4.rs: New test.
* rust/execute/torture/arrays.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diff:
---
gcc/rust/parse/rust-parse-impl.h | 3 ---
gcc/testsuite/rust/compile/array4.rs | 3 +++
gcc/testsuite/rust/execute/torture/arrays.rs | 3 +++
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 79dd4e2423c..7c554e8bd0f 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -7449,9 +7449,6 @@ Parser<ManagedTokenSource>::parse_expr_without_block (
case MOVE:
// closure expr (though not all closure exprs require this)
return parse_closure_expr (std::move (outer_attrs));
- case LEFT_SQUARE:
- // array expr (creation, not index)
- return parse_array_expr (std::move (outer_attrs));
default: {
/* HACK: piggyback on pratt parsed expr and abuse polymorphism to
* essentially downcast */
diff --git a/gcc/testsuite/rust/compile/array4.rs b/gcc/testsuite/rust/compile/array4.rs
new file mode 100644
index 00000000000..c70ca0a970a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/array4.rs
@@ -0,0 +1,3 @@
+pub fn foo() {
+ [0, 1, 2][1];
+}
diff --git a/gcc/testsuite/rust/execute/torture/arrays.rs b/gcc/testsuite/rust/execute/torture/arrays.rs
new file mode 100644
index 00000000000..e30285f89e5
--- /dev/null
+++ b/gcc/testsuite/rust/execute/torture/arrays.rs
@@ -0,0 +1,3 @@
+fn main() -> i32 {
+ [55, 66, 77][1] - 66
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-30 6:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 6:47 [gcc/devel/rust/master] Fix parsing of array expressions Thomas Schwinge
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).