]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: collector: Fix remaining trait & extern issues
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 28 Jun 2023 13:54:12 +0000 (15:54 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:34 +0000 (18:49 +0100)
Fix remaining failing tests with trait and extern. Outer attributes were
missing and the semicolon did output on macro invocations.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Fix
external item trailing semicolon and outer attributes.

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

index 88a25f0b41fa9b5aa60be2c0b9bc08ec0afc3080..f1306e738fd602104c007b3ae78d41d6e057bf03 100644 (file)
@@ -2097,8 +2097,10 @@ TokenCollector::visit (TraitItemConst &item)
 void
 TokenCollector::visit (TraitItemType &item)
 {
+  visit_items_as_lines (item.get_outer_attrs ());
   auto id = item.get_identifier ().as_string ();
   indentation ();
+
   push (Rust::Token::make (TYPE, item.get_locus ()));
   push (Rust::Token::make_identifier (Location (), std::move (id)));
   push (Rust::Token::make (SEMICOLON, Location ()));
@@ -2220,6 +2222,7 @@ TokenCollector::visit (ExternalFunctionItem &function)
       push (Rust::Token::make (RETURN_TYPE, Location ()));
       visit (function.get_return_type ());
     }
+  push (Rust::Token::make (SEMICOLON, Location ()));
 }
 
 void
@@ -2234,8 +2237,7 @@ TokenCollector::visit (ExternBlock &block)
       push (Rust::Token::make_string (Location (), std::move (abi)));
     }
 
-  visit_items_as_block (block.get_extern_items (),
-                       {Rust::Token::make (SEMICOLON, Location ())});
+  visit_items_as_block (block.get_extern_items (), {});
 }
 
 static std::pair<TokenId, TokenId>