aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse-impl.h
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-20 12:00:11 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-06-11 15:53:17 +0000
commit2a1e169956f9faa13928eda3f146ea0cc770b864 (patch)
tree141cfaa57d9b37d06f5cf28df31756a85e402bc8 /gcc/rust/parse/rust-parse-impl.h
parent50862befdb2c33ad6b71f0c4c8ce3d455c92cffd (diff)
downloadgcc-2a1e169956f9faa13928eda3f146ea0cc770b864.zip
gcc-2a1e169956f9faa13928eda3f146ea0cc770b864.tar.gz
gcc-2a1e169956f9faa13928eda3f146ea0cc770b864.tar.bz2
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/rust-parse-impl.h')
-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 b501c8e..3548fcc 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