Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions gcc/rust/ast/rust-fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ffi::Piece> (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<ffi::Piece> (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
2 changes: 0 additions & 2 deletions gcc/rust/ast/rust-fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ struct Pieces
Pieces (const Pieces &other);
Pieces &operator= (const Pieces &other);

Pieces (Pieces &&other);

const std::vector<ffi::Piece> &get_pieces () const { return pieces_vector; }

// {
Expand Down
Loading