(si: &SourceInfo, hasher: &mut blake3::Hasher)
| 620 | fn hash_substring(ss: &Substring, hasher: &mut blake3::Hasher) { |
| 621 | hasher.update(&[MSSTR]); |
| 622 | hasher.update(ss.str.as_bytes()); |
| 623 | hasher.update(&ss.start_pos.to_le_bytes()); |
| 624 | hasher.update(&ss.stop_pos.to_le_bytes()); |
| 625 | } |
| 626 | |
| 627 | /// Source location metadata attached to syntax nodes. |
| 628 | #[derive(Debug, PartialEq, Eq, Clone, Hash)] |
| 629 | pub enum SourceInfo { |
| 630 | /// Original source with leading whitespace, leading position, trailing whitespace, trailing position. |
| 631 | Original(Substring, Nat, Substring, Nat), |
| 632 | /// Synthetic source span with start position, stop position, and canonical flag. |
| 633 | Synthetic(Nat, Nat, bool), |
| 634 | /// No source information available. |
| 635 | None, |
| 636 | } |
| 637 | |
| 638 | fn hash_source_info(si: &SourceInfo, hasher: &mut blake3::Hasher) { |
| 639 | hasher.update(&[MSINFO]); |
| 640 | match si { |
| 641 | SourceInfo::Original(leading, leading_pos, trailing, trailing_pos) => { |
| 642 | hasher.update(&[0]); |
| 643 | hash_substring(leading, hasher); |
| 644 | hasher.update(&leading_pos.to_le_bytes()); |
| 645 | hash_substring(trailing, hasher); |
no test coverage detected