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

Reapply clippy on the workspace and bump MSRV to 1.83 #84

Merged
merged 3 commits into from
Dec 5, 2024
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ homepage = "https://github.com/posit-dev/air"
keywords = ["parser", "formatter"]
license = "MIT"
repository = "https://github.com/posit-dev/air"
rust-version = "1.83"

[profile.release-with-debug]
debug = true
Expand Down Expand Up @@ -124,7 +125,6 @@ empty_drop = "warn"
empty_enum_variants_with_brackets = "warn"
float_cmp_const = "warn"
get_unwrap = "warn"
infinite_loop = "warn"
lossy_float_literal = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
Expand Down
1 change: 1 addition & 0 deletions crates/air/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ homepage.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
air_r_formatter = { workspace = true }
Expand Down
23 changes: 12 additions & 11 deletions crates/air_formatter_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
authors.workspace = true
categories.workspace = true
description = "Air's formatter test shared infrastructure"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "air_formatter_test"
publish = false
repository.workspace = true
version = "0.0.0"
authors.workspace = true
categories.workspace = true
description = "Air's formatter test shared infrastructure"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "air_formatter_test"
publish = false
repository.workspace = true
rust-version.workspace = true
version = "0.0.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
1 change: 1 addition & 0 deletions crates/air_r_factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ homepage.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
air_r_syntax = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/air_r_formatter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license.workspace = true
name = "air_r_formatter"
publish = false
repository.workspace = true
rust-version.workspace = true
version = "0.0.0"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/air_r_formatter/src/r/auxiliary/call_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ struct FormatAllArgsBrokenOut<'a> {
expand: bool,
}

impl<'a> Format<RFormatContext> for FormatAllArgsBrokenOut<'a> {
impl Format<RFormatContext> for FormatAllArgsBrokenOut<'_> {
fn fmt(&self, f: &mut Formatter<RFormatContext>) -> FormatResult<()> {
let args = format_with(|f| {
for (index, entry) in self.args.iter().enumerate() {
Expand Down
23 changes: 12 additions & 11 deletions crates/air_r_parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
authors.workspace = true
categories.workspace = true
description = "Air R parser"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "air_r_parser"
publish = false
repository.workspace = true
version = "0.0.0"
authors.workspace = true
categories.workspace = true
description = "Air R parser"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "air_r_parser"
publish = false
repository.workspace = true
rust-version.workspace = true
version = "0.0.0"

[dependencies]
air_r_factory = { workspace = true }
Expand Down
23 changes: 12 additions & 11 deletions crates/air_r_syntax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
authors.workspace = true
categories.workspace = true
description = "SyntaxKind and common rowan definitions for air_r_parser"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "air_r_syntax"
publish = false
repository.workspace = true
version = "0.0.0"
authors.workspace = true
categories.workspace = true
description = "SyntaxKind and common rowan definitions for air_r_parser"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "air_r_syntax"
publish = false
repository.workspace = true
rust-version.workspace = true
version = "0.0.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
23 changes: 12 additions & 11 deletions crates/biome_ungrammar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
authors.workspace = true
categories.workspace = true
description = "A DSL for describing concrete syntax trees"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "biome_ungrammar"
publish = false
repository.workspace = true
version = "0.3.1"
authors.workspace = true
categories.workspace = true
description = "A DSL for describing concrete syntax trees"
edition.workspace = true
homepage.workspace = true
keywords.workspace = true
license.workspace = true
name = "biome_ungrammar"
publish = false
repository.workspace = true
rust-version.workspace = true
version = "0.3.1"

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ homepage.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
air_r_formatter.workspace = true
Expand Down
8 changes: 1 addition & 7 deletions crates/lsp/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::Serialize;
use struct_field_names_as_array::FieldNamesAsArray;

/// Configuration of the LSP
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub(crate) struct LspConfig {}

/// Configuration of a document.
Expand Down Expand Up @@ -62,12 +62,6 @@ pub(crate) enum VscIndentSize {
Size(usize),
}

impl Default for LspConfig {
fn default() -> Self {
Self {}
}
}

impl Default for IndentationConfig {
fn default() -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ mod tests {
insta::assert_debug_snapshot!(original_syntax);

let edit = TextEdit::replace(
TextRange::new(TextSize::from(4 as u32), TextSize::from(7)),
TextRange::new(TextSize::from(4_u32), TextSize::from(7)),
String::from("1 + 2"),
);
let edits = to_proto::doc_edit_vec(&doc.line_index, edit).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn convert_character_from_utf16_to_utf8(x: &str, character: usize) -> usize {
}

log::error!("Failed to locate UTF-16 offset of {character}. Line: '{x}'.");
return 0;
0
}

/// Converts a character offset into a particular line from UTF-8 to UTF-16
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/handlers_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn format_ts_node(cursor: &mut tree_sitter::TreeCursor, depth: usize, output: &m
let node = cursor.node();
let field_name = match cursor.field_name() {
Some(name) => format!("{name}: "),
None => String::from(""),
None => String::new(),
};

let start = node.start_position();
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/handlers_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod tests {
let edits = client.format_document_edits(&doc).await.unwrap();
assert!(edits.len() == 1);

let edit = edits.get(0).unwrap();
let edit = &edits[0];
assert_eq!(edit.new_text, " + ");

client
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/handlers_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ async fn update_config(

// --- Documents
// For each document, deserialise the vector of JSON values into a typed config
for uri in uris.into_iter() {
for uri in uris {
let keys = document_keys.into_iter();
let items: Vec<Value> = configs.by_ref().take(n_document_items).collect();

Expand Down
17 changes: 12 additions & 5 deletions crates/lsp/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl GlobalState {
LspRequest::Initialize(params) => {
respond(tx, handlers_state::initialize(params, &mut self.lsp_state, &mut self.world), LspResponse::Initialize)?;
},
LspRequest::Shutdown() => {
LspRequest::Shutdown => {
out = LoopControl::Shutdown;
respond(tx, Ok(()), LspResponse::Shutdown)?;
},
Expand Down Expand Up @@ -379,6 +379,7 @@ impl AuxiliaryState {
// with the auxiliary loop (logging messages or spawning a task) from
// free functions.
unsafe {
#[allow(static_mut_refs)]
if let Some(val) = AUXILIARY_EVENT_TX.get_mut() {
// Reset channel if already set. Happens e.g. on reconnection after a refresh.
*val = auxiliary_event_tx;
Expand Down Expand Up @@ -411,7 +412,7 @@ impl AuxiliaryState {
///
/// Takes ownership of auxiliary state and start the low-latency auxiliary
/// loop.
async fn start(mut self) {
async fn start(mut self) -> ! {
loop {
match self.next_event().await {
AuxiliaryEvent::Log(level, message) => self.log(level, message).await,
Expand Down Expand Up @@ -454,7 +455,10 @@ impl AuxiliaryState {
fn auxiliary_tx() -> &'static TokioUnboundedSender<AuxiliaryEvent> {
// If we get here that means the LSP was initialised at least once. The
// channel might be closed if the LSP was dropped, but it should exist.
unsafe { AUXILIARY_EVENT_TX.get().unwrap() }
unsafe {
#[allow(static_mut_refs)]
AUXILIARY_EVENT_TX.get().unwrap()
}
}

fn send_auxiliary(event: AuxiliaryEvent) {
Expand All @@ -474,7 +478,10 @@ pub(crate) fn log(level: lsp_types::MessageType, message: String) {

// Check that channel is still alive in case the LSP was closed.
// If closed, fallthrough.
if let Ok(_) = auxiliary_tx().send(AuxiliaryEvent::Log(level, message.clone())) {
if auxiliary_tx()
.send(AuxiliaryEvent::Log(level, message.clone()))
.is_ok()
{
return;
}

Expand All @@ -500,7 +507,7 @@ where
Handler: FnOnce() -> anyhow::Result<Option<AuxiliaryEvent>>,
Handler: Send + 'static,
{
let handle = tokio::task::spawn_blocking(|| handler());
let handle = tokio::task::spawn_blocking(handler);

// Send the join handle to the auxiliary loop so it can log any errors
// or panics
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/rust_analyzer/text_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ mod tests {
let mut builder = TextEditBuilder::default();
builder.replace(range(1, 3), "au".into());
builder.replace(range(3, 5), "www".into());
builder.replace(range(5, 8), "".into());
builder.replace(range(5, 8), String::new());
builder.replace(range(8, 9), "ub".into());

let edit = builder.finish();
Expand Down
7 changes: 5 additions & 2 deletions crates/lsp/src/tower_lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ macro_rules! cast_response {
}};
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
pub(crate) enum LspMessage {
Notification(LspNotification),
Expand All @@ -53,14 +54,16 @@ pub(crate) enum LspNotification {
DidCloseTextDocument(DidCloseTextDocumentParams),
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
pub(crate) enum LspRequest {
Initialize(InitializeParams),
DocumentFormatting(DocumentFormattingParams),
Shutdown(),
Shutdown,
AirViewFile(ViewFileParams),
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
pub(crate) enum LspResponse {
Initialize(InitializeResult),
Expand Down Expand Up @@ -130,7 +133,7 @@ impl LanguageServer for Backend {

async fn shutdown(&self) -> Result<()> {
cast_response!(
self.request(LspRequest::Shutdown()).await,
self.request(LspRequest::Shutdown).await,
LspResponse::Shutdown
)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/tower_lsp_test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl TestClientExt for TestClient {
}

async fn format_document_edits(&mut self, doc: &Document) -> Option<Vec<lsp_types::TextEdit>> {
let lsp_doc = self.open_document(&doc).await;
let lsp_doc = self.open_document(doc).await;

let options = lsp_types::FormattingOptions {
tab_size: 4,
Expand Down
1 change: 1 addition & 0 deletions crates/lsp_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ homepage.workspace = true
keywords.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true

[dependencies]
bytes.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp_test/src/lsp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl TestClient {

pub async fn initialize(&mut self) -> i64 {
let params: Option<lsp_types::InitializeParams> = std::mem::take(&mut self.init_params);
let params = params.unwrap_or(Default::default());
let params = params.unwrap_or_default();
self.request::<lsp_types::request::Initialize>(params).await
}

Expand Down
2 changes: 1 addition & 1 deletion crates/lsp_test/src/tower_lsp/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn decode_headers(headers: &[httparse::Header<'_>]) -> Result<usize, ParseError>
.find_map(|param| param.strip_prefix("charset="));

match charset {
Some("utf-8") | Some("utf8") => {}
Some("utf-8" | "utf8") => {}
_ => return Err(ParseError::InvalidContentType),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp_test/src/tower_lsp/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl Display for Request {
inner: &'a mut Formatter<'b>,
}

impl<'a, 'b> io::Write for WriterFormatter<'a, 'b> {
impl io::Write for WriterFormatter<'_, '_> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
fn io_error<E>(_: E) -> io::Error {
// Error value does not matter because fmt::Display impl below just
Expand Down
Loading
Loading