Skip to content

Commit a72c25f

Browse files
authored
Resolve all the pedantic lints (#313)
* fix(clippy): allow cast_precision_loss and cast_sign_loss pedantic lints Signed-off-by: Jérémy Audiger <[email protected]> * fix(clippy): allow unsafe_derive_deserialize pedantic lint Signed-off-by: Jérémy Audiger <[email protected]> * fix(clippy): resolve default_trait_access pedantic lint Signed-off-by: Jérémy Audiger <[email protected]> * refactor(cargo): fully enable pedantic lints in codebase Signed-off-by: Jérémy Audiger <[email protected]> --------- Signed-off-by: Jérémy Audiger <[email protected]>
1 parent 0165b98 commit a72c25f

File tree

17 files changed

+88
-107
lines changed

17 files changed

+88
-107
lines changed

Cargo.toml

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ resolver = "3"
1414
[workspace.lints.clippy]
1515
all = { level = "warn", priority = -1 }
1616
nursery = { level = "warn", priority = -1 }
17+
pedantic = { level = "warn", priority = -1 }
1718
cognitive_complexity = "allow"
1819
future_not_send = "allow"
1920
implicit_hasher = "allow"
@@ -24,53 +25,11 @@ struct_excessive_bools = "allow"
2425
struct_field_names = "allow"
2526
too_many_lines = "allow"
2627
allow_attributes = "warn"
27-
cast_lossless = "warn"
28-
cast_possible_truncation = "warn"
29-
cast_possible_wrap = "warn"
30-
checked_conversions = "warn"
3128
dbg_macro = "warn"
32-
explicit_deref_methods = "warn"
33-
explicit_into_iter_loop = "warn"
34-
explicit_iter_loop = "warn"
35-
filter_map_next = "warn"
36-
flat_map_option = "warn"
37-
from_iter_instead_of_collect = "warn"
38-
if_not_else = "warn"
39-
ignored_unit_patterns = "warn"
40-
implicit_clone = "warn"
41-
items_after_statements = "warn"
4229
large_const_arrays = "warn"
43-
large_futures = "warn"
44-
manual_assert = "warn"
45-
manual_is_variant_and = "warn"
46-
manual_let_else = "warn"
47-
map_unwrap_or = "warn"
48-
match_same_arms = "warn"
49-
must_use_candidate = "warn"
50-
needless_continue = "warn"
51-
needless_for_each = "warn"
52-
needless_pass_by_value = "warn"
53-
option_as_ref_cloned = "warn"
5430
print_stderr = "warn"
5531
print_stdout = "warn"
56-
redundant_else = "warn"
57-
ref_option = "warn"
58-
ref_option_ref = "warn"
59-
return_self_not_must_use = "warn"
60-
semicolon_if_nothing_returned = "warn"
61-
similar_names = "warn"
62-
trivially_copy_pass_by_ref = "warn"
63-
uninlined_format_args = "warn"
64-
unnecessary_wraps = "warn"
65-
unnested_or_patterns = "warn"
66-
unreadable_literal = "warn"
67-
unused_async = "warn"
68-
unused_self = "warn"
6932
unused_trait_names = "warn"
70-
used_underscore_binding = "warn"
71-
used_underscore_items = "warn"
72-
unnecessary_debug_formatting = "warn"
73-
unnecessary_semicolon = "warn"
7433

7534
[profile.dev]
7635
debug = "limited"

crates/brioche-core/benches/input.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::HashMap;
22
use std::io::Write as _;
3+
use std::sync::Arc;
34

45
use brioche_core::Brioche;
56

@@ -62,7 +63,7 @@ fn bench_input(bencher: divan::Bencher, removal: Removal) {
6263
.bench_values(|ctx| {
6364
ctx.runtime.block_on(async {
6465
let mut saved_paths = HashMap::default();
65-
let meta = Default::default();
66+
let meta = Arc::default();
6667

6768
brioche_core::input::create_input(
6869
&ctx.brioche,
@@ -133,7 +134,7 @@ fn bench_input_with_shared_resources(bencher: divan::Bencher, removal: Removal)
133134
.bench_values(|ctx| {
134135
ctx.runtime.block_on(async {
135136
let mut saved_paths = HashMap::default();
136-
let meta = Default::default();
137+
let meta = Arc::default();
137138

138139
brioche_core::input::create_input(
139140
&ctx.brioche,
@@ -242,7 +243,7 @@ fn bench_input_with_shared_ancestor_resources(bencher: divan::Bencher, removal:
242243
})
243244
.bench_values(|ctx| {
244245
ctx.runtime.block_on(async {
245-
let meta = Default::default();
246+
let meta = Arc::default();
246247
brioche_core::input::create_input(
247248
&ctx.brioche,
248249
brioche_core::input::InputOptions {

crates/brioche-core/src/download.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ pub async fn fetch_git_commit_for_ref(
103103
.with_context(|| format!("failed to parse git repository URL: {repository}"))?;
104104
move || {
105105
// Connect to the repository by URL
106-
let transport = gix::protocol::transport::connect(repository, Default::default());
106+
let transport = gix::protocol::transport::connect(
107+
repository,
108+
gix::protocol::transport::client::connect::Options::default(),
109+
);
107110
let mut transport = match transport {
108111
Ok(transport) => transport,
109112
Err(error) => {

crates/brioche-core/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub async fn create_input(
9797
&mut blob_permit,
9898
&path,
9999
super::blob::SaveBlobOptions::default().remove_input(remove_blob),
100-
&mut Default::default(),
100+
&mut Vec::default(),
101101
)
102102
.await?;
103103

crates/brioche-core/src/project/load.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tracing::Instrument as _;
1414
use crate::{
1515
Brioche,
1616
project::{DependencyRef, ProjectEntry, Workspace, WorkspaceHash},
17-
recipe::Artifact,
17+
recipe::{Artifact, Directory},
1818
};
1919

2020
use super::{
@@ -941,7 +941,7 @@ async fn resolve_static(
941941
project_root.display(),
942942
);
943943
let mut saved_paths = HashMap::default();
944-
let meta = Default::default();
944+
let meta = Arc::default();
945945

946946
let artifact = crate::input::create_input(
947947
brioche,
@@ -1023,7 +1023,7 @@ async fn resolve_static(
10231023
let artifacts = futures::stream::iter(paths)
10241024
.then(|(full_path, relative_path)| async move {
10251025
let mut saved_paths = HashMap::default();
1026-
let meta = Default::default();
1026+
let meta = Arc::default();
10271027

10281028
let artifact = crate::input::create_input(
10291029
brioche,
@@ -1125,7 +1125,7 @@ async fn resolve_static(
11251125
let download_artifact = crate::recipe::Artifact::File(crate::recipe::File {
11261126
content_blob: blob_hash,
11271127
executable: false,
1128-
resources: Default::default(),
1128+
resources: Directory::default(),
11291129
});
11301130

11311131
let download_recipe_json = serde_json::to_string(&download_recipe)

crates/brioche-core/src/recipe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ pub struct File {
674674
pub resources: Directory,
675675
}
676676

677+
#[expect(clippy::unsafe_derive_deserialize)]
677678
#[serde_with::serde_as]
678679
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
679680
#[serde(rename_all = "camelCase")]

crates/brioche-core/src/reporter/console.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,11 @@ impl superconsole::Component for JobsComponent {
652652
struct JobComponent<'a>(JobId, &'a Job);
653653

654654
impl superconsole::Component for JobComponent<'_> {
655-
#[expect(clippy::cast_possible_truncation)]
655+
#[expect(
656+
clippy::cast_possible_truncation,
657+
clippy::cast_precision_loss,
658+
clippy::cast_sign_loss
659+
)]
656660
fn draw_unchecked(
657661
&self,
658662
dimensions: superconsole::Dimensions,
@@ -1022,7 +1026,11 @@ fn indicator_span(kind: IndicatorKind) -> superconsole::Span {
10221026
}
10231027
}
10241028

1025-
#[expect(clippy::cast_possible_truncation)]
1029+
#[expect(
1030+
clippy::cast_possible_truncation,
1031+
clippy::cast_precision_loss,
1032+
clippy::cast_sign_loss
1033+
)]
10261034
fn progress_bar_spans(
10271035
interior: &str,
10281036
width: usize,

crates/brioche-core/src/reporter/job.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Job {
103103
finished_at: None,
104104
},
105105
NewJob::Process { status } => Self::Process {
106-
packet_queue: Default::default(),
106+
packet_queue: DebugIgnore::default(),
107107
status,
108108
},
109109
NewJob::CacheFetch {

crates/brioche-core/src/script/evaluate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async fn evaluate_with_deno(
127127

128128
// Resolve the export if it's a promise
129129
let resolved_result_fut = js_runtime.resolve(result);
130-
let resolved_result = js_runtime.with_event_loop_promise(resolved_result_fut, Default::default()).await?;
130+
let resolved_result = js_runtime.with_event_loop_promise(resolved_result_fut, deno_core::PollEventLoopOptions::default()).await?;
131131

132132
// Call the `briocheSerialize` function on the result
133133
let serialized_result = {
@@ -164,7 +164,7 @@ async fn evaluate_with_deno(
164164

165165
// Resolve the result of `briocheSerialize` if it's a promise
166166
let serialized_resolved_result_fut = js_runtime.resolve(serialized_result);
167-
let serialized_resolved_result = js_runtime.with_event_loop_promise(serialized_resolved_result_fut, Default::default()).await?;
167+
let serialized_resolved_result = js_runtime.with_event_loop_promise(serialized_resolved_result_fut, deno_core::PollEventLoopOptions::default()).await?;
168168

169169
let mut js_scope = js_runtime.handle_scope();
170170

crates/brioche-core/src/script/lsp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use tower_lsp::lsp_types::{
1212
DocumentDiagnosticReport, DocumentDiagnosticReportResult, DocumentFormattingParams,
1313
DocumentHighlight, DocumentHighlightParams, FullDocumentDiagnosticReport, GotoDefinitionParams,
1414
GotoDefinitionResponse, Hover, HoverParams, HoverProviderCapability, InitializeParams,
15-
InitializeResult, InitializedParams, Location, MessageType, OneOf, Position,
16-
PrepareRenameResponse, Range, ReferenceParams, RelatedFullDocumentDiagnosticReport,
15+
InitializeResult, InitializedParams, Location, MessageType, OneOf, PartialResultParams,
16+
Position, PrepareRenameResponse, Range, ReferenceParams, RelatedFullDocumentDiagnosticReport,
1717
RenameOptions, RenameParams, ServerCapabilities, TextDocumentIdentifier,
1818
TextDocumentPositionParams, TextDocumentSyncCapability, TextDocumentSyncKind, TextEdit,
19-
WorkspaceEdit,
19+
WorkDoneProgressOptions, WorkDoneProgressParams, WorkspaceEdit,
2020
};
2121
use tower_lsp::{Client, LanguageServer};
2222
use tracing::Instrument as _;
@@ -97,9 +97,9 @@ impl BriocheLspServer {
9797
.send(JsLspMessage::Diagnostic(DocumentDiagnosticParams {
9898
identifier: None,
9999
previous_result_id: None,
100-
partial_result_params: Default::default(),
100+
partial_result_params: PartialResultParams::default(),
101101
text_document,
102-
work_done_progress_params: Default::default(),
102+
work_done_progress_params: WorkDoneProgressParams::default(),
103103
}))
104104
.await?;
105105
Ok(diagnostics)
@@ -126,7 +126,7 @@ impl LanguageServer for BriocheLspServer {
126126
document_highlight_provider: Some(OneOf::Left(true)),
127127
rename_provider: Some(OneOf::Right(RenameOptions {
128128
prepare_provider: Some(true),
129-
work_done_progress_options: Default::default(),
129+
work_done_progress_options: WorkDoneProgressOptions::default(),
130130
})),
131131
document_formatting_provider: Some(OneOf::Left(true)),
132132
..Default::default()

0 commit comments

Comments
 (0)