Skip to content

Commit 12e3b4c

Browse files
committed
reformat the world
1 parent 5cb1d41 commit 12e3b4c

File tree

129 files changed

+728
-2510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+728
-2510
lines changed

crates/gen_lsp_server/src/msg.rs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ impl RawMessage {
8080
#[serde(flatten)]
8181
msg: RawMessage,
8282
}
83-
let text = to_string(&JsonRpc {
84-
jsonrpc: "2.0",
85-
msg: self,
86-
})?;
83+
let text = to_string(&JsonRpc { jsonrpc: "2.0", msg: self })?;
8784
write_msg_text(w, &text)?;
8885
Ok(())
8986
}
@@ -95,11 +92,7 @@ impl RawRequest {
9592
R: Request,
9693
R::Params: serde::Serialize,
9794
{
98-
RawRequest {
99-
id,
100-
method: R::METHOD.to_string(),
101-
params: to_value(params).unwrap(),
102-
}
95+
RawRequest { id, method: R::METHOD.to_string(), params: to_value(params).unwrap() }
10396
}
10497
pub fn cast<R>(self) -> ::std::result::Result<(u64, R::Params), RawRequest>
10598
where
@@ -121,23 +114,11 @@ impl RawResponse {
121114
R: Request,
122115
R::Result: serde::Serialize,
123116
{
124-
RawResponse {
125-
id,
126-
result: Some(to_value(&result).unwrap()),
127-
error: None,
128-
}
117+
RawResponse { id, result: Some(to_value(&result).unwrap()), error: None }
129118
}
130119
pub fn err(id: u64, code: i32, message: String) -> RawResponse {
131-
let error = RawResponseError {
132-
code,
133-
message,
134-
data: None,
135-
};
136-
RawResponse {
137-
id,
138-
result: None,
139-
error: Some(error),
140-
}
120+
let error = RawResponseError { code, message, data: None };
121+
RawResponse { id, result: None, error: Some(error) }
141122
}
142123
}
143124

@@ -147,10 +128,7 @@ impl RawNotification {
147128
N: Notification,
148129
N::Params: serde::Serialize,
149130
{
150-
RawNotification {
151-
method: N::METHOD.to_string(),
152-
params: to_value(params).unwrap(),
153-
}
131+
RawNotification { method: N::METHOD.to_string(), params: to_value(params).unwrap() }
154132
}
155133
pub fn is<N>(&self) -> bool
156134
where
@@ -187,9 +165,8 @@ fn read_msg_text(inp: &mut impl BufRead) -> Result<Option<String>> {
187165
}
188166
let mut parts = buf.splitn(2, ": ");
189167
let header_name = parts.next().unwrap();
190-
let header_value = parts
191-
.next()
192-
.ok_or_else(|| format_err!("malformed header: {:?}", buf))?;
168+
let header_value =
169+
parts.next().ok_or_else(|| format_err!("malformed header: {:?}", buf))?;
193170
if header_name == "Content-Length" {
194171
size = Some(header_value.parse::<usize>()?);
195172
}

crates/gen_lsp_server/src/stdio.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads)
1313
let writer = thread::spawn(move || {
1414
let stdout = stdout();
1515
let mut stdout = stdout.lock();
16-
writer_receiver
17-
.into_iter()
18-
.try_for_each(|it| it.write(&mut stdout))?;
16+
writer_receiver.into_iter().try_for_each(|it| it.write(&mut stdout))?;
1917
Ok(())
2018
});
2119
let (reader_sender, reader_receiver) = bounded::<RawMessage>(16);

crates/ra_arena/src/lib.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ pub struct Arena<ID: ArenaId, T> {
4444

4545
impl<ID: ArenaId, T: fmt::Debug> fmt::Debug for Arena<ID, T> {
4646
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
47-
fmt.debug_struct("Arena")
48-
.field("len", &self.len())
49-
.field("data", &self.data)
50-
.finish()
47+
fmt.debug_struct("Arena").field("len", &self.len()).field("data", &self.data).finish()
5148
}
5249
}
5350

@@ -80,19 +77,13 @@ impl<ID: ArenaId, T> Arena<ID, T> {
8077
ID::from_raw(id)
8178
}
8279
pub fn iter<'a>(&'a self) -> impl Iterator<Item = (ID, &'a T)> {
83-
self.data
84-
.iter()
85-
.enumerate()
86-
.map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value))
80+
self.data.iter().enumerate().map(|(idx, value)| (ID::from_raw(RawId(idx as u32)), value))
8781
}
8882
}
8983

9084
impl<ID: ArenaId, T> Default for Arena<ID, T> {
9185
fn default() -> Arena<ID, T> {
92-
Arena {
93-
data: Vec::new(),
94-
_ty: PhantomData,
95-
}
86+
Arena { data: Vec::new(), _ty: PhantomData }
9687
}
9788
}
9889

@@ -116,9 +107,6 @@ impl<ID: ArenaId, T> FromIterator<T> for Arena<ID, T> {
116107
where
117108
I: IntoIterator<Item = T>,
118109
{
119-
Arena {
120-
data: Vec::from_iter(iter),
121-
_ty: PhantomData,
122-
}
110+
Arena { data: Vec::from_iter(iter), _ty: PhantomData }
123111
}
124112
}

crates/ra_arena/src/map.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ impl<ID: ArenaId, T> ArenaMap<ID, T> {
4242
}
4343

4444
pub fn iter(&self) -> impl Iterator<Item = (ID, &T)> {
45-
self.v
46-
.iter()
47-
.enumerate()
48-
.filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?)))
45+
self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?)))
4946
}
5047

5148
fn to_idx(id: ID) -> usize {
@@ -66,9 +63,6 @@ impl<ID: ArenaId, T> std::ops::Index<ID> for ArenaMap<ID, T> {
6663

6764
impl<ID, T> Default for ArenaMap<ID, T> {
6865
fn default() -> Self {
69-
ArenaMap {
70-
v: Vec::new(),
71-
_ty: PhantomData,
72-
}
66+
ArenaMap { v: Vec::new(), _ty: PhantomData }
7367
}
7468
}

crates/ra_assists/src/add_derive.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ pub(crate) fn add_derive(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
3030

3131
// Insert `derive` after doc comments.
3232
fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextUnit> {
33-
let non_ws_child = nominal
34-
.syntax()
35-
.children()
36-
.find(|it| it.kind() != COMMENT && it.kind() != WHITESPACE)?;
33+
let non_ws_child =
34+
nominal.syntax().children().find(|it| it.kind() != COMMENT && it.kind() != WHITESPACE)?;
3735
Some(non_ws_child.range().start())
3836
}
3937

crates/ra_assists/src/add_impl.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ pub(crate) fn add_impl(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
2121
buf.push_str(" ");
2222
buf.push_str(name.text().as_str());
2323
if let Some(type_params) = type_params {
24-
let lifetime_params = type_params
25-
.lifetime_params()
26-
.filter_map(|it| it.lifetime())
27-
.map(|it| it.text());
28-
let type_params = type_params
29-
.type_params()
30-
.filter_map(|it| it.name())
31-
.map(|it| it.text());
32-
join(lifetime_params.chain(type_params))
33-
.surround_with("<", ">")
34-
.to_buf(&mut buf);
24+
let lifetime_params =
25+
type_params.lifetime_params().filter_map(|it| it.lifetime()).map(|it| it.text());
26+
let type_params =
27+
type_params.type_params().filter_map(|it| it.name()).map(|it| it.text());
28+
join(lifetime_params.chain(type_params)).surround_with("<", ">").to_buf(&mut buf);
3529
}
3630
buf.push_str(" {\n");
3731
edit.set_cursor(start_offset + TextUnit::of_str(&buf));
@@ -47,11 +41,7 @@ mod tests {
4741

4842
#[test]
4943
fn test_add_impl() {
50-
check_assist(
51-
add_impl,
52-
"struct Foo {<|>}\n",
53-
"struct Foo {}\n\nimpl Foo {\n<|>\n}\n",
54-
);
44+
check_assist(add_impl, "struct Foo {<|>}\n", "struct Foo {}\n\nimpl Foo {\n<|>\n}\n");
5545
check_assist(
5646
add_impl,
5747
"struct Foo<T: Clone> {<|>}",

crates/ra_assists/src/assist_ctx.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,7 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
6969
F: FnOnce(AssistCtx<DB>) -> T,
7070
{
7171
let source_file = &db.parse(frange.file_id);
72-
let ctx = AssistCtx {
73-
db,
74-
frange,
75-
source_file,
76-
should_compute_edit,
77-
};
72+
let ctx = AssistCtx { db, frange, source_file, should_compute_edit };
7873
f(ctx)
7974
}
8075

@@ -83,9 +78,7 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
8378
label: impl Into<String>,
8479
f: impl FnOnce(&mut AssistBuilder),
8580
) -> Option<Assist> {
86-
let label = AssistLabel {
87-
label: label.into(),
88-
};
81+
let label = AssistLabel { label: label.into() };
8982
if !self.should_compute_edit {
9083
return Some(Assist::Unresolved(label));
9184
}
@@ -146,9 +139,6 @@ impl AssistBuilder {
146139
}
147140

148141
fn build(self) -> AssistAction {
149-
AssistAction {
150-
edit: self.edit.finish(),
151-
cursor_position: self.cursor_position,
152-
}
142+
AssistAction { edit: self.edit.finish(), cursor_position: self.cursor_position }
153143
}
154144
}

crates/ra_assists/src/change_visibility.rs

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,11 @@ mod tests {
8181

8282
#[test]
8383
fn change_visibility_adds_pub_crate_to_items() {
84-
check_assist(
85-
change_visibility,
86-
"<|>fn foo() {}",
87-
"<|>pub(crate) fn foo() {}",
88-
);
89-
check_assist(
90-
change_visibility,
91-
"f<|>n foo() {}",
92-
"<|>pub(crate) fn foo() {}",
93-
);
94-
check_assist(
95-
change_visibility,
96-
"<|>struct Foo {}",
97-
"<|>pub(crate) struct Foo {}",
98-
);
99-
check_assist(
100-
change_visibility,
101-
"<|>mod foo {}",
102-
"<|>pub(crate) mod foo {}",
103-
);
104-
check_assist(
105-
change_visibility,
106-
"<|>trait Foo {}",
107-
"<|>pub(crate) trait Foo {}",
108-
);
84+
check_assist(change_visibility, "<|>fn foo() {}", "<|>pub(crate) fn foo() {}");
85+
check_assist(change_visibility, "f<|>n foo() {}", "<|>pub(crate) fn foo() {}");
86+
check_assist(change_visibility, "<|>struct Foo {}", "<|>pub(crate) struct Foo {}");
87+
check_assist(change_visibility, "<|>mod foo {}", "<|>pub(crate) mod foo {}");
88+
check_assist(change_visibility, "<|>trait Foo {}", "<|>pub(crate) trait Foo {}");
10989
check_assist(change_visibility, "m<|>od {}", "<|>pub(crate) mod {}");
11090
check_assist(
11191
change_visibility,
@@ -125,20 +105,12 @@ mod tests {
125105

126106
#[test]
127107
fn change_visibility_pub_to_pub_crate() {
128-
check_assist(
129-
change_visibility,
130-
"<|>pub fn foo() {}",
131-
"<|>pub(crate) fn foo() {}",
132-
)
108+
check_assist(change_visibility, "<|>pub fn foo() {}", "<|>pub(crate) fn foo() {}")
133109
}
134110

135111
#[test]
136112
fn change_visibility_pub_crate_to_pub() {
137-
check_assist(
138-
change_visibility,
139-
"<|>pub(crate) fn foo() {}",
140-
"<|>pub fn foo() {}",
141-
)
113+
check_assist(change_visibility, "<|>pub(crate) fn foo() {}", "<|>pub fn foo() {}")
142114
}
143115

144116
#[test]

crates/ra_assists/src/fill_match_arms.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
2727
let node_expr = syntax_mapping.node_expr(expr)?;
2828
let match_expr_ty = infer_result[node_expr].clone();
2929
let enum_def = match match_expr_ty {
30-
Ty::Adt {
31-
def_id: AdtDef::Enum(e),
32-
..
33-
} => e,
30+
Ty::Adt { def_id: AdtDef::Enum(e), .. } => e,
3431
_ => return None,
3532
};
3633
let enum_name = enum_def.name(ctx.db)?;

crates/ra_assists/src/introduce_variable.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ fn anchor_stmt(expr: &ast::Expr) -> Option<(&SyntaxNode, bool)> {
8181
return Some((node, false));
8282
}
8383

84-
if let Some(expr) = node
85-
.parent()
86-
.and_then(ast::Block::cast)
87-
.and_then(|it| it.expr())
88-
{
84+
if let Some(expr) = node.parent().and_then(ast::Block::cast).and_then(|it| it.expr()) {
8985
if expr.syntax() == node {
9086
return Some((node, false));
9187
}

0 commit comments

Comments
 (0)