From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id AE7AB3858025; Mon, 29 Aug 2022 15:31:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE7AB3858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661787082; bh=jDuAFxE/T+8gWvaMi6TM14MpZcRbiiH0qds75u8mq40=; h=From:To:Subject:Date:From; b=rnF4LADjvYT/zw3s576DTXbM2jGIupWFEYANKDMilHD4MDzX84Oz8PmK6HUt1/8Gu 0HEYEbgubcPxy6VhLvqP3Cg8FXKEygnyhbPMj5mWX59JUSfr6jsThvSaGNSmemTOdM v4q2E022VZHOIzRLSZjWBM1+CCjAsq+wRTPlgzds= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Cleanup canonical path usage on impl blocks X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 0f4ec11e8c2399ca20f80b4006e294794f9b2e0f X-Git-Newrev: 6dea70e1dafa603b2327bfb936d26fac95f46069 Message-Id: <20220829153122.AE7AB3858025@sourceware.org> Date: Mon, 29 Aug 2022 15:31:22 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6dea70e1dafa603b2327bfb936d26fac95f46069 commit 6dea70e1dafa603b2327bfb936d26fac95f46069 Author: Philip Herron Date: Mon Aug 22 12:22:54 2022 +0100 Cleanup canonical path usage on impl blocks Diff: --- gcc/rust/resolve/rust-ast-resolve-item.cc | 40 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index 75bd2e10b1c..0c38f28d530 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -534,25 +534,17 @@ ResolveItem::visit (AST::InherentImpl &impl_block) // FIXME this needs to be protected behind nominal type-checks see: // rustc --explain E0118 - - NodeId resolved_node = ResolveType::go (impl_block.get_type ().get ()); - if (resolved_node == UNKNOWN_NODEID) - { - resolver->get_type_scope ().pop (); - resolver->get_name_scope ().pop (); - return; - } + ResolveType::go (impl_block.get_type ().get ()); // Setup paths CanonicalPath self_cpath = CanonicalPath::create_empty (); bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_type ().get (), self_cpath); rust_assert (ok); + rust_debug ("AST::InherentImpl resolve Self: {%s}", + self_cpath.get ().c_str ()); - std::string raw_impl_type_path = impl_block.get_type ()->as_string (); - CanonicalPath impl_type - = CanonicalPath::new_seg (impl_block.get_type ()->get_node_id (), - raw_impl_type_path); + CanonicalPath impl_type = self_cpath; CanonicalPath impl_prefix = prefix.append (impl_type); // see https://godbolt.org/z/a3vMbsT6W @@ -580,6 +572,9 @@ ResolveItem::visit (AST::InherentImpl &impl_block) for (auto &impl_item : impl_block.get_impl_items ()) { + rust_debug ( + "AST::InherentImpl resolve_impl_item: impl_prefix={%s} cpath={%s}", + impl_prefix.get ().c_str (), cpath.get ().c_str ()); resolve_impl_item (impl_item.get (), impl_prefix, cpath); } @@ -703,22 +698,20 @@ ResolveItem::visit (AST::TraitImpl &impl_block) canonical_trait_type); rust_assert (ok); + rust_debug ("AST::TraitImpl resolve trait type: {%s}", + canonical_trait_type.get ().c_str ()); + CanonicalPath canonical_impl_type = CanonicalPath::create_empty (); ok = ResolveTypeToCanonicalPath::go (impl_block.get_type ().get (), canonical_impl_type); rust_assert (ok); - // raw paths - std::string raw_impl_type_path = impl_block.get_type ()->as_string (); - CanonicalPath impl_type_seg - = CanonicalPath::new_seg (impl_block.get_type ()->get_node_id (), - raw_impl_type_path); - - std::string raw_trait_type_path = impl_block.get_trait_path ().as_string (); - CanonicalPath trait_type_seg - = CanonicalPath::new_seg (impl_block.get_trait_path ().get_node_id (), - raw_trait_type_path); + rust_debug ("AST::TraitImpl resolve self: {%s}", + canonical_impl_type.get ().c_str ()); + // raw paths + CanonicalPath impl_type_seg = canonical_impl_type; + CanonicalPath trait_type_seg = canonical_trait_type; CanonicalPath projection = CanonicalPath::trait_impl_projection_seg (impl_block.get_node_id (), trait_type_seg, impl_type_seg); @@ -756,6 +749,9 @@ ResolveItem::visit (AST::TraitImpl &impl_block) for (auto &impl_item : impl_block.get_impl_items ()) { + rust_debug ( + "AST::TraitImpl resolve_impl_item: impl_prefix={%s} cpath={%s}", + impl_prefix.get ().c_str (), cpath.get ().c_str ()); resolve_impl_item (impl_item.get (), impl_prefix, cpath); }