@@ -91,14 +91,17 @@ DeriveClone::clone_impl (
91
91
std::unique_ptr<AssociatedItem> &&clone_fn, std::string name,
92
92
const std::vector<std::unique_ptr<GenericParam>> &type_generics)
93
93
{
94
- auto clone = builder.type_path (LangItem::Kind::CLONE);
94
+ // we should have two of these, so we don't run into issues with
95
+ // two paths sharing a node id
96
+ auto clone_bound = builder.type_path (LangItem::Kind::CLONE);
97
+ auto clone_trait_path = builder.type_path (LangItem::Kind::CLONE);
95
98
96
99
auto trait_items = vec (std::move (clone_fn));
97
100
98
- auto generics
99
- = setup_impl_generics (name, type_generics, builder.trait_bound (clone ));
101
+ auto generics = setup_impl_generics (name, type_generics,
102
+ builder.trait_bound (clone_bound ));
100
103
101
- return builder.trait_impl (clone , std::move (generics.self_type ),
104
+ return builder.trait_impl (clone_trait_path , std::move (generics.self_type ),
102
105
std::move (trait_items),
103
106
std::move (generics.impl ));
104
107
}
@@ -173,9 +176,14 @@ DeriveClone::clone_enum_identifier (PathInExpression variant_path,
173
176
const std::unique_ptr<EnumItem> &variant)
174
177
{
175
178
auto pattern = std::unique_ptr<Pattern> (new ReferencePattern (
176
- std::unique_ptr<Pattern> (new PathInExpression (variant_path)), false ,
177
- false , loc));
178
- auto expr = std::unique_ptr<Expr> (new PathInExpression (variant_path));
179
+ std::unique_ptr<Pattern> (new PathInExpression (
180
+ variant_path.get_segments (), {}, variant_path.get_locus (),
181
+ variant_path.opening_scope_resolution ())),
182
+ false , false , loc));
183
+ auto expr = std::unique_ptr<Expr> (
184
+ new PathInExpression (variant_path.get_segments (), {},
185
+ variant_path.get_locus (),
186
+ variant_path.opening_scope_resolution ()));
179
187
180
188
return builder.match_case (std::move (pattern), std::move (expr));
181
189
}
@@ -206,14 +214,19 @@ DeriveClone::clone_enum_tuple (PathInExpression variant_path,
206
214
auto pattern_items = std::unique_ptr<TupleStructItems> (
207
215
new TupleStructItemsNoRange (std::move (patterns)));
208
216
209
- auto pattern = std::unique_ptr<Pattern> (
210
- new ReferencePattern (std::unique_ptr<Pattern> (new TupleStructPattern (
211
- variant_path, std::move (pattern_items))),
212
- false , false , loc));
213
-
214
- auto expr
215
- = builder.call (std::unique_ptr<Expr> (new PathInExpression (variant_path)),
216
- std::move (cloned_patterns));
217
+ auto pattern = std::unique_ptr<Pattern> (new ReferencePattern (
218
+ std::unique_ptr<Pattern> (new TupleStructPattern (
219
+ PathInExpression (variant_path.get_segments (), {},
220
+ variant_path.get_locus (),
221
+ variant_path.opening_scope_resolution ()),
222
+ std::move (pattern_items))),
223
+ false , false , loc));
224
+
225
+ auto expr = builder.call (std::unique_ptr<Expr> (new PathInExpression (
226
+ variant_path.get_segments (), {},
227
+ variant_path.get_locus (),
228
+ variant_path.opening_scope_resolution ())),
229
+ std::move (cloned_patterns));
217
230
218
231
return builder.match_case (std::move (pattern), std::move (expr));
219
232
}
0 commit comments