From c41733105898850fa3c3b783995f6199b2e18978 Mon Sep 17 00:00:00 2001 From: underfin Date: Mon, 12 Jun 2023 20:04:55 +0800 Subject: [PATCH] fix: replace source should hash inner source (#60) * fix: replace source should hash inner source * fix test --------- Co-authored-by: ahabhgk --- src/replace_source.rs | 5 +++-- src/source.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/replace_source.rs b/src/replace_source.rs index 7d5476f8..d4ae954e 100644 --- a/src/replace_source.rs +++ b/src/replace_source.rs @@ -547,8 +547,9 @@ impl Hash for ReplaceSource { self.sort_replacement(); "ReplaceSource".hash(state); for repl in self.replacements.lock().iter() { - repl.hash(state) + repl.hash(state); } + self.inner.hash(state); } } @@ -962,7 +963,7 @@ return
{data.foo}
assert_eq!(source.map(&MapOptions::default()), None); let mut hasher = twox_hash::XxHash64::default(); source.hash(&mut hasher); - assert_eq!(format!("{:x}", hasher.finish()), "ab891b4c45dc95b4"); + assert_eq!(format!("{:x}", hasher.finish()), "e9877250d7449bc5"); } #[test] diff --git a/src/source.rs b/src/source.rs index 28752ac2..c644fe62 100644 --- a/src/source.rs +++ b/src/source.rs @@ -532,7 +532,7 @@ mod tests { RawSource::from("g").boxed().hash(&mut state); (&RawSource::from("h") as &dyn Source).hash(&mut state); ReplaceSource::new(RawSource::from("i").boxed()).hash(&mut state); - assert_eq!(format!("{:x}", state.finish()), "940ec870b6ce313a"); + assert_eq!(format!("{:x}", state.finish()), "fb814b430ddd31e0"); } #[test]