aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-01-31 15:26:53 +0000
committerGitHub <noreply@github.com>2022-01-31 15:26:53 +0000
commit6e5f8f76cbe47880ceae1bcf0bf7f07f601517ec (patch)
tree5fda817832faec93924e017371321bb110ffdb48 /gcc/rust/resolve
parent631f7ae7b9dbb55ed3adce942952f93b48983a53 (diff)
parent4c36c7c8d31e92d780f925b3bb62eec7db052442 (diff)
downloadgcc-6e5f8f76cbe47880ceae1bcf0bf7f07f601517ec.zip
gcc-6e5f8f76cbe47880ceae1bcf0bf7f07f601517ec.tar.gz
gcc-6e5f8f76cbe47880ceae1bcf0bf7f07f601517ec.tar.bz2
Merge #900
900: Fixup logic in canonical-path for impl-blocks r=philberty a=philberty 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. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
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