Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiser
Avoid specialization in the metadata serialization code With the exception of a perf-only specialization for byte slices and byte vectors. This uses the same trick of introducing a new trait and having the Encodable and Decodable derives add a bound to it as used for TyEncoder/TyDecoder. The new code is clearer about which encoder/decoder uses which impl and it reduces the dependency of rustc on specialization, making it easier to remove support for specialization entirely or turn it into a construct that is only allowed for perf optimizations if we decide to do this.
This commit is contained in:
commit
e21f4cd98f
24 changed files with 478 additions and 400 deletions
|
@ -9,7 +9,6 @@ use rustc_data_structures::stable_hasher::{
|
|||
};
|
||||
use rustc_data_structures::sync::Lock;
|
||||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
@ -2078,19 +2077,6 @@ impl ToString for Symbol {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S: Encoder> Encodable<S> for Symbol {
|
||||
default fn encode(&self, s: &mut S) {
|
||||
s.emit_str(self.as_str());
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: Decoder> Decodable<D> for Symbol {
|
||||
#[inline]
|
||||
default fn decode(d: &mut D) -> Symbol {
|
||||
Symbol::intern(d.read_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX> HashStable<CTX> for Symbol {
|
||||
#[inline]
|
||||
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue