Skip to content

Commit 582b9cb

Browse files
committed
Don't pass in a vector to Encoder::new.
It's not necessary.
1 parent 92b1ab8 commit 582b9cb

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

compiler/rustc_codegen_ssa/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const RUSTC_VERSION: Option<&str> = option_env!("CFG_VERSION");
203203

204204
impl CodegenResults {
205205
pub fn serialize_rlink(codegen_results: &CodegenResults) -> Vec<u8> {
206-
let mut encoder = opaque::Encoder::new(vec![]);
206+
let mut encoder = opaque::Encoder::new();
207207
encoder.emit_raw_bytes(RLINK_MAGIC).unwrap();
208208
// `emit_raw_bytes` is used to make sure that the version representation does not depend on
209209
// Encoder's inner representation of `u32`.

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
21942194
}
21952195

21962196
fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
2197-
let mut encoder = opaque::Encoder::new(vec![]);
2197+
let mut encoder = opaque::Encoder::new();
21982198
encoder.emit_raw_bytes(METADATA_HEADER).unwrap();
21992199

22002200
// Will be filled with the root position after encoding everything.

compiler/rustc_serialize/src/opaque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pub struct Encoder {
1818
}
1919

2020
impl Encoder {
21-
pub fn new(data: Vec<u8>) -> Encoder {
22-
Encoder { data }
21+
pub fn new() -> Encoder {
22+
Encoder { data: vec![] }
2323
}
2424

2525
pub fn into_inner(self) -> Vec<u8> {

compiler/rustc_serialize/tests/opaque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct Struct {
3131
fn check_round_trip<T: Encodable<Encoder> + for<'a> Decodable<Decoder<'a>> + PartialEq + Debug>(
3232
values: Vec<T>,
3333
) {
34-
let mut encoder = Encoder::new(Vec::new());
34+
let mut encoder = Encoder::new();
3535

3636
for value in &values {
3737
Encodable::encode(value, &mut encoder).unwrap();

0 commit comments

Comments
 (0)