Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | crates/span/Cargo.toml | 1 | ||||
| -rw-r--r-- | crates/span/src/ast_id.rs | 3 | ||||
| -rw-r--r-- | crates/span/src/hygiene.rs | 8 | ||||
| -rw-r--r-- | crates/span/src/lib.rs | 23 |
5 files changed, 6 insertions, 30 deletions
diff --git a/Cargo.lock b/Cargo.lock index fbaeff1eb5..42eaeb01f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2648,7 +2648,6 @@ dependencies = [ "la-arena 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 2.1.1", "salsa", - "serde", "stdx", "syntax", "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/crates/span/Cargo.toml b/crates/span/Cargo.toml index d331f63d0c..cfb319d688 100644 --- a/crates/span/Cargo.toml +++ b/crates/span/Cargo.toml @@ -21,7 +21,6 @@ text-size.workspace = true vfs.workspace = true syntax.workspace = true stdx.workspace = true -serde.workspace = true [dev-dependencies] syntax.workspace = true diff --git a/crates/span/src/ast_id.rs b/crates/span/src/ast_id.rs index 37954ca0b0..599b3c7175 100644 --- a/crates/span/src/ast_id.rs +++ b/crates/span/src/ast_id.rs @@ -29,7 +29,6 @@ use std::{ use la_arena::{Arena, Idx, RawIdx}; use rustc_hash::{FxBuildHasher, FxHashMap}; -use serde::{Deserialize, Serialize}; use syntax::{ AstNode, AstPtr, SyntaxKind, SyntaxNode, SyntaxNodePtr, ast::{self, HasName}, @@ -55,7 +54,7 @@ pub const NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER: ErasedFileAstId = ErasedFileAstId(pack_hash_index_and_kind(0, 0, ErasedFileAstIdKind::NoDownmap as u32)); /// This is a type erased FileAstId. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct ErasedFileAstId(u32); impl fmt::Debug for ErasedFileAstId { diff --git a/crates/span/src/hygiene.rs b/crates/span/src/hygiene.rs index 1a82f221c6..ea4f4c5efb 100644 --- a/crates/span/src/hygiene.rs +++ b/crates/span/src/hygiene.rs @@ -19,16 +19,12 @@ //! # The Call-site Hierarchy //! //! `ExpnData::call_site` in rustc, [`MacroCallLoc::call_site`] in rust-analyzer. -use std::fmt; - -#[cfg(feature = "salsa")] -use serde::{Deserialize, Serialize}; - use crate::Edition; +use std::fmt; /// A syntax context describes a hierarchy tracking order of macro definitions. #[cfg(feature = "salsa")] -#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)] +#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] pub struct SyntaxContext( /// # Invariant /// diff --git a/crates/span/src/lib.rs b/crates/span/src/lib.rs index f6581de38c..bfe7b2620d 100644 --- a/crates/span/src/lib.rs +++ b/crates/span/src/lib.rs @@ -20,7 +20,6 @@ pub use self::{ map::{RealSpanMap, SpanMap}, }; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; pub use syntax::Edition; pub use text_size::{TextRange, TextSize}; pub use vfs::FileId; @@ -69,12 +68,11 @@ impl Span { /// Spans represent a region of code, used by the IDE to be able link macro inputs and outputs /// together. Positions in spans are relative to some [`SpanAnchor`] to make them more incremental /// friendly. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Span { /// The text range of this span, relative to the anchor. /// We need the anchor for incrementality, as storing absolute ranges will require /// recomputation on every change in a file at all times. - #[serde(serialize_with = "serialize_text_range", deserialize_with = "deserialize_text_range")] pub range: TextRange, /// The anchor this span is relative to. pub anchor: SpanAnchor, @@ -82,21 +80,6 @@ pub struct Span { pub ctx: SyntaxContext, } -fn serialize_text_range<S>(range: &TextRange, serializer: S) -> Result<S::Ok, S::Error> -where - S: Serializer, -{ - (u32::from(range.start()), u32::from(range.end())).serialize(serializer) -} - -fn deserialize_text_range<'de, D>(deserializer: D) -> Result<TextRange, D::Error> -where - D: Deserializer<'de>, -{ - let (start, end) = <(u32, u32)>::deserialize(deserializer)?; - Ok(TextRange::new(TextSize::from(start), TextSize::from(end))) -} - impl fmt::Debug for Span { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if f.alternate() { @@ -129,7 +112,7 @@ impl fmt::Display for Span { } } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct SpanAnchor { pub file_id: EditionedFileId, pub ast_id: ErasedFileAstId, @@ -143,7 +126,7 @@ impl fmt::Debug for SpanAnchor { /// A [`FileId`] and [`Edition`] bundled up together. /// The MSB is reserved for `HirFileId` encoding, more upper bits are used to then encode the edition. -#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct EditionedFileId(u32); impl fmt::Debug for EditionedFileId { |