Skip to content

Commit e984f14

Browse files
authored
Appease two remaining Clippy lints (#689)
Part of #155 Leaving the `needless_return` for a dedicated PR.
1 parent af6ca1e commit e984f14

File tree

9 files changed

+35
-29
lines changed

9 files changed

+35
-29
lines changed

.cargo/config.toml

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ incremental = true
66
lto = true
77

88
[build]
9+
# TODO: Replace with `[lints]` once we upgrade to Rust 1.74
10+
# https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html#lint-configuration-through-cargo
911
rustflags = [
1012
# rustc additional warnings:
1113
"--warn",
1214
"unused_crate_dependencies",
1315
# clippy additional warnings:
1416
"--warn",
1517
"clippy::wildcard_imports",
16-
# This is a list of allowed Clippy rules for the purposes of gradual migration.
17-
# See https://github.com/NomicFoundation/slang/pull/626
18-
"-A",
19-
"clippy::comparison_chain",
20-
"-A",
21-
"clippy::should_implement_trait",
2218
]

crates/codegen/parser/runtime/src/napi/napi_cursor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ impl Cursor {
3333
}
3434

3535
#[napi]
36+
#[allow(clippy::should_implement_trait)] // These are meant to be explicitly exposed to NAPI
3637
pub fn clone(&self) -> Self {
3738
Self(self.0.clone())
3839
}

crates/codegen/parser/runtime/src/support/context.rs

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl<'s> ParserContext<'s> {
9292
self.source[self.position.utf8..].chars().next()
9393
}
9494

95+
#[allow(clippy::should_implement_trait)]
9596
pub fn next(&mut self) -> Option<char> {
9697
self.undo_position = Some(self.position);
9798

crates/solidity/outputs/cargo/crate/src/generated/napi/napi_cursor.rs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/support/context.rs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/tests/src/cst_output/runner.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ pub fn run(parser_name: &str, test_name: &str) -> Result<()> {
4646
let errors = output
4747
.errors()
4848
.iter()
49-
.map(|error| {
50-
error.to_error_report(source_id, &source, /* with_color */ false)
51-
})
49+
.map(|error| error.to_error_report(source_id, &source, /* with_color */ false))
5250
.collect();
5351

5452
let cursor = output.create_tree_cursor();

crates/solidity/outputs/npm/crate/src/generated/napi/napi_cursor.rs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/npm/crate/src/generated/support/context.rs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/testing/sanctuary/src/reporting.rs

+26-20
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,33 @@ impl Reporter {
6767

6868
let failures_before_update = self.failed_tests.fetch_add(1, Ordering::Relaxed);
6969

70-
if failures_before_update < Self::MAX_PRINTED_FAILURES {
71-
let reports = errors
72-
.iter()
73-
.take(Self::MAX_PRINTED_FAILURES - failures_before_update)
74-
.map(|error| error.to_error_report(source_id, source, /* with_color */ true))
75-
.collect::<Vec<String>>();
76-
77-
self.progress_bar.suspend(|| {
78-
for report in reports {
70+
match Self::MAX_PRINTED_FAILURES.checked_sub(failures_before_update) {
71+
None => { /* Don't print more errors */ }
72+
Some(0) => {
73+
self.progress_bar.suspend(|| {
7974
eprintln!();
80-
eprintln!("[{version}] {report}");
81-
}
82-
});
83-
} else if failures_before_update == Self::MAX_PRINTED_FAILURES {
84-
self.progress_bar.suspend(|| {
85-
eprintln!();
86-
eprintln!(
87-
"More than {max_failures} tests failed. Further errors will not be shown.",
88-
max_failures = Self::MAX_PRINTED_FAILURES
89-
);
90-
});
75+
eprintln!(
76+
"More than {max_failures} tests failed. Further errors will not be shown.",
77+
max_failures = Self::MAX_PRINTED_FAILURES
78+
);
79+
});
80+
}
81+
Some(remaining) => {
82+
let reports: Vec<_> = errors
83+
.iter()
84+
.take(remaining)
85+
.map(|error| {
86+
error.to_error_report(source_id, source, /* with_color */ true)
87+
})
88+
.collect();
89+
90+
self.progress_bar.suspend(|| {
91+
for report in reports {
92+
eprintln!();
93+
eprintln!("[{version}] {report}");
94+
}
95+
});
96+
}
9197
}
9298
}
9399
}

0 commit comments

Comments
 (0)