public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] parser: Parse reference patterns correctly
@ 2023-05-02  7:08 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-05-02  7:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:82e26f836210a2defed7e49d7d2655b5525f0561

commit 82e26f836210a2defed7e49d7d2655b5525f0561
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Wed Apr 19 17:40:15 2023 +0200

    parser: Parse reference patterns correctly
    
    Reference patterns cannot contain AltPatterns per the Rust reference,
    so we should not call into `parse_pattern` to parse the referenced pattern,
    but rather the more restrictive `parse_pattern_no_alt`.
    
    gcc/rust/ChangeLog:
    
            * parse/rust-parse-impl.h (Parser::parse_reference_pattern): Do not
            call into `parse_pattern` anymore.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/issue-1807.rs: New test.

Diff:
---
 gcc/rust/parse/rust-parse-impl.h         | 2 +-
 gcc/testsuite/rust/compile/issue-1807.rs | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 48ac521a867..b3b1bb218d6 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -10949,7 +10949,7 @@ Parser<ManagedTokenSource>::parse_reference_pattern ()
     }
 
   // parse pattern to get reference of (required)
-  std::unique_ptr<AST::Pattern> pattern = parse_pattern ();
+  std::unique_ptr<AST::Pattern> pattern = parse_pattern_no_alt ();
   if (pattern == nullptr)
     {
       Error error (lexer.peek_token ()->get_locus (),
diff --git a/gcc/testsuite/rust/compile/issue-1807.rs b/gcc/testsuite/rust/compile/issue-1807.rs
new file mode 100644
index 00000000000..fe821f0fc90
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-1807.rs
@@ -0,0 +1,6 @@
+// { dg-additional-options "-fsyntax-only" }
+
+fn main() {
+    let is_zero = &|&&d: &&u8| -> bool { d == b'0' };
+    let lambda = |&c| c != b'9';
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-02  7:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-02  7:08 [gcc/devel/rust/master] parser: Parse reference patterns correctly 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).