]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: ast: Fix ICE on generic args path
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 4 Apr 2023 17:52:38 +0000 (19:52 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:28:44 +0000 (18:28 +0100)
The path should be retrieved only when a generic arg has either type.

gcc/rust/ChangeLog:

* ast/rust-ast-tokenstream.cc (TokenStream::visit): Fix ICE.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-tokenstream.cc

index 2fc7c2b3039c28e7d4d2a35dcbe2b58c9005981c..3e2fdfc9e7b3d2ef1d74c663243ae60fad5f4921 100644 (file)
@@ -644,7 +644,6 @@ TokenStream::visit (GenericArg &arg)
 {
   // `GenericArg` implements `accept_vis` but it is not useful for this case as
   // it ignores unresolved cases (`Kind::Either`).
-  auto path = arg.get_path ();
   switch (arg.get_kind ())
     {
     case GenericArg::Kind::Const:
@@ -653,9 +652,11 @@ TokenStream::visit (GenericArg &arg)
     case GenericArg::Kind::Type:
       visit (arg.get_type ());
       break;
-    case GenericArg::Kind::Either:
-      tokens.push_back (
-       Rust::Token::make_identifier (Location (), std::move (path)));
+      case GenericArg::Kind::Either: {
+       auto path = arg.get_path ();
+       tokens.push_back (
+         Rust::Token::make_identifier (Location (), std::move (path)));
+      }
       break;
     case GenericArg::Kind::Error:
       gcc_unreachable ();