diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-04-04 19:52:38 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-04-05 08:09:09 +0000 |
commit | 7035cd6ba104fb1e600528ae6a91eda736029d4c (patch) | |
tree | e52b1cc38375d3124f9bf7a8fbd3e14c27aeefad /gcc | |
parent | f499a356a85e0a25201bd6de0943c08090c9d919 (diff) | |
download | gcc-7035cd6ba104fb1e600528ae6a91eda736029d4c.zip gcc-7035cd6ba104fb1e600528ae6a91eda736029d4c.tar.gz gcc-7035cd6ba104fb1e600528ae6a91eda736029d4c.tar.bz2 |
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 (); |