aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-01-30 23:57:46 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-01-31 00:14:31 +0000
commit4c36c7c8d31e92d780f925b3bb62eec7db052442 (patch)
tree5fda817832faec93924e017371321bb110ffdb48 /gcc/rust/resolve
parent631f7ae7b9dbb55ed3adce942952f93b48983a53 (diff)
downloadgcc-4c36c7c8d31e92d780f925b3bb62eec7db052442.zip
gcc-4c36c7c8d31e92d780f925b3bb62eec7db052442.tar.gz
gcc-4c36c7c8d31e92d780f925b3bb62eec7db052442.tar.bz2
Fixup logic in canonical-path for impl-blocks
Impl blocks canonical prefix when the size is one will only contain the respective crate name but impl blocks canonical path will be of the Self type which has its own respective crate and path so this will become the canonical path of this. If the segment size greater than one this means it is likely inside a mod block or other item so this means we should just append as usual.
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h
index e428880..234d865 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.h
+++ b/gcc/rust/resolve/rust-ast-resolve-item.h
@@ -579,17 +579,17 @@ public:
// see https://godbolt.org/z/a3vMbsT6W
CanonicalPath cpath = CanonicalPath::create_empty ();
- if (canonical_prefix.size () > 1)
+ if (canonical_prefix.size () <= 1)
+ {
+ cpath = self_cpath;
+ }
+ else
{
std::string seg_buf = "<impl " + self_cpath.get () + ">";
CanonicalPath seg
= CanonicalPath::new_seg (impl_block.get_node_id (), seg_buf);
cpath = canonical_prefix.append (seg);
}
- else
- {
- cpath = canonical_prefix.append (self_cpath);
- }
// done setup paths
auto Self
@@ -757,7 +757,11 @@ public:
canonical_trait_type,
canonical_impl_type);
CanonicalPath cpath = CanonicalPath::create_empty ();
- if (canonical_prefix.size () > 1)
+ if (canonical_prefix.size () <= 1)
+ {
+ cpath = canonical_projection;
+ }
+ else
{
std::string projection_str = canonical_projection.get ();
std::string seg_buf
@@ -767,10 +771,7 @@ public:
= CanonicalPath::new_seg (impl_block.get_node_id (), seg_buf);
cpath = canonical_prefix.append (seg);
}
- else
- {
- cpath = canonical_prefix.append (canonical_projection);
- }
+
// DONE setup canonical-path
auto Self