@@ -2831,6 +2831,7 @@ class Trait : public VisItem
2831
2831
bool has_auto;
2832
2832
Identifier name;
2833
2833
std::vector<std::unique_ptr<GenericParam>> generic_params;
2834
+ TypeParam self_param;
2834
2835
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds;
2835
2836
WhereClause where_clause;
2836
2837
std::vector<Attribute> inner_attrs;
@@ -2870,7 +2871,7 @@ class Trait : public VisItem
2870
2871
std::vector<Attribute> inner_attrs, location_t locus)
2871
2872
: VisItem (std::move (vis), std::move (outer_attrs)),
2872
2873
has_unsafe (is_unsafe), has_auto (is_auto), name (std::move (name)),
2873
- generic_params (std::move (generic_params)),
2874
+ generic_params (std::move (generic_params)), self_param ({ " Self " }, locus),
2874
2875
type_param_bounds (std::move (type_param_bounds)),
2875
2876
where_clause (std::move (where_clause)),
2876
2877
inner_attrs (std::move (inner_attrs)),
@@ -2880,8 +2881,9 @@ class Trait : public VisItem
2880
2881
// Copy constructor with vector clone
2881
2882
Trait (Trait const &other)
2882
2883
: VisItem (other), has_unsafe (other.has_unsafe), has_auto (other.has_auto),
2883
- name (other.name), where_clause (other.where_clause),
2884
- inner_attrs (other.inner_attrs), locus (other.locus)
2884
+ name (other.name), self_param (other.self_param),
2885
+ where_clause (other.where_clause), inner_attrs (other.inner_attrs),
2886
+ locus (other.locus)
2885
2887
{
2886
2888
generic_params.reserve (other.generic_params .size ());
2887
2889
for (const auto &e : other.generic_params )
@@ -2901,6 +2903,7 @@ class Trait : public VisItem
2901
2903
{
2902
2904
VisItem::operator = (other);
2903
2905
name = other.name ;
2906
+ self_param = other.self_param ;
2904
2907
has_unsafe = other.has_unsafe ;
2905
2908
has_auto = other.has_auto ;
2906
2909
where_clause = other.where_clause ;
@@ -2968,19 +2971,7 @@ class Trait : public VisItem
2968
2971
2969
2972
WhereClause &get_where_clause () { return where_clause; }
2970
2973
2971
- void insert_implict_self (std::unique_ptr<AST::GenericParam> &¶m)
2972
- {
2973
- std::vector<std::unique_ptr<GenericParam>> new_list;
2974
- new_list.reserve (generic_params.size () + 1 );
2975
-
2976
- new_list.push_back (std::move (param));
2977
- for (auto &p : generic_params)
2978
- {
2979
- new_list.push_back (std::move (p));
2980
- }
2981
-
2982
- generic_params = std::move (new_list);
2983
- }
2974
+ AST::TypeParam &get_implicit_self () { return self_param; }
2984
2975
2985
2976
protected:
2986
2977
/* Use covariance to implement clone function as returning this object
0 commit comments