aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-item.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/ast/rust-item.h')
-rw-r--r--gcc/rust/ast/rust-item.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 3969398..0ee1313 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -3172,7 +3172,7 @@ class TraitImpl : public Impl
{
bool has_unsafe;
bool has_exclam;
- TypePath trait_path;
+ std::unique_ptr<Path> trait_path;
// bool has_impl_items;
std::vector<std::unique_ptr<AssociatedItem>> impl_items;
@@ -3184,7 +3184,7 @@ public:
bool has_impl_items () const { return !impl_items.empty (); }
// Mega-constructor
- TraitImpl (TypePath trait_path, bool is_unsafe, bool has_exclam,
+ TraitImpl (std::unique_ptr<Path> trait_path, bool is_unsafe, bool has_exclam,
std::vector<std::unique_ptr<AssociatedItem>> impl_items,
std::vector<std::unique_ptr<GenericParam>> generic_params,
std::unique_ptr<Type> trait_type, WhereClause where_clause,
@@ -3197,10 +3197,26 @@ public:
trait_path (std::move (trait_path)), impl_items (std::move (impl_items))
{}
+ // Helper constructor with a typepath
+ TraitImpl (TypePath trait_path, bool is_unsafe, bool has_exclam,
+ std::vector<std::unique_ptr<AssociatedItem>> impl_items,
+ std::vector<std::unique_ptr<GenericParam>> generic_params,
+ std::unique_ptr<Type> trait_type, WhereClause where_clause,
+ Visibility vis, std::vector<Attribute> inner_attrs,
+ std::vector<Attribute> outer_attrs, location_t locus)
+ : Impl (std::move (generic_params), std::move (trait_type),
+ std::move (where_clause), std::move (vis), std::move (inner_attrs),
+ std::move (outer_attrs), locus),
+ has_unsafe (is_unsafe), has_exclam (has_exclam),
+ trait_path (std::unique_ptr<TypePath> (new TypePath (trait_path))),
+ impl_items (std::move (impl_items))
+ {}
+
// Copy constructor with vector clone
TraitImpl (TraitImpl const &other)
: Impl (other), has_unsafe (other.has_unsafe),
- has_exclam (other.has_exclam), trait_path (other.trait_path)
+ has_exclam (other.has_exclam),
+ trait_path (other.trait_path->clone_path ())
{
impl_items.reserve (other.impl_items.size ());
for (const auto &e : other.impl_items)
@@ -3211,7 +3227,7 @@ public:
TraitImpl &operator= (TraitImpl const &other)
{
Impl::operator= (other);
- trait_path = other.trait_path;
+ trait_path = other.trait_path->clone_path ();
has_unsafe = other.has_unsafe;
has_exclam = other.has_exclam;
@@ -3242,10 +3258,10 @@ public:
}
// TODO: is this better? Or is a "vis_block" better?
- TypePath &get_trait_path ()
+ Path &get_trait_path ()
{
// TODO: assert that trait path is not empty?
- return trait_path;
+ return *trait_path;
}
protected: