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 b570d5c
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 21 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: 48 additions & 4 deletions tests/avr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,62 @@ 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
5 changes: 3 additions & 2 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 Expand Up @@ -129,7 +130,7 @@ mod sim {

use arduino_hal::avr_device;

pub fn exit(_code: u32) -> ! {
pub(crate) fn exit(_code: u32) -> ! {
// Note that there is no way to exit simavr with a non-zero exit code.
// https://github.com/buserror/simavr/issues/362
avr_device::interrupt::disable();
Expand All @@ -138,7 +139,7 @@ mod sim {
loop {}
}

pub struct Usart<USART, RX, TX>(pub arduino_hal::usart::Usart<USART, RX, TX>)
pub(crate) struct Usart<USART, RX, TX>(pub(crate) arduino_hal::usart::Usart<USART, RX, TX>)
where
USART: arduino_hal::usart::UsartOps<arduino_hal::hal::Atmega, RX, TX>;
impl<USART, RX, TX> fmt::Write for Usart<USART, RX, TX>
Expand Down
53 changes: 50 additions & 3 deletions tests/gba/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,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
53 changes: 50 additions & 3 deletions tests/msp430/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,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
3 changes: 2 additions & 1 deletion 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 @@ -146,7 +147,7 @@ extern "C" fn abort() -> ! {
mod simio {
use core::{convert::Infallible, fmt};

pub struct Console;
pub(crate) struct Console;
impl Console {
fn write_str(&mut self, s: &str) {
// https://github.com/dlbeer/mspdebug/blob/v0.25/simio/simio_console.c#L130
Expand Down
52 changes: 49 additions & 3 deletions tests/no-std-qemu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,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 b570d5c

Please sign in to comment.