From 213b638b3269078d77f02a46602105917616372f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Wed, 9 Jun 2021 15:20:35 +0200 Subject: Fix: do not use object after it has been moved After std::move(mapping), mapping is unspecified --- gcc/rust/hir/rust-ast-lower-type.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h index 86e802e..5e19850 100644 --- a/gcc/rust/hir/rust-ast-lower-type.h +++ b/gcc/rust/hir/rust-ast-lower-type.h @@ -72,15 +72,15 @@ public: }); auto crate_num = mappings->get_current_crate (); - Analysis::NodeMapping mapping (crate_num, path.get_node_id (), - mappings->get_next_hir_id (crate_num), + auto hirid = mappings->get_next_hir_id (crate_num); + Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid, mappings->get_next_localdef_id (crate_num)); + translated = new HIR::TypePath (std::move (mapping), std::move (translated_segments), path.get_locus (), path.has_opening_scope_resolution_op ()); - mappings->insert_hir_type (mapping.get_crate_num (), mapping.get_hirid (), - translated); + mappings->insert_hir_type (crate_num, hirid, translated); } private: -- cgit v1.1 From 09d26b3e0b11859bc9fa27f9a4b176da47bc7add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Sun, 6 Jun 2021 15:08:03 +0200 Subject: Make 3 error messages slightly more informational Add more context to some internal error messages (ie. not intended for user) --- gcc/rust/backend/rust-compile-expr.h | 6 ++++-- gcc/rust/typecheck/rust-hir-type-check-type.h | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 59ae815..09652f1 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -183,8 +183,10 @@ public: if (!ctx->get_tyctx ()->lookup_type ( expr.get_mappings ().get_hirid (), &tyty)) { - rust_fatal_error (expr.get_locus (), - "did not resolve type for this literal expr"); + rust_fatal_error ( + expr.get_locus (), + "did not resolve type for this literal expr (HirId %d)", + expr.get_mappings ().get_hirid ()); return; } diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.h b/gcc/rust/typecheck/rust-hir-type-check-type.h index 70b9cfa..136c0c2 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.h +++ b/gcc/rust/typecheck/rust-hir-type-check-type.h @@ -118,18 +118,20 @@ public: { // lookup the Node this resolves to NodeId ref; - if (!resolver->lookup_resolved_type (path.get_mappings ().get_nodeid (), - &ref)) + auto nid = path.get_mappings ().get_nodeid (); + if (!resolver->lookup_resolved_type (nid, &ref)) { rust_fatal_error (path.get_locus (), - "Failed to resolve node id to HIR"); + "failed to resolve node '%d' to HIR", nid); return; } HirId hir_lookup; if (!context->lookup_type_by_node_id (ref, &hir_lookup)) { - rust_error_at (path.get_locus (), "failed to lookup HIR node"); + rust_error_at (path.get_locus (), + "failed to lookup HIR %d for node '%s'", ref, + path.as_string ().c_str ()); return; } -- cgit v1.1 From c143022ebee18a2d32d2844521d5ec1f0b06bdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Sat, 5 Jun 2021 22:21:50 +0200 Subject: Add more info in HIR dump for struct Make struct fields more visible in dumps and add the mapping in the dump string. --- gcc/rust/hir/tree/rust-hir-full-test.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/hir/tree/rust-hir-full-test.cc b/gcc/rust/hir/tree/rust-hir-full-test.cc index 14b64d2..236ff3d 100644 --- a/gcc/rust/hir/tree/rust-hir-full-test.cc +++ b/gcc/rust/hir/tree/rust-hir-full-test.cc @@ -577,11 +577,12 @@ StructStruct::as_string () const { for (const auto &field : fields) { - str += "\n " + field.as_string (); + str += "\n - " + field.as_string (); } + str += "\n"; } - return str; + return str + "::" + get_mappings ().as_string () + "\n"; } std::string -- cgit v1.1