Skip to content

Commit 41f4245

Browse files
committed
remove serde from span
1 parent 49c15b2 commit 41f4245

5 files changed

Lines changed: 6 additions & 30 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/span/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ text-size.workspace = true
2121
vfs.workspace = true
2222
syntax.workspace = true
2323
stdx.workspace = true
24-
serde.workspace = true
2524

2625
[dev-dependencies]
2726
syntax.workspace = true

crates/span/src/ast_id.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use std::{
2929

3030
use la_arena::{Arena, Idx, RawIdx};
3131
use rustc_hash::{FxBuildHasher, FxHashMap};
32-
use serde::{Deserialize, Serialize};
3332
use syntax::{
3433
AstNode, AstPtr, SyntaxKind, SyntaxNode, SyntaxNodePtr,
3534
ast::{self, HasName},
@@ -55,7 +54,7 @@ pub const NO_DOWNMAP_ERASED_FILE_AST_ID_MARKER: ErasedFileAstId =
5554
ErasedFileAstId(pack_hash_index_and_kind(0, 0, ErasedFileAstIdKind::NoDownmap as u32));
5655

5756
/// This is a type erased FileAstId.
58-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
57+
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
5958
pub struct ErasedFileAstId(u32);
6059

6160
impl fmt::Debug for ErasedFileAstId {

crates/span/src/hygiene.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@
1919
//! # The Call-site Hierarchy
2020
//!
2121
//! `ExpnData::call_site` in rustc, [`MacroCallLoc::call_site`] in rust-analyzer.
22-
use std::fmt;
23-
24-
#[cfg(feature = "salsa")]
25-
use serde::{Deserialize, Serialize};
26-
2722
use crate::Edition;
23+
use std::fmt;
2824

2925
/// A syntax context describes a hierarchy tracking order of macro definitions.
3026
#[cfg(feature = "salsa")]
31-
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
27+
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
3228
pub struct SyntaxContext(
3329
/// # Invariant
3430
///

crates/span/src/lib.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub use self::{
2020
map::{RealSpanMap, SpanMap},
2121
};
2222

23-
use serde::{Deserialize, Deserializer, Serialize, Serializer};
2423
pub use syntax::Edition;
2524
pub use text_size::{TextRange, TextSize};
2625
pub use vfs::FileId;
@@ -69,34 +68,18 @@ impl Span {
6968
/// Spans represent a region of code, used by the IDE to be able link macro inputs and outputs
7069
/// together. Positions in spans are relative to some [`SpanAnchor`] to make them more incremental
7170
/// friendly.
72-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
71+
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
7372
pub struct Span {
7473
/// The text range of this span, relative to the anchor.
7574
/// We need the anchor for incrementality, as storing absolute ranges will require
7675
/// recomputation on every change in a file at all times.
77-
#[serde(serialize_with = "serialize_text_range", deserialize_with = "deserialize_text_range")]
7876
pub range: TextRange,
7977
/// The anchor this span is relative to.
8078
pub anchor: SpanAnchor,
8179
/// The syntax context of the span.
8280
pub ctx: SyntaxContext,
8381
}
8482

85-
fn serialize_text_range<S>(range: &TextRange, serializer: S) -> Result<S::Ok, S::Error>
86-
where
87-
S: Serializer,
88-
{
89-
(u32::from(range.start()), u32::from(range.end())).serialize(serializer)
90-
}
91-
92-
fn deserialize_text_range<'de, D>(deserializer: D) -> Result<TextRange, D::Error>
93-
where
94-
D: Deserializer<'de>,
95-
{
96-
let (start, end) = <(u32, u32)>::deserialize(deserializer)?;
97-
Ok(TextRange::new(TextSize::from(start), TextSize::from(end)))
98-
}
99-
10083
impl fmt::Debug for Span {
10184
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10285
if f.alternate() {
@@ -129,7 +112,7 @@ impl fmt::Display for Span {
129112
}
130113
}
131114

132-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
115+
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
133116
pub struct SpanAnchor {
134117
pub file_id: EditionedFileId,
135118
pub ast_id: ErasedFileAstId,
@@ -143,7 +126,7 @@ impl fmt::Debug for SpanAnchor {
143126

144127
/// A [`FileId`] and [`Edition`] bundled up together.
145128
/// The MSB is reserved for `HirFileId` encoding, more upper bits are used to then encode the edition.
146-
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
129+
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
147130
pub struct EditionedFileId(u32);
148131

149132
impl fmt::Debug for EditionedFileId {

0 commit comments

Comments
 (0)