mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Merge #138
138: Fix some clippy lints r=matklad a=alanhdu
I went ahead and fixed all the clippy lints (there were a couple I thought would be better unfixed and added `cfg` statements to allow them) and also re-enabled clippy and rustfmt in CI.
They were disabled with `no time to explain, disable clippy checks`, so hopefully this won't go against whatever the reason at the time was 😆.
One question about the CI though: right now, it's an allowed failure that runs against the latest nightly each time. Would it be better to pin it to a specific nightly (or use the `beta` versions) to lower the churn?
Co-authored-by: Alan Du <alanhdu@gmail.com>
This commit is contained in:
commit
27694abd94
26 changed files with 67 additions and 68 deletions
|
@ -65,7 +65,7 @@ impl ConvWith for TextUnit {
|
|||
fn conv_with(self, line_index: &LineIndex) -> Position {
|
||||
let line_col = line_index.line_col(self);
|
||||
// TODO: UTF-16
|
||||
Position::new(line_col.line as u64, u32::from(line_col.col) as u64)
|
||||
Position::new(u64::from(line_col.line), u64::from(u32::from(line_col.col)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ impl TryConvWith for SourceChange {
|
|||
.map(|it| it.edits.as_slice())
|
||||
.unwrap_or(&[]);
|
||||
let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits);
|
||||
let position = Position::new(line_col.line as u64, u32::from(line_col.col) as u64);
|
||||
let position = Position::new(u64::from(line_col.line), u64::from(u32::from(line_col.col)));
|
||||
Some(TextDocumentPositionParams {
|
||||
text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?),
|
||||
position,
|
||||
|
|
|
@ -18,7 +18,7 @@ fn main() -> Result<()> {
|
|||
.directory("log")
|
||||
.start()?;
|
||||
info!("lifecycle: server started");
|
||||
match ::std::panic::catch_unwind(|| main_inner()) {
|
||||
match ::std::panic::catch_unwind(main_inner) {
|
||||
Ok(res) => {
|
||||
info!("lifecycle: terminating process with {:?}", res);
|
||||
res
|
||||
|
|
|
@ -154,8 +154,8 @@ pub fn handle_workspace_symbol(
|
|||
world: ServerWorld,
|
||||
params: req::WorkspaceSymbolParams,
|
||||
) -> Result<Option<Vec<SymbolInformation>>> {
|
||||
let all_symbols = params.query.contains("#");
|
||||
let libs = params.query.contains("*");
|
||||
let all_symbols = params.query.contains('#');
|
||||
let libs = params.query.contains('*');
|
||||
let query = {
|
||||
let query: String = params
|
||||
.query
|
||||
|
@ -279,8 +279,8 @@ pub fn handle_runnables(
|
|||
.filter_map(|ws| {
|
||||
let tgt = ws.target_by_root(path)?;
|
||||
Some((
|
||||
tgt.package(ws).name(ws).clone(),
|
||||
tgt.name(ws).clone(),
|
||||
tgt.package(ws).name(ws),
|
||||
tgt.name(ws),
|
||||
tgt.kind(ws),
|
||||
))
|
||||
})
|
||||
|
|
|
@ -173,7 +173,6 @@ pub fn workspace_loader() -> (Worker<PathBuf, Result<CargoWorkspace>>, ThreadWat
|
|||
1,
|
||||
|input_receiver, output_sender| {
|
||||
input_receiver
|
||||
.into_iter()
|
||||
.map(|path| CargoWorkspace::from_cargo_metadata(path.as_path()))
|
||||
.for_each(|it| output_sender.send(it))
|
||||
},
|
||||
|
|
|
@ -73,9 +73,7 @@ impl ServerWorldState {
|
|||
events
|
||||
.into_iter()
|
||||
.map(|event| {
|
||||
let text = match event.kind {
|
||||
FileEventKind::Add(text) => text,
|
||||
};
|
||||
let FileEventKind::Add(text) = event.kind;
|
||||
(event.path, text)
|
||||
})
|
||||
.map(|(path, text)| (pm.get_or_insert(path, Root::Lib), text))
|
||||
|
|
|
@ -17,8 +17,7 @@ impl<I, O> Worker<I, O> {
|
|||
I: Send + 'static,
|
||||
O: Send + 'static,
|
||||
{
|
||||
let ((inp, out), inp_r, out_s) = worker_chan(buf);
|
||||
let worker = Worker { inp, out };
|
||||
let (worker, inp_r, out_s) = worker_chan(buf);
|
||||
let watcher = ThreadWatcher::spawn(name, move || f(inp_r, out_s));
|
||||
(worker, watcher)
|
||||
}
|
||||
|
@ -67,11 +66,14 @@ impl ThreadWatcher {
|
|||
/// Sets up worker channels in a deadlock-avoind way.
|
||||
/// If one sets both input and output buffers to a fixed size,
|
||||
/// a worker might get stuck.
|
||||
fn worker_chan<I, O>(buf: usize) -> ((Sender<I>, Receiver<O>), Receiver<I>, Sender<O>) {
|
||||
fn worker_chan<I, O>(buf: usize) -> (Worker<I, O>, Receiver<I>, Sender<O>) {
|
||||
let (input_sender, input_receiver) = bounded::<I>(buf);
|
||||
let (output_sender, output_receiver) = unbounded::<O>();
|
||||
(
|
||||
(input_sender, output_receiver),
|
||||
Worker {
|
||||
inp: input_sender,
|
||||
out: output_receiver,
|
||||
},
|
||||
input_receiver,
|
||||
output_sender,
|
||||
)
|
||||
|
|
|
@ -24,7 +24,6 @@ pub fn roots_loader() -> (Worker<PathBuf, (PathBuf, Vec<FileEvent>)>, ThreadWatc
|
|||
128,
|
||||
|input_receiver, output_sender| {
|
||||
input_receiver
|
||||
.into_iter()
|
||||
.map(|path| {
|
||||
debug!("loading {} ...", path.as_path().display());
|
||||
let events = load_root(path.as_path());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue