Skip to content
Open
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
10 changes: 0 additions & 10 deletions crates/lsp-async-stub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use std::marker::PhantomData;

#[async_trait(?Send)]
pub(crate) trait Handler<W: Clone> {
fn method(&self) -> &'static str;

async fn handle(
&mut self,
context: Context<W>,
Expand Down Expand Up @@ -72,10 +70,6 @@ where
F: Future<Output = Result<R::Result, rpc::Error>> + 'static,
W: Clone + 'static,
{
fn method(&self) -> &'static str {
R::METHOD
}

async fn handle(
&mut self,
context: Context<W>,
Expand Down Expand Up @@ -160,10 +154,6 @@ where
F: Future + 'static,
W: Clone + 'static,
{
fn method(&self) -> &'static str {
N::METHOD
}

async fn handle(
&mut self,
context: Context<W>,
Expand Down
4 changes: 2 additions & 2 deletions crates/lsp-async-stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ impl<W: Clone> RequestWriter for Context<W> {
}
}

pub trait MessageWriter: Sink<rpc::Message, Error = io::Error> + Unpin {}
impl<T: Sink<rpc::Message, Error = io::Error> + Unpin> MessageWriter for T {}
pub trait MessageWriter: Sink<rpc::Message, Error = io::Error> + Unpin + Send + Sync {}
impl<T: Sink<rpc::Message, Error = io::Error> + Unpin + Send + Sync> MessageWriter for T {}

struct Inner<W: Clone> {
next_request_id: i32,
Expand Down
2 changes: 1 addition & 1 deletion crates/taplo-cli/src/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl<E: Environment> Taplo<E> {
self.env
.stderr()
.write_all(
format!("Failed to write diff to stdout: {:?}", e)
format!("Failed to write diff to stdout: {e:?}")
.as_str()
.as_bytes(),
)
Expand Down
14 changes: 5 additions & 9 deletions crates/taplo-wasm/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ impl AsyncRead for JsAsyncRead {
let ret: JsValue = match self.f.call1(&this, &JsValue::from(buf.remaining())) {
Ok(val) => val,
Err(error) => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
format!("{:?}", error),
)));
return Poll::Ready(Err(io::Error::other(format!("{error:?}"))));
}
};

Expand All @@ -58,7 +55,7 @@ impl AsyncRead for JsAsyncRead {

Ok(())
}
Err(err) => Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", err))),
Err(err) => Err(io::Error::other(format!("{err:?}"))),
};

self.fut = None;
Expand Down Expand Up @@ -96,9 +93,8 @@ impl AsyncWrite for JsAsyncWrite {
let ret: JsValue = match self.f.call1(&this, &Uint8Array::from(buf).into()) {
Ok(val) => val,
Err(error) => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
format!("{:?}", error),
return Poll::Ready(Err(io::Error::other(
format!("{error:?}"),
)));
}
};
Expand All @@ -114,7 +110,7 @@ impl AsyncWrite for JsAsyncWrite {
let n = num_written.as_f64().unwrap_or(0.0).floor() as usize;
Ok(n)
}
Err(err) => Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", err))),
Err(err) => Err(io::Error::other(format!("{err:?}"))),
};

self.fut = None;
Expand Down
4 changes: 4 additions & 0 deletions crates/taplo-wasm/src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ pub(crate) struct WasmLspInterface {
js_on_message: Function,
}

// SAFETY: This is safe because WASM is single-threaded
unsafe impl Send for WasmLspInterface {}
unsafe impl Sync for WasmLspInterface {}

impl From<JsValue> for WasmLspInterface {
fn from(val: JsValue) -> Self {
Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/taplo/src/dom/to_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Node {

// Use the original representation of primitives if available.
if let Some(syntax) = self.syntax() {
return write!(f, "{}", syntax);
return write!(f, "{syntax}");
}
}

Expand Down Expand Up @@ -153,7 +153,7 @@ impl Node {
Node::Bool(b) => write!(f, "{}", b.value())?,
Node::Str(s) => {
if let Some(syntax) = s.syntax() {
write!(f, "{}", syntax)?;
write!(f, "{syntax}")?;
} else {
let escaped = escape(s.value());

Expand Down
15 changes: 3 additions & 12 deletions crates/taplo/src/formatter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ impl core::fmt::Display for OptionParseError {
"invalid formatting option: {}",
match self {
OptionParseError::InvalidOption(k) => {
format!(r#"invalid option "{}""#, k)
format!(r#"invalid option "{k}""#)
}
OptionParseError::InvalidValue { key, error } => {
format!(r#"invalid value for option "{}": {}"#, key, error)
format!(r#"invalid value for option "{key}": {error}"#)
}
}
)
Expand Down Expand Up @@ -418,10 +418,6 @@ impl FormattedItem for FormattedEntry {
fn trailing_comment(&self) -> Option<String> {
self.comment.clone()
}

fn syntax(&self) -> SyntaxElement {
self.syntax.clone()
}
}

fn format_root(node: SyntaxNode, options: &Options, context: &Context) -> String {
Expand Down Expand Up @@ -1194,22 +1190,17 @@ fn format_table_header(
}

// Simply a tuple of the formatted item and an optional trailing comment.
impl<T: AsRef<str>> FormattedItem for (SyntaxElement, T, Option<T>) {
impl<T: AsRef<str> + Clone> FormattedItem for (SyntaxElement, T, Option<T>) {
fn write_to(&self, formatted: &mut String, _options: &Options) {
*formatted += self.1.as_ref()
}

fn trailing_comment(&self) -> Option<String> {
self.2.as_ref().map(|s| s.as_ref().to_string())
}

fn syntax(&self) -> SyntaxElement {
self.0.clone()
}
}

trait FormattedItem {
fn syntax(&self) -> SyntaxElement;
#[allow(clippy::ptr_arg)]
fn write_to(&self, formatted: &mut String, options: &Options);
fn trailing_comment(&self) -> Option<String>;
Expand Down
4 changes: 2 additions & 2 deletions crates/taplo/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn time_in_arrays() {

let errors = parse(src).errors;

assert!(errors.is_empty(), "{:#?}", errors);
assert!(errors.is_empty(), "{errors:#?}");
}

#[test]
Expand All @@ -25,5 +25,5 @@ fn comments_after_tables() {
"#;
let errors = parse(src).errors;

assert!(errors.is_empty(), "{:#?}", errors);
assert!(errors.is_empty(), "{errors:#?}");
}
4 changes: 2 additions & 2 deletions editors/vscode/src/syntax/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const comment = {
},
comment: 'Comments',
match: '\\s*((#).*)$',
}
};

export const commentDirective = {
captures: {
Expand All @@ -22,5 +22,5 @@ export const commentDirective = {
},
comment: 'Comments',
match: '\\s*((#):.*)$',
}
};

Loading