diff options
Diffstat (limited to 'src/librustc_span/lib.rs')
| -rw-r--r-- | src/librustc_span/lib.rs | 56 | 
1 files changed, 27 insertions, 29 deletions
diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 697d88ad063..c654dade2ab 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -15,8 +15,7 @@ #![feature(option_expect_none)] #![feature(refcell_take)] -// FIXME(#56935): Work around ICEs during cross-compilation. -#[allow(unused)] +#[macro_use] extern crate rustc_macros; use rustc_data_structures::AtomicRef; @@ -105,8 +104,8 @@ scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals); // // FIXME: We should use this enum or something like it to get rid of the // use of magic `/rust/1.x/...` paths across the board. -#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)] -#[derive(HashStable_Generic)] +#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)] +#[derive(HashStable_Generic, Decodable, Encodable)] pub enum RealFileName { Named(PathBuf), /// For de-virtualized paths (namely paths into libstd that have been mapped @@ -152,8 +151,8 @@ impl RealFileName { } /// Differentiates between real files and common virtual files. -#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)] -#[derive(HashStable_Generic)] +#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)] +#[derive(HashStable_Generic, Decodable, Encodable)] pub enum FileName { Real(RealFileName), /// Call to `quote!`. @@ -333,7 +332,7 @@ impl Ord for Span { /// the error, and would be rendered with `^^^`. /// - They can have a *label*. In this case, the label is written next /// to the mark in the snippet when we render. -#[derive(Clone, Debug, Hash, PartialEq, Eq, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable)] pub struct MultiSpan { primary_spans: Vec<Span>, span_labels: Vec<(Span, String)>, @@ -698,23 +697,22 @@ impl Default for Span { } } -impl rustc_serialize::UseSpecializedEncodable for Span { - fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { +impl<E: Encoder> Encodable<E> for Span { + default fn encode(&self, s: &mut E) -> Result<(), E::Error> { let span = self.data(); s.emit_struct("Span", 2, |s| { s.emit_struct_field("lo", 0, |s| span.lo.encode(s))?; - s.emit_struct_field("hi", 1, |s| span.hi.encode(s)) }) } } - -impl rustc_serialize::UseSpecializedDecodable for Span { - fn default_decode<D: Decoder>(d: &mut D) -> Result<Span, D::Error> { - d.read_struct("Span", 2, |d| { +impl<D: Decoder> Decodable<D> for Span { + default fn decode(s: &mut D) -> Result<Span, D::Error> { + s.read_struct("Span", 2, |d| { let lo = d.read_struct_field("lo", 0, Decodable::decode)?; let hi = d.read_struct_field("hi", 1, Decodable::decode)?; - Ok(Span::with_root_ctxt(lo, hi)) + + Ok(Span::new(lo, hi, SyntaxContext::root())) }) } } @@ -889,7 +887,7 @@ impl From<Vec<Span>> for MultiSpan { } /// Identifies an offset of a multi-byte character in a `SourceFile`. -#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug)] pub struct MultiByteChar { /// The absolute offset of the character in the `SourceMap`. pub pos: BytePos, @@ -898,7 +896,7 @@ pub struct MultiByteChar { } /// Identifies an offset of a non-narrow character in a `SourceFile`. -#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug)] pub enum NonNarrowChar { /// Represents a zero-width character. ZeroWidth(BytePos), @@ -960,7 +958,7 @@ impl Sub<BytePos> for NonNarrowChar { } /// Identifies an offset of a character that was normalized away from `SourceFile`. -#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug)] pub struct NormalizedPos { /// The absolute offset of the character in the `SourceMap`. pub pos: BytePos, @@ -1012,7 +1010,7 @@ impl ExternalSource { #[derive(Debug)] pub struct OffsetOverflowError; -#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)] pub enum SourceFileHashAlgorithm { Md5, Sha1, @@ -1033,8 +1031,8 @@ impl FromStr for SourceFileHashAlgorithm { rustc_data_structures::impl_stable_hash_via_hash!(SourceFileHashAlgorithm); /// The hash of the on-disk source file used for debug info. -#[derive(Copy, Clone, PartialEq, Eq, Debug, RustcEncodable, RustcDecodable)] -#[derive(HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[derive(HashStable_Generic, Encodable, Decodable)] pub struct SourceFileHash { pub kind: SourceFileHashAlgorithm, value: [u8; 20], @@ -1113,8 +1111,8 @@ pub struct SourceFile { pub cnum: CrateNum, } -impl Encodable for SourceFile { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { +impl<S: Encoder> Encodable<S> for SourceFile { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_struct("SourceFile", 8, |s| { s.emit_struct_field("name", 0, |s| self.name.encode(s))?; s.emit_struct_field("name_was_remapped", 1, |s| self.name_was_remapped.encode(s))?; @@ -1183,8 +1181,8 @@ impl Encodable for SourceFile { } } -impl Decodable for SourceFile { - fn decode<D: Decoder>(d: &mut D) -> Result<SourceFile, D::Error> { +impl<D: Decoder> Decodable<D> for SourceFile { + fn decode(d: &mut D) -> Result<SourceFile, D::Error> { d.read_struct("SourceFile", 8, |d| { let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?; let name_was_remapped: bool = @@ -1585,14 +1583,14 @@ impl Sub for BytePos { } } -impl Encodable for BytePos { - fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { +impl<S: rustc_serialize::Encoder> Encodable<S> for BytePos { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { s.emit_u32(self.0) } } -impl Decodable for BytePos { - fn decode<D: Decoder>(d: &mut D) -> Result<BytePos, D::Error> { +impl<D: rustc_serialize::Decoder> Decodable<D> for BytePos { + fn decode(d: &mut D) -> Result<BytePos, D::Error> { Ok(BytePos(d.read_u32()?)) } }  | 
