Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make clippy happy #369

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/custom_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl LanguageServer for Backend {
self.client
.log_message(
MessageType::INFO,
format!("Command executed with params: {:?}", params),
format!("Command executed with params: {params:?}"),
)
.await;
Ok(None)
Expand Down
14 changes: 7 additions & 7 deletions src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ pub enum ParseError {
impl Display for ParseError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
ParseError::Body(ref e) => write!(f, "unable to parse JSON body: {}", e),
ParseError::Encode(ref e) => write!(f, "failed to encode response: {}", e),
ParseError::Headers(ref e) => write!(f, "failed to parse headers: {}", e),
ParseError::Body(ref e) => write!(f, "unable to parse JSON body: {e}"),
ParseError::Encode(ref e) => write!(f, "failed to encode response: {e}"),
ParseError::Headers(ref e) => write!(f, "failed to parse headers: {e}"),
ParseError::InvalidContentType => write!(f, "unable to parse content type"),
ParseError::InvalidContentLength(ref e) => {
write!(f, "unable to parse content length: {}", e)
write!(f, "unable to parse content length: {e}")
}
ParseError::MissingContentLength => {
write!(f, "missing required `Content-Length` header")
}
ParseError::Utf8(ref e) => write!(f, "request contains invalid UTF8: {}", e),
ParseError::Utf8(ref e) => write!(f, "request contains invalid UTF8: {e}"),
}
}
}
Expand Down Expand Up @@ -271,7 +271,7 @@ mod tests {

fn encode_message(content_type: Option<&str>, message: &str) -> String {
let content_type = content_type
.map(|ty| format!("\r\nContent-Type: {}", ty))
.map(|ty| format!("\r\nContent-Type: {ty}"))
.unwrap_or_default();

format!(
Expand Down Expand Up @@ -361,7 +361,7 @@ mod tests {
fn recovers_from_parse_error() {
let decoded = r#"{"jsonrpc":"2.0","method":"exit"}"#;
let encoded = encode_message(None, decoded);
let mixed = format!("foobar{}Content-Length: foobar\r\n\r\n{}", encoded, encoded);
let mixed = format!("foobar{encoded}Content-Length: foobar\r\n\r\n{encoded}");

let mut codec = LanguageServerCodec::default();
let mut buffer = BytesMut::from(mixed.as_str());
Expand Down
8 changes: 2 additions & 6 deletions src/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub type Result<T> = std::result::Result<T, Error>;
/// A unique ID used to correlate requests and responses together.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Deserialize, Serialize)]
#[serde(untagged)]
#[derive(Default)]
pub enum Id {
/// Numeric ID.
Number(i64),
Expand All @@ -35,15 +36,10 @@ pub enum Id {
/// While `null` is considered a valid request ID by the JSON-RPC 2.0 specification, its use is
/// _strongly_ discouraged because the specification also uses a `null` value to indicate an
/// unknown ID in the [`Response`] object.
#[default]
Null,
}

impl Default for Id {
fn default() -> Self {
Id::Null
}
}

impl Display for Id {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
Expand Down
2 changes: 1 addition & 1 deletion src/jsonrpc/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub trait FromParams: private::Sealed + Send + Sized + 'static {
impl FromParams for () {
fn from_params(params: Option<Value>) -> super::Result<Self> {
if let Some(p) = params {
Err(Error::invalid_params(format!("Unexpected params: {}", p)))
Err(Error::invalid_params(format!("Unexpected params: {p}")))
} else {
Ok(())
}
Expand Down