Skip to content

Commit

Permalink
Delete Decoder::read_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Feb 22, 2022
1 parent 2098ea6 commit f1bcb0f
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2418,8 +2418,7 @@ impl<S: Encoder> rustc_serialize::Encodable<S> for AttrId {
}

impl<D: Decoder> rustc_serialize::Decodable<D> for AttrId {
fn decode(d: &mut D) -> AttrId {
d.read_unit();
fn decode(_: &mut D) -> AttrId {
crate::attr::mk_attr_id()
}
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/mir/predecessors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ impl<S: serialize::Encoder> serialize::Encodable<S> for PredecessorCache {

impl<D: serialize::Decoder> serialize::Decodable<D> for PredecessorCache {
#[inline]
fn decode(d: &mut D) -> Self {
let () = d.read_unit();
fn decode(_: &mut D) -> Self {
Self::new()
}
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/ty/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,6 @@ macro_rules! implement_ty_decoder {

impl<$($typaram ),*> Decoder for $DecoderName<$($typaram),*> {
$crate::__impl_decoder_methods! {
read_unit -> ();

read_u128 -> u128;
read_u64 -> u64;
read_u32 -> u32;
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_serialize/src/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,6 @@ macro_rules! read_leb128 {
}

impl<'a> serialize::Decoder for Decoder<'a> {
#[inline]
fn read_unit(&mut self) -> () {
()
}

#[inline]
fn read_u128(&mut self) -> u128 {
read_leb128!(self, read_u128_leb128)
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_serialize/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ pub trait Encoder {
// concise.
pub trait Decoder {
// Primitive types:
fn read_unit(&mut self) -> ();
fn read_usize(&mut self) -> usize;
fn read_u128(&mut self) -> u128;
fn read_u64(&mut self) -> u64;
Expand Down Expand Up @@ -324,9 +323,7 @@ impl<S: Encoder> Encodable<S> for () {
}

impl<D: Decoder> Decodable<D> for () {
fn decode(d: &mut D) -> () {
d.read_unit()
}
fn decode(_: &mut D) -> () {}
}

impl<S: Encoder, T> Encodable<S> for PhantomData<T> {
Expand All @@ -336,8 +333,7 @@ impl<S: Encoder, T> Encodable<S> for PhantomData<T> {
}

impl<D: Decoder, T> Decodable<D> for PhantomData<T> {
fn decode(d: &mut D) -> PhantomData<T> {
d.read_unit();
fn decode(_: &mut D) -> PhantomData<T> {
PhantomData
}
}
Expand Down

0 comments on commit f1bcb0f

Please sign in to comment.