Enforce `#[expect(lint)]`
This commit is contained in:
parent
0dca168717
commit
95bbc7f367
|
@ -46,6 +46,9 @@ exclude = [
|
|||
"target/osdk/test-base",
|
||||
]
|
||||
|
||||
[workspace.lints.clippy]
|
||||
allow_attributes = "warn"
|
||||
|
||||
# Cargo only looks at the profile settings
|
||||
# in the Cargo.toml manifest at the root of the workspace
|
||||
|
||||
|
|
|
@ -26,10 +26,10 @@ can easily be misinterpreted as the trait itself being dead code.
|
|||
Instead, the following pattern is preferred:
|
||||
```rust
|
||||
trait SomeTrait {
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
fn foo();
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[expect(dead_code)]
|
||||
fn bar();
|
||||
|
||||
fn baz();
|
||||
|
@ -38,26 +38,26 @@ trait SomeTrait {
|
|||
|
||||
There is one exception:
|
||||
If it is clear enough that every member will trigger the lint,
|
||||
it is reasonable to allow the lint at the type level.
|
||||
it is reasonable to expect the lint at the type level.
|
||||
For example, in the following code,
|
||||
we add `#[allow(non_camel_case_types)]` for the type `SomeEnum`,
|
||||
we add `#[expect(non_camel_case_types)]` for the type `SomeEnum`,
|
||||
instead of for each variant of the type:
|
||||
```rust
|
||||
#[allow(non_camel_case_types)]
|
||||
#[expect(non_camel_case_types)]
|
||||
enum SomeEnum {
|
||||
FOO_ABC,
|
||||
BAR_DEF,
|
||||
}
|
||||
```
|
||||
|
||||
### When to `#[allow(dead_code)]`
|
||||
### When to `#[expect(dead_code)]`
|
||||
|
||||
In general, dead code should be avoided because
|
||||
_(i)_ it introduces unnecessary maintenance overhead, and
|
||||
_(ii)_ its correctness can only be guaranteed by
|
||||
manual and error-pruned review of the code.
|
||||
|
||||
In the case where allowing dead code is necessary,
|
||||
In the case where expecting dead code is necessary,
|
||||
it should fulfill the following requirements:
|
||||
1. We have a _concrete case_ that will be implemented in the future and
|
||||
will turn the dead code into used code.
|
||||
|
|
|
@ -71,3 +71,6 @@ riscv = { version = "0.11.1", features = ["s-mode"] }
|
|||
all = ["cvm_guest"]
|
||||
|
||||
cvm_guest = ["dep:tdx-guest", "ostd/cvm_guest"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -17,4 +17,5 @@ log = "0.4"
|
|||
static_assertions = "1.1.0"
|
||||
bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] }
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -13,4 +13,5 @@ aster-util = { path = "../../libs/aster-util" }
|
|||
component = { path = "../../libs/comp-sys/component" }
|
||||
log = "0.4"
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -15,4 +15,5 @@ font8x8 = { version = "0.2.5", default-features = false, features = [
|
|||
"unicode",
|
||||
] }
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -16,4 +16,5 @@ int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
|||
log = "0.4"
|
||||
ascii = { version = "1.1", default-features = false, features = ["alloc"] }
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -18,3 +18,6 @@ cfg-if = "1.0"
|
|||
[features]
|
||||
default = ["log_color"]
|
||||
log_color = ["dep:owo-colors"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -20,3 +20,6 @@ lru = "0.12.3"
|
|||
postcard = "1.0.6"
|
||||
serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] }
|
||||
static_assertions = "1.1.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -17,3 +17,6 @@ int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
|||
log = "0.4"
|
||||
ostd = { path = "../../../ostd" }
|
||||
spin = "0.9.4"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -12,4 +12,5 @@ aster-logger = { path = "../logger" }
|
|||
intrusive-collections = "0.9.5"
|
||||
spin = "0.9.4"
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -16,4 +16,5 @@ spin = "0.9.4"
|
|||
[target.riscv64gc-unknown-none-elf.dependencies]
|
||||
chrono = { version = "0.4.38", default-features = false }
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -24,3 +24,6 @@ component = { path = "../../libs/comp-sys/component" }
|
|||
log = "0.4"
|
||||
bit_field = "0.10.1"
|
||||
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -21,3 +21,6 @@ smoltcp = { git = "https://github.com/asterinas/smoltcp", tag = "r_2024-11-08_f0
|
|||
spin = "0.9.4"
|
||||
static_assertions = "1.1.0"
|
||||
takeable = "0.2.2"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -12,3 +12,6 @@ proc-macro = true
|
|||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = {version = "1.0.90", features = ["full", "fold"]}
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -11,4 +11,5 @@ typeflags-util = { path = "../typeflags-util" }
|
|||
bitflags = "1.3"
|
||||
aster-rights-proc = { path = "../aster-rights-proc" }
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -12,4 +12,5 @@ aster-rights-proc = { path = "../aster-rights-proc" }
|
|||
aster-rights = { path = "../aster-rights" }
|
||||
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e" }
|
||||
|
||||
[features]
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -10,3 +10,6 @@ proc-macro = true
|
|||
proc-macro2 = "1.0.86"
|
||||
quote = "1.0.37"
|
||||
syn = { version = "2.0.77", features = ["full"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -8,4 +8,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
|
||||
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
|
||||
lending-iterator = "0.1.7"
|
||||
lending-iterator = "0.1.7"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -15,3 +15,6 @@ int-to-c-enum-derive = { path = "derive", optional = true, version = "0.1.0"}
|
|||
[features]
|
||||
default = ["derive"]
|
||||
derive = ["int-to-c-enum-derive"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -15,3 +15,6 @@ proc-macro = true
|
|||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = { version = "2.0.15", features = ["parsing"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -4,3 +4,6 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -7,3 +7,5 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -6,3 +6,6 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -14,3 +14,6 @@ proc-macro2 = "1.0"
|
|||
quote = "1.0"
|
||||
syn = { version = "1.0.90" }
|
||||
typeflags-util = { path = "../typeflags-util" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -11,3 +11,6 @@ repository ="https://github.com/asterinas/asterinas"
|
|||
[dependencies]
|
||||
ostd = { version = "0.11.1", path = "../../ostd" }
|
||||
owo-colors = "4.0.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -65,3 +65,6 @@ fdt = { version = "0.1.5", features = ["pretty-printing"] }
|
|||
default = ["cvm_guest"]
|
||||
# The guest OS support for Confidential VMs (CVMs), e.g., Intel TDX
|
||||
cvm_guest = ["dep:tdx-guest", "dep:iced-x86"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -5,4 +5,9 @@ edition = "2021"
|
|||
description = " An extension trait for Rust integer types to make integers aligned to a power of two"
|
||||
license = "MPL-2.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -10,3 +10,6 @@ repository = "https://github.com/asterinas/asterinas"
|
|||
|
||||
[dependencies]
|
||||
bitvec = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -9,3 +9,6 @@ repository = "https://github.com/asterinas/asterinas"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -14,3 +14,6 @@ bitflags = "1.3"
|
|||
libflate = "2.1.0"
|
||||
serde = { version = "1.0.192", features = ["derive"] }
|
||||
xmas-elf = "0.9.1"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -32,3 +32,6 @@ tdx-guest = { version = "0.1.8", optional = true }
|
|||
default = ["cvm_guest"]
|
||||
debug_print = []
|
||||
cvm_guest = ["dep:tdx-guest"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -16,3 +16,6 @@ proc-macro2 = "1.0.78"
|
|||
quote = "1.0.35"
|
||||
rand = "0.8.5"
|
||||
syn = { version = "2.0.48", features = ["full"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -7,3 +7,8 @@ license = "MPL-2.0"
|
|||
repository ="https://github.com/asterinas/asterinas"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
Loading…
Reference in New Issue