mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Remove all names from Encoder
They aren't used anymore now that the json format has been removed
This commit is contained in:
parent
ede5ac251c
commit
5cd29225a5
@ -140,23 +140,14 @@ fn encodable_body(
|
|||||||
|
|
||||||
let encode_body = match s.variants() {
|
let encode_body = match s.variants() {
|
||||||
[_] => {
|
[_] => {
|
||||||
let mut field_idx = 0usize;
|
|
||||||
let encode_inner = s.each_variant(|vi| {
|
let encode_inner = s.each_variant(|vi| {
|
||||||
vi.bindings()
|
vi.bindings()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|binding| {
|
.map(|binding| {
|
||||||
let bind_ident = &binding.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! {
|
let result = quote! {
|
||||||
match ::rustc_serialize::Encoder::emit_struct_field(
|
match ::rustc_serialize::Encoder::emit_struct_field(
|
||||||
__encoder,
|
__encoder,
|
||||||
#field_name,
|
|
||||||
#first,
|
|
||||||
|__encoder|
|
|__encoder|
|
||||||
::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder),
|
::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder),
|
||||||
) {
|
) {
|
||||||
@ -165,14 +156,12 @@ fn encodable_body(
|
|||||||
=> return ::std::result::Result::Err(__err),
|
=> return ::std::result::Result::Err(__err),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
field_idx += 1;
|
|
||||||
result
|
result
|
||||||
})
|
})
|
||||||
.collect::<TokenStream>()
|
.collect::<TokenStream>()
|
||||||
});
|
});
|
||||||
let no_fields = field_idx == 0;
|
|
||||||
quote! {
|
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 })
|
::std::result::Result::Ok(match *self { #encode_inner })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -180,19 +169,14 @@ fn encodable_body(
|
|||||||
_ => {
|
_ => {
|
||||||
let mut variant_idx = 0usize;
|
let mut variant_idx = 0usize;
|
||||||
let encode_inner = s.each_variant(|vi| {
|
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
|
let encode_fields: TokenStream = vi
|
||||||
.bindings()
|
.bindings()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|binding| {
|
.map(|binding| {
|
||||||
let bind_ident = &binding.binding;
|
let bind_ident = &binding.binding;
|
||||||
let first = field_idx == 0;
|
|
||||||
let result = quote! {
|
let result = quote! {
|
||||||
match ::rustc_serialize::Encoder::emit_enum_variant_arg(
|
match ::rustc_serialize::Encoder::emit_enum_variant_arg(
|
||||||
__encoder,
|
__encoder,
|
||||||
#first,
|
|
||||||
|__encoder|
|
|__encoder|
|
||||||
::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder),
|
::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder),
|
||||||
) {
|
) {
|
||||||
@ -201,18 +185,15 @@ fn encodable_body(
|
|||||||
=> return ::std::result::Result::Err(__err),
|
=> return ::std::result::Result::Err(__err),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
field_idx += 1;
|
|
||||||
result
|
result
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let result = if field_idx != 0 {
|
let result = if !vi.bindings().is_empty() {
|
||||||
quote! {
|
quote! {
|
||||||
::rustc_serialize::Encoder::emit_enum_variant(
|
::rustc_serialize::Encoder::emit_enum_variant(
|
||||||
__encoder,
|
__encoder,
|
||||||
#variant_name,
|
|
||||||
#variant_idx,
|
#variant_idx,
|
||||||
#field_idx,
|
|
||||||
|__encoder| { ::std::result::Result::Ok({ #encode_fields }) }
|
|__encoder| { ::std::result::Result::Ok({ #encode_fields }) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -220,7 +201,6 @@ fn encodable_body(
|
|||||||
quote! {
|
quote! {
|
||||||
::rustc_serialize::Encoder::emit_fieldless_enum_variant::<#variant_idx>(
|
::rustc_serialize::Encoder::emit_fieldless_enum_variant::<#variant_idx>(
|
||||||
__encoder,
|
__encoder,
|
||||||
#variant_name,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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> {
|
impl<S: Encoder, T: Encodable<S>> Encodable<S> for LinkedList<T> {
|
||||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
s.emit_seq(self.len(), |s| {
|
s.emit_seq(self.len(), |s| {
|
||||||
for (i, e) in self.iter().enumerate() {
|
for e in self.iter() {
|
||||||
s.emit_seq_elt(i, |s| e.encode(s))?;
|
s.emit_seq_elt(|s| e.encode(s))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
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> {
|
impl<S: Encoder, T: Encodable<S>> Encodable<S> for VecDeque<T> {
|
||||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
s.emit_seq(self.len(), |s| {
|
s.emit_seq(self.len(), |s| {
|
||||||
for (i, e) in self.iter().enumerate() {
|
for e in self.iter() {
|
||||||
s.emit_seq_elt(i, |s| e.encode(s))?;
|
s.emit_seq_elt(|s| e.encode(s))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -66,8 +66,8 @@ where
|
|||||||
{
|
{
|
||||||
fn encode(&self, e: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, e: &mut S) -> Result<(), S::Error> {
|
||||||
e.emit_map(self.len(), |e| {
|
e.emit_map(self.len(), |e| {
|
||||||
for (i, (key, val)) in self.iter().enumerate() {
|
for (key, val) in self.iter() {
|
||||||
e.emit_map_elt_key(i, |e| key.encode(e))?;
|
e.emit_map_elt_key(|e| key.encode(e))?;
|
||||||
e.emit_map_elt_val(|e| val.encode(e))?;
|
e.emit_map_elt_val(|e| val.encode(e))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -98,8 +98,8 @@ where
|
|||||||
{
|
{
|
||||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
s.emit_seq(self.len(), |s| {
|
s.emit_seq(self.len(), |s| {
|
||||||
for (i, e) in self.iter().enumerate() {
|
for e in self.iter() {
|
||||||
s.emit_seq_elt(i, |s| e.encode(s))?;
|
s.emit_seq_elt(|s| e.encode(s))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -128,8 +128,8 @@ where
|
|||||||
{
|
{
|
||||||
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
||||||
e.emit_map(self.len(), |e| {
|
e.emit_map(self.len(), |e| {
|
||||||
for (i, (key, val)) in self.iter().enumerate() {
|
for (key, val) in self.iter() {
|
||||||
e.emit_map_elt_key(i, |e| key.encode(e))?;
|
e.emit_map_elt_key(|e| key.encode(e))?;
|
||||||
e.emit_map_elt_val(|e| val.encode(e))?;
|
e.emit_map_elt_val(|e| val.encode(e))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -163,8 +163,8 @@ where
|
|||||||
{
|
{
|
||||||
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
||||||
s.emit_seq(self.len(), |s| {
|
s.emit_seq(self.len(), |s| {
|
||||||
for (i, e) in self.iter().enumerate() {
|
for e in self.iter() {
|
||||||
s.emit_seq_elt(i, |s| e.encode(s))?;
|
s.emit_seq_elt(|s| e.encode(s))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -195,8 +195,8 @@ where
|
|||||||
{
|
{
|
||||||
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
||||||
e.emit_map(self.len(), |e| {
|
e.emit_map(self.len(), |e| {
|
||||||
for (i, (key, val)) in self.iter().enumerate() {
|
for (key, val) in self.iter() {
|
||||||
e.emit_map_elt_key(i, |e| key.encode(e))?;
|
e.emit_map_elt_key(|e| key.encode(e))?;
|
||||||
e.emit_map_elt_val(|e| val.encode(e))?;
|
e.emit_map_elt_val(|e| val.encode(e))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -230,8 +230,8 @@ where
|
|||||||
{
|
{
|
||||||
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
||||||
s.emit_seq(self.len(), |s| {
|
s.emit_seq(self.len(), |s| {
|
||||||
for (i, e) in self.iter().enumerate() {
|
for e in self.iter() {
|
||||||
s.emit_seq_elt(i, |s| e.encode(s))?;
|
s.emit_seq_elt(|s| e.encode(s))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
@ -44,13 +44,7 @@ pub trait Encoder {
|
|||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_enum_variant<F>(
|
fn emit_enum_variant<F>(&mut self, v_id: usize, f: F) -> Result<(), Self::Error>
|
||||||
&mut self,
|
|
||||||
_v_name: &str,
|
|
||||||
v_id: usize,
|
|
||||||
_len: usize,
|
|
||||||
f: F,
|
|
||||||
) -> Result<(), Self::Error>
|
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
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
|
// optimization that would otherwise be necessary here, likely due to the
|
||||||
// multiple levels of inlining and const-prop that are needed.
|
// multiple levels of inlining and const-prop that are needed.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn emit_fieldless_enum_variant<const ID: usize>(
|
fn emit_fieldless_enum_variant<const ID: usize>(&mut self) -> Result<(), Self::Error> {
|
||||||
&mut self,
|
|
||||||
_v_name: &str,
|
|
||||||
) -> Result<(), Self::Error> {
|
|
||||||
self.emit_usize(ID)
|
self.emit_usize(ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||||
{
|
{
|
||||||
@ -81,7 +72,7 @@ pub trait Encoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||||
{
|
{
|
||||||
@ -89,7 +80,7 @@ pub trait Encoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||||
{
|
{
|
||||||
@ -97,7 +88,7 @@ pub trait Encoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||||
{
|
{
|
||||||
@ -105,7 +96,7 @@ pub trait Encoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||||
{
|
{
|
||||||
@ -122,14 +113,14 @@ pub trait Encoder {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn emit_option_none(&mut self) -> Result<(), Self::Error> {
|
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>
|
fn emit_option_some<F>(&mut self, f: F) -> Result<(), Self::Error>
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
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>
|
fn emit_seq<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error>
|
||||||
@ -141,7 +132,7 @@ pub trait Encoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||||
{
|
{
|
||||||
@ -157,7 +148,7 @@ pub trait Encoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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
|
where
|
||||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
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] {
|
impl<S: Encoder, T: Encodable<S>> Encodable<S> for [T] {
|
||||||
default fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
default fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
s.emit_seq(self.len(), |s| {
|
s.emit_seq(self.len(), |s| {
|
||||||
for (i, e) in self.iter().enumerate() {
|
for e in self.iter() {
|
||||||
s.emit_seq_elt(i, |s| e.encode(s))?
|
s.emit_seq_elt(|s| e.encode(s))?
|
||||||
}
|
}
|
||||||
Ok(())
|
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> {
|
impl<S: Encoder, T1: Encodable<S>, T2: Encodable<S>> Encodable<S> for Result<T1, T2> {
|
||||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
s.emit_enum(|s| match *self {
|
s.emit_enum(|s| match *self {
|
||||||
Ok(ref v) => {
|
Ok(ref v) => s.emit_enum_variant(0, |s| s.emit_enum_variant_arg(|s| v.encode(s))),
|
||||||
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(1, |s| s.emit_enum_variant_arg(|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)))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,18 +481,6 @@ macro_rules! peel {
|
|||||||
($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
|
($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 {
|
macro_rules! tuple {
|
||||||
() => ();
|
() => ();
|
||||||
( $($name:ident,)+ ) => (
|
( $($name:ident,)+ ) => (
|
||||||
@ -518,10 +493,8 @@ macro_rules! tuple {
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
let ($(ref $name,)+) = *self;
|
let ($(ref $name,)+) = *self;
|
||||||
let len: usize = count!($($name)+);
|
s.emit_tuple(|s| {
|
||||||
s.emit_tuple(len, |s| {
|
$(s.emit_tuple_arg(|s| $name.encode(s))?;)+
|
||||||
let mut i = 0;
|
|
||||||
$(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s))?;)+
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -307,10 +307,10 @@ impl DefId {
|
|||||||
|
|
||||||
impl<E: Encoder> Encodable<E> for DefId {
|
impl<E: Encoder> Encodable<E> for DefId {
|
||||||
default fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
default fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
||||||
s.emit_struct(false, |s| {
|
s.emit_struct(|s| {
|
||||||
s.emit_struct_field("krate", true, |s| self.krate.encode(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))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,20 +197,19 @@ impl Hash for RealFileName {
|
|||||||
impl<S: Encoder> Encodable<S> for RealFileName {
|
impl<S: Encoder> Encodable<S> for RealFileName {
|
||||||
fn encode(&self, encoder: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, encoder: &mut S) -> Result<(), S::Error> {
|
||||||
encoder.emit_enum(|encoder| match *self {
|
encoder.emit_enum(|encoder| match *self {
|
||||||
RealFileName::LocalPath(ref local_path) => {
|
RealFileName::LocalPath(ref local_path) => encoder.emit_enum_variant(0, |encoder| {
|
||||||
encoder.emit_enum_variant("LocalPath", 0, 1, |encoder| {
|
Ok({
|
||||||
encoder.emit_enum_variant_arg(true, |encoder| local_path.encode(encoder))?;
|
encoder.emit_enum_variant_arg(|encoder| local_path.encode(encoder))?;
|
||||||
Ok(())
|
|
||||||
})
|
})
|
||||||
}
|
}),
|
||||||
|
|
||||||
RealFileName::Remapped { ref local_path, ref virtual_name } => 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
|
// For privacy and build reproducibility, we must not embed host-dependant path in artifacts
|
||||||
// if they have been remapped by --remap-path-prefix
|
// if they have been remapped by --remap-path-prefix
|
||||||
assert!(local_path.is_none());
|
assert!(local_path.is_none());
|
||||||
encoder.emit_enum_variant_arg(true, |encoder| local_path.encode(encoder))?;
|
encoder.emit_enum_variant_arg(|encoder| local_path.encode(encoder))?;
|
||||||
encoder.emit_enum_variant_arg(false, |encoder| virtual_name.encode(encoder))?;
|
encoder.emit_enum_variant_arg(|encoder| virtual_name.encode(encoder))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@ -950,9 +949,9 @@ impl Default for Span {
|
|||||||
impl<E: Encoder> Encodable<E> for Span {
|
impl<E: Encoder> Encodable<E> for Span {
|
||||||
default fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
default fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
||||||
let span = self.data();
|
let span = self.data();
|
||||||
s.emit_struct(false, |s| {
|
s.emit_struct(|s| {
|
||||||
s.emit_struct_field("lo", true, |s| span.lo.encode(s))?;
|
s.emit_struct_field(|s| span.lo.encode(s))?;
|
||||||
s.emit_struct_field("hi", false, |s| span.hi.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 {
|
impl<S: Encoder> Encodable<S> for SourceFile {
|
||||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
s.emit_struct(false, |s| {
|
s.emit_struct(|s| {
|
||||||
s.emit_struct_field("name", true, |s| self.name.encode(s))?;
|
s.emit_struct_field(|s| self.name.encode(s))?;
|
||||||
s.emit_struct_field("src_hash", false, |s| self.src_hash.encode(s))?;
|
s.emit_struct_field(|s| self.src_hash.encode(s))?;
|
||||||
s.emit_struct_field("start_pos", false, |s| self.start_pos.encode(s))?;
|
s.emit_struct_field(|s| self.start_pos.encode(s))?;
|
||||||
s.emit_struct_field("end_pos", false, |s| self.end_pos.encode(s))?;
|
s.emit_struct_field(|s| self.end_pos.encode(s))?;
|
||||||
s.emit_struct_field("lines", false, |s| {
|
s.emit_struct_field(|s| {
|
||||||
// We are always in `Lines` form by the time we reach here.
|
// We are always in `Lines` form by the time we reach here.
|
||||||
assert!(self.lines.borrow().is_lines());
|
assert!(self.lines.borrow().is_lines());
|
||||||
self.lines(|lines| {
|
self.lines(|lines| {
|
||||||
@ -1369,11 +1368,11 @@ impl<S: Encoder> Encodable<S> for SourceFile {
|
|||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
s.emit_struct_field("multibyte_chars", false, |s| self.multibyte_chars.encode(s))?;
|
s.emit_struct_field(|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(|s| self.non_narrow_chars.encode(s))?;
|
||||||
s.emit_struct_field("name_hash", false, |s| self.name_hash.encode(s))?;
|
s.emit_struct_field(|s| self.name_hash.encode(s))?;
|
||||||
s.emit_struct_field("normalized_pos", false, |s| self.normalized_pos.encode(s))?;
|
s.emit_struct_field(|s| self.normalized_pos.encode(s))?;
|
||||||
s.emit_struct_field("cnum", false, |s| self.cnum.encode(s))
|
s.emit_struct_field(|s| self.cnum.encode(s))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -719,111 +719,111 @@ where
|
|||||||
rustc_serialize::Encoder::emit_enum(e, |e| {
|
rustc_serialize::Encoder::emit_enum(e, |e| {
|
||||||
let disc = discriminant(self);
|
let disc = discriminant(self);
|
||||||
match self {
|
match self {
|
||||||
Bool => e.emit_enum_variant("Bool", disc, 0, |_| Ok(())),
|
Bool => e.emit_enum_variant(disc, |_| Ok(())),
|
||||||
Char => e.emit_enum_variant("Char", disc, 0, |_| Ok(())),
|
Char => e.emit_enum_variant(disc, |_| Ok(())),
|
||||||
Int(i) => e.emit_enum_variant("Int", disc, 1, |e| {
|
Int(i) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| i.encode(e))?;
|
e.emit_enum_variant_arg(|e| i.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Uint(u) => e.emit_enum_variant("Uint", disc, 1, |e| {
|
Uint(u) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| u.encode(e))?;
|
e.emit_enum_variant_arg(|e| u.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Float(f) => e.emit_enum_variant("Float", disc, 1, |e| {
|
Float(f) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| f.encode(e))?;
|
e.emit_enum_variant_arg(|e| f.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Adt(adt, substs) => e.emit_enum_variant("Adt", disc, 2, |e| {
|
Adt(adt, substs) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| adt.encode(e))?;
|
e.emit_enum_variant_arg(|e| adt.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
|
e.emit_enum_variant_arg(|e| substs.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Foreign(def_id) => e.emit_enum_variant("Foreign", disc, 1, |e| {
|
Foreign(def_id) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
|
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Str => e.emit_enum_variant("Str", disc, 0, |_| Ok(())),
|
Str => e.emit_enum_variant(disc, |_| Ok(())),
|
||||||
Array(t, c) => e.emit_enum_variant("Array", disc, 2, |e| {
|
Array(t, c) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| t.encode(e))?;
|
e.emit_enum_variant_arg(|e| t.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| c.encode(e))?;
|
e.emit_enum_variant_arg(|e| c.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Slice(t) => e.emit_enum_variant("Slice", disc, 1, |e| {
|
Slice(t) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| t.encode(e))?;
|
e.emit_enum_variant_arg(|e| t.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
RawPtr(tam) => e.emit_enum_variant("RawPtr", disc, 1, |e| {
|
RawPtr(tam) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| tam.encode(e))?;
|
e.emit_enum_variant_arg(|e| tam.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Ref(r, t, m) => e.emit_enum_variant("Ref", disc, 3, |e| {
|
Ref(r, t, m) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| r.encode(e))?;
|
e.emit_enum_variant_arg(|e| r.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| t.encode(e))?;
|
e.emit_enum_variant_arg(|e| t.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| m.encode(e))?;
|
e.emit_enum_variant_arg(|e| m.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
FnDef(def_id, substs) => e.emit_enum_variant("FnDef", disc, 2, |e| {
|
FnDef(def_id, substs) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
|
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
|
e.emit_enum_variant_arg(|e| substs.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
FnPtr(polyfnsig) => e.emit_enum_variant("FnPtr", disc, 1, |e| {
|
FnPtr(polyfnsig) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| polyfnsig.encode(e))?;
|
e.emit_enum_variant_arg(|e| polyfnsig.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Dynamic(l, r) => e.emit_enum_variant("Dynamic", disc, 2, |e| {
|
Dynamic(l, r) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| l.encode(e))?;
|
e.emit_enum_variant_arg(|e| l.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| r.encode(e))?;
|
e.emit_enum_variant_arg(|e| r.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Closure(def_id, substs) => e.emit_enum_variant("Closure", disc, 2, |e| {
|
Closure(def_id, substs) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
|
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
|
e.emit_enum_variant_arg(|e| substs.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Generator(def_id, substs, m) => e.emit_enum_variant("Generator", disc, 3, |e| {
|
Generator(def_id, substs, m) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
|
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
|
e.emit_enum_variant_arg(|e| substs.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| m.encode(e))?;
|
e.emit_enum_variant_arg(|e| m.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
GeneratorWitness(b) => e.emit_enum_variant("GeneratorWitness", disc, 1, |e| {
|
GeneratorWitness(b) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| b.encode(e))?;
|
e.emit_enum_variant_arg(|e| b.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Never => e.emit_enum_variant("Never", disc, 0, |_| Ok(())),
|
Never => e.emit_enum_variant(disc, |_| Ok(())),
|
||||||
Tuple(substs) => e.emit_enum_variant("Tuple", disc, 1, |e| {
|
Tuple(substs) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| substs.encode(e))?;
|
e.emit_enum_variant_arg(|e| substs.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Projection(p) => e.emit_enum_variant("Projection", disc, 1, |e| {
|
Projection(p) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| p.encode(e))?;
|
e.emit_enum_variant_arg(|e| p.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Opaque(def_id, substs) => e.emit_enum_variant("Opaque", disc, 2, |e| {
|
Opaque(def_id, substs) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
|
e.emit_enum_variant_arg(|e| def_id.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
|
e.emit_enum_variant_arg(|e| substs.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Param(p) => e.emit_enum_variant("Param", disc, 1, |e| {
|
Param(p) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| p.encode(e))?;
|
e.emit_enum_variant_arg(|e| p.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Bound(d, b) => e.emit_enum_variant("Bound", disc, 2, |e| {
|
Bound(d, b) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| d.encode(e))?;
|
e.emit_enum_variant_arg(|e| d.encode(e))?;
|
||||||
e.emit_enum_variant_arg(false, |e| b.encode(e))?;
|
e.emit_enum_variant_arg(|e| b.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Placeholder(p) => e.emit_enum_variant("Placeholder", disc, 1, |e| {
|
Placeholder(p) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| p.encode(e))?;
|
e.emit_enum_variant_arg(|e| p.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Infer(i) => e.emit_enum_variant("Infer", disc, 1, |e| {
|
Infer(i) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| i.encode(e))?;
|
e.emit_enum_variant_arg(|e| i.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
Error(d) => e.emit_enum_variant("Error", disc, 1, |e| {
|
Error(d) => e.emit_enum_variant(disc, |e| {
|
||||||
e.emit_enum_variant_arg(true, |e| d.encode(e))?;
|
e.emit_enum_variant_arg(|e| d.encode(e))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user