diff --git a/gcc/rust/ast/rust-fmt.cc b/gcc/rust/ast/rust-fmt.cc index a29c8203ae8f..9090c190240a 100644 --- a/gcc/rust/ast/rust-fmt.cc +++ b/gcc/rust/ast/rust-fmt.cc @@ -49,24 +49,26 @@ Pieces::collect (const std::string &to_parse, bool append_newline, Pieces::~Pieces () { ffi::destroy_pieces (handle); } -Pieces::Pieces (const Pieces &other) : pieces_vector (other.pieces_vector) +Pieces::Pieces (const Pieces &other) : handle (ffi::clone_pieces (other.handle)) { - handle = ffi::clone_pieces (other.handle); + // reconstruct + pieces_vector = std::vector (handle.piece_slice.base_ptr, + handle.piece_slice.base_ptr + + handle.piece_slice.len); } Pieces & Pieces::operator= (const Pieces &other) { handle = ffi::clone_pieces (other.handle); - pieces_vector = other.pieces_vector; + + // reconstruct + pieces_vector = std::vector (handle.piece_slice.base_ptr, + handle.piece_slice.base_ptr + + handle.piece_slice.len); return *this; } -Pieces::Pieces (Pieces &&other) - : pieces_vector (std::move (other.pieces_vector)), - handle (clone_pieces (other.handle)) -{} - } // namespace Fmt } // namespace Rust diff --git a/gcc/rust/ast/rust-fmt.h b/gcc/rust/ast/rust-fmt.h index 3722db291ab8..a541b4124bf7 100644 --- a/gcc/rust/ast/rust-fmt.h +++ b/gcc/rust/ast/rust-fmt.h @@ -286,8 +286,6 @@ struct Pieces Pieces (const Pieces &other); Pieces &operator= (const Pieces &other); - Pieces (Pieces &&other); - const std::vector &get_pieces () const { return pieces_vector; } // {