Move finish
out of the Encoder
trait.
This simplifies things, but requires making `CacheEncoder` non-generic. (This was previously merged as commit 4 in #94732 and then was reverted in #97905 because it caused a perf regression.)
This commit is contained in:
parent
ca983054e1
commit
bb02cc47c4
13 changed files with 51 additions and 111 deletions
|
@ -94,9 +94,6 @@ macro_rules! encoder_methods {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx> {
|
||||
type Ok = <MemEncoder as Encoder>::Ok;
|
||||
type Err = <MemEncoder as Encoder>::Err;
|
||||
|
||||
encoder_methods! {
|
||||
emit_usize(usize);
|
||||
emit_u128(u128);
|
||||
|
@ -119,10 +116,6 @@ impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx> {
|
|||
emit_str(&str);
|
||||
emit_raw_bytes(&[u8]);
|
||||
}
|
||||
|
||||
fn finish(self) -> Result<Self::Ok, Self::Err> {
|
||||
self.opaque.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, T> Encodable<EncodeContext<'a, 'tcx>> for LazyValue<T> {
|
||||
|
@ -2216,7 +2209,7 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
|
|||
// culminating in the `CrateRoot` which points to all of it.
|
||||
let root = ecx.encode_crate_root();
|
||||
|
||||
let mut result = ecx.opaque.finish().unwrap();
|
||||
let mut result = ecx.opaque.finish();
|
||||
|
||||
// Encode the root position.
|
||||
let header = METADATA_HEADER.len();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue