aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-resolve-path.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-08-11 14:10:05 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-08-11 15:55:28 +0100
commitd4ddd73b0b8ddd44204844a4d650424539335899 (patch)
tree26fb40b1fcbc93baa1c122286e7dc4e9bf806272 /gcc/rust/backend/rust-compile-resolve-path.cc
parent70a0039b82b3419820359c8a1552470e48b458f6 (diff)
downloadgcc-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-resolve-path.cc')
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index 8c1b7ef..f799445 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -64,6 +64,13 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
return error_mark_node;
TyTy::ADTType *adt = static_cast<TyTy::ADTType *> (lookup);
+
+ // it might be a unit-struct
+ if (adt->is_unit ())
+ {
+ return ctx->get_backend ()->unit_expression ();
+ }
+
if (!adt->is_enum ())
return error_mark_node;
@@ -121,6 +128,14 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
return ctx->get_backend ()->var_expression (var, expr_locus);
}
+ // might be a match pattern binding
+ tree binding = error_mark_node;
+ if (ctx->lookup_pattern_binding (ref, &binding))
+ {
+ TREE_USED (binding) = 1;
+ return binding;
+ }
+
// it might be a function call
if (lookup->get_kind () == TyTy::TypeKind::FNDEF)
{