about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2019-11-10 17:31:21 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2019-11-22 19:56:38 +0100
commit640797fdd700ab30addcd3497621422989f9826f (patch)
tree4949c09099ccae4a57ddec922a94ecd660ee2fce /src/libsyntax_pos
parent1de5fdb5babf74f729b008585a8aaf16110bb1fd (diff)
downloadrust-640797fdd700ab30addcd3497621422989f9826f.tar.gz
rust-640797fdd700ab30addcd3497621422989f9826f.zip
Invert flow in impl HashStable of Span.
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/lib.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index d11ef5fcab2..25391ad5ce6 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -34,7 +34,7 @@ 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;
@@ -245,6 +245,14 @@ impl Ord for Span {
     }
 }
 
+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
@@ -1566,4 +1574,6 @@ fn lookup_line(lines: &[BytePos], pos: BytePos) -> isize {
 /// 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 {}
+pub trait StableHashingContextLike {
+    fn hash_stable_span(&mut self, span: &Span, hasher: &mut StableHasher);
+}