Skip to content

Commit

Permalink
Merge #739
Browse files Browse the repository at this point in the history
739: Clean `xtask` r=Urhengulas a=Urhengulas

This PR
- makes `xtask test-lint` fail if a warning is present
- runs `clippy` in the `firmware/` directory
- remove unnecessary `--workspace` options
- fixes clippy lints

Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
  • Loading branch information
bors[bot] and Urhengulas authored Mar 10, 2023
2 parents ce767b4 + cc6ef15 commit 62fd76c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 53 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- [#739]: `xtask`: Clean up
- [#737]: `panic-probe`: Add `hard_fault()` for use in `defmt::panic_handler`
- [#733]: `defmt`: Add formatting for `core::net` with the `ip_in_core` feature
- [#603]: `defmt`: Raw pointers now print as `0x1234` instead of `1234`
- [#536]: `defmt-parser`: Switch to using an enum for errors, and add some help text pointing you to the defmt docs if you use the wrong type specifier in a format string.

[#739]: https://github.com/knurling-rs/defmt/pull/739
[#737]: https://github.com/knurling-rs/defmt/pull/737
[#733]: https://github.com/knurling-rs/defmt/pull/733
[#603]: https://github.com/knurling-rs/defmt/pull/734
Expand Down
2 changes: 1 addition & 1 deletion parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ where
}
}

pub fn parse<'f>(format_string: &'f str, mode: ParserMode) -> Result<Vec<Fragment<'f>>, Error> {
pub fn parse(format_string: &str, mode: ParserMode) -> Result<Vec<Fragment<'_>>, Error> {
let mut fragments = Vec::new();

// Index after the `}` of the last format specifier.
Expand Down
10 changes: 2 additions & 8 deletions parser/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{ops::Range, str::FromStr};

#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub enum Type {
BitField(Range<u8>),
Bool,
Expand All @@ -15,6 +15,7 @@ pub enum Type {
F64,

/// `{=?}` OR `{}`
#[default] // when not specified in the format string, this type is assumed
Format,
FormatArray(usize), // FIXME: This `usize` is not the target's `usize`; use `u64` instead?
/// `{=[?]}`
Expand Down Expand Up @@ -78,10 +79,3 @@ impl FromStr for Type {
})
}
}

// when not specified in the format string, this type is assumed
impl Default for Type {
fn default() -> Self {
Type::Format
}
}
2 changes: 2 additions & 0 deletions print/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ fn main() -> anyhow::Result<()> {
false => return Err(DecodeError::Malformed.into()),
// if recovery is possible, skip the current frame and continue with new data
true => {
// bug: https://github.com/rust-lang/rust-clippy/issues/9810
#[allow(clippy::print_literal)]
if show_skipped_frames || verbose {
println!("(HOST) malformed frame skipped");
println!("└─ {} @ {}:{}", env!("CARGO_PKG_NAME"), file!(), line!());
Expand Down
73 changes: 29 additions & 44 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,56 +150,25 @@ fn test_host(deny_warnings: bool) {
vec![]
};

do_test(
|| run_command("cargo", &["check", "--workspace"], None, &env),
"host",
);
do_test(|| run_command("cargo", &["check"], None, &env), "host");

do_test(
|| {
run_command(
"cargo",
&["check", "--workspace", "--features", "unstable-test"],
None,
&env,
)
},
|| run_command("cargo", &["check", "--features", "unstable-test"], None, &env),
"host",
);

do_test(
|| {
run_command(
"cargo",
&["check", "--workspace", "--features", "alloc"],
None,
&env,
)
},
|| run_command("cargo", &["check", "--features", "alloc"], None, &env),
"host",
);

do_test(
|| {
run_command(
"cargo",
&["test", "--workspace", "--features", "unstable-test"],
None,
&[],
)
},
|| run_command("cargo", &["test", "--features", "unstable-test"], None, &[]),
"host",
);

do_test(
|| {
run_command(
"cargo",
&["test", "--workspace", "--features", "unstable-test,alloc"],
None,
&[],
)
},
|| run_command("cargo", &["test", "--features", "unstable-test,alloc"], None, &[]),
"host",
);
}
Expand Down Expand Up @@ -255,7 +224,7 @@ fn test_cross() {
|| {
run_command(
"cargo",
&["check", "--target", "thumbv7em-none-eabi", "--workspace"],
&["check", "--target", "thumbv7em-none-eabi"],
Some("firmware"),
&[],
)
Expand Down Expand Up @@ -297,7 +266,19 @@ fn test_cross() {
)
},
"cross",
)
);

do_test(
|| {
run_command(
"cargo",
&["clippy", "--target", "thumbv7m-none-eabi", "--", "-D", "warnings"],
Some("firmware/"),
&[],
)
},
"lint",
);
}

fn test_snapshot(overwrite: bool, snapshot: Option<Snapshot>) {
Expand Down Expand Up @@ -441,14 +422,18 @@ fn test_book() {

fn test_lint() {
println!("🧪 lint");
do_test(|| run_command("cargo", &["clean"], None, &[]), "lint");
do_test(
|| run_command("cargo", &["fmt", "--all", "--", "--check"], None, &[]),
"lint",
);

// rustfmt
for cwd in [None, Some("firmware/")] {
do_test(
|| run_command("cargo", &["fmt", "--", "--check"], cwd, &[]),
"lint",
);
}

// clippy
do_test(
|| run_command("cargo", &["clippy", "--workspace"], None, &[]),
|| run_command("cargo", &["clippy", "--", "-D", "warnings"], None, &[]),
"lint",
);
}
Expand Down

0 comments on commit 62fd76c

Please sign in to comment.