Unnamed repository; edit this file 'description' to name the repository.
Reformat
Lukas Wirth 5 months ago
parent 9295f8e · commit ae4b7f6
-rw-r--r--Cargo.lock38
-rw-r--r--lib/text-size/src/range.rs20
-rw-r--r--lib/text-size/src/serde_impls.rs5
-rw-r--r--lib/text-size/src/size.rs1
-rw-r--r--lib/text-size/tests/serde.rs42
5 files changed, 43 insertions, 63 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 643b0f7e1d..6f5db9e8fc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -883,7 +883,7 @@ dependencies = [
"syntax-bridge",
"test-fixture",
"test-utils",
- "text-size",
+ "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"thin-vec",
"tracing",
"triomphe",
@@ -1403,7 +1403,7 @@ version = "0.1.2"
dependencies = [
"nohash-hasher",
"oorandom",
- "text-size",
+ "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1413,7 +1413,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e27e0ed5a392a7f5ba0b3808a2afccff16c64933312c84b57618b49d1209bd2"
dependencies = [
"nohash-hasher",
- "text-size",
+ "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2334,7 +2334,7 @@ dependencies = [
"hashbrown 0.14.5",
"memoffset",
"rustc-hash 1.1.0",
- "text-size",
+ "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2667,6 +2667,15 @@ dependencies = [
]
[[package]]
+name = "serde_test"
+version = "1.0.177"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f901ee573cab6b3060453d2d5f0bae4e6d628c23c0a962ff9b5f1d7c8d4f1ed"
+dependencies = [
+ "serde",
+]
+
+[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2721,7 +2730,7 @@ dependencies = [
"salsa",
"stdx",
"syntax",
- "text-size",
+ "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"vfs",
]
@@ -2741,6 +2750,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
name = "stdx"
version = "0.0.0"
dependencies = [
@@ -2862,7 +2877,16 @@ dependencies = [
"profile",
"rustc-hash 2.1.1",
"stdx",
- "text-size",
+ "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "text-size"
+version = "1.1.1"
+dependencies = [
+ "serde",
+ "serde_test",
+ "static_assertions",
]
[[package]]
@@ -3147,7 +3171,7 @@ dependencies = [
"intern",
"ra-ap-rustc_lexer",
"stdx",
- "text-size",
+ "text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
diff --git a/lib/text-size/src/range.rs b/lib/text-size/src/range.rs
index 9b981642d1..6067115207 100644
--- a/lib/text-size/src/range.rs
+++ b/lib/text-size/src/range.rs
@@ -83,10 +83,7 @@ impl TextRange {
/// ```
#[inline]
pub const fn empty(offset: TextSize) -> TextRange {
- TextRange {
- start: offset,
- end: offset,
- }
+ TextRange { start: offset, end: offset }
}
/// Create a range up to the given end (`..end`).
@@ -105,10 +102,7 @@ impl TextRange {
/// ```
#[inline]
pub const fn up_to(end: TextSize) -> TextRange {
- TextRange {
- start: TextSize::new(0),
- end,
- }
+ TextRange { start: TextSize::new(0), end }
}
}
@@ -130,9 +124,7 @@ impl TextRange {
#[inline]
pub const fn len(self) -> TextSize {
// HACK for const fn: math on primitives only
- TextSize {
- raw: self.end().raw - self.start().raw,
- }
+ TextSize { raw: self.end().raw - self.start().raw }
}
/// Check if this range is empty.
@@ -418,8 +410,7 @@ impl Add<TextSize> for TextRange {
type Output = TextRange;
#[inline]
fn add(self, offset: TextSize) -> TextRange {
- self.checked_add(offset)
- .expect("TextRange +offset overflowed")
+ self.checked_add(offset).expect("TextRange +offset overflowed")
}
}
@@ -427,8 +418,7 @@ impl Sub<TextSize> for TextRange {
type Output = TextRange;
#[inline]
fn sub(self, offset: TextSize) -> TextRange {
- self.checked_sub(offset)
- .expect("TextRange -offset overflowed")
+ self.checked_sub(offset).expect("TextRange -offset overflowed")
}
}
diff --git a/lib/text-size/src/serde_impls.rs b/lib/text-size/src/serde_impls.rs
index a94bee9567..7f3f757510 100644
--- a/lib/text-size/src/serde_impls.rs
+++ b/lib/text-size/src/serde_impls.rs
@@ -38,10 +38,7 @@ impl<'de> Deserialize<'de> for TextRange {
{
let (start, end) = Deserialize::deserialize(deserializer)?;
if !(start <= end) {
- return Err(de::Error::custom(format!(
- "invalid range: {:?}..{:?}",
- start, end
- )));
+ return Err(de::Error::custom(format!("invalid range: {:?}..{:?}", start, end)));
}
Ok(TextRange::new(start, end))
}
diff --git a/lib/text-size/src/size.rs b/lib/text-size/src/size.rs
index c950d2edd0..05328b45ea 100644
--- a/lib/text-size/src/size.rs
+++ b/lib/text-size/src/size.rs
@@ -5,7 +5,6 @@ use {
fmt, iter,
num::TryFromIntError,
ops::{Add, AddAssign, Sub, SubAssign},
- u32,
},
};
diff --git a/lib/text-size/tests/serde.rs b/lib/text-size/tests/serde.rs
index 874258a35f..cc4d538958 100644
--- a/lib/text-size/tests/serde.rs
+++ b/lib/text-size/tests/serde.rs
@@ -20,39 +20,19 @@ fn size_serialization() {
fn range_serialization() {
assert_tokens(
&range(00..10),
- &[
- Token::Tuple { len: 2 },
- Token::U32(00),
- Token::U32(10),
- Token::TupleEnd,
- ],
+ &[Token::Tuple { len: 2 }, Token::U32(00), Token::U32(10), Token::TupleEnd],
);
assert_tokens(
&range(10..20),
- &[
- Token::Tuple { len: 2 },
- Token::U32(10),
- Token::U32(20),
- Token::TupleEnd,
- ],
+ &[Token::Tuple { len: 2 }, Token::U32(10), Token::U32(20), Token::TupleEnd],
);
assert_tokens(
&range(20..30),
- &[
- Token::Tuple { len: 2 },
- Token::U32(20),
- Token::U32(30),
- Token::TupleEnd,
- ],
+ &[Token::Tuple { len: 2 }, Token::U32(20), Token::U32(30), Token::TupleEnd],
);
assert_tokens(
&range(30..40),
- &[
- Token::Tuple { len: 2 },
- Token::U32(30),
- Token::U32(40),
- Token::TupleEnd,
- ],
+ &[Token::Tuple { len: 2 }, Token::U32(30), Token::U32(40), Token::TupleEnd],
);
}
@@ -60,20 +40,10 @@ fn range_serialization() {
fn invalid_range_deserialization() {
assert_tokens::<TextRange>(
&range(62..92),
- &[
- Token::Tuple { len: 2 },
- Token::U32(62),
- Token::U32(92),
- Token::TupleEnd,
- ],
+ &[Token::Tuple { len: 2 }, Token::U32(62), Token::U32(92), Token::TupleEnd],
);
assert_de_tokens_error::<TextRange>(
- &[
- Token::Tuple { len: 2 },
- Token::U32(92),
- Token::U32(62),
- Token::TupleEnd,
- ],
+ &[Token::Tuple { len: 2 }, Token::U32(92), Token::U32(62), Token::TupleEnd],
"invalid range: 92..62",
);
}