aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast.h
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/ast/rust-ast.h
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/ast/rust-ast.h')
-rw-r--r--gcc/rust/ast/rust-ast.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 0693b10..ee1c58c 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1602,7 +1602,7 @@ class LifetimeParam : public GenericParam
{
Lifetime lifetime;
std::vector<Lifetime> lifetime_bounds;
- Attribute outer_attr;
+ AST::AttrVec outer_attrs;
location_t locus;
public:
@@ -1610,7 +1610,7 @@ public:
Lifetime &get_lifetime () { return lifetime; }
- Attribute &get_outer_attribute () { return outer_attr; }
+ AST::AttrVec &get_outer_attrs () { return outer_attrs; }
// Returns whether the lifetime param has any lifetime bounds.
bool has_lifetime_bounds () const { return !lifetime_bounds.empty (); }
@@ -1618,13 +1618,12 @@ public:
std::vector<Lifetime> &get_lifetime_bounds () { return lifetime_bounds; }
// Returns whether the lifetime param has an outer attribute.
- bool has_outer_attribute () const { return !outer_attr.is_empty (); }
+ bool has_outer_attribute () const { return !outer_attrs.empty (); }
// Creates an error state lifetime param.
static LifetimeParam create_error ()
{
- return LifetimeParam (Lifetime::error (), {}, Attribute::create_empty (),
- UNDEF_LOCATION);
+ return LifetimeParam (Lifetime::error (), {}, {}, UNDEF_LOCATION);
}
// Returns whether the lifetime param is in an error state.
@@ -1632,10 +1631,10 @@ public:
// Constructor
LifetimeParam (Lifetime lifetime, std::vector<Lifetime> lifetime_bounds,
- Attribute outer_attr, location_t locus)
+ AST::AttrVec outer_attrs, location_t locus)
: lifetime (std::move (lifetime)),
lifetime_bounds (std::move (lifetime_bounds)),
- outer_attr (std::move (outer_attr)), locus (locus)
+ outer_attrs (std::move (outer_attrs)), locus (locus)
{}
std::string as_string () const override;