Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup a few Decoder methods #94288

Merged
merged 3 commits into from
Feb 24, 2022
Merged
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/mir/predecessors.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/ty/codec.rs
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 0 additions & 5 deletions compiler/rustc_serialize/src/opaque.rs
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 2 additions & 6 deletions compiler/rustc_serialize/src/serialize.rs
Original file line number Diff line number Diff line change
@@ -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;
@@ -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> {
@@ -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
}
}