Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-api/src/msg/flat.rs')
-rw-r--r--crates/proc-macro-api/src/msg/flat.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/proc-macro-api/src/msg/flat.rs b/crates/proc-macro-api/src/msg/flat.rs
index fe82b8d045..bfb3213a25 100644
--- a/crates/proc-macro-api/src/msg/flat.rs
+++ b/crates/proc-macro-api/src/msg/flat.rs
@@ -38,6 +38,7 @@
use std::collections::{HashMap, VecDeque};
use serde::{Deserialize, Serialize};
+use text_size::TextRange;
use tt::Span;
use crate::msg::{ENCODE_CLOSE_SPAN_VERSION, VARIABLE_SIZED_SPANS};
@@ -55,6 +56,19 @@ impl SerializableSpan<1> for tt::TokenId {
}
}
+impl<FileId> SerializableSpan<3> for tt::SpanData<FileId>
+where
+ FileId: From<u32> + Into<u32>,
+ Self: Span,
+{
+ fn into_u32(self) -> [u32; 3] {
+ [self.anchor.into(), self.range.start().into(), self.range.end().into()]
+ }
+ fn from_u32([file_id, start, end]: [u32; 3]) -> Self {
+ tt::SpanData { anchor: file_id.into(), range: TextRange::new(start.into(), end.into()) }
+ }
+}
+
#[derive(Serialize, Deserialize, Debug)]
pub struct FlatTree {
subtree: Vec<u32>,