Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit d234212

Browse files
committed
Use () type instead of NoParams
1 parent 09630fd commit d234212

File tree

6 files changed

+20
-33
lines changed

6 files changed

+20
-33
lines changed

src/actions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use actions::post_build::{BuildResults, PostBuildHandler};
2323
use actions::notifications::BeginBuild;
2424
use build::*;
2525
use lsp_data::*;
26-
use server::{Output, Notification, NoParams};
26+
use server::{Output, Notification};
2727

2828
use std::collections::HashMap;
2929
use std::path::{Path, PathBuf};
@@ -195,7 +195,7 @@ impl InitActionContext {
195195
}
196196
};
197197

198-
out.notify(Notification::<BeginBuild>::new(NoParams {}));
198+
out.notify(Notification::<BeginBuild>::new(()));
199199
self.build_queue
200200
.request_build(project_path, priority, move |result| pbh.handle(result));
201201
}

src/actions/notifications.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use Span;
2121

2222
use build::*;
2323
use lsp_data::*;
24-
use server::{Action, BlockingNotificationAction, LsState, NoParams, Output};
24+
use server::{Action, BlockingNotificationAction, LsState, Output};
2525

2626
use std::thread;
2727

@@ -30,7 +30,7 @@ use std::thread;
3030
pub struct Initialized;
3131

3232
impl Action for Initialized {
33-
type Params = NoParams;
33+
type Params = ();
3434
const METHOD: &'static str = "initialized";
3535
}
3636

@@ -395,7 +395,7 @@ impl Action for ShowMessage {
395395
pub struct DiagnosticsBegin;
396396

397397
impl Action for DiagnosticsBegin {
398-
type Params = NoParams;
398+
type Params = ();
399399
const METHOD: &'static str = "rustDocument/diagnosticsBegin";
400400
}
401401

@@ -408,7 +408,7 @@ impl Action for DiagnosticsBegin {
408408
pub struct DiagnosticsEnd;
409409

410410
impl Action for DiagnosticsEnd {
411-
type Params = NoParams;
411+
type Params = ();
412412
const METHOD: &'static str = "rustDocument/diagnosticsEnd";
413413
}
414414

@@ -417,6 +417,6 @@ impl Action for DiagnosticsEnd {
417417
pub struct BeginBuild;
418418

419419
impl Action for BeginBuild {
420-
type Params = NoParams;
420+
type Params = ();
421421
const METHOD: &'static str = "rustDocument/beginBuild";
422422
}

src/actions/post_build.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::thread;
1616
use build::BuildResult;
1717
use lsp_data::{ls_util, PublishDiagnosticsParams};
1818
use actions::notifications::{DiagnosticsBegin, DiagnosticsEnd, PublishDiagnostics};
19-
use server::{Notification, Output, NoParams};
19+
use server::{Notification, Output};
2020
use CRATE_BLACKLIST;
2121
use Span;
2222

@@ -41,7 +41,7 @@ pub struct PostBuildHandler<O: Output> {
4141

4242
impl<O: Output> PostBuildHandler<O> {
4343
pub fn handle(self, result: BuildResult) {
44-
self.out.notify(Notification::<DiagnosticsBegin>::new(NoParams {}));
44+
self.out.notify(Notification::<DiagnosticsBegin>::new(()));
4545

4646
match result {
4747
BuildResult::Success(messages, new_analysis)
@@ -60,16 +60,16 @@ impl<O: Output> PostBuildHandler<O> {
6060
self.reload_analysis_from_memory(new_analysis);
6161
}
6262

63-
self.out.notify(Notification::<DiagnosticsEnd>::new(NoParams{}));
63+
self.out.notify(Notification::<DiagnosticsEnd>::new(()));
6464
});
6565
}
6666
BuildResult::Squashed => {
6767
trace!("build - Squashed");
68-
self.out.notify(Notification::<DiagnosticsEnd>::new(NoParams{}));
68+
self.out.notify(Notification::<DiagnosticsEnd>::new(()));
6969
}
7070
BuildResult::Err => {
7171
trace!("build - Error");
72-
self.out.notify(Notification::<DiagnosticsEnd>::new(NoParams{}));
72+
self.out.notify(Notification::<DiagnosticsEnd>::new(()));
7373
}
7474
}
7575
}

src/cmd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use actions::requests;
1616
use analysis::{AnalysisHost, Target};
1717
use config::Config;
18-
use server::{self, LsService, NoParams, Notification, Request};
18+
use server::{self, LsService, Notification, Request};
1919
use vfs::Vfs;
2020

2121
use ls_types::{ClientCapabilities, DocumentFormattingParams, DocumentRangeFormattingParams,
@@ -283,15 +283,15 @@ fn range_format(
283283
fn shutdown<'a>() -> Request<server::ShutdownRequest<'a>> {
284284
Request {
285285
id: next_id(),
286-
params: NoParams {},
286+
params: (),
287287
received: Instant::now(),
288288
_action: PhantomData,
289289
}
290290
}
291291

292292
fn exit<'a>() -> Notification<server::ExitNotification<'a>> {
293293
Notification {
294-
params: NoParams {},
294+
params: () ,
295295
_action: PhantomData,
296296
}
297297
}

src/server/mod.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,6 @@ pub struct Ack;
6060
#[derive(Debug)]
6161
pub struct NoResponse;
6262

63-
/// Empty extra parameters to some request or notification.
64-
#[derive(Debug, Serialize, PartialEq)]
65-
pub struct NoParams;
66-
67-
impl<'de> Deserialize<'de> for NoParams {
68-
fn deserialize<D>(_deserializer: D) -> Result<NoParams, D::Error>
69-
where
70-
D: serde::Deserializer<'de>,
71-
{
72-
Ok(NoParams)
73-
}
74-
}
75-
7663
/// A response to some request.
7764
pub trait Response {
7865
/// Send the response along the given output.
@@ -236,7 +223,7 @@ pub struct ShutdownRequest<'a> {
236223
}
237224

238225
impl<'a> Action for ShutdownRequest<'a> {
239-
type Params = NoParams;
226+
type Params = ();
240227
const METHOD: &'static str = "shutdown";
241228
}
242229

@@ -266,7 +253,7 @@ pub struct ExitNotification<'a> {
266253
}
267254

268255
impl<'a> Action for ExitNotification<'a> {
269-
type Params = NoParams;
256+
type Params = ();
270257
const METHOD: &'static str = "exit";
271258
}
272259

@@ -688,7 +675,7 @@ mod test {
688675

689676
assert_eq!(
690677
notification,
691-
Ok(Notification::<notifications::Initialized>::new(NoParams {}))
678+
Ok(Notification::<notifications::Initialized>::new(()))
692679
);
693680
}
694681
}

src/test/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod harness;
1616
use analysis;
1717
use actions::requests;
1818
use config::{Config, Inferrable};
19-
use server::{self as ls_server, NoParams, Request, ShutdownRequest};
19+
use server::{self as ls_server, Request, ShutdownRequest};
2020
use jsonrpc_core;
2121
use vfs;
2222

@@ -95,7 +95,7 @@ fn test_shutdown() {
9595

9696
let messages = vec![
9797
initialize(0, root_path.as_os_str().to_str().map(|x| x.to_owned())).to_string(),
98-
blocking_request::<ShutdownRequest>(1, NoParams).to_string(),
98+
blocking_request::<ShutdownRequest>(1, ()).to_string(),
9999
];
100100

101101
let (mut server, results) = env.mock_server(messages);

0 commit comments

Comments
 (0)