diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-05-20 12:00:11 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:31 +0100 |
commit | 6fef5bc497572798b817ad7afdcf5e5fb00c7910 (patch) | |
tree | 4a452e7f1fb4d191b360c9c3582b62747572e7b3 /gcc/rust/ast/rust-ast-collector.cc | |
parent | f092edae96511e92b9d458184b23848f95138ab2 (diff) | |
download | gcc-6fef5bc497572798b817ad7afdcf5e5fb00c7910.zip gcc-6fef5bc497572798b817ad7afdcf5e5fb00c7910.tar.gz gcc-6fef5bc497572798b817ad7afdcf5e5fb00c7910.tar.bz2 |
gccrs: Allow multiple outer attributes on generic params
Previously generic params only allowed one outer attribute in front of
them.
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Visit outer
attributes.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Change outer
attribute visit, we need to visit all of them.
* ast/rust-ast.cc (LifetimeParam::as_string): Change as_string
implementation to allow multiple outer attributes.
(TypeParam::as_string): Likewise.
* ast/rust-ast.h (class LifetimeParam): Allow multiple outer
attributes.
* ast/rust-item.h (class TypeParam): Likewise.
* ast/rust-path.h: Likewise.
* parse/rust-parse-impl.h (Parser::parse_generic_param): Change call
to outer attribute parsing to collect several attributes.
(Parser::parse_lifetime_param): Likewise.
(Parser::parse_type_param): Likewise.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-ast-collector.cc')
-rw-r--r-- | gcc/rust/ast/rust-ast-collector.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc index a7f6ed5..a757225 100644 --- a/gcc/rust/ast/rust-ast-collector.cc +++ b/gcc/rust/ast/rust-ast-collector.cc @@ -476,6 +476,7 @@ TokenCollector::visit (LifetimeParam &lifetime_param) // TODO what to do with outer attr? They are not mentioned in the reference. + visit_items_as_lines (lifetime_param.get_outer_attrs ()); auto lifetime = lifetime_param.get_lifetime (); visit (lifetime); @@ -495,6 +496,7 @@ TokenCollector::visit (ConstGenericParam ¶m) // Syntax: // const IDENTIFIER : Type ( = Block | IDENTIFIER | -?LITERAL )? + visit_items_as_lines (param.get_outer_attrs ()); push (Rust::Token::make (CONST, param.get_locus ())); auto id = param.get_name ().as_string (); push (Rust::Token::make_identifier (UNDEF_LOCATION, std::move (id))); @@ -1509,6 +1511,7 @@ TokenCollector::visit (TypeParam ¶m) // TypeParamBounds : // TypeParamBound ( + TypeParamBound )* +? + visit_items_as_lines (param.get_outer_attrs ()); auto id = param.get_type_representation ().as_string (); push (Rust::Token::make_identifier (param.get_locus (), std::move (id))); if (param.has_type_param_bounds ()) |