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

commit e7caf68fe08f371102b605450e5a9ab516e2a90b
Author: Pierre-Emmanuel Patry <[email protected]>
Date:   Wed Oct 25 16:51:31 2023 +0200

    Small fix to the ast collector visitor
    
    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 <[email protected]>

Diff:
---
 gcc/rust/ast/rust-ast-collector.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-collector.cc 
b/gcc/rust/ast/rust-ast-collector.cc
index dbc3ef2997cd..71cc09835c3a 100644
--- a/gcc/rust/ast/rust-ast-collector.cc
+++ b/gcc/rust/ast/rust-ast-collector.cc
@@ -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 ());
     }
 }

Reply via email to