diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-04-04 19:52:38 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:28:44 +0100 |
commit | 88c5d5555530b6dc54f5aeb3dc5735aa8153a602 (patch) | |
tree | 4949808fed0ca83956f29fc8670645d044362997 /gcc | |
parent | efb24f60a818a8bec65a6204de9bb7f6866a4539 (diff) | |
download | gcc-88c5d5555530b6dc54f5aeb3dc5735aa8153a602.zip gcc-88c5d5555530b6dc54f5aeb3dc5735aa8153a602.tar.gz gcc-88c5d5555530b6dc54f5aeb3dc5735aa8153a602.tar.bz2 |
gccrs: ast: Fix ICE on generic args path
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-ast-tokenstream.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/rust/ast/rust-ast-tokenstream.cc b/gcc/rust/ast/rust-ast-tokenstream.cc index 2fc7c2b..3e2fdfc 100644 --- a/gcc/rust/ast/rust-ast-tokenstream.cc +++ b/gcc/rust/ast/rust-ast-tokenstream.cc @@ -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 (); |