aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-20 12:00:11 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:31 +0100
commit6fef5bc497572798b817ad7afdcf5e5fb00c7910 (patch)
tree4a452e7f1fb4d191b360c9c3582b62747572e7b3 /gcc/rust/parse
parentf092edae96511e92b9d458184b23848f95138ab2 (diff)
downloadgcc-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/parse')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 2c6b3d8..6eb1955 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -3093,7 +3093,7 @@ template <typename EndTokenPred>
std::unique_ptr<AST::GenericParam>
Parser<ManagedTokenSource>::parse_generic_param (EndTokenPred is_end_token)
{
- auto outer_attrs = parse_outer_attribute ();
+ auto outer_attrs = parse_outer_attributes ();
std::unique_ptr<AST::GenericParam> param;
auto token = lexer.peek_token ();
@@ -3460,8 +3460,8 @@ template <typename ManagedTokenSource>
AST::LifetimeParam
Parser<ManagedTokenSource>::parse_lifetime_param ()
{
- // parse outer attribute, which is optional and may not exist
- AST::Attribute outer_attr = parse_outer_attribute ();
+ // parse outer attributes, which are optional and may not exist
+ auto outer_attrs = parse_outer_attributes ();
// save lifetime token - required
const_TokenPtr lifetime_tok = lexer.peek_token ();
@@ -3484,7 +3484,7 @@ Parser<ManagedTokenSource>::parse_lifetime_param ()
}
return AST::LifetimeParam (std::move (lifetime), std::move (lifetime_bounds),
- std::move (outer_attr),
+ std::move (outer_attrs),
lifetime_tok->get_locus ());
}
@@ -3561,8 +3561,8 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::TypeParam>
Parser<ManagedTokenSource>::parse_type_param ()
{
- // parse outer attribute, which is optional and may not exist
- AST::Attribute outer_attr = parse_outer_attribute ();
+ // parse outer attributes, which are optional and may not exist
+ auto outer_attrs = parse_outer_attributes ();
const_TokenPtr identifier_tok = lexer.peek_token ();
if (identifier_tok->get_id () != IDENTIFIER)
@@ -3605,7 +3605,7 @@ Parser<ManagedTokenSource>::parse_type_param ()
return std::unique_ptr<AST::TypeParam> (
new AST::TypeParam (std::move (ident), identifier_tok->get_locus (),
std::move (type_param_bounds), std::move (type),
- std::move (outer_attr)));
+ std::move (outer_attrs)));
}
/* Parses regular (i.e. non-generic) parameters in functions or methods. Also