Skip to content

Commit 8a9ef1d

Browse files
committed
Overhaul and reuse workspace-wide Rust lints
Overhaul the set of Rust lints in use and make them apply in a workspace-wide manner. Fix everything new that is being flagged. Signed-off-by: Daniel Müller <[email protected]>
1 parent 06c035b commit 8a9ef1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+185
-201
lines changed

Cargo.toml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,37 @@ license = "BSD-3-Clause"
1818
repository = "https://github.com/libbpf/blazesym"
1919
homepage = "https://github.com/libbpf/blazesym"
2020

21+
[workspace.lints.rust]
22+
deprecated-safe = "warn"
23+
future-incompatible = "warn"
24+
keyword-idents = "warn"
25+
let-underscore = "warn"
26+
missing-debug-implementations = "warn"
27+
missing-docs = "warn"
28+
trivial-numeric-casts = "warn"
29+
unexpected_cfgs = {level = "warn", check-cfg = ['cfg(has_procmap_query_ioctl)', 'cfg(has_large_test_files)']}
30+
unsafe-op-in-unsafe-fn = "warn"
31+
unused = "warn"
32+
33+
[workspace.lints.clippy]
34+
collapsible-else-if = "allow"
35+
collapsible-if = "allow"
36+
fn-to-numeric-cast = "allow"
37+
let-and-return = "allow"
38+
let-unit-value = "allow"
39+
module-inception = "allow"
40+
type-complexity = "allow"
41+
absolute-paths = "warn"
42+
allow-attributes = "warn"
43+
clone-on-ref-ptr = "warn"
44+
dbg-macro = "warn"
45+
doc-markdown = "warn"
46+
join-absolute-paths = "warn"
47+
large-enum-variant = "warn"
48+
redundant-closure-for-method-calls = "warn"
49+
unchecked-duration-subtraction = "warn"
50+
uninlined-format-args = "warn"
51+
2152
[package]
2253
name = "blazesym"
2354
description = "blazesym is a library for address symbolization and related tasks."
@@ -171,5 +202,5 @@ features = ["apk", "backtrace", "breakpad", "demangle", "dwarf", "gsym"]
171202
# defines the configuration attribute `docsrs`
172203
rustdoc-args = ["--cfg", "docsrs"]
173204

174-
[lints.rust]
175-
unexpected_cfgs = {level = "warn", check-cfg = ['cfg(has_procmap_query_ioctl)', 'cfg(has_large_test_files)']}
205+
[lints]
206+
workspace = true

benches/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#![allow(
2-
clippy::incompatible_msrv,
3-
clippy::let_and_return,
4-
clippy::let_unit_value
5-
)]
1+
//! Benchmarks for `blazesym`.
2+
3+
#![allow(missing_docs)]
64

75
macro_rules! bench_fn {
86
($group:expr, $bench_fn:ident) => {

benches/normalize.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(clippy::fn_to_numeric_cast)]
2-
31
use std::hint::black_box;
42

53
use blazesym::normalize::NormalizeOpts;

benches/symbolize.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(clippy::fn_to_numeric_cast)]
2-
31
use std::hint::black_box;
42
use std::path::Path;
53

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Build script for `blazesym`.
2+
13
use std::env;
24

35

capi/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,6 @@ criterion = {git = "https://github.com/bheisler/criterion.rs.git", rev = "b913e2
8989
tempfile = "3.19"
9090
test-log = {version = "0.2.14", default-features = false, features = ["trace"]}
9191
test-tag = "0.1"
92+
93+
[lints]
94+
workspace = true

capi/benches/capi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::let_and_return, clippy::let_unit_value)]
1+
#![allow(missing_docs)]
22

33
macro_rules! bench_fn {
44
($group:expr, $bench_fn:ident) => {

capi/benches/normalize.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(clippy::fn_to_numeric_cast, clippy::incompatible_msrv)]
2-
31
use std::hint::black_box;
42
use std::ptr;
53

capi/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::let_unit_value)]
1+
//! Build script for `blazesym-c`.
22
33
use std::env;
44
use std::ffi::OsStr;

capi/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ thread_local! {
7777
/// Retrieve the error reported by the last fallible API function invoked.
7878
#[no_mangle]
7979
pub extern "C" fn blaze_err_last() -> blaze_err {
80-
LAST_ERR.with(|cell| cell.get())
80+
LAST_ERR.with(Cell::get)
8181
}
8282

8383
/// Retrieve the error reported by the last fallible API function invoked.

0 commit comments

Comments
 (0)