Skip to content

Commit 1c2dbb2

Browse files
committed
clippy/rustfmt
1 parent f638720 commit 1c2dbb2

File tree

4 files changed

+64
-50
lines changed

4 files changed

+64
-50
lines changed

Cargo.lock

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

crates/language-server/src/backend.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use crate::handlers::request::{handle_goto_definition, handle_hover};
22

33
use crate::workspace::SyncableIngotFileContext;
44

5-
use futures_batch::ChunksTimeoutStreamExt;
65
use common::InputDb;
76
use fork_stream::StreamExt as _;
7+
use futures_batch::ChunksTimeoutStreamExt;
88
use fxhash::FxHashSet;
99

1010
use futures::StreamExt;
@@ -85,11 +85,13 @@ impl Backend {
8585
Box::pin(async move { matches!(change_type, lsp_types::FileChangeType::CREATED) })
8686
});
8787

88-
let mut did_delete_watch_file_stream =
89-
flat_did_change_watched_files.clone().filter(|change| {
88+
let mut did_delete_watch_file_stream = flat_did_change_watched_files
89+
.clone()
90+
.filter(|change| {
9091
let change_type = change.typ;
9192
Box::pin(async move { matches!(change_type, lsp_types::FileChangeType::DELETED) })
92-
}).fuse();
93+
})
94+
.fuse();
9395

9496
let did_open_stream = messaging.did_open_stream.fuse();
9597
let did_change_stream = messaging.did_change_stream.fuse();
@@ -134,14 +136,15 @@ impl Backend {
134136

135137
let (tx_needs_diagnostics, rx_needs_diagnostics) = tokio::sync::mpsc::unbounded_channel();
136138

137-
let mut diagnostics_stream =
138-
UnboundedReceiverStream::from(rx_needs_diagnostics)
139+
let mut diagnostics_stream = UnboundedReceiverStream::from(rx_needs_diagnostics)
139140
.chunks_timeout(100, std::time::Duration::from_millis(100))
140141
.map(|changed_paths| {
141-
changed_paths.iter().fold(FxHashSet::default(), |mut acc, path: &String| {
142-
acc.insert(path.clone());
143-
acc
144-
})
142+
changed_paths
143+
.iter()
144+
.fold(FxHashSet::default(), |mut acc, path: &String| {
145+
acc.insert(path.clone());
146+
acc
147+
})
145148
})
146149
.fuse();
147150

@@ -216,13 +219,13 @@ impl Backend {
216219
info!("ingots need diagnostics: {:?}", ingots_need_diagnostics);
217220
for ingot in ingots_need_diagnostics.into_iter() {
218221
for file in ingot.files(db.as_input_db()) {
219-
let file = file.clone();
222+
let file = *file;
220223
let path = file.path(db.as_input_db());
221224
let path = lsp_types::Url::from_file_path(path).unwrap();
222225
let db = db.snapshot();
223226
let client = client.clone();
224227
let workspace = workspace.clone();
225-
let _ = self.workers.spawn(
228+
self.workers.spawn(
226229
async move { handle_diagnostics(client.clone(), workspace.clone(), db, path).await }
227230
);
228231
}

crates/language-server/src/stream_buffer_until.rs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use futures::stream::Stream;
22
use futures::stream::{iter, Iter};
3-
use log::info;
43
use std::{
54
collections::VecDeque,
65
fmt::Debug,
76
pin::{pin, Pin},
87
task::{Context, Poll},
98
};
9+
use tokio_stream::wrappers::IntervalStream;
1010

1111
use pin_project::pin_project;
1212

@@ -33,22 +33,6 @@ where
3333
ready_buffer: VecDeque::new(),
3434
}
3535
}
36-
37-
// pub fn input_stream_mut(&mut self) -> &mut I {
38-
// &mut self.input_stream
39-
// }
40-
41-
// pub fn input_stream(&self) -> &I {
42-
// &self.input_stream
43-
// }
44-
45-
// pub fn trigger_stream_mut(&mut self) -> &mut T {
46-
// &mut self.trigger_stream
47-
// }
48-
49-
// pub fn trigger_stream(&self) -> &T {
50-
// &self.trigger_stream
51-
// }
5236
}
5337
impl<I, T, U: Debug> Stream for BufferUntilStream<I, T, U>
5438
where
@@ -66,18 +50,18 @@ where
6650

6751
// Check if the input_stream has a new value
6852
while let Poll::Ready(Some(item)) = this.input_stream.as_mut().poll_next(cx) {
69-
info!("Received item from input_stream: {:?}", item);
53+
// info!("Received item from input_stream: {:?}", item);
7054
pending_buffer.push_back(item);
7155
}
7256

7357
if let Poll::Ready(None) = this.input_stream.as_mut().poll_next(cx) {
74-
info!("input_stream finished");
58+
// info!("input_stream finished");
7559
finished = true;
7660
}
7761

7862
match this.trigger_stream.as_mut().poll_next(cx) {
7963
Poll::Ready(Some(_)) => {
80-
info!("Triggered, moving pending_buffer to ready_buffer");
64+
// info!("Triggered, moving pending_buffer to ready_buffer");
8165
ready_buffer.append(pending_buffer);
8266
}
8367
Poll::Ready(None) => {
@@ -90,7 +74,7 @@ where
9074

9175
// Send any ready buffer or finish up
9276
if !ready_buffer.is_empty() {
93-
info!("Returning items stream from ready_buffer");
77+
// info!("Returning items stream from ready_buffer");
9478
let current_ready_buffer = std::mem::take(this.ready_buffer);
9579
Poll::Ready(Some(iter(current_ready_buffer)))
9680
} else if finished {
@@ -101,20 +85,35 @@ where
10185
}
10286
}
10387

104-
pub trait BufferUntilStreamExt<I, T, U: Debug>: Sized
88+
pub trait BufferUntilStreamExt<S>: Sized
10589
where
106-
I: Stream<Item = U>,
107-
T: Stream,
90+
S: Stream,
10891
{
109-
fn buffer_until(self, trigger: T) -> BufferUntilStream<I, T, U>;
92+
fn buffer_until<T>(self, trigger: T) -> BufferUntilStream<S, T, S::Item>
93+
where
94+
T: Stream;
95+
fn debounce_buffer_until(
96+
self,
97+
duration: std::time::Duration,
98+
) -> BufferUntilStream<S, IntervalStream, S::Item>;
11099
}
111100

112-
impl<I, T, U: Debug> BufferUntilStreamExt<I, T, U> for I
101+
impl<S> BufferUntilStreamExt<S> for S
113102
where
114-
I: Stream<Item = U>,
115-
T: Stream,
103+
S: Stream,
116104
{
117-
fn buffer_until(self, trigger: T) -> BufferUntilStream<I, T, U> {
105+
fn buffer_until<T>(self, trigger: T) -> BufferUntilStream<S, T, S::Item>
106+
where
107+
T: Stream,
108+
{
109+
BufferUntilStream::new(self, trigger)
110+
}
111+
112+
fn debounce_buffer_until(
113+
self,
114+
duration: std::time::Duration,
115+
) -> BufferUntilStream<S, IntervalStream, S::Item> {
116+
let trigger = IntervalStream::new(tokio::time::interval(duration));
118117
BufferUntilStream::new(self, trigger)
119118
}
120119
}

crates/language-server/src/workspace.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use std::{borrow::Cow, collections::BTreeSet, path::PathBuf};
1+
use std::{
2+
borrow::Cow,
3+
collections::BTreeSet,
4+
path::{Path, PathBuf},
5+
};
26

37
use anyhow::Result;
48
use common::{
@@ -272,11 +276,10 @@ impl Workspace {
272276
pub fn load_std_lib(
273277
&mut self,
274278
db: &mut LanguageServerDatabase,
275-
root_path: &PathBuf,
279+
root_path: &Path,
276280
) -> Result<()> {
277281
let root_path = root_path.to_str().unwrap();
278-
self
279-
.touch_ingot_for_file_path(db, &format!("{}/std/fe.toml", root_path))
282+
self.touch_ingot_for_file_path(db, &format!("{}/std/fe.toml", root_path))
280283
.unwrap();
281284

282285
info!("Loading std lib...");
@@ -288,10 +291,7 @@ impl Workspace {
288291
if let Some(file) = StdLib::get(path) {
289292
let contents = String::from_utf8(file.data.as_ref().to_vec());
290293
if let Ok(contents) = contents {
291-
let input = self.touch_input_for_file_path(
292-
db,
293-
&std_path,
294-
);
294+
let input = self.touch_input_for_file_path(db, &std_path);
295295
input.unwrap().set_text(db).to(contents);
296296
};
297297
};
@@ -302,7 +302,7 @@ impl Workspace {
302302
pub fn set_workspace_root(
303303
&mut self,
304304
db: &mut LanguageServerDatabase,
305-
root_path: &PathBuf,
305+
root_path: &Path,
306306
) -> Result<()> {
307307
let path = root_path;
308308
self.root_path = Some(path.to_path_buf());

0 commit comments

Comments
 (0)