diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-08-11 14:10:05 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-08-11 15:55:28 +0100 |
commit | d4ddd73b0b8ddd44204844a4d650424539335899 (patch) | |
tree | 26fb40b1fcbc93baa1c122286e7dc4e9bf806272 /gcc/rust/backend/rust-compile.cc | |
parent | 70a0039b82b3419820359c8a1552470e48b458f6 (diff) | |
download | gcc-d4ddd73b0b8ddd44204844a4d650424539335899.zip gcc-d4ddd73b0b8ddd44204844a4d650424539335899.tar.gz gcc-d4ddd73b0b8ddd44204844a4d650424539335899.tar.bz2 |
Desugar HIR::IdentifierExpr into HIR::PathInExpression
This completly removes the HIR::IdentifierExpr and unifies how we handle
generics in general. There was a hack from last year that did not infer
generic arguments on IdentifierExpr's which leads to a type inferencing
behvaiour mismatch which was becoming difficult to debug. This simplifies
everything.
The changes to the test case reflect making our code more compliant to
real rustc apart from compile/traits3.rs which will be fixed as part of the
refactoring effort going on in the type system.
Fixes #1456
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); } |