From: Owen Avery Date: Sat, 3 May 2025 00:28:15 +0000 (-0400) Subject: Improve canonical path handling for impl items X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98573bd61ef95e4224bc2d050fa1f47d893f2c31;p=thirdparty%2Fgcc.git Improve canonical path handling for impl items gcc/rust/ChangeLog: * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Use the return values of CanonicalPath::inherent_impl_seg and CanonicalPath::trait_impl_projection_seg more directly. * util/rust-canonical-path.h (CanonicalPath::trait_impl_projection_seg): Append " --- diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index fc226cf28c0..c2626ea0bbb 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -608,10 +608,7 @@ ResolveItem::visit (AST::InherentImpl &impl_block) } else { - std::string seg_buf = ""; - CanonicalPath seg - = CanonicalPath::new_seg (impl_block.get_node_id (), seg_buf); - cpath = canonical_prefix.append (seg); + cpath = canonical_prefix.append (impl_type_seg); } // done setup paths @@ -732,13 +729,7 @@ ResolveItem::visit (AST::TraitImpl &impl_block) } else { - std::string projection_str = canonical_projection.get (); - std::string seg_buf - = ""; - CanonicalPath seg - = CanonicalPath::new_seg (impl_block.get_node_id (), seg_buf); - cpath = canonical_prefix.append (seg); + cpath = canonical_prefix.append (canonical_projection); } // DONE setup canonical-path diff --git a/gcc/rust/util/rust-canonical-path.h b/gcc/rust/util/rust-canonical-path.h index 15846348f9c..33fead9c6c2 100644 --- a/gcc/rust/util/rust-canonical-path.h +++ b/gcc/rust/util/rust-canonical-path.h @@ -68,14 +68,18 @@ public: trait_impl_projection_seg (NodeId id, const CanonicalPath &trait_seg, const CanonicalPath &impl_type_seg) { - return CanonicalPath::new_seg (id, "<" + impl_type_seg.get () + " as " + // https://doc.rust-lang.org/reference/paths.html#canonical-paths + // should be ""? + return CanonicalPath::new_seg (id, ""); } static CanonicalPath inherent_impl_seg (NodeId id, const CanonicalPath &impl_type_seg) { - return CanonicalPath::new_seg (id, "<" + impl_type_seg.get () + ">"); + // https://doc.rust-lang.org/reference/paths.html#canonical-paths + // should be ""? + return CanonicalPath::new_seg (id, ""); } std::string get () const