rustc_metadata: remove Encodable requirements from LazyMeta impls.
This commit is contained in:
parent
ee42979eeb
commit
d7444c122e
@ -32,7 +32,7 @@
|
|||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
|
||||||
use rustc_serialize::{Decodable, Decoder, Encodable, SpecializedDecoder, opaque};
|
use rustc_serialize::{Decodable, Decoder, SpecializedDecoder, opaque};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::ast::{self, Ident};
|
use syntax::ast::{self, Ident};
|
||||||
use syntax::source_map::{self, respan, Spanned};
|
use syntax::source_map::{self, respan, Spanned};
|
||||||
@ -217,7 +217,7 @@ fn tcx(self) -> Option<TyCtxt<'tcx>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, T: Encodable + Decodable> Lazy<T> {
|
impl<'a, 'tcx, T: Decodable> Lazy<T> {
|
||||||
fn decode<M: Metadata<'a, 'tcx>>(self, metadata: M) -> T {
|
fn decode<M: Metadata<'a, 'tcx>>(self, metadata: M) -> T {
|
||||||
let mut dcx = metadata.decoder(self.position.get());
|
let mut dcx = metadata.decoder(self.position.get());
|
||||||
dcx.lazy_state = LazyState::NodeStart(self.position);
|
dcx.lazy_state = LazyState::NodeStart(self.position);
|
||||||
@ -225,7 +225,7 @@ fn decode<M: Metadata<'a, 'tcx>>(self, metadata: M) -> T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a: 'x, 'tcx: 'x, 'x, T: Encodable + Decodable> Lazy<[T]> {
|
impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> Lazy<[T]> {
|
||||||
fn decode<M: Metadata<'a, 'tcx>>(
|
fn decode<M: Metadata<'a, 'tcx>>(
|
||||||
self,
|
self,
|
||||||
metadata: M,
|
metadata: M,
|
||||||
@ -324,13 +324,13 @@ fn map_encoded_cnum_to_current(&self, cnum: CrateNum) -> CrateNum {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, T: Encodable> SpecializedDecoder<Lazy<T>> for DecodeContext<'a, 'tcx> {
|
impl<'a, 'tcx, T> SpecializedDecoder<Lazy<T>> for DecodeContext<'a, 'tcx> {
|
||||||
fn specialized_decode(&mut self) -> Result<Lazy<T>, Self::Error> {
|
fn specialized_decode(&mut self) -> Result<Lazy<T>, Self::Error> {
|
||||||
self.read_lazy_with_meta(())
|
self.read_lazy_with_meta(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, T: Encodable> SpecializedDecoder<Lazy<[T]>> for DecodeContext<'a, 'tcx> {
|
impl<'a, 'tcx, T> SpecializedDecoder<Lazy<[T]>> for DecodeContext<'a, 'tcx> {
|
||||||
fn specialized_decode(&mut self) -> Result<Lazy<[T]>, Self::Error> {
|
fn specialized_decode(&mut self) -> Result<Lazy<[T]>, Self::Error> {
|
||||||
let len = self.read_usize()?;
|
let len = self.read_usize()?;
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
|
@ -122,13 +122,13 @@ fn emit_unit(&mut self) -> Result<(), Self::Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Encodable> SpecializedEncoder<Lazy<T>> for EncodeContext<'tcx> {
|
impl<'tcx, T> SpecializedEncoder<Lazy<T>> for EncodeContext<'tcx> {
|
||||||
fn specialized_encode(&mut self, lazy: &Lazy<T>) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, lazy: &Lazy<T>) -> Result<(), Self::Error> {
|
||||||
self.emit_lazy_distance(*lazy)
|
self.emit_lazy_distance(*lazy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Encodable> SpecializedEncoder<Lazy<[T]>> for EncodeContext<'tcx> {
|
impl<'tcx, T> SpecializedEncoder<Lazy<[T]>> for EncodeContext<'tcx> {
|
||||||
fn specialized_encode(&mut self, lazy: &Lazy<[T]>) -> Result<(), Self::Error> {
|
fn specialized_encode(&mut self, lazy: &Lazy<[T]>) -> Result<(), Self::Error> {
|
||||||
self.emit_usize(lazy.meta)?;
|
self.emit_usize(lazy.meta)?;
|
||||||
if lazy.meta == 0 {
|
if lazy.meta == 0 {
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_data_structures::svh::Svh;
|
use rustc_data_structures::svh::Svh;
|
||||||
use rustc_data_structures::sync::MetadataRef;
|
use rustc_data_structures::sync::MetadataRef;
|
||||||
use rustc_serialize::Encodable;
|
|
||||||
use syntax::{ast, attr};
|
use syntax::{ast, attr};
|
||||||
use syntax::edition::Edition;
|
use syntax::edition::Edition;
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
@ -59,7 +58,7 @@ trait LazyMeta {
|
|||||||
fn min_size(meta: Self::Meta) -> usize;
|
fn min_size(meta: Self::Meta) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Encodable> LazyMeta for T {
|
impl<T> LazyMeta for T {
|
||||||
type Meta = ();
|
type Meta = ();
|
||||||
|
|
||||||
fn min_size(_: ()) -> usize {
|
fn min_size(_: ()) -> usize {
|
||||||
@ -68,7 +67,7 @@ fn min_size(_: ()) -> usize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Encodable> LazyMeta for [T] {
|
impl<T> LazyMeta for [T] {
|
||||||
type Meta = usize;
|
type Meta = usize;
|
||||||
|
|
||||||
fn min_size(len: usize) -> usize {
|
fn min_size(len: usize) -> usize {
|
||||||
@ -124,13 +123,13 @@ fn from_position_and_meta(position: NonZeroUsize, meta: T::Meta) -> Lazy<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Encodable> Lazy<T> {
|
impl<T> Lazy<T> {
|
||||||
fn from_position(position: NonZeroUsize) -> Lazy<T> {
|
fn from_position(position: NonZeroUsize) -> Lazy<T> {
|
||||||
Lazy::from_position_and_meta(position, ())
|
Lazy::from_position_and_meta(position, ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Encodable> Lazy<[T]> {
|
impl<T> Lazy<[T]> {
|
||||||
fn empty() -> Lazy<[T]> {
|
fn empty() -> Lazy<[T]> {
|
||||||
Lazy::from_position_and_meta(NonZeroUsize::new(1).unwrap(), 0)
|
Lazy::from_position_and_meta(NonZeroUsize::new(1).unwrap(), 0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user