diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 17dcc461e28..e99fa6c113b 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -146,10 +146,9 @@ fn encodable_body( .map(|binding| { let bind_ident = &binding.binding; let result = quote! { - match ::rustc_serialize::Encoder::emit_struct_field( + match ::rustc_serialize::Encodable::<#encoder_ty>::encode( + #bind_ident, __encoder, - |__encoder| - ::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder), ) { ::std::result::Result::Ok(()) => (), ::std::result::Result::Err(__err) @@ -161,9 +160,7 @@ fn encodable_body( .collect::() }); quote! { - ::rustc_serialize::Encoder::emit_struct(__encoder, |__encoder| { - ::std::result::Result::Ok(match *self { #encode_inner }) - }) + ::std::result::Result::Ok(match *self { #encode_inner }) } } _ => { @@ -175,10 +172,9 @@ fn encodable_body( .map(|binding| { let bind_ident = &binding.binding; let result = quote! { - match ::rustc_serialize::Encoder::emit_enum_variant_arg( + match ::rustc_serialize::Encodable::<#encoder_ty>::encode( + #bind_ident, __encoder, - |__encoder| - ::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder), ) { ::std::result::Result::Ok(()) => (), ::std::result::Result::Err(__err) @@ -208,11 +204,9 @@ fn encodable_body( result }); quote! { - ::rustc_serialize::Encoder::emit_enum(__encoder, |__encoder| { - match *self { - #encode_inner - } - }) + match *self { + #encode_inner + } } } }; diff --git a/compiler/rustc_serialize/src/collection_impls.rs b/compiler/rustc_serialize/src/collection_impls.rs index f4bf0a23970..c4541bbcac9 100644 --- a/compiler/rustc_serialize/src/collection_impls.rs +++ b/compiler/rustc_serialize/src/collection_impls.rs @@ -25,12 +25,11 @@ impl>> Decodable for SmallVec { impl> Encodable for LinkedList { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for e in self.iter() { - s.emit_seq_elt(|s| e.encode(s))?; - } - Ok(()) - }) + s.emit_usize(self.len())?; + for e in self.iter() { + e.encode(s)?; + } + Ok(()) } } @@ -43,12 +42,11 @@ impl> Decodable for LinkedList { impl> Encodable for VecDeque { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for e in self.iter() { - s.emit_seq_elt(|s| e.encode(s))?; - } - Ok(()) - }) + s.emit_usize(self.len())?; + for e in self.iter() { + e.encode(s)?; + } + Ok(()) } } @@ -65,13 +63,12 @@ where V: Encodable, { fn encode(&self, e: &mut S) -> Result<(), S::Error> { - e.emit_map(self.len(), |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(()) - }) + e.emit_usize(self.len())?; + for (key, val) in self.iter() { + key.encode(e)?; + val.encode(e)?; + } + Ok(()) } } @@ -97,12 +94,11 @@ where T: Encodable + PartialEq + Ord, { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for e in self.iter() { - s.emit_seq_elt(|s| e.encode(s))?; - } - Ok(()) - }) + s.emit_usize(self.len())?; + for e in self.iter() { + e.encode(s)?; + } + Ok(()) } } @@ -127,13 +123,12 @@ where S: BuildHasher, { fn encode(&self, e: &mut E) -> Result<(), E::Error> { - e.emit_map(self.len(), |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(()) - }) + e.emit_usize(self.len())?; + for (key, val) in self.iter() { + key.encode(e)?; + val.encode(e)?; + } + Ok(()) } } @@ -162,12 +157,11 @@ where S: BuildHasher, { fn encode(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_seq(self.len(), |s| { - for e in self.iter() { - s.emit_seq_elt(|s| e.encode(s))?; - } - Ok(()) - }) + s.emit_usize(self.len())?; + for e in self.iter() { + e.encode(s)?; + } + Ok(()) } } @@ -194,13 +188,12 @@ where S: BuildHasher, { fn encode(&self, e: &mut E) -> Result<(), E::Error> { - e.emit_map(self.len(), |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(()) - }) + e.emit_usize(self.len())?; + for (key, val) in self.iter() { + key.encode(e)?; + val.encode(e)?; + } + Ok(()) } } @@ -229,12 +222,11 @@ where S: BuildHasher, { fn encode(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_seq(self.len(), |s| { - for e in self.iter() { - s.emit_seq_elt(|s| e.encode(s))?; - } - Ok(()) - }) + s.emit_usize(self.len())?; + for e in self.iter() { + e.encode(s)?; + } + Ok(()) } } diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index 84fd3b40e63..8c12d250f0f 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -35,15 +35,7 @@ pub trait Encoder { fn emit_str(&mut self, v: &str) -> Result<(), Self::Error>; fn emit_raw_bytes(&mut self, s: &[u8]) -> Result<(), Self::Error>; - // Compound types: - #[inline] - fn emit_enum(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - + // Convenience for the derive macro: fn emit_enum_variant(&mut self, v_id: usize, f: F) -> Result<(), Self::Error> where F: FnOnce(&mut Self) -> Result<(), Self::Error>, @@ -62,106 +54,6 @@ pub trait Encoder { fn emit_fieldless_enum_variant(&mut self) -> Result<(), Self::Error> { self.emit_usize(ID) } - - #[inline] - fn emit_enum_variant_arg(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - #[inline] - fn emit_struct(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - #[inline] - fn emit_struct_field(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - #[inline] - fn emit_tuple(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - #[inline] - fn emit_tuple_arg(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - // Specialized types: - fn emit_option(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_enum(f) - } - - #[inline] - fn emit_option_none(&mut self) -> Result<(), Self::Error> { - self.emit_enum_variant(0, |_| Ok(())) - } - - fn emit_option_some(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_enum_variant(1, f) - } - - fn emit_seq(&mut self, len: usize, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_usize(len)?; - f(self) - } - - #[inline] - fn emit_seq_elt(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - fn emit_map(&mut self, len: usize, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_usize(len)?; - f(self) - } - - #[inline] - fn emit_map_elt_key(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - #[inline] - fn emit_map_elt_val(&mut self, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } } // Note: all the methods in this trait are infallible, which may be surprising. @@ -353,12 +245,11 @@ impl> Decodable for Rc { impl> Encodable for [T] { default fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_seq(self.len(), |s| { - for e in self.iter() { - s.emit_seq_elt(|s| e.encode(s))? - } - Ok(()) - }) + s.emit_usize(self.len())?; + for e in self.iter() { + e.encode(s)? + } + Ok(()) } } @@ -441,10 +332,10 @@ impl<'a, D: Decoder> Decodable for Cow<'a, str> { impl> Encodable for Option { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_option(|s| match *self { - None => s.emit_option_none(), - Some(ref v) => s.emit_option_some(|s| v.encode(s)), - }) + match *self { + None => s.emit_enum_variant(0, |_| Ok(())), + Some(ref v) => s.emit_enum_variant(1, |s| v.encode(s)), + } } } @@ -460,10 +351,10 @@ impl> Decodable for Option { impl, T2: Encodable> Encodable for Result { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_enum(|s| match *self { - 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))), - }) + match *self { + Ok(ref v) => s.emit_enum_variant(0, |s| v.encode(s)), + Err(ref v) => s.emit_enum_variant(1, |s| v.encode(s)), + } } } @@ -493,10 +384,8 @@ macro_rules! tuple { #[allow(non_snake_case)] fn encode(&self, s: &mut S) -> Result<(), S::Error> { let ($(ref $name,)+) = *self; - s.emit_tuple(|s| { - $(s.emit_tuple_arg(|s| $name.encode(s))?;)+ - Ok(()) - }) + $($name.encode(s)?;)+ + Ok(()) } } peel! { $($name,)+ } diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index ccc59b5b647..2bd0880a7c4 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -307,11 +307,8 @@ impl DefId { impl Encodable for DefId { default fn encode(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_struct(|s| { - s.emit_struct_field(|s| self.krate.encode(s))?; - - s.emit_struct_field(|s| self.index.encode(s)) - }) + self.krate.encode(s)?; + self.index.encode(s) } } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 4559a772e6b..01fe9aea89b 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -196,10 +196,10 @@ impl Hash for RealFileName { // an added assert statement impl Encodable for RealFileName { fn encode(&self, encoder: &mut S) -> Result<(), S::Error> { - encoder.emit_enum(|encoder| match *self { + match *self { RealFileName::LocalPath(ref local_path) => encoder.emit_enum_variant(0, |encoder| { Ok({ - encoder.emit_enum_variant_arg(|encoder| local_path.encode(encoder))?; + local_path.encode(encoder)?; }) }), @@ -208,11 +208,11 @@ impl Encodable for RealFileName { // 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(|encoder| local_path.encode(encoder))?; - encoder.emit_enum_variant_arg(|encoder| virtual_name.encode(encoder))?; + local_path.encode(encoder)?; + virtual_name.encode(encoder)?; Ok(()) }), - }) + } } } @@ -949,10 +949,8 @@ impl Default for Span { impl Encodable for Span { default fn encode(&self, s: &mut E) -> Result<(), E::Error> { let span = self.data(); - s.emit_struct(|s| { - s.emit_struct_field(|s| span.lo.encode(s))?; - s.emit_struct_field(|s| span.hi.encode(s)) - }) + span.lo.encode(s)?; + span.hi.encode(s) } } impl Decodable for Span { @@ -1301,79 +1299,77 @@ pub struct SourceFile { impl Encodable for SourceFile { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - 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| { - // Store the length. - s.emit_u32(lines.len() as u32)?; + self.name.encode(s)?; + self.src_hash.encode(s)?; + self.start_pos.encode(s)?; + self.end_pos.encode(s)?; - // Compute and store the difference list. - if lines.len() != 0 { - let max_line_length = if lines.len() == 1 { - 0 - } else { - lines - .array_windows() - .map(|&[fst, snd]| snd - fst) - .map(|bp| bp.to_usize()) - .max() - .unwrap() - }; + // We are always in `Lines` form by the time we reach here. + assert!(self.lines.borrow().is_lines()); + self.lines(|lines| { + // Store the length. + s.emit_u32(lines.len() as u32)?; - let bytes_per_diff: usize = match max_line_length { - 0..=0xFF => 1, - 0x100..=0xFFFF => 2, - _ => 4, - }; + // Compute and store the difference list. + if lines.len() != 0 { + let max_line_length = if lines.len() == 1 { + 0 + } else { + lines + .array_windows() + .map(|&[fst, snd]| snd - fst) + .map(|bp| bp.to_usize()) + .max() + .unwrap() + }; - // Encode the number of bytes used per diff. - s.emit_u8(bytes_per_diff as u8)?; + let bytes_per_diff: usize = match max_line_length { + 0..=0xFF => 1, + 0x100..=0xFFFF => 2, + _ => 4, + }; - // Encode the first element. - lines[0].encode(s)?; + // Encode the number of bytes used per diff. + s.emit_u8(bytes_per_diff as u8)?; - // Encode the difference list. - let diff_iter = lines.array_windows().map(|&[fst, snd]| snd - fst); - let num_diffs = lines.len() - 1; - let mut raw_diffs; - match bytes_per_diff { - 1 => { - raw_diffs = Vec::with_capacity(num_diffs); - for diff in diff_iter { - raw_diffs.push(diff.0 as u8); - } - } - 2 => { - raw_diffs = Vec::with_capacity(bytes_per_diff * num_diffs); - for diff in diff_iter { - raw_diffs.extend_from_slice(&(diff.0 as u16).to_le_bytes()); - } - } - 4 => { - raw_diffs = Vec::with_capacity(bytes_per_diff * num_diffs); - for diff in diff_iter { - raw_diffs.extend_from_slice(&(diff.0 as u32).to_le_bytes()); - } - } - _ => unreachable!(), + // Encode the first element. + lines[0].encode(s)?; + + // Encode the difference list. + let diff_iter = lines.array_windows().map(|&[fst, snd]| snd - fst); + let num_diffs = lines.len() - 1; + let mut raw_diffs; + match bytes_per_diff { + 1 => { + raw_diffs = Vec::with_capacity(num_diffs); + for diff in diff_iter { + raw_diffs.push(diff.0 as u8); } - s.emit_raw_bytes(&raw_diffs)?; } - Ok(()) - }) - })?; - 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)) - }) + 2 => { + raw_diffs = Vec::with_capacity(bytes_per_diff * num_diffs); + for diff in diff_iter { + raw_diffs.extend_from_slice(&(diff.0 as u16).to_le_bytes()); + } + } + 4 => { + raw_diffs = Vec::with_capacity(bytes_per_diff * num_diffs); + for diff in diff_iter { + raw_diffs.extend_from_slice(&(diff.0 as u32).to_le_bytes()); + } + } + _ => unreachable!(), + } + s.emit_raw_bytes(&raw_diffs)?; + } + Ok(()) + })?; + + self.multibyte_chars.encode(s)?; + self.non_narrow_chars.encode(s)?; + self.name_hash.encode(s)?; + self.normalized_pos.encode(s)?; + self.cnum.encode(s) } } diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index 8980f1babbb..22b5b475b2c 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -716,118 +716,116 @@ where I::AllocId: Encodable, { fn encode(&self, e: &mut E) -> Result<(), ::Error> { - rustc_serialize::Encoder::emit_enum(e, |e| { - let disc = discriminant(self); - match self { - 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(disc, |e| { - e.emit_enum_variant_arg(|e| u.encode(e))?; - Ok(()) - }), - 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(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(disc, |e| { - e.emit_enum_variant_arg(|e| def_id.encode(e))?; - Ok(()) - }), - 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(disc, |e| { - e.emit_enum_variant_arg(|e| t.encode(e))?; - Ok(()) - }), - 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(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(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(disc, |e| { - e.emit_enum_variant_arg(|e| polyfnsig.encode(e))?; - Ok(()) - }), - 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(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(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(disc, |e| { - e.emit_enum_variant_arg(|e| b.encode(e))?; - Ok(()) - }), - 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(disc, |e| { - e.emit_enum_variant_arg(|e| p.encode(e))?; - Ok(()) - }), - 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(disc, |e| { - e.emit_enum_variant_arg(|e| p.encode(e))?; - Ok(()) - }), - 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(disc, |e| { - e.emit_enum_variant_arg(|e| p.encode(e))?; - Ok(()) - }), - Infer(i) => e.emit_enum_variant(disc, |e| { - e.emit_enum_variant_arg(|e| i.encode(e))?; - Ok(()) - }), - Error(d) => e.emit_enum_variant(disc, |e| { - e.emit_enum_variant_arg(|e| d.encode(e))?; - Ok(()) - }), - } - }) + let disc = discriminant(self); + match self { + Bool => e.emit_enum_variant(disc, |_| Ok(())), + Char => e.emit_enum_variant(disc, |_| Ok(())), + Int(i) => e.emit_enum_variant(disc, |e| { + i.encode(e)?; + Ok(()) + }), + Uint(u) => e.emit_enum_variant(disc, |e| { + u.encode(e)?; + Ok(()) + }), + Float(f) => e.emit_enum_variant(disc, |e| { + f.encode(e)?; + Ok(()) + }), + Adt(adt, substs) => e.emit_enum_variant(disc, |e| { + adt.encode(e)?; + substs.encode(e)?; + Ok(()) + }), + Foreign(def_id) => e.emit_enum_variant(disc, |e| { + def_id.encode(e)?; + Ok(()) + }), + Str => e.emit_enum_variant(disc, |_| Ok(())), + Array(t, c) => e.emit_enum_variant(disc, |e| { + t.encode(e)?; + c.encode(e)?; + Ok(()) + }), + Slice(t) => e.emit_enum_variant(disc, |e| { + t.encode(e)?; + Ok(()) + }), + RawPtr(tam) => e.emit_enum_variant(disc, |e| { + tam.encode(e)?; + Ok(()) + }), + Ref(r, t, m) => e.emit_enum_variant(disc, |e| { + r.encode(e)?; + t.encode(e)?; + m.encode(e)?; + Ok(()) + }), + FnDef(def_id, substs) => e.emit_enum_variant(disc, |e| { + def_id.encode(e)?; + substs.encode(e)?; + Ok(()) + }), + FnPtr(polyfnsig) => e.emit_enum_variant(disc, |e| { + polyfnsig.encode(e)?; + Ok(()) + }), + Dynamic(l, r) => e.emit_enum_variant(disc, |e| { + l.encode(e)?; + r.encode(e)?; + Ok(()) + }), + Closure(def_id, substs) => e.emit_enum_variant(disc, |e| { + def_id.encode(e)?; + substs.encode(e)?; + Ok(()) + }), + Generator(def_id, substs, m) => e.emit_enum_variant(disc, |e| { + def_id.encode(e)?; + substs.encode(e)?; + m.encode(e)?; + Ok(()) + }), + GeneratorWitness(b) => e.emit_enum_variant(disc, |e| { + b.encode(e)?; + Ok(()) + }), + Never => e.emit_enum_variant(disc, |_| Ok(())), + Tuple(substs) => e.emit_enum_variant(disc, |e| { + substs.encode(e)?; + Ok(()) + }), + Projection(p) => e.emit_enum_variant(disc, |e| { + p.encode(e)?; + Ok(()) + }), + Opaque(def_id, substs) => e.emit_enum_variant(disc, |e| { + def_id.encode(e)?; + substs.encode(e)?; + Ok(()) + }), + Param(p) => e.emit_enum_variant(disc, |e| { + p.encode(e)?; + Ok(()) + }), + Bound(d, b) => e.emit_enum_variant(disc, |e| { + d.encode(e)?; + b.encode(e)?; + Ok(()) + }), + Placeholder(p) => e.emit_enum_variant(disc, |e| { + p.encode(e)?; + Ok(()) + }), + Infer(i) => e.emit_enum_variant(disc, |e| { + i.encode(e)?; + Ok(()) + }), + Error(d) => e.emit_enum_variant(disc, |e| { + d.encode(e)?; + Ok(()) + }), + } } }