2020-06-11 14:49:57 +00:00
|
|
|
use proc_macro2::TokenStream;
|
2021-12-16 23:35:15 +00:00
|
|
|
use quote::{quote, quote_spanned};
|
2020-06-11 14:49:57 +00:00
|
|
|
use syn::parse_quote;
|
2021-12-16 23:35:15 +00:00
|
|
|
use syn::spanned::Spanned;
|
2020-06-11 14:49:57 +00:00
|
|
|
|
|
|
|
pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
|
|
|
let decoder_ty = quote! { __D };
|
|
|
|
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
|
|
|
s.add_impl_generic(parse_quote! { 'tcx });
|
|
|
|
}
|
2022-05-28 03:03:57 +00:00
|
|
|
s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_type_ir::codec::TyDecoder<I = ::rustc_middle::ty::TyCtxt<'tcx>>});
|
2020-06-11 14:49:57 +00:00
|
|
|
s.add_bounds(synstructure::AddBounds::Generics);
|
|
|
|
|
|
|
|
decodable_body(s, decoder_ty)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
|
|
|
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
|
|
|
s.add_impl_generic(parse_quote! { 'tcx });
|
|
|
|
}
|
|
|
|
s.add_impl_generic(parse_quote! { '__a });
|
|
|
|
let decoder_ty = quote! { DecodeContext<'__a, 'tcx> };
|
|
|
|
s.add_bounds(synstructure::AddBounds::Generics);
|
|
|
|
|
|
|
|
decodable_body(s, decoder_ty)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
|
|
|
let decoder_ty = quote! { __D };
|
|
|
|
s.add_impl_generic(parse_quote! {#decoder_ty: ::rustc_serialize::Decoder});
|
|
|
|
s.add_bounds(synstructure::AddBounds::Generics);
|
|
|
|
|
|
|
|
decodable_body(s, decoder_ty)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn decodable_body(
|
|
|
|
s: synstructure::Structure<'_>,
|
|
|
|
decoder_ty: TokenStream,
|
|
|
|
) -> proc_macro2::TokenStream {
|
|
|
|
if let syn::Data::Union(_) = s.ast().data {
|
|
|
|
panic!("cannot derive on union")
|
|
|
|
}
|
|
|
|
let ty_name = s.ast().ident.to_string();
|
|
|
|
let decode_body = match s.variants() {
|
2023-02-24 22:58:32 +00:00
|
|
|
[] => {
|
2023-07-25 20:00:13 +00:00
|
|
|
let message = format!("`{ty_name}` has no variants to decode");
|
2023-02-24 22:58:32 +00:00
|
|
|
quote! {
|
|
|
|
panic!(#message)
|
|
|
|
}
|
|
|
|
}
|
2022-02-09 22:26:17 +00:00
|
|
|
[vi] => vi.construct(|field, _index| decode_field(field)),
|
2020-06-11 14:49:57 +00:00
|
|
|
variants => {
|
|
|
|
let match_inner: TokenStream = variants
|
|
|
|
.iter()
|
|
|
|
.enumerate()
|
|
|
|
.map(|(idx, vi)| {
|
2022-02-09 22:26:17 +00:00
|
|
|
let construct = vi.construct(|field, _index| decode_field(field));
|
Make `Decodable` and `Decoder` infallible.
`Decoder` has two impls:
- opaque: this impl is already partly infallible, i.e. in some places it
currently panics on failure (e.g. if the input is too short, or on a
bad `Result` discriminant), and in some places it returns an error
(e.g. on a bad `Option` discriminant). The number of places where
either happens is surprisingly small, just because the binary
representation has very little redundancy and a lot of input reading
can occur even on malformed data.
- json: this impl is fully fallible, but it's only used (a) for the
`.rlink` file production, and there's a `FIXME` comment suggesting it
should change to a binary format, and (b) in a few tests in
non-fundamental ways. Indeed #85993 is open to remove it entirely.
And the top-level places in the compiler that call into decoding just
abort on error anyway. So the fallibility is providing little value, and
getting rid of it leads to some non-trivial performance improvements.
Much of this commit is pretty boring and mechanical. Some notes about
a few interesting parts:
- The commit removes `Decoder::{Error,error}`.
- `InternIteratorElement::intern_with`: the impl for `T` now has the same
optimization for small counts that the impl for `Result<T, E>` has,
because it's now much hotter.
- Decodable impls for SmallVec, LinkedList, VecDeque now all use
`collect`, which is nice; the one for `Vec` uses unsafe code, because
that gave better perf on some benchmarks.
2022-01-18 02:22:50 +00:00
|
|
|
quote! { #idx => { #construct } }
|
2020-06-11 14:49:57 +00:00
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
let message = format!(
|
2023-08-16 22:51:52 +00:00
|
|
|
"invalid enum variant tag while decoding `{}`, expected 0..{}, actual {{}}",
|
2020-06-11 14:49:57 +00:00
|
|
|
ty_name,
|
|
|
|
variants.len()
|
|
|
|
);
|
|
|
|
quote! {
|
2022-02-09 22:48:06 +00:00
|
|
|
match ::rustc_serialize::Decoder::read_usize(__decoder) {
|
|
|
|
#match_inner
|
2023-08-16 22:51:52 +00:00
|
|
|
n => panic!(#message, n),
|
2022-02-09 22:48:06 +00:00
|
|
|
}
|
2020-06-11 14:49:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
s.bound_impl(
|
|
|
|
quote!(::rustc_serialize::Decodable<#decoder_ty>),
|
|
|
|
quote! {
|
Make `Decodable` and `Decoder` infallible.
`Decoder` has two impls:
- opaque: this impl is already partly infallible, i.e. in some places it
currently panics on failure (e.g. if the input is too short, or on a
bad `Result` discriminant), and in some places it returns an error
(e.g. on a bad `Option` discriminant). The number of places where
either happens is surprisingly small, just because the binary
representation has very little redundancy and a lot of input reading
can occur even on malformed data.
- json: this impl is fully fallible, but it's only used (a) for the
`.rlink` file production, and there's a `FIXME` comment suggesting it
should change to a binary format, and (b) in a few tests in
non-fundamental ways. Indeed #85993 is open to remove it entirely.
And the top-level places in the compiler that call into decoding just
abort on error anyway. So the fallibility is providing little value, and
getting rid of it leads to some non-trivial performance improvements.
Much of this commit is pretty boring and mechanical. Some notes about
a few interesting parts:
- The commit removes `Decoder::{Error,error}`.
- `InternIteratorElement::intern_with`: the impl for `T` now has the same
optimization for small counts that the impl for `Result<T, E>` has,
because it's now much hotter.
- Decodable impls for SmallVec, LinkedList, VecDeque now all use
`collect`, which is nice; the one for `Vec` uses unsafe code, because
that gave better perf on some benchmarks.
2022-01-18 02:22:50 +00:00
|
|
|
fn decode(__decoder: &mut #decoder_ty) -> Self {
|
2020-06-11 14:49:57 +00:00
|
|
|
#decode_body
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-09 22:26:17 +00:00
|
|
|
fn decode_field(field: &syn::Field) -> proc_macro2::TokenStream {
|
2021-12-16 23:35:15 +00:00
|
|
|
let field_span = field.ident.as_ref().map_or(field.ty.span(), |ident| ident.span());
|
|
|
|
|
2020-06-11 14:49:57 +00:00
|
|
|
let decode_inner_method = if let syn::Type::Reference(_) = field.ty {
|
|
|
|
quote! { ::rustc_middle::ty::codec::RefDecodable::decode }
|
|
|
|
} else {
|
|
|
|
quote! { ::rustc_serialize::Decodable::decode }
|
|
|
|
};
|
2022-02-09 22:17:04 +00:00
|
|
|
let __decoder = quote! { __decoder };
|
2022-02-09 22:26:17 +00:00
|
|
|
// Use the span of the field for the method call, so
|
|
|
|
// that backtraces will point to the field.
|
|
|
|
quote_spanned! {field_span=> #decode_inner_method(#__decoder) }
|
2020-06-11 14:49:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
|
|
|
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
|
|
|
s.add_impl_generic(parse_quote! {'tcx});
|
|
|
|
}
|
|
|
|
let encoder_ty = quote! { __E };
|
2022-05-28 03:03:57 +00:00
|
|
|
s.add_impl_generic(parse_quote! {#encoder_ty: ::rustc_type_ir::codec::TyEncoder<I = ::rustc_middle::ty::TyCtxt<'tcx>>});
|
2020-06-11 14:49:57 +00:00
|
|
|
s.add_bounds(synstructure::AddBounds::Generics);
|
|
|
|
|
|
|
|
encodable_body(s, encoder_ty, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
|
|
|
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
|
|
|
|
s.add_impl_generic(parse_quote! {'tcx});
|
|
|
|
}
|
|
|
|
s.add_impl_generic(parse_quote! { '__a });
|
|
|
|
let encoder_ty = quote! { EncodeContext<'__a, 'tcx> };
|
|
|
|
s.add_bounds(synstructure::AddBounds::Generics);
|
|
|
|
|
|
|
|
encodable_body(s, encoder_ty, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
|
|
|
let encoder_ty = quote! { __E };
|
|
|
|
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder});
|
|
|
|
s.add_bounds(synstructure::AddBounds::Generics);
|
|
|
|
|
|
|
|
encodable_body(s, encoder_ty, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn encodable_body(
|
|
|
|
mut s: synstructure::Structure<'_>,
|
|
|
|
encoder_ty: TokenStream,
|
|
|
|
allow_unreachable_code: bool,
|
|
|
|
) -> proc_macro2::TokenStream {
|
|
|
|
if let syn::Data::Union(_) = s.ast().data {
|
|
|
|
panic!("cannot derive on union")
|
|
|
|
}
|
|
|
|
|
|
|
|
s.bind_with(|binding| {
|
|
|
|
// Handle the lack of a blanket reference impl.
|
|
|
|
if let syn::Type::Reference(_) = binding.ast().ty {
|
|
|
|
synstructure::BindStyle::Move
|
|
|
|
} else {
|
|
|
|
synstructure::BindStyle::Ref
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
let encode_body = match s.variants() {
|
2023-02-24 22:58:32 +00:00
|
|
|
[] => {
|
|
|
|
quote! {
|
|
|
|
match *self {}
|
|
|
|
}
|
|
|
|
}
|
2020-06-11 14:49:57 +00:00
|
|
|
[_] => {
|
|
|
|
let encode_inner = s.each_variant(|vi| {
|
|
|
|
vi.bindings()
|
|
|
|
.iter()
|
|
|
|
.map(|binding| {
|
|
|
|
let bind_ident = &binding.binding;
|
|
|
|
let result = quote! {
|
Use delayed error handling for `Encodable` and `Encoder` infallible.
There are two impls of the `Encoder` trait: `opaque::Encoder` and
`opaque::FileEncoder`. The former encodes into memory and is infallible, the
latter writes to file and is fallible.
Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a
bit verbose and has non-trivial cost, which is annoying given how rare failures
are (especially in the infallible `opaque::Encoder` case).
This commit changes how `Encoder` fallibility is handled. All the `emit_*`
methods are now infallible. `opaque::Encoder` requires no great changes for
this. `opaque::FileEncoder` now implements a delayed error handling strategy.
If a failure occurs, it records this via the `res` field, and all subsequent
encoding operations are skipped if `res` indicates an error has occurred. Once
encoding is complete, the new `finish` method is called, which returns a
`Result`. In other words, there is now a single `Result`-producing method
instead of many of them.
This has very little effect on how any file errors are reported if
`opaque::FileEncoder` has any failures.
Much of this commit is boring mechanical changes, removing `Result` return
values and `?` or `unwrap` from expressions. The more interesting parts are as
follows.
- serialize.rs: The `Encoder` trait gains an `Ok` associated type. The
`into_inner` method is changed into `finish`, which returns
`Result<Vec<u8>, !>`.
- opaque.rs: The `FileEncoder` adopts the delayed error handling
strategy. Its `Ok` type is a `usize`, returning the number of bytes
written, replacing previous uses of `FileEncoder::position`.
- Various methods that take an encoder now consume it, rather than being
passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-07 03:30:45 +00:00
|
|
|
::rustc_serialize::Encodable::<#encoder_ty>::encode(
|
2021-06-04 16:23:50 +00:00
|
|
|
#bind_ident,
|
2020-06-11 14:49:57 +00:00
|
|
|
__encoder,
|
Use delayed error handling for `Encodable` and `Encoder` infallible.
There are two impls of the `Encoder` trait: `opaque::Encoder` and
`opaque::FileEncoder`. The former encodes into memory and is infallible, the
latter writes to file and is fallible.
Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a
bit verbose and has non-trivial cost, which is annoying given how rare failures
are (especially in the infallible `opaque::Encoder` case).
This commit changes how `Encoder` fallibility is handled. All the `emit_*`
methods are now infallible. `opaque::Encoder` requires no great changes for
this. `opaque::FileEncoder` now implements a delayed error handling strategy.
If a failure occurs, it records this via the `res` field, and all subsequent
encoding operations are skipped if `res` indicates an error has occurred. Once
encoding is complete, the new `finish` method is called, which returns a
`Result`. In other words, there is now a single `Result`-producing method
instead of many of them.
This has very little effect on how any file errors are reported if
`opaque::FileEncoder` has any failures.
Much of this commit is boring mechanical changes, removing `Result` return
values and `?` or `unwrap` from expressions. The more interesting parts are as
follows.
- serialize.rs: The `Encoder` trait gains an `Ok` associated type. The
`into_inner` method is changed into `finish`, which returns
`Result<Vec<u8>, !>`.
- opaque.rs: The `FileEncoder` adopts the delayed error handling
strategy. Its `Ok` type is a `usize`, returning the number of bytes
written, replacing previous uses of `FileEncoder::position`.
- Various methods that take an encoder now consume it, rather than being
passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-07 03:30:45 +00:00
|
|
|
);
|
2020-06-11 14:49:57 +00:00
|
|
|
};
|
|
|
|
result
|
|
|
|
})
|
|
|
|
.collect::<TokenStream>()
|
|
|
|
});
|
|
|
|
quote! {
|
Use delayed error handling for `Encodable` and `Encoder` infallible.
There are two impls of the `Encoder` trait: `opaque::Encoder` and
`opaque::FileEncoder`. The former encodes into memory and is infallible, the
latter writes to file and is fallible.
Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a
bit verbose and has non-trivial cost, which is annoying given how rare failures
are (especially in the infallible `opaque::Encoder` case).
This commit changes how `Encoder` fallibility is handled. All the `emit_*`
methods are now infallible. `opaque::Encoder` requires no great changes for
this. `opaque::FileEncoder` now implements a delayed error handling strategy.
If a failure occurs, it records this via the `res` field, and all subsequent
encoding operations are skipped if `res` indicates an error has occurred. Once
encoding is complete, the new `finish` method is called, which returns a
`Result`. In other words, there is now a single `Result`-producing method
instead of many of them.
This has very little effect on how any file errors are reported if
`opaque::FileEncoder` has any failures.
Much of this commit is boring mechanical changes, removing `Result` return
values and `?` or `unwrap` from expressions. The more interesting parts are as
follows.
- serialize.rs: The `Encoder` trait gains an `Ok` associated type. The
`into_inner` method is changed into `finish`, which returns
`Result<Vec<u8>, !>`.
- opaque.rs: The `FileEncoder` adopts the delayed error handling
strategy. Its `Ok` type is a `usize`, returning the number of bytes
written, replacing previous uses of `FileEncoder::position`.
- Various methods that take an encoder now consume it, rather than being
passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-07 03:30:45 +00:00
|
|
|
match *self { #encode_inner }
|
2020-06-11 14:49:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {
|
2023-02-24 22:58:32 +00:00
|
|
|
let disc = {
|
|
|
|
let mut variant_idx = 0usize;
|
|
|
|
let encode_inner = s.each_variant(|_| {
|
|
|
|
let result = quote! {
|
|
|
|
#variant_idx
|
|
|
|
};
|
|
|
|
variant_idx += 1;
|
|
|
|
result
|
|
|
|
});
|
|
|
|
quote! {
|
|
|
|
let disc = match *self {
|
|
|
|
#encode_inner
|
|
|
|
};
|
|
|
|
::rustc_serialize::Encoder::emit_usize(__encoder, disc);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-11 14:49:57 +00:00
|
|
|
let mut variant_idx = 0usize;
|
|
|
|
let encode_inner = s.each_variant(|vi| {
|
|
|
|
let encode_fields: TokenStream = vi
|
|
|
|
.bindings()
|
|
|
|
.iter()
|
|
|
|
.map(|binding| {
|
|
|
|
let bind_ident = &binding.binding;
|
|
|
|
let result = quote! {
|
Use delayed error handling for `Encodable` and `Encoder` infallible.
There are two impls of the `Encoder` trait: `opaque::Encoder` and
`opaque::FileEncoder`. The former encodes into memory and is infallible, the
latter writes to file and is fallible.
Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a
bit verbose and has non-trivial cost, which is annoying given how rare failures
are (especially in the infallible `opaque::Encoder` case).
This commit changes how `Encoder` fallibility is handled. All the `emit_*`
methods are now infallible. `opaque::Encoder` requires no great changes for
this. `opaque::FileEncoder` now implements a delayed error handling strategy.
If a failure occurs, it records this via the `res` field, and all subsequent
encoding operations are skipped if `res` indicates an error has occurred. Once
encoding is complete, the new `finish` method is called, which returns a
`Result`. In other words, there is now a single `Result`-producing method
instead of many of them.
This has very little effect on how any file errors are reported if
`opaque::FileEncoder` has any failures.
Much of this commit is boring mechanical changes, removing `Result` return
values and `?` or `unwrap` from expressions. The more interesting parts are as
follows.
- serialize.rs: The `Encoder` trait gains an `Ok` associated type. The
`into_inner` method is changed into `finish`, which returns
`Result<Vec<u8>, !>`.
- opaque.rs: The `FileEncoder` adopts the delayed error handling
strategy. Its `Ok` type is a `usize`, returning the number of bytes
written, replacing previous uses of `FileEncoder::position`.
- Various methods that take an encoder now consume it, rather than being
passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-07 03:30:45 +00:00
|
|
|
::rustc_serialize::Encodable::<#encoder_ty>::encode(
|
2021-06-04 16:23:50 +00:00
|
|
|
#bind_ident,
|
2020-06-11 14:49:57 +00:00
|
|
|
__encoder,
|
Use delayed error handling for `Encodable` and `Encoder` infallible.
There are two impls of the `Encoder` trait: `opaque::Encoder` and
`opaque::FileEncoder`. The former encodes into memory and is infallible, the
latter writes to file and is fallible.
Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a
bit verbose and has non-trivial cost, which is annoying given how rare failures
are (especially in the infallible `opaque::Encoder` case).
This commit changes how `Encoder` fallibility is handled. All the `emit_*`
methods are now infallible. `opaque::Encoder` requires no great changes for
this. `opaque::FileEncoder` now implements a delayed error handling strategy.
If a failure occurs, it records this via the `res` field, and all subsequent
encoding operations are skipped if `res` indicates an error has occurred. Once
encoding is complete, the new `finish` method is called, which returns a
`Result`. In other words, there is now a single `Result`-producing method
instead of many of them.
This has very little effect on how any file errors are reported if
`opaque::FileEncoder` has any failures.
Much of this commit is boring mechanical changes, removing `Result` return
values and `?` or `unwrap` from expressions. The more interesting parts are as
follows.
- serialize.rs: The `Encoder` trait gains an `Ok` associated type. The
`into_inner` method is changed into `finish`, which returns
`Result<Vec<u8>, !>`.
- opaque.rs: The `FileEncoder` adopts the delayed error handling
strategy. Its `Ok` type is a `usize`, returning the number of bytes
written, replacing previous uses of `FileEncoder::position`.
- Various methods that take an encoder now consume it, rather than being
passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-07 03:30:45 +00:00
|
|
|
);
|
2020-06-11 14:49:57 +00:00
|
|
|
};
|
|
|
|
result
|
|
|
|
})
|
|
|
|
.collect();
|
|
|
|
variant_idx += 1;
|
2023-02-24 22:58:32 +00:00
|
|
|
encode_fields
|
2020-06-11 14:49:57 +00:00
|
|
|
});
|
|
|
|
quote! {
|
2023-02-24 22:58:32 +00:00
|
|
|
#disc
|
2021-06-04 16:23:50 +00:00
|
|
|
match *self {
|
|
|
|
#encode_inner
|
|
|
|
}
|
2020-06-11 14:49:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let lints = if allow_unreachable_code {
|
|
|
|
quote! { #![allow(unreachable_code)] }
|
|
|
|
} else {
|
|
|
|
quote! {}
|
|
|
|
};
|
|
|
|
|
|
|
|
s.bound_impl(
|
|
|
|
quote!(::rustc_serialize::Encodable<#encoder_ty>),
|
|
|
|
quote! {
|
|
|
|
fn encode(
|
|
|
|
&self,
|
|
|
|
__encoder: &mut #encoder_ty,
|
Use delayed error handling for `Encodable` and `Encoder` infallible.
There are two impls of the `Encoder` trait: `opaque::Encoder` and
`opaque::FileEncoder`. The former encodes into memory and is infallible, the
latter writes to file and is fallible.
Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a
bit verbose and has non-trivial cost, which is annoying given how rare failures
are (especially in the infallible `opaque::Encoder` case).
This commit changes how `Encoder` fallibility is handled. All the `emit_*`
methods are now infallible. `opaque::Encoder` requires no great changes for
this. `opaque::FileEncoder` now implements a delayed error handling strategy.
If a failure occurs, it records this via the `res` field, and all subsequent
encoding operations are skipped if `res` indicates an error has occurred. Once
encoding is complete, the new `finish` method is called, which returns a
`Result`. In other words, there is now a single `Result`-producing method
instead of many of them.
This has very little effect on how any file errors are reported if
`opaque::FileEncoder` has any failures.
Much of this commit is boring mechanical changes, removing `Result` return
values and `?` or `unwrap` from expressions. The more interesting parts are as
follows.
- serialize.rs: The `Encoder` trait gains an `Ok` associated type. The
`into_inner` method is changed into `finish`, which returns
`Result<Vec<u8>, !>`.
- opaque.rs: The `FileEncoder` adopts the delayed error handling
strategy. Its `Ok` type is a `usize`, returning the number of bytes
written, replacing previous uses of `FileEncoder::position`.
- Various methods that take an encoder now consume it, rather than being
passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-07 03:30:45 +00:00
|
|
|
) {
|
2020-06-11 14:49:57 +00:00
|
|
|
#lints
|
|
|
|
#encode_body
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|