Skip to content

Commit

Permalink
tests: Apply more lints to no-std tests
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 5, 2025
1 parent 932ecb9 commit 52836df
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ members = [
]

# This table is shared by projects under github.com/taiki-e.
# It is not intended for manual editing.
# Expect for unexpected_cfgs.check-cfg, it is not intended for manual editing.
[workspace.lints.rust]
deprecated_safe = "warn"
improper_ctypes = "warn"
Expand All @@ -139,7 +139,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
] }
unnameable_types = "warn"
unreachable_pub = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 merged in Rust 1.65 is not available on MSRV
[workspace.lints.clippy]
all = "warn" # Downgrade deny-by-default lints
pedantic = "warn"
Expand Down
52 changes: 49 additions & 3 deletions tests/avr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "avr-test"
version = "0.0.0"
edition = "2021"
rust-version = "1.64" # Prevent clippy from suggesting a code that requires a new version.
publish = false

[dependencies]
Expand All @@ -13,18 +14,63 @@ ufmt = "0.2"
[target.avr-unknown-gnu-atmega2560.dependencies]
arduino-hal = { features = ["arduino-mega2560"], git = "https://github.com/taiki-e/avr-hal.git", rev = "352567e" }

[lints]
workspace = true

[workspace]
resolver = "2"

[lints.rust]
# This table is shared by projects under github.com/taiki-e.
# Expect for unexpected_cfgs.check-cfg, it is not intended for manual editing.
[workspace.lints.rust]
deprecated_safe = "warn"
improper_ctypes = "warn"
improper_ctypes_definitions = "warn"
non_ascii_idents = "warn"
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(qemu)',
] }
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV
[lints.clippy]
# unnameable_types = "warn"
# unreachable_pub = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 merged in Rust 1.65 is not available on MSRV
[workspace.lints.clippy]
all = "warn" # Downgrade deny-by-default lints
pedantic = "warn"
as_ptr_cast_mut = "warn"
as_underscore = "warn"
default_union_representation = "warn"
inline_asm_x86_att_syntax = "warn"
trailing_empty_array = "warn"
transmute_undefined_repr = "warn"
undocumented_unsafe_blocks = "warn"
unused_trait_names = "warn"
# Suppress buggy or noisy clippy lints
bool_assert_comparison = { level = "allow", priority = 1 }
borrow_as_ptr = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/8286
cast_lossless = { level = "allow", priority = 1 } # https://godbolt.org/z/Pv6vbGG6E
declare_interior_mutable_const = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7665
doc_markdown = { level = "allow", priority = 1 }
float_cmp = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7725
incompatible_msrv = { level = "allow", priority = 1 } # buggy: doesn't consider cfg, https://github.com/rust-lang/rust-clippy/issues/12280, https://github.com/rust-lang/rust-clippy/issues/12257#issuecomment-2093667187
lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12920
manual_assert = { level = "allow", priority = 1 }
manual_range_contains = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/6455#issuecomment-1225966395
missing_errors_doc = { level = "allow", priority = 1 }
module_name_repetitions = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+module_name_repetitions
naive_bytecount = { level = "allow", priority = 1 }
nonminimal_bool = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+nonminimal_bool
range_plus_one = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+range_plus_one
similar_names = { level = "allow", priority = 1 }
single_match = { level = "allow", priority = 1 }
single_match_else = { level = "allow", priority = 1 }
struct_excessive_bools = { level = "allow", priority = 1 }
struct_field_names = { level = "allow", priority = 1 }
too_many_arguments = { level = "allow", priority = 1 }
too_many_lines = { level = "allow", priority = 1 }
type_complexity = { level = "allow", priority = 1 }
unreadable_literal = { level = "allow", priority = 1 }

[profile.dev]
lto = true
Expand Down
1 change: 1 addition & 0 deletions tests/avr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![no_main]
#![no_std]
#![warn(unsafe_op_in_unsafe_fn)]
#![allow(clippy::undocumented_unsafe_blocks, clippy::wildcard_imports)]

#[macro_use]
#[path = "../../api-test/src/helper.rs"]
Expand Down
54 changes: 51 additions & 3 deletions tests/gba/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "gba-test"
version = "0.0.0"
edition = "2021"
rust-version = "1.64" # Prevent clippy from suggesting a code that requires a new version.
publish = false

[dependencies]
Expand All @@ -10,15 +11,62 @@ portable-atomic = { path = "../..", features = ["float"] }
gba = "0.14"
paste = "1"

[lints]
workspace = true

[workspace]
resolver = "2"

[lints.rust]
# This table is shared by projects under github.com/taiki-e.
# Expect for unexpected_cfgs.check-cfg, it is not intended for manual editing.
[workspace.lints.rust]
deprecated_safe = "warn"
improper_ctypes = "warn"
improper_ctypes_definitions = "warn"
non_ascii_idents = "warn"
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV
[lints.clippy]
unexpected_cfgs = { level = "warn", check-cfg = [
] }
# unnameable_types = "warn"
# unreachable_pub = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 merged in Rust 1.65 is not available on MSRV
[workspace.lints.clippy]
all = "warn" # Downgrade deny-by-default lints
pedantic = "warn"
as_ptr_cast_mut = "warn"
as_underscore = "warn"
default_union_representation = "warn"
inline_asm_x86_att_syntax = "warn"
trailing_empty_array = "warn"
transmute_undefined_repr = "warn"
undocumented_unsafe_blocks = "warn"
unused_trait_names = "warn"
# Suppress buggy or noisy clippy lints
bool_assert_comparison = { level = "allow", priority = 1 }
borrow_as_ptr = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/8286
cast_lossless = { level = "allow", priority = 1 } # https://godbolt.org/z/Pv6vbGG6E
declare_interior_mutable_const = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7665
doc_markdown = { level = "allow", priority = 1 }
float_cmp = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7725
incompatible_msrv = { level = "allow", priority = 1 } # buggy: doesn't consider cfg, https://github.com/rust-lang/rust-clippy/issues/12280, https://github.com/rust-lang/rust-clippy/issues/12257#issuecomment-2093667187
lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12920
manual_assert = { level = "allow", priority = 1 }
manual_range_contains = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/6455#issuecomment-1225966395
missing_errors_doc = { level = "allow", priority = 1 }
module_name_repetitions = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+module_name_repetitions
naive_bytecount = { level = "allow", priority = 1 }
nonminimal_bool = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+nonminimal_bool
range_plus_one = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+range_plus_one
similar_names = { level = "allow", priority = 1 }
single_match = { level = "allow", priority = 1 }
single_match_else = { level = "allow", priority = 1 }
struct_excessive_bools = { level = "allow", priority = 1 }
struct_field_names = { level = "allow", priority = 1 }
too_many_arguments = { level = "allow", priority = 1 }
too_many_lines = { level = "allow", priority = 1 }
type_complexity = { level = "allow", priority = 1 }
unreadable_literal = { level = "allow", priority = 1 }

[profile.dev]
# TODO: "GBA: Illegal opcode: e7ffdefe" on opt-level=0, GBA hang on opt-level={1,s,z}
Expand Down
1 change: 1 addition & 0 deletions tests/gba/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![no_main]
#![no_std]
#![warn(unsafe_op_in_unsafe_fn)]
#![allow(clippy::wildcard_imports)]

#[macro_use]
#[path = "../../api-test/src/helper.rs"]
Expand Down
54 changes: 51 additions & 3 deletions tests/msp430/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "msp430-test"
version = "0.0.0"
edition = "2021"
rust-version = "1.64" # Prevent clippy from suggesting a code that requires a new version.
publish = false

[features]
Expand Down Expand Up @@ -32,15 +33,62 @@ msp430f5529 = { features = ["rt"], git = "https://github.com/cr1901/msp430f5529.
paste = "1"
ufmt = "0.2"

[lints]
workspace = true

[workspace]
resolver = "2"

[lints.rust]
# This table is shared by projects under github.com/taiki-e.
# Expect for unexpected_cfgs.check-cfg, it is not intended for manual editing.
[workspace.lints.rust]
deprecated_safe = "warn"
improper_ctypes = "warn"
improper_ctypes_definitions = "warn"
non_ascii_idents = "warn"
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV
[lints.clippy]
unexpected_cfgs = { level = "warn", check-cfg = [
] }
# unnameable_types = "warn"
# unreachable_pub = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 merged in Rust 1.65 is not available on MSRV
[workspace.lints.clippy]
all = "warn" # Downgrade deny-by-default lints
pedantic = "warn"
as_ptr_cast_mut = "warn"
as_underscore = "warn"
default_union_representation = "warn"
inline_asm_x86_att_syntax = "warn"
trailing_empty_array = "warn"
transmute_undefined_repr = "warn"
undocumented_unsafe_blocks = "warn"
unused_trait_names = "warn"
# Suppress buggy or noisy clippy lints
bool_assert_comparison = { level = "allow", priority = 1 }
borrow_as_ptr = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/8286
cast_lossless = { level = "allow", priority = 1 } # https://godbolt.org/z/Pv6vbGG6E
declare_interior_mutable_const = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7665
doc_markdown = { level = "allow", priority = 1 }
float_cmp = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7725
incompatible_msrv = { level = "allow", priority = 1 } # buggy: doesn't consider cfg, https://github.com/rust-lang/rust-clippy/issues/12280, https://github.com/rust-lang/rust-clippy/issues/12257#issuecomment-2093667187
lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12920
manual_assert = { level = "allow", priority = 1 }
manual_range_contains = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/6455#issuecomment-1225966395
missing_errors_doc = { level = "allow", priority = 1 }
module_name_repetitions = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+module_name_repetitions
naive_bytecount = { level = "allow", priority = 1 }
nonminimal_bool = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+nonminimal_bool
range_plus_one = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+range_plus_one
similar_names = { level = "allow", priority = 1 }
single_match = { level = "allow", priority = 1 }
single_match_else = { level = "allow", priority = 1 }
struct_excessive_bools = { level = "allow", priority = 1 }
struct_field_names = { level = "allow", priority = 1 }
too_many_arguments = { level = "allow", priority = 1 }
too_many_lines = { level = "allow", priority = 1 }
type_complexity = { level = "allow", priority = 1 }
unreadable_literal = { level = "allow", priority = 1 }

[profile.dev]
codegen-units = 1
Expand Down
17 changes: 8 additions & 9 deletions tests/msp430/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![no_main]
#![no_std]
#![warn(unsafe_op_in_unsafe_fn)]
#![allow(clippy::undocumented_unsafe_blocks, clippy::wildcard_imports)]

#[macro_use]
#[path = "../../api-test/src/helper.rs"]
Expand Down Expand Up @@ -147,25 +148,23 @@ mod simio {
use core::{convert::Infallible, fmt};

pub struct Console;
impl Console {
fn write_str(&mut self, s: &str) {
// https://github.com/dlbeer/mspdebug/blob/v0.25/simio/simio_console.c#L130
let addr = 0x00FF_usize as *mut u8;
for &b in s.as_bytes() {
unsafe { addr.write_volatile(b) }
}
fn write_str(s: &str) {
// https://github.com/dlbeer/mspdebug/blob/v0.25/simio/simio_console.c#L130
let addr = 0x00FF_usize as *mut u8;
for &b in s.as_bytes() {
unsafe { addr.write_volatile(b) }
}
}
impl ufmt::uWrite for Console {
type Error = Infallible;
fn write_str(&mut self, s: &str) -> Result<(), Self::Error> {
self.write_str(s);
write_str(s);
Ok(())
}
}
impl fmt::Write for Console {
fn write_str(&mut self, s: &str) -> fmt::Result {
self.write_str(s);
write_str(s);
Ok(())
}
}
Expand Down
53 changes: 50 additions & 3 deletions tests/no-std-qemu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "no-std-qemu-test"
version = "0.0.0"
edition = "2021"
rust-version = "1.64" # Prevent clippy from suggesting a code that requires a new version.
publish = false

[dependencies]
Expand All @@ -11,16 +12,62 @@ paste = "1"
semihosting = { version = "0.1", features = ["stdio", "panic-handler"] }
semihosting-no-std-test-rt = { features = ["qemu-system"], git = "https://github.com/taiki-e/semihosting.git", rev = "3874a1e" }

[lints]
workspace = true

[workspace]
resolver = "2"

[lints.rust]
# This table is shared by projects under github.com/taiki-e.
# Expect for unexpected_cfgs.check-cfg, it is not intended for manual editing.
[workspace.lints.rust]
deprecated_safe = "warn"
improper_ctypes = "warn"
improper_ctypes_definitions = "warn"
non_ascii_idents = "warn"
rust_2018_idioms = "warn"
single_use_lifetimes = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 is not available on MSRV
[lints.clippy]
unexpected_cfgs = { level = "warn", check-cfg = [
] }
# unnameable_types = "warn"
# unreachable_pub = "warn"
# unsafe_op_in_unsafe_fn = "warn" # Set at crate-level instead since https://github.com/rust-lang/rust/pull/100081 merged in Rust 1.65 is not available on MSRV
[workspace.lints.clippy]
all = "warn" # Downgrade deny-by-default lints
pedantic = "warn"
as_ptr_cast_mut = "warn"
as_underscore = "warn"
default_union_representation = "warn"
inline_asm_x86_att_syntax = "warn"
trailing_empty_array = "warn"
transmute_undefined_repr = "warn"
undocumented_unsafe_blocks = "warn"
unused_trait_names = "warn"
# Suppress buggy or noisy clippy lints
bool_assert_comparison = { level = "allow", priority = 1 }
borrow_as_ptr = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/8286
cast_lossless = { level = "allow", priority = 1 } # https://godbolt.org/z/Pv6vbGG6E
declare_interior_mutable_const = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7665
doc_markdown = { level = "allow", priority = 1 }
float_cmp = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/7725
incompatible_msrv = { level = "allow", priority = 1 } # buggy: doesn't consider cfg, https://github.com/rust-lang/rust-clippy/issues/12280, https://github.com/rust-lang/rust-clippy/issues/12257#issuecomment-2093667187
lint_groups_priority = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/12920
manual_assert = { level = "allow", priority = 1 }
manual_range_contains = { level = "allow", priority = 1 } # https://github.com/rust-lang/rust-clippy/issues/6455#issuecomment-1225966395
missing_errors_doc = { level = "allow", priority = 1 }
module_name_repetitions = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+module_name_repetitions
naive_bytecount = { level = "allow", priority = 1 }
nonminimal_bool = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+nonminimal_bool
range_plus_one = { level = "allow", priority = 1 } # buggy: https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+range_plus_one
similar_names = { level = "allow", priority = 1 }
single_match = { level = "allow", priority = 1 }
single_match_else = { level = "allow", priority = 1 }
struct_excessive_bools = { level = "allow", priority = 1 }
struct_field_names = { level = "allow", priority = 1 }
too_many_arguments = { level = "allow", priority = 1 }
too_many_lines = { level = "allow", priority = 1 }
type_complexity = { level = "allow", priority = 1 }
unreadable_literal = { level = "allow", priority = 1 }

[profile.dev]
opt-level = "s"
Expand Down
1 change: 1 addition & 0 deletions tests/no-std-qemu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![no_main]
#![no_std]
#![warn(unsafe_op_in_unsafe_fn)]
#![allow(clippy::wildcard_imports)]

#[macro_use]
#[path = "../../api-test/src/helper.rs"]
Expand Down
Loading

0 comments on commit 52836df

Please sign in to comment.