diff options
author | Philip Herron <herron.philip@googlemail.com> | 2023-03-01 22:09:47 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-03-03 19:27:24 +0000 |
commit | 4ab9d9ce3366e51ccfe8a6a1a94e0eafedec5abb (patch) | |
tree | 341d783caf88e7061cb929c17426120141072297 /gcc/rust/hir | |
parent | 22465fbc8cca239aadcb35cd51d820d6d7213238 (diff) | |
download | gcc-4ab9d9ce3366e51ccfe8a6a1a94e0eafedec5abb.zip gcc-4ab9d9ce3366e51ccfe8a6a1a94e0eafedec5abb.tar.gz gcc-4ab9d9ce3366e51ccfe8a6a1a94e0eafedec5abb.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')
-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 740de93..f8a7dab 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 0ddb841..3a4362f 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 (); |