aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.cc29
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.h20
-rw-r--r--gcc/rust/backend/rust-compile.cc18
3 files changed, 15 insertions, 52 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index ffc2655..1a798ee 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -93,34 +93,5 @@ ResolvePathRef::visit (HIR::PathInExpression &expr)
= ctx->get_backend ()->function_code_expression (fn, expr.get_locus ());
}
-void
-ResolvePathType::visit (HIR::PathInExpression &expr)
-{
- // need to look up the reference for this identifier
- NodeId ref_node_id;
- if (!ctx->get_resolver ()->lookup_resolved_type (
- expr.get_mappings ().get_nodeid (), &ref_node_id))
- {
- return;
- }
-
- HirId ref;
- if (!ctx->get_mappings ()->lookup_node_to_hir (
- expr.get_mappings ().get_crate_num (), ref_node_id, &ref))
- {
- rust_error_at (expr.get_locus (), "reverse lookup failure");
- return;
- }
-
- TyTy::BaseType *tyty = nullptr;
- if (!ctx->get_tyctx ()->lookup_type (ref, &tyty))
- {
- rust_error_at (expr.get_locus (), "unknown type");
- return;
- }
-
- resolved = TyTyResolveCompile::compile (ctx, tyty);
-}
-
} // namespace Compile
} // namespace Rust
diff --git a/gcc/rust/backend/rust-compile-resolve-path.h b/gcc/rust/backend/rust-compile-resolve-path.h
index 2f3cb68..ae469e6 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.h
+++ b/gcc/rust/backend/rust-compile-resolve-path.h
@@ -35,7 +35,7 @@ public:
return resolver.resolved;
}
- void visit (HIR::PathInExpression &expr);
+ void visit (HIR::PathInExpression &expr) override;
private:
ResolvePathRef (Context *ctx) : HIRCompileBase (ctx), resolved (nullptr) {}
@@ -43,24 +43,6 @@ private:
Bexpression *resolved;
};
-class ResolvePathType : public HIRCompileBase
-{
-public:
- static Btype *Compile (HIR::Expr *expr, Context *ctx)
- {
- ResolvePathType resolver (ctx);
- expr->accept_vis (resolver);
- return resolver.resolved;
- }
-
- void visit (HIR::PathInExpression &expr);
-
-private:
- ResolvePathType (Context *ctx) : HIRCompileBase (ctx), resolved (nullptr) {}
-
- Btype *resolved;
-};
-
} // namespace Compile
} // namespace Rust
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc
index 61bacf3..2c83527 100644
--- a/gcc/rust/backend/rust-compile.cc
+++ b/gcc/rust/backend/rust-compile.cc
@@ -53,11 +53,21 @@ CompileCrate::go ()
void
CompileExpr::visit (HIR::CallExpr &expr)
{
- Btype *type = ResolvePathType::Compile (expr.get_fnexpr (), ctx);
- if (type != nullptr)
+ TyTy::BaseType *tyty = nullptr;
+ if (!ctx->get_tyctx ()->lookup_type (
+ expr.get_fnexpr ()->get_mappings ().get_hirid (), &tyty))
{
- // this assumes all fields are in order from type resolution and if a base
- // struct was specified those fields are filed via accesors
+ rust_error_at (expr.get_locus (), "unknown type");
+ return;
+ }
+
+ // must be a tuple constructor
+ if (tyty->get_kind () != TyTy::TypeKind::FNDEF)
+ {
+ Btype *type = TyTyResolveCompile::compile (ctx, tyty);
+
+ // this assumes all fields are in order from type resolution and if a
+ // base struct was specified those fields are filed via accesors
std::vector<Bexpression *> vals;
expr.iterate_params ([&] (HIR::Expr *argument) mutable -> bool {
Bexpression *e = CompileExpr::Compile (argument, ctx);