diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-03-01 22:09:47 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:19:03 +0100 |
commit | fca49c4d4a19c88bd6f3f18d27a56047e4a9bb80 (patch) | |
tree | b1f4b3f8c12912ae8a7fc51ea37c7b8d6a12c00f /gcc/rust/hir/tree | |
parent | 3df5ed955d338231ec896462b658283c46d31c60 (diff) | |
download | gcc-fca49c4d4a19c88bd6f3f18d27a56047e4a9bb80.zip gcc-fca49c4d4a19c88bd6f3f18d27a56047e4a9bb80.tar.gz gcc-fca49c4d4a19c88bd6f3f18d27a56047e4a9bb80.tar.bz2 |
gccrs: Fix missing move and copy constructors missing the associated-path
Addresses #1524
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:
* ast/rust-ast.cc (QualifiedPathInType::as_string): add missing to string
* ast/rust-path.h: add missing copy+move constructors and assignment overloads
* hir/tree/rust-hir-path.h: likewise
* hir/tree/rust-hir.cc (QualifiedPathInType::as_string): add missing to string
gcc/testsuite/ChangeLog:
* rust/compile/parse_associated_type_as_generic_arg.rs: it now works without -fsyntax-only
* rust/compile/parse_associated_type_as_generic_arg2.rs: likewise
Diffstat (limited to 'gcc/rust/hir/tree')
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-path.h | 15 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir.cc | 1 |
2 files changed, 8 insertions, 8 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h index 8f26ac6..f17b8a3 100644 --- a/gcc/rust/hir/tree/rust-hir-path.h +++ b/gcc/rust/hir/tree/rust-hir-path.h @@ -431,6 +431,7 @@ protected: bool has_separating_scope_resolution; SegmentType type; +public: // Clone function implementation - not pure virtual as overrided by subclasses virtual TypePathSegment *clone_type_path_segment_impl () const { @@ -538,7 +539,6 @@ public: return SegmentType::GENERIC; } -protected: // Use covariance to override base class method TypePathSegmentGeneric *clone_type_path_segment_impl () const override { @@ -654,7 +654,6 @@ public: TypePathFunction &get_function_path () { return function_path; } -protected: // Use covariance to override base class method TypePathSegmentFunction *clone_type_path_segment_impl () const override { @@ -933,24 +932,24 @@ public: segments (std::move (path_segments)) {} - /* TODO: maybe make a shortcut constructor that has QualifiedPathType elements - * as params */ - // Copy constructor with vector clone QualifiedPathInType (QualifiedPathInType const &other) : TypeNoBounds (other.mappings, other.locus), path_type (other.path_type) { + auto seg = other.associated_segment->clone_type_path_segment_impl (); + associated_segment = std::unique_ptr<TypePathSegment> (seg); + segments.reserve (other.segments.size ()); for (const auto &e : other.segments) segments.push_back (e->clone_type_path_segment ()); - - // Untested. - gcc_unreachable (); } // Overloaded assignment operator with vector clone QualifiedPathInType &operator= (QualifiedPathInType const &other) { + auto seg = other.associated_segment->clone_type_path_segment_impl (); + associated_segment = std::unique_ptr<TypePathSegment> (seg); + path_type = other.path_type; locus = other.locus; mappings = other.mappings; diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc index 20e92ac..93108c8 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -2112,6 +2112,7 @@ QualifiedPathInType::as_string () const { std::string str = path_type.as_string (); + str += "::" + associated_segment->as_string (); for (const auto &segment : segments) { str += "::" + segment->as_string (); |