Skip to content

Commit 1c00a2a

Browse files
Veykrillnicola
authored andcommitted
Reformat
1 parent dad1224 commit 1c00a2a

File tree

5 files changed

+43
-63
lines changed

5 files changed

+43
-63
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ dependencies = [
883883
"syntax-bridge",
884884
"test-fixture",
885885
"test-utils",
886-
"text-size",
886+
"text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
887887
"thin-vec",
888888
"tracing",
889889
"triomphe",
@@ -1403,7 +1403,7 @@ version = "0.1.2"
14031403
dependencies = [
14041404
"nohash-hasher",
14051405
"oorandom",
1406-
"text-size",
1406+
"text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
14071407
]
14081408

14091409
[[package]]
@@ -1413,7 +1413,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
14131413
checksum = "3e27e0ed5a392a7f5ba0b3808a2afccff16c64933312c84b57618b49d1209bd2"
14141414
dependencies = [
14151415
"nohash-hasher",
1416-
"text-size",
1416+
"text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
14171417
]
14181418

14191419
[[package]]
@@ -2334,7 +2334,7 @@ dependencies = [
23342334
"hashbrown 0.14.5",
23352335
"memoffset",
23362336
"rustc-hash 1.1.0",
2337-
"text-size",
2337+
"text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
23382338
]
23392339

23402340
[[package]]
@@ -2666,6 +2666,15 @@ dependencies = [
26662666
"serde",
26672667
]
26682668

2669+
[[package]]
2670+
name = "serde_test"
2671+
version = "1.0.177"
2672+
source = "registry+https://github.com/rust-lang/crates.io-index"
2673+
checksum = "7f901ee573cab6b3060453d2d5f0bae4e6d628c23c0a962ff9b5f1d7c8d4f1ed"
2674+
dependencies = [
2675+
"serde",
2676+
]
2677+
26692678
[[package]]
26702679
name = "sharded-slab"
26712680
version = "0.1.7"
@@ -2721,7 +2730,7 @@ dependencies = [
27212730
"salsa",
27222731
"stdx",
27232732
"syntax",
2724-
"text-size",
2733+
"text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
27252734
"vfs",
27262735
]
27272736

@@ -2740,6 +2749,12 @@ version = "1.2.0"
27402749
source = "registry+https://github.com/rust-lang/crates.io-index"
27412750
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
27422751

2752+
[[package]]
2753+
name = "static_assertions"
2754+
version = "1.1.0"
2755+
source = "registry+https://github.com/rust-lang/crates.io-index"
2756+
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
2757+
27432758
[[package]]
27442759
name = "stdx"
27452760
version = "0.0.0"
@@ -2862,7 +2877,16 @@ dependencies = [
28622877
"profile",
28632878
"rustc-hash 2.1.1",
28642879
"stdx",
2865-
"text-size",
2880+
"text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2881+
]
2882+
2883+
[[package]]
2884+
name = "text-size"
2885+
version = "1.1.1"
2886+
dependencies = [
2887+
"serde",
2888+
"serde_test",
2889+
"static_assertions",
28662890
]
28672891

28682892
[[package]]
@@ -3147,7 +3171,7 @@ dependencies = [
31473171
"intern",
31483172
"ra-ap-rustc_lexer",
31493173
"stdx",
3150-
"text-size",
3174+
"text-size 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
31513175
]
31523176

31533177
[[package]]

src/tools/rust-analyzer/lib/text-size/src/range.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ impl TextRange {
8383
/// ```
8484
#[inline]
8585
pub const fn empty(offset: TextSize) -> TextRange {
86-
TextRange {
87-
start: offset,
88-
end: offset,
89-
}
86+
TextRange { start: offset, end: offset }
9087
}
9188

9289
/// Create a range up to the given end (`..end`).
@@ -105,10 +102,7 @@ impl TextRange {
105102
/// ```
106103
#[inline]
107104
pub const fn up_to(end: TextSize) -> TextRange {
108-
TextRange {
109-
start: TextSize::new(0),
110-
end,
111-
}
105+
TextRange { start: TextSize::new(0), end }
112106
}
113107
}
114108

@@ -130,9 +124,7 @@ impl TextRange {
130124
#[inline]
131125
pub const fn len(self) -> TextSize {
132126
// HACK for const fn: math on primitives only
133-
TextSize {
134-
raw: self.end().raw - self.start().raw,
135-
}
127+
TextSize { raw: self.end().raw - self.start().raw }
136128
}
137129

138130
/// Check if this range is empty.
@@ -418,17 +410,15 @@ impl Add<TextSize> for TextRange {
418410
type Output = TextRange;
419411
#[inline]
420412
fn add(self, offset: TextSize) -> TextRange {
421-
self.checked_add(offset)
422-
.expect("TextRange +offset overflowed")
413+
self.checked_add(offset).expect("TextRange +offset overflowed")
423414
}
424415
}
425416

426417
impl Sub<TextSize> for TextRange {
427418
type Output = TextRange;
428419
#[inline]
429420
fn sub(self, offset: TextSize) -> TextRange {
430-
self.checked_sub(offset)
431-
.expect("TextRange -offset overflowed")
421+
self.checked_sub(offset).expect("TextRange -offset overflowed")
432422
}
433423
}
434424

src/tools/rust-analyzer/lib/text-size/src/serde_impls.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ impl<'de> Deserialize<'de> for TextRange {
3838
{
3939
let (start, end) = Deserialize::deserialize(deserializer)?;
4040
if !(start <= end) {
41-
return Err(de::Error::custom(format!(
42-
"invalid range: {:?}..{:?}",
43-
start, end
44-
)));
41+
return Err(de::Error::custom(format!("invalid range: {:?}..{:?}", start, end)));
4542
}
4643
Ok(TextRange::new(start, end))
4744
}

src/tools/rust-analyzer/lib/text-size/src/size.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use {
55
fmt, iter,
66
num::TryFromIntError,
77
ops::{Add, AddAssign, Sub, SubAssign},
8-
u32,
98
},
109
};
1110

src/tools/rust-analyzer/lib/text-size/tests/serde.rs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,60 +20,30 @@ fn size_serialization() {
2020
fn range_serialization() {
2121
assert_tokens(
2222
&range(00..10),
23-
&[
24-
Token::Tuple { len: 2 },
25-
Token::U32(00),
26-
Token::U32(10),
27-
Token::TupleEnd,
28-
],
23+
&[Token::Tuple { len: 2 }, Token::U32(00), Token::U32(10), Token::TupleEnd],
2924
);
3025
assert_tokens(
3126
&range(10..20),
32-
&[
33-
Token::Tuple { len: 2 },
34-
Token::U32(10),
35-
Token::U32(20),
36-
Token::TupleEnd,
37-
],
27+
&[Token::Tuple { len: 2 }, Token::U32(10), Token::U32(20), Token::TupleEnd],
3828
);
3929
assert_tokens(
4030
&range(20..30),
41-
&[
42-
Token::Tuple { len: 2 },
43-
Token::U32(20),
44-
Token::U32(30),
45-
Token::TupleEnd,
46-
],
31+
&[Token::Tuple { len: 2 }, Token::U32(20), Token::U32(30), Token::TupleEnd],
4732
);
4833
assert_tokens(
4934
&range(30..40),
50-
&[
51-
Token::Tuple { len: 2 },
52-
Token::U32(30),
53-
Token::U32(40),
54-
Token::TupleEnd,
55-
],
35+
&[Token::Tuple { len: 2 }, Token::U32(30), Token::U32(40), Token::TupleEnd],
5636
);
5737
}
5838

5939
#[test]
6040
fn invalid_range_deserialization() {
6141
assert_tokens::<TextRange>(
6242
&range(62..92),
63-
&[
64-
Token::Tuple { len: 2 },
65-
Token::U32(62),
66-
Token::U32(92),
67-
Token::TupleEnd,
68-
],
43+
&[Token::Tuple { len: 2 }, Token::U32(62), Token::U32(92), Token::TupleEnd],
6944
);
7045
assert_de_tokens_error::<TextRange>(
71-
&[
72-
Token::Tuple { len: 2 },
73-
Token::U32(92),
74-
Token::U32(62),
75-
Token::TupleEnd,
76-
],
46+
&[Token::Tuple { len: 2 }, Token::U32(92), Token::U32(62), Token::TupleEnd],
7747
"invalid range: 92..62",
7848
);
7949
}

0 commit comments

Comments
 (0)