]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax_pos/lib.rs
Fix rebase fallout.
[rust.git] / src / libsyntax_pos / lib.rs
index a762d8af49a21149d10c03e7bfc7dae70c7081d4..25391ad5ce6f442945347912f8716a2fced60856 100644 (file)
@@ -15,6 +15,9 @@
 #![feature(step_trait)]
 
 use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
+use rustc_macros::HashStable_Generic;
+
+pub mod source_map;
 
 pub mod edition;
 use edition::Edition;
@@ -29,8 +32,9 @@
 pub use symbol::{Symbol, sym};
 
 mod analyze_source_file;
+pub mod fatal_error;
 
-use rustc_data_structures::stable_hasher::StableHasher;
+use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_data_structures::sync::{Lrc, Lock};
 
 use std::borrow::Cow;
@@ -63,7 +67,8 @@ pub fn new(edition: Edition) -> Globals {
 scoped_tls::scoped_thread_local!(pub static GLOBALS: Globals);
 
 /// Differentiates between real files and common virtual files.
-#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)]
+#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash,
+         RustcDecodable, RustcEncodable, HashStable_Generic)]
 pub enum FileName {
     Real(PathBuf),
     /// A macro. This includes the full name of the macro, so that there are no clashes.
@@ -240,6 +245,14 @@ fn cmp(&self, rhs: &Self) -> Ordering {
     }
 }
 
+impl<CTX> HashStable<CTX> for Span
+    where CTX: StableHashingContextLike
+{
+    fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
+        ctx.hash_stable_span(self, hasher)
+    }
+}
+
 /// A collection of spans. Spans have two orthogonal attributes:
 ///
 /// - They can be *primary spans*. In this case they are the locus of
@@ -1557,3 +1570,10 @@ fn lookup_line(lines: &[BytePos], pos: BytePos) -> isize {
         Err(line) => line as isize - 1
     }
 }
+
+/// Requirements for a `StableHashingContext` to be used in this crate.
+/// This is a hack to allow using the `HashStable_Generic` derive macro
+/// instead of implementing everything in librustc.
+pub trait StableHashingContextLike {
+    fn hash_stable_span(&mut self, span: &Span, hasher: &mut StableHasher);
+}