Don't pass in a vector to Encoder::new.

It's not necessary.
This commit is contained in:
Nicholas Nethercote 2022-06-07 13:30:08 +10:00
parent 92b1ab8d57
commit 582b9cbc45
4 changed files with 5 additions and 5 deletions

View file

@ -203,7 +203,7 @@ const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");
impl CodegenResults {
pub fn serialize_rlink(codegen_results: &CodegenResults) -> Vec<u8> {
let mut encoder = opaque::Encoder::new(vec![]);
let mut encoder = opaque::Encoder::new();
encoder.emit_raw_bytes(RLINK_MAGIC).unwrap();
// `emit_raw_bytes` is used to make sure that the version representation does not depend on
// Encoder's inner representation of `u32`.

View file

@ -2194,7 +2194,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
}
fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
let mut encoder = opaque::Encoder::new(vec![]);
let mut encoder = opaque::Encoder::new();
encoder.emit_raw_bytes(METADATA_HEADER).unwrap();
// Will be filled with the root position after encoding everything.

View file

@ -18,8 +18,8 @@ pub struct Encoder {
}
impl Encoder {
pub fn new(data: Vec<u8>) -> Encoder {
Encoder { data }
pub fn new() -> Encoder {
Encoder { data: vec![] }
}
pub fn into_inner(self) -> Vec<u8> {

View file

@ -31,7 +31,7 @@ struct Struct {
fn check_round_trip<T: Encodable<Encoder> + for<'a> Decodable<Decoder<'a>> + PartialEq + Debug>(
values: Vec<T>,
) {
let mut encoder = Encoder::new(Vec::new());
let mut encoder = Encoder::new();
for value in &values {
Encodable::encode(value, &mut encoder).unwrap();