diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 8a614f2..c4100c4 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -188,10 +188,17 @@ CompileStructExprField::visit (HIR::StructExprFieldIndexValue &field) void CompileStructExprField::visit (HIR::StructExprFieldIdentifier &field) { - // we can make the field look like an identifier expr to take advantage of - // existing code - HIR::IdentifierExpr expr (field.get_mappings (), field.get_field_name (), - field.get_locus ()); + // we can make the field look like a path expr to take advantage of existing + // code + + Analysis::NodeMapping mappings_copy1 = field.get_mappings (); + Analysis::NodeMapping mappings_copy2 = field.get_mappings (); + + HIR::PathIdentSegment ident_seg (field.get_field_name ()); + HIR::PathExprSegment seg (mappings_copy1, ident_seg, field.get_locus (), + HIR::GenericArgs::create_empty ()); + HIR::PathInExpression expr (mappings_copy2, {seg}, field.get_locus (), false, + {}); translated = CompileExpr::Compile (&expr, ctx); } |