public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] parser: Fix handling of multiple left angles in null denotation
@ 2023-03-08  9:56 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-08  9:56 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bdd36f1de036c7ab94c46f50015a88655ee1cbf8

commit bdd36f1de036c7ab94c46f50015a88655ee1cbf8
Author: goar5670 <mahadelr19@gmail.com>
Date:   Sat Mar 4 22:13:18 2023 +0300

    parser: Fix handling of multiple left angles in null denotation
    
    gcc/rust/ChangeLog:
    
            * parse/rust-parse-impl.h (Parser::parse_expr):
            split LEFT_SHIFT before null_denotation.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/complex_qualified_path_in_expr.rs : New test.
    
    Signed-off-by: Mahmoud Mohamed <mahadelr19@gmail.com>

Diff:
---
 gcc/rust/parse/rust-parse-impl.h                   |  7 +++++
 .../rust/compile/complex_qualified_path_in_expr.rs | 34 ++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 9b2bea73c99..79dd4e2423c 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -12650,6 +12650,13 @@ Parser<ManagedTokenSource>::parse_expr (int right_binding_power,
 	  || id == RIGHT_SQUARE)
 	return nullptr;
     }
+
+  if (current_token->get_id () == LEFT_SHIFT)
+    {
+      lexer.split_current_token (LEFT_ANGLE, LEFT_ANGLE);
+      current_token = lexer.peek_token ();
+    }
+
   lexer.skip_token ();
 
   // parse null denotation (unary part of expression)
diff --git a/gcc/testsuite/rust/compile/complex_qualified_path_in_expr.rs b/gcc/testsuite/rust/compile/complex_qualified_path_in_expr.rs
new file mode 100644
index 00000000000..6244a6bf100
--- /dev/null
+++ b/gcc/testsuite/rust/compile/complex_qualified_path_in_expr.rs
@@ -0,0 +1,34 @@
+struct S; // { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }
+impl S {
+  fn f() -> i32 { return 0; }
+  // { dg-warning "associated function is never used" "" { target *-*-* } .-1 }
+}
+
+trait T1 {
+  type A;
+  fn f() -> i32 { return 0; }
+}
+
+impl T1 for S {
+  type A = S;
+}
+
+trait T2 {
+  type B;
+  fn f() -> i32 { return 0; }
+}
+
+impl T2 for S {
+  type B = S;
+}
+
+trait T3 {
+  fn f() -> i32 { return 0; }
+}
+
+impl T3 for S {}
+
+fn main() {
+  let _ = <<S as T1>::A as T2>::f();
+  let _ = <<<S as T1>::A as T2>::B as T3>::f();
+}

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

only message in thread, other threads:[~2023-03-08  9:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08  9:56 [gcc/devel/rust/master] parser: Fix handling of multiple left angles in null denotation 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).