]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Small fix to the ast collector visitor
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 25 Oct 2023 14:51:31 +0000 (16:51 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:13:11 +0000 (19:13 +0100)
The parameter type was used instead of the default value.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Check for presence
of a type and use the default value instead of the type.

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

index dbc3ef2997cd78866122bcb293252ca483b6ba37..71cc09835c3a1abd754bc24b8f791b5d0a0c37a6 100644 (file)
@@ -534,11 +534,12 @@ TokenCollector::visit (ConstGenericParam &param)
   auto id = param.get_name ().as_string ();
   push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id)));
   push (Rust::Token::make (COLON, UNDEF_LOCATION));
-  visit (param.get_type ());
+  if (param.has_type ())
+    visit (param.get_type ());
   if (param.has_default_value ())
     {
       push (Rust::Token::make (EQUAL, UNDEF_LOCATION));
-      visit (param.get_type ());
+      visit (param.get_default_value ());
     }
 }