Remove all names from Encoder

They aren't used anymore now that the json format has been removed
This commit is contained in:
bjorn3 2021-06-04 17:33:26 +02:00
parent ede5ac251c
commit 5cd29225a5
6 changed files with 120 additions and 168 deletions

View File

@ -140,23 +140,14 @@ fn encodable_body(
let encode_body = match s.variants() {
[_] => {
let mut field_idx = 0usize;
let encode_inner = s.each_variant(|vi| {
vi.bindings()
.iter()
.map(|binding| {
let bind_ident = &binding.binding;
let field_name = binding
.ast()
.ident
.as_ref()
.map_or_else(|| field_idx.to_string(), |i| i.to_string());
let first = field_idx == 0;
let result = quote! {
match ::rustc_serialize::Encoder::emit_struct_field(
__encoder,
#field_name,
#first,
|__encoder|
::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder),
) {
@ -165,14 +156,12 @@ fn encodable_body(
=> return ::std::result::Result::Err(__err),
}
};
field_idx += 1;
result
})
.collect::<TokenStream>()
});
let no_fields = field_idx == 0;
quote! {
::rustc_serialize::Encoder::emit_struct(__encoder, #no_fields, |__encoder| {
::rustc_serialize::Encoder::emit_struct(__encoder, |__encoder| {
::std::result::Result::Ok(match *self { #encode_inner })
})
}
@ -180,19 +169,14 @@ fn encodable_body(
_ => {
let mut variant_idx = 0usize;
let encode_inner = s.each_variant(|vi| {
let variant_name = vi.ast().ident.to_string();
let mut field_idx = 0usize;
let encode_fields: TokenStream = vi
.bindings()
.iter()
.map(|binding| {
let bind_ident = &binding.binding;
let first = field_idx == 0;
let result = quote! {
match ::rustc_serialize::Encoder::emit_enum_variant_arg(
__encoder,
#first,
|__encoder|
::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder),
) {
@ -201,18 +185,15 @@ fn encodable_body(
=> return ::std::result::Result::Err(__err),
}
};
field_idx += 1;
result
})
.collect();
let result = if field_idx != 0 {
let result = if !vi.bindings().is_empty() {
quote! {
::rustc_serialize::Encoder::emit_enum_variant(
__encoder,
#variant_name,
#variant_idx,
#field_idx,
|__encoder| { ::std::result::Result::Ok({ #encode_fields }) }
)
}
@ -220,7 +201,6 @@ fn encodable_body(
quote! {
::rustc_serialize::Encoder::emit_fieldless_enum_variant::<#variant_idx>(
__encoder,
#variant_name,
)
}
};

View File

@ -26,8 +26,8 @@ impl<D: Decoder, A: Array<Item: Decodable<D>>> Decodable<D> for SmallVec<A> {
impl<S: Encoder, T: Encodable<S>> Encodable<S> for LinkedList<T> {
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
for e in self.iter() {
s.emit_seq_elt(|s| e.encode(s))?;
}
Ok(())
})
@ -44,8 +44,8 @@ impl<D: Decoder, T: Decodable<D>> Decodable<D> for LinkedList<T> {
impl<S: Encoder, T: Encodable<S>> Encodable<S> for VecDeque<T> {
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
for e in self.iter() {
s.emit_seq_elt(|s| e.encode(s))?;
}
Ok(())
})
@ -66,8 +66,8 @@ where
{
fn encode(&self, e: &mut S) -> Result<(), S::Error> {
e.emit_map(self.len(), |e| {
for (i, (key, val)) in self.iter().enumerate() {
e.emit_map_elt_key(i, |e| key.encode(e))?;
for (key, val) in self.iter() {
e.emit_map_elt_key(|e| key.encode(e))?;
e.emit_map_elt_val(|e| val.encode(e))?;
}
Ok(())
@ -98,8 +98,8 @@ where
{
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
for e in self.iter() {
s.emit_seq_elt(|s| e.encode(s))?;
}
Ok(())
})
@ -128,8 +128,8 @@ where
{
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
e.emit_map(self.len(), |e| {
for (i, (key, val)) in self.iter().enumerate() {
e.emit_map_elt_key(i, |e| key.encode(e))?;
for (key, val) in self.iter() {
e.emit_map_elt_key(|e| key.encode(e))?;
e.emit_map_elt_val(|e| val.encode(e))?;
}
Ok(())
@ -163,8 +163,8 @@ where
{
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
for e in self.iter() {
s.emit_seq_elt(|s| e.encode(s))?;
}
Ok(())
})
@ -195,8 +195,8 @@ where
{
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
e.emit_map(self.len(), |e| {
for (i, (key, val)) in self.iter().enumerate() {
e.emit_map_elt_key(i, |e| key.encode(e))?;
for (key, val) in self.iter() {
e.emit_map_elt_key(|e| key.encode(e))?;
e.emit_map_elt_val(|e| val.encode(e))?;
}
Ok(())
@ -230,8 +230,8 @@ where
{
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?;
for e in self.iter() {
s.emit_seq_elt(|s| e.encode(s))?;
}
Ok(())
})

View File

@ -44,13 +44,7 @@ pub trait Encoder {
f(self)
}
fn emit_enum_variant<F>(
&mut self,
_v_name: &str,
v_id: usize,
_len: usize,
f: F,
) -> Result<(), Self::Error>
fn emit_enum_variant<F>(&mut self, v_id: usize, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -65,15 +59,12 @@ pub trait Encoder {
// optimization that would otherwise be necessary here, likely due to the
// multiple levels of inlining and const-prop that are needed.
#[inline]
fn emit_fieldless_enum_variant<const ID: usize>(
&mut self,
_v_name: &str,
) -> Result<(), Self::Error> {
fn emit_fieldless_enum_variant<const ID: usize>(&mut self) -> Result<(), Self::Error> {
self.emit_usize(ID)
}
#[inline]
fn emit_enum_variant_arg<F>(&mut self, _first: bool, f: F) -> Result<(), Self::Error>
fn emit_enum_variant_arg<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -81,7 +72,7 @@ pub trait Encoder {
}
#[inline]
fn emit_struct<F>(&mut self, _no_fields: bool, f: F) -> Result<(), Self::Error>
fn emit_struct<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -89,7 +80,7 @@ pub trait Encoder {
}
#[inline]
fn emit_struct_field<F>(&mut self, _f_name: &str, _first: bool, f: F) -> Result<(), Self::Error>
fn emit_struct_field<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -97,7 +88,7 @@ pub trait Encoder {
}
#[inline]
fn emit_tuple<F>(&mut self, _len: usize, f: F) -> Result<(), Self::Error>
fn emit_tuple<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -105,7 +96,7 @@ pub trait Encoder {
}
#[inline]
fn emit_tuple_arg<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
fn emit_tuple_arg<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -122,14 +113,14 @@ pub trait Encoder {
#[inline]
fn emit_option_none(&mut self) -> Result<(), Self::Error> {
self.emit_enum_variant("None", 0, 0, |_| Ok(()))
self.emit_enum_variant(0, |_| Ok(()))
}
fn emit_option_some<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
self.emit_enum_variant("Some", 1, 1, f)
self.emit_enum_variant(1, f)
}
fn emit_seq<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error>
@ -141,7 +132,7 @@ pub trait Encoder {
}
#[inline]
fn emit_seq_elt<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
fn emit_seq_elt<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -157,7 +148,7 @@ pub trait Encoder {
}
#[inline]
fn emit_map_elt_key<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
fn emit_map_elt_key<F>(&mut self, f: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
{
@ -363,8 +354,8 @@ impl<D: Decoder, T: Decodable<D>> Decodable<D> for Rc<T> {
impl<S: Encoder, T: Encodable<S>> Encodable<S> for [T] {
default fn encode(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_seq(self.len(), |s| {
for (i, e) in self.iter().enumerate() {
s.emit_seq_elt(i, |s| e.encode(s))?
for e in self.iter() {
s.emit_seq_elt(|s| e.encode(s))?
}
Ok(())
})
@ -470,12 +461,8 @@ impl<D: Decoder, T: Decodable<D>> Decodable<D> for Option<T> {
impl<S: Encoder, T1: Encodable<S>, T2: Encodable<S>> Encodable<S> for Result<T1, T2> {
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_enum(|s| match *self {
Ok(ref v) => {
s.emit_enum_variant("Ok", 0, 1, |s| s.emit_enum_variant_arg(true, |s| v.encode(s)))
}
Err(ref v) => {
s.emit_enum_variant("Err", 1, 1, |s| s.emit_enum_variant_arg(true, |s| v.encode(s)))
}
Ok(ref v) => s.emit_enum_variant(0, |s| s.emit_enum_variant_arg(|s| v.encode(s))),
Err(ref v) => s.emit_enum_variant(1, |s| s.emit_enum_variant_arg(|s| v.encode(s))),
})
}
}
@ -494,18 +481,6 @@ macro_rules! peel {
($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
}
/// Evaluates to the number of tokens passed to it.
///
/// Logarithmic counting: every one or two recursive expansions, the number of
/// tokens to count is divided by two, instead of being reduced by one.
/// Therefore, the recursion depth is the binary logarithm of the number of
/// tokens to count, and the expanded tree is likewise very small.
macro_rules! count {
($one:tt) => (1usize);
($($pairs:tt $_p:tt)*) => (count!($($pairs)*) << 1usize);
($odd:tt $($rest:tt)*) => (count!($($rest)*) | 1usize);
}
macro_rules! tuple {
() => ();
( $($name:ident,)+ ) => (
@ -518,10 +493,8 @@ macro_rules! tuple {
#[allow(non_snake_case)]
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
let ($(ref $name,)+) = *self;
let len: usize = count!($($name)+);
s.emit_tuple(len, |s| {
let mut i = 0;
$(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s))?;)+
s.emit_tuple(|s| {
$(s.emit_tuple_arg(|s| $name.encode(s))?;)+
Ok(())
})
}

View File

@ -307,10 +307,10 @@ impl DefId {
impl<E: Encoder> Encodable<E> for DefId {
default fn encode(&self, s: &mut E) -> Result<(), E::Error> {
s.emit_struct(false, |s| {
s.emit_struct_field("krate", true, |s| self.krate.encode(s))?;
s.emit_struct(|s| {
s.emit_struct_field(|s| self.krate.encode(s))?;
s.emit_struct_field("index", false, |s| self.index.encode(s))
s.emit_struct_field(|s| self.index.encode(s))
})
}
}

View File

@ -197,20 +197,19 @@ impl Hash for RealFileName {
impl<S: Encoder> Encodable<S> for RealFileName {
fn encode(&self, encoder: &mut S) -> Result<(), S::Error> {
encoder.emit_enum(|encoder| match *self {
RealFileName::LocalPath(ref local_path) => {
encoder.emit_enum_variant("LocalPath", 0, 1, |encoder| {
encoder.emit_enum_variant_arg(true, |encoder| local_path.encode(encoder))?;
Ok(())
RealFileName::LocalPath(ref local_path) => encoder.emit_enum_variant(0, |encoder| {
Ok({
encoder.emit_enum_variant_arg(|encoder| local_path.encode(encoder))?;
})
}
}),
RealFileName::Remapped { ref local_path, ref virtual_name } => encoder
.emit_enum_variant("Remapped", 1, 2, |encoder| {
.emit_enum_variant(1, |encoder| {
// For privacy and build reproducibility, we must not embed host-dependant path in artifacts
// if they have been remapped by --remap-path-prefix
assert!(local_path.is_none());
encoder.emit_enum_variant_arg(true, |encoder| local_path.encode(encoder))?;
encoder.emit_enum_variant_arg(false, |encoder| virtual_name.encode(encoder))?;
encoder.emit_enum_variant_arg(|encoder| local_path.encode(encoder))?;
encoder.emit_enum_variant_arg(|encoder| virtual_name.encode(encoder))?;
Ok(())
}),
})
@ -950,9 +949,9 @@ impl Default for Span {
impl<E: Encoder> Encodable<E> for Span {
default fn encode(&self, s: &mut E) -> Result<(), E::Error> {
let span = self.data();
s.emit_struct(false, |s| {
s.emit_struct_field("lo", true, |s| span.lo.encode(s))?;
s.emit_struct_field("hi", false, |s| span.hi.encode(s))
s.emit_struct(|s| {
s.emit_struct_field(|s| span.lo.encode(s))?;
s.emit_struct_field(|s| span.hi.encode(s))
})
}
}
@ -1302,12 +1301,12 @@ pub struct SourceFile {
impl<S: Encoder> Encodable<S> for SourceFile {
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_struct(false, |s| {
s.emit_struct_field("name", true, |s| self.name.encode(s))?;
s.emit_struct_field("src_hash", false, |s| self.src_hash.encode(s))?;
s.emit_struct_field("start_pos", false, |s| self.start_pos.encode(s))?;
s.emit_struct_field("end_pos", false, |s| self.end_pos.encode(s))?;
s.emit_struct_field("lines", false, |s| {
s.emit_struct(|s| {
s.emit_struct_field(|s| self.name.encode(s))?;
s.emit_struct_field(|s| self.src_hash.encode(s))?;
s.emit_struct_field(|s| self.start_pos.encode(s))?;
s.emit_struct_field(|s| self.end_pos.encode(s))?;
s.emit_struct_field(|s| {
// We are always in `Lines` form by the time we reach here.
assert!(self.lines.borrow().is_lines());
self.lines(|lines| {
@ -1369,11 +1368,11 @@ impl<S: Encoder> Encodable<S> for SourceFile {
Ok(())
})
})?;
s.emit_struct_field("multibyte_chars", false, |s| self.multibyte_chars.encode(s))?;
s.emit_struct_field("non_narrow_chars", false, |s| self.non_narrow_chars.encode(s))?;
s.emit_struct_field("name_hash", false, |s| self.name_hash.encode(s))?;
s.emit_struct_field("normalized_pos", false, |s| self.normalized_pos.encode(s))?;
s.emit_struct_field("cnum", false, |s| self.cnum.encode(s))
s.emit_struct_field(|s| self.multibyte_chars.encode(s))?;
s.emit_struct_field(|s| self.non_narrow_chars.encode(s))?;
s.emit_struct_field(|s| self.name_hash.encode(s))?;
s.emit_struct_field(|s| self.normalized_pos.encode(s))?;
s.emit_struct_field(|s| self.cnum.encode(s))
})
}
}

View File

@ -719,111 +719,111 @@ where
rustc_serialize::Encoder::emit_enum(e, |e| {
let disc = discriminant(self);
match self {
Bool => e.emit_enum_variant("Bool", disc, 0, |_| Ok(())),
Char => e.emit_enum_variant("Char", disc, 0, |_| Ok(())),
Int(i) => e.emit_enum_variant("Int", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| i.encode(e))?;
Bool => e.emit_enum_variant(disc, |_| Ok(())),
Char => e.emit_enum_variant(disc, |_| Ok(())),
Int(i) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| i.encode(e))?;
Ok(())
}),
Uint(u) => e.emit_enum_variant("Uint", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| u.encode(e))?;
Uint(u) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| u.encode(e))?;
Ok(())
}),
Float(f) => e.emit_enum_variant("Float", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| f.encode(e))?;
Float(f) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| f.encode(e))?;
Ok(())
}),
Adt(adt, substs) => e.emit_enum_variant("Adt", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| adt.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
Adt(adt, substs) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| adt.encode(e))?;
e.emit_enum_variant_arg(|e| substs.encode(e))?;
Ok(())
}),
Foreign(def_id) => e.emit_enum_variant("Foreign", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
Foreign(def_id) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
Ok(())
}),
Str => e.emit_enum_variant("Str", disc, 0, |_| Ok(())),
Array(t, c) => e.emit_enum_variant("Array", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| t.encode(e))?;
e.emit_enum_variant_arg(false, |e| c.encode(e))?;
Str => e.emit_enum_variant(disc, |_| Ok(())),
Array(t, c) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| t.encode(e))?;
e.emit_enum_variant_arg(|e| c.encode(e))?;
Ok(())
}),
Slice(t) => e.emit_enum_variant("Slice", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| t.encode(e))?;
Slice(t) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| t.encode(e))?;
Ok(())
}),
RawPtr(tam) => e.emit_enum_variant("RawPtr", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| tam.encode(e))?;
RawPtr(tam) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| tam.encode(e))?;
Ok(())
}),
Ref(r, t, m) => e.emit_enum_variant("Ref", disc, 3, |e| {
e.emit_enum_variant_arg(true, |e| r.encode(e))?;
e.emit_enum_variant_arg(false, |e| t.encode(e))?;
e.emit_enum_variant_arg(false, |e| m.encode(e))?;
Ref(r, t, m) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| r.encode(e))?;
e.emit_enum_variant_arg(|e| t.encode(e))?;
e.emit_enum_variant_arg(|e| m.encode(e))?;
Ok(())
}),
FnDef(def_id, substs) => e.emit_enum_variant("FnDef", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
FnDef(def_id, substs) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
e.emit_enum_variant_arg(|e| substs.encode(e))?;
Ok(())
}),
FnPtr(polyfnsig) => e.emit_enum_variant("FnPtr", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| polyfnsig.encode(e))?;
FnPtr(polyfnsig) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| polyfnsig.encode(e))?;
Ok(())
}),
Dynamic(l, r) => e.emit_enum_variant("Dynamic", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| l.encode(e))?;
e.emit_enum_variant_arg(false, |e| r.encode(e))?;
Dynamic(l, r) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| l.encode(e))?;
e.emit_enum_variant_arg(|e| r.encode(e))?;
Ok(())
}),
Closure(def_id, substs) => e.emit_enum_variant("Closure", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
Closure(def_id, substs) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
e.emit_enum_variant_arg(|e| substs.encode(e))?;
Ok(())
}),
Generator(def_id, substs, m) => e.emit_enum_variant("Generator", disc, 3, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
e.emit_enum_variant_arg(false, |e| m.encode(e))?;
Generator(def_id, substs, m) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
e.emit_enum_variant_arg(|e| substs.encode(e))?;
e.emit_enum_variant_arg(|e| m.encode(e))?;
Ok(())
}),
GeneratorWitness(b) => e.emit_enum_variant("GeneratorWitness", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| b.encode(e))?;
GeneratorWitness(b) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| b.encode(e))?;
Ok(())
}),
Never => e.emit_enum_variant("Never", disc, 0, |_| Ok(())),
Tuple(substs) => e.emit_enum_variant("Tuple", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| substs.encode(e))?;
Never => e.emit_enum_variant(disc, |_| Ok(())),
Tuple(substs) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| substs.encode(e))?;
Ok(())
}),
Projection(p) => e.emit_enum_variant("Projection", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| p.encode(e))?;
Projection(p) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| p.encode(e))?;
Ok(())
}),
Opaque(def_id, substs) => e.emit_enum_variant("Opaque", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
Opaque(def_id, substs) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
e.emit_enum_variant_arg(|e| substs.encode(e))?;
Ok(())
}),
Param(p) => e.emit_enum_variant("Param", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| p.encode(e))?;
Param(p) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| p.encode(e))?;
Ok(())
}),
Bound(d, b) => e.emit_enum_variant("Bound", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| d.encode(e))?;
e.emit_enum_variant_arg(false, |e| b.encode(e))?;
Bound(d, b) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| d.encode(e))?;
e.emit_enum_variant_arg(|e| b.encode(e))?;
Ok(())
}),
Placeholder(p) => e.emit_enum_variant("Placeholder", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| p.encode(e))?;
Placeholder(p) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| p.encode(e))?;
Ok(())
}),
Infer(i) => e.emit_enum_variant("Infer", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| i.encode(e))?;
Infer(i) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| i.encode(e))?;
Ok(())
}),
Error(d) => e.emit_enum_variant("Error", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| d.encode(e))?;
Error(d) => e.emit_enum_variant(disc, |e| {
e.emit_enum_variant_arg(|e| d.encode(e))?;
Ok(())
}),
}