From 6529a84799f70884e2fc64667d2bc0ca6e6250d3 Mon Sep 17 00:00:00 2001 From: Alexander Koz Date: Sat, 13 Jul 2024 11:46:46 +0400 Subject: [PATCH] fix const_trait usage, CI fixes, fmt, because some nightly rustfmt fixes --- .github/workflows/tests.yml | 30 ++------ Cargo.lock | 26 +++---- api/color/Cargo.toml | 2 +- api/color/src/lib.rs | 50 +++++++++---- api/ctrl/Cargo.toml | 2 +- api/ctrl/src/buttons.rs | 2 +- api/ctrl/src/peripherals.rs | 4 +- api/fs/Cargo.toml | 2 +- api/fs/src/lib.rs | 1 - api/fs/src/options.rs | 4 +- api/gfx/Cargo.toml | 2 +- api/gfx/src/lib.rs | 1 - api/lua/Cargo.toml | 2 +- api/lua/src/lib.rs | 1 - api/menu/Cargo.toml | 2 +- api/menu/src/lib.rs | 1 - api/playdate/Cargo.toml | 2 +- api/scoreboards/Cargo.toml | 2 +- api/scoreboards/src/lib.rs | 1 - api/sound/Cargo.toml | 2 +- api/sound/src/lib.rs | 1 - api/sys/README.md | 2 +- api/sys/src/lib.rs | 1 - cargo/Cargo.toml | 2 +- cargo/src/build/mod.rs | 121 ++++++++++++++++---------------- cargo/src/config.rs | 13 ++-- cargo/src/init/mod.rs | 7 +- cargo/src/package/mod.rs | 2 +- support/device/Cargo.toml | 2 +- support/device/src/mount/win.rs | 16 ++--- support/device/src/usb/mod.rs | 9 +-- 31 files changed, 157 insertions(+), 158 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 75d1d6e9..0a4c8e5e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -475,31 +475,11 @@ jobs: - name: Check id: check - continue-on-error: true - run: >- - cargo fmt --all -- --check || - (echo "::error::Rust format error." && exit 1) - - - name: Format - id: format - if: steps.check.outcome == 'failure' - run: cargo fmt --all - - - name: Suggestions - uses: reviewdog/action-suggester@v1 - with: - filter_mode: diff_context - fail_on_error: false - tool_name: Rustfmt - cleanup: false - - - name: Post Check - if: steps.check.outcome == 'failure' - run: exit 1 + run: cargo fmt --all -- --check clippy: - name: Clippy - if: github.event_name == 'pull_request' + name: Clippy + fmt suggestions + if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' defaults: run: shell: bash @@ -521,7 +501,6 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ inputs.ref || github.ref }} - # fetch-depth: 2 - name: Install Clippy run: rustup component add clippy @@ -557,7 +536,6 @@ jobs: -p=playdate-tool --bins --examples --all-targets -- -Aclippy::cargo - || (echo "::error::Rust format error." && exit 1) # needed after clippy fix - name: fmt @@ -572,6 +550,6 @@ jobs: with: filter_mode: diff_context fail_on_error: false - tool_name: Clippy + tool_name: Clippy & fmt cleanup: false diff --git a/Cargo.lock b/Cargo.lock index c90b0025..9e58f442 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,7 +729,7 @@ dependencies = [ [[package]] name = "cargo-playdate" -version = "0.5.0" +version = "0.5.1" dependencies = [ "anstyle", "anyhow", @@ -805,9 +805,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "907d8581360765417f8f2e0e7d602733bbed60156b4465b7617243689ef9b83d" +checksum = "47de7e88bbbd467951ae7f5a6f34f70d1b4d9cfce53d5fd70f74ebe118b3db56" dependencies = [ "jobserver", "libc", @@ -4020,7 +4020,7 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] name = "playdate" -version = "0.2.1" +version = "0.2.2" dependencies = [ "playdate-controls", "playdate-display", @@ -4090,14 +4090,14 @@ dependencies = [ [[package]] name = "playdate-color" -version = "0.2.4" +version = "0.2.5" dependencies = [ "playdate-sys", ] [[package]] name = "playdate-controls" -version = "0.3.5" +version = "0.3.6" dependencies = [ "playdate-display", "playdate-graphics", @@ -4107,7 +4107,7 @@ dependencies = [ [[package]] name = "playdate-device" -version = "0.2.12" +version = "0.2.13" dependencies = [ "async-std", "clap", @@ -4144,7 +4144,7 @@ dependencies = [ [[package]] name = "playdate-fs" -version = "0.2.8" +version = "0.2.9" dependencies = [ "playdate-sys", "playdate-system", @@ -4152,7 +4152,7 @@ dependencies = [ [[package]] name = "playdate-graphics" -version = "0.4.0" +version = "0.4.1" dependencies = [ "playdate-color", "playdate-display", @@ -4163,7 +4163,7 @@ dependencies = [ [[package]] name = "playdate-lua" -version = "0.1.1" +version = "0.1.2" dependencies = [ "playdate-sys", "playdate-system", @@ -4171,7 +4171,7 @@ dependencies = [ [[package]] name = "playdate-menu" -version = "0.2.4" +version = "0.2.5" dependencies = [ "playdate-graphics", "playdate-sys", @@ -4180,7 +4180,7 @@ dependencies = [ [[package]] name = "playdate-scoreboards" -version = "0.1.2" +version = "0.1.3" dependencies = [ "erased_set", "playdate-sys", @@ -4201,7 +4201,7 @@ dependencies = [ [[package]] name = "playdate-sound" -version = "0.4.1" +version = "0.4.2" dependencies = [ "playdate-fs", "playdate-graphics", diff --git a/api/color/Cargo.toml b/api/color/Cargo.toml index 8c255531..22934d7a 100644 --- a/api/color/Cargo.toml +++ b/api/color/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-color" -version = "0.2.4" +version = "0.2.5" readme = "README.md" description = "Color extension for Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/color/src/lib.rs b/api/color/src/lib.rs index 4b910613..c6b62108 100644 --- a/api/color/src/lib.rs +++ b/api/color/src/lib.rs @@ -46,10 +46,10 @@ impl<'t> TryFrom for Color<'t> fn try_from(color: LCDColor) -> Result { match color { - 0 => Ok(Self::Solid(LCDSolidColor::Black())), - 1 => Ok(Self::Solid(LCDSolidColor::White())), - 2 => Ok(Self::Solid(LCDSolidColor::Clear())), - 3 => Ok(Self::Solid(LCDSolidColor::XOR())), + 0 => Ok(Self::Solid(LCDSolidColor::BLACK)), + 1 => Ok(Self::Solid(LCDSolidColor::WHITE)), + 2 => Ok(Self::Solid(LCDSolidColor::CLEAR)), + 3 => Ok(Self::Solid(::XOR)), color => { NonNull::new(color as *mut LCDPattern).ok_or(NullPtrError) .map(|nn| Self::Pattern(unsafe { nn.as_ref() })) @@ -63,7 +63,8 @@ impl<'t> From<&'t LCDPattern> for Color<'t> { } -#[const_trait] +// TODO: LCDColorExt should be const_trait +#[deprecated = "Useless until const_trait is experimental and incomplete. Use LCDColorConst instead."] pub trait LCDColorExt { #![allow(non_snake_case)] fn White() -> Self; @@ -72,7 +73,8 @@ pub trait LCDColorExt { fn XOR() -> Self; } -impl const LCDColorExt for LCDColor { +#[allow(deprecated)] +impl LCDColorExt for LCDColor { #![allow(non_snake_case)] fn White() -> Self { LCDSolidColor::kColorWhite as Self } fn Black() -> Self { LCDSolidColor::kColorBlack as Self } @@ -80,7 +82,8 @@ impl const LCDColorExt for LCDColor { fn XOR() -> Self { LCDSolidColor::kColorXOR as Self } } -impl const LCDColorExt for LCDSolidColor { +#[allow(deprecated)] +impl LCDColorExt for LCDSolidColor { #![allow(non_snake_case)] fn White() -> Self { LCDSolidColor::kColorWhite } fn Black() -> Self { LCDSolidColor::kColorBlack } @@ -88,14 +91,35 @@ impl const LCDColorExt for LCDSolidColor { fn XOR() -> Self { LCDSolidColor::kColorXOR } } +pub trait LCDColorConst { + const WHITE: Self; + const BLACK: Self; + const CLEAR: Self; + const XOR: Self; +} + +impl LCDColorConst for LCDColor { + const WHITE: Self = LCDSolidColor::kColorWhite as Self; + const BLACK: Self = LCDSolidColor::kColorBlack as Self; + const CLEAR: Self = LCDSolidColor::kColorClear as Self; + const XOR: Self = LCDSolidColor::kColorXOR as Self; +} + +impl LCDColorConst for LCDSolidColor { + const WHITE: Self = LCDSolidColor::kColorWhite as Self; + const BLACK: Self = LCDSolidColor::kColorBlack as Self; + const CLEAR: Self = LCDSolidColor::kColorClear as Self; + const XOR: Self = LCDSolidColor::kColorXOR as Self; +} + -#[const_trait] +// TODO: LCDColorIs should be const_trait pub trait LCDColorIs { fn is_solid(&self) -> bool; fn is_pattern(&self) -> bool; } -impl const LCDColorIs for LCDColor { +impl LCDColorIs for LCDColor { fn is_solid(&self) -> bool { let color = *self as usize; color >= LCDSolidColor::kColorBlack as _ && color <= LCDSolidColor::kColorXOR as _ @@ -104,12 +128,12 @@ impl const LCDColorIs for LCDColor { } -#[const_trait] +// TODO: IntoLCDColor should be const_trait pub trait IntoLCDColor { fn into_color(self) -> LCDColor; } -impl const IntoLCDColor for LCDSolidColor { +impl IntoLCDColor for LCDSolidColor { fn into_color(self) -> LCDColor { self as LCDColor } } @@ -119,13 +143,13 @@ impl<'t> IntoLCDColor for &'t LCDPattern where LCDColor: 't { } -#[const_trait] +// TODO: LCDColorFmt should be const_trait pub trait LCDColorFmt<'t> { type Display: 't + core::fmt::Debug + core::fmt::Display; fn display(&'t self) -> Self::Display; } -impl<'t> const LCDColorFmt<'t> for LCDSolidColor { +impl<'t> LCDColorFmt<'t> for LCDSolidColor { type Display = LCDColorDisplay<'t, Self>; fn display(&self) -> LCDColorDisplay<'_, Self> { LCDColorDisplay(self) } } diff --git a/api/ctrl/Cargo.toml b/api/ctrl/Cargo.toml index 16b6cd5c..55f1454d 100644 --- a/api/ctrl/Cargo.toml +++ b/api/ctrl/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-controls" -version = "0.3.5" +version = "0.3.6" readme = "README.md" description = "High-level controls API built on-top of Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/ctrl/src/buttons.rs b/api/ctrl/src/buttons.rs index 9f4bb131..1655bf36 100644 --- a/api/ctrl/src/buttons.rs +++ b/api/ctrl/src/buttons.rs @@ -58,7 +58,7 @@ pub trait PDButtonsExt: Sized + BitAnd { } -impl const PDButtonsExt for PDButtons { +impl PDButtonsExt for PDButtons { #![allow(non_snake_case)] #[inline(always)] diff --git a/api/ctrl/src/peripherals.rs b/api/ctrl/src/peripherals.rs index 14624dfd..38a7c44d 100644 --- a/api/ctrl/src/peripherals.rs +++ b/api/ctrl/src/peripherals.rs @@ -86,7 +86,7 @@ impl Peripherals { } -#[const_trait] +// TODO: SystemExt should be const_trait pub trait SystemExt { fn peripherals(&self) -> Peripherals; fn accelerometer(&self) -> Accelerometer; @@ -94,7 +94,7 @@ pub trait SystemExt { fn crank(&self) -> Crank; } -impl const SystemExt for system::System { +impl SystemExt for system::System { fn peripherals(&self) -> Peripherals { Peripherals::new_with(self.inner()) } fn accelerometer(&self) -> Accelerometer { Accelerometer::new_with(self.inner()) } fn buttons(&self) -> Buttons { Buttons::new_with(self.inner()) } diff --git a/api/fs/Cargo.toml b/api/fs/Cargo.toml index 0678b53f..ab46e049 100644 --- a/api/fs/Cargo.toml +++ b/api/fs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-fs" -version = "0.2.8" +version = "0.2.9" readme = "README.md" description = "High-level file-system API built on-top of Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/fs/src/lib.rs b/api/fs/src/lib.rs index 8dfdac81..41eb4762 100644 --- a/api/fs/src/lib.rs +++ b/api/fs/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(test), no_std)] -#![feature(error_in_core)] #![feature(const_trait_impl)] #[macro_use] diff --git a/api/fs/src/options.rs b/api/fs/src/options.rs index 5626351f..874cf79f 100644 --- a/api/fs/src/options.rs +++ b/api/fs/src/options.rs @@ -7,7 +7,7 @@ use crate::error::ApiError; /// Extension for [`sys::ffi::FileOptions`] make it looks like [`std::fs::OpenOptions`]. -#[const_trait] +// TODO: FileOptionsExt should be const_trait pub trait FileOptionsExt: Into { /// Creates new empty file options. fn new() -> Self; @@ -55,7 +55,7 @@ impl OpenOptions for FileOptions { } -impl const FileOptionsExt for FileOptions { +impl FileOptionsExt for FileOptions { fn new() -> Self { FileOptions(0) } /// Read access to Game’s package (bundle) directory. diff --git a/api/gfx/Cargo.toml b/api/gfx/Cargo.toml index 797d1ca0..b032e9ec 100644 --- a/api/gfx/Cargo.toml +++ b/api/gfx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-graphics" -version = "0.4.0" +version = "0.4.1" readme = "README.md" description = "High-level graphics API built on-top of Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/gfx/src/lib.rs b/api/gfx/src/lib.rs index 9fe6f18f..b44e1366 100644 --- a/api/gfx/src/lib.rs +++ b/api/gfx/src/lib.rs @@ -1,6 +1,5 @@ //! Playdate graphics API #![cfg_attr(not(test), no_std)] -#![feature(error_in_core)] extern crate sys; extern crate alloc; diff --git a/api/lua/Cargo.toml b/api/lua/Cargo.toml index 23630f93..979daa22 100644 --- a/api/lua/Cargo.toml +++ b/api/lua/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-lua" -version = "0.1.1" +version = "0.1.2" readme = "README.md" description = "High-level Lua API built on-top of Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/lua/src/lib.rs b/api/lua/src/lib.rs index 79fc4f3f..3a33d7c2 100644 --- a/api/lua/src/lib.rs +++ b/api/lua/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(test), no_std)] -#![feature(error_in_core)] // #[macro_use] extern crate sys; diff --git a/api/menu/Cargo.toml b/api/menu/Cargo.toml index 6e513841..59d2e4c5 100644 --- a/api/menu/Cargo.toml +++ b/api/menu/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-menu" -version = "0.2.4" +version = "0.2.5" readme = "README.md" description = "High-level system menu API built on-top of Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/menu/src/lib.rs b/api/menu/src/lib.rs index d79b1137..8789a2e4 100644 --- a/api/menu/src/lib.rs +++ b/api/menu/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(test), no_std)] -#![feature(error_in_core)] #[macro_use] extern crate sys; diff --git a/api/playdate/Cargo.toml b/api/playdate/Cargo.toml index c0697f91..af486b37 100644 --- a/api/playdate/Cargo.toml +++ b/api/playdate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate" -version = "0.2.1" +version = "0.2.2" readme = "README.md" description = "High-level Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/scoreboards/Cargo.toml b/api/scoreboards/Cargo.toml index 4040c8af..936f692a 100644 --- a/api/scoreboards/Cargo.toml +++ b/api/scoreboards/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-scoreboards" -version = "0.1.2" +version = "0.1.3" readme = "README.md" description = "High-level Scoreboards API built on-top of Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/scoreboards/src/lib.rs b/api/scoreboards/src/lib.rs index 1dac4125..82f51ca2 100644 --- a/api/scoreboards/src/lib.rs +++ b/api/scoreboards/src/lib.rs @@ -4,7 +4,6 @@ //! [Official documentation](https://help.play.date/catalog-developer/scoreboard-api/#c-api-reference). #![cfg_attr(not(test), no_std)] -#![feature(error_in_core)] #[macro_use] extern crate sys; diff --git a/api/sound/Cargo.toml b/api/sound/Cargo.toml index ff7f8439..f9bdf8d6 100644 --- a/api/sound/Cargo.toml +++ b/api/sound/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-sound" -version = "0.4.1" +version = "0.4.2" readme = "README.md" description = "High-level sound API built on-top of Playdate API" keywords = ["playdate", "sdk", "api", "gamedev"] diff --git a/api/sound/src/lib.rs b/api/sound/src/lib.rs index bacd5db2..2bad57c6 100644 --- a/api/sound/src/lib.rs +++ b/api/sound/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(test), no_std)] -#![feature(error_in_core)] #![feature(const_trait_impl)] use core::ffi::c_int; diff --git a/api/sys/README.md b/api/sys/README.md index f1dd194a..1ecf5117 100644 --- a/api/sys/README.md +++ b/api/sys/README.md @@ -23,7 +23,7 @@ _I've experimented enough with wrapping the entire API with results at every ste ## Prerequisites -MNRV is [`1.81.0` from 2024-06-29][rust-toolchain.toml] +MNRV is [`1.81.0` from 2024-06-30][rust-toolchain.toml] 1. Rust __nightly__ toolchain (rustup is optional) 1. [Playdate SDK][sdk] diff --git a/api/sys/src/lib.rs b/api/sys/src/lib.rs index 72c29cea..035a721e 100644 --- a/api/sys/src/lib.rs +++ b/api/sys/src/lib.rs @@ -11,7 +11,6 @@ #![cfg_attr(feature = "allocator", feature(allocator_api))] #![cfg_attr(feature = "allocator", feature(alloc_layout_extra))] // error -#![feature(error_in_core)] #![cfg_attr(feature = "try-trait-v2", feature(try_trait_v2))] // experimental features #![cfg_attr(feature = "bindings-derive-constparamty", diff --git a/cargo/Cargo.toml b/cargo/Cargo.toml index 1d6c5745..4c316562 100644 --- a/cargo/Cargo.toml +++ b/cargo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-playdate" -version = "0.5.0" +version = "0.5.1" readme = "README.md" description = "Build tool for neat yellow console." keywords = ["playdate", "build", "cargo", "plugin", "cargo-subcommand"] diff --git a/cargo/src/build/mod.rs b/cargo/src/build/mod.rs index a5bf89b1..aa363341 100644 --- a/cargo/src/build/mod.rs +++ b/cargo/src/build/mod.rs @@ -210,53 +210,53 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult> { let mut crate_types_cache = BTreeMap::new(); let removed = roots.extract_if(|root| { - let tk = root.node().target().kind(); - let ck = root.node().unit().platform; - - log::trace!(" check {} {}", tk.description(), match ck { - CompileKind::Host => "host", - CompileKind::Target(ref kind) => kind.short_name(), - }); - - if reserved_roots.contains(root) { - log::trace!(" excluding, reserved root"); - return true; - } - - { - use cargo::core::TargetKind as Tk; - if executable && !matches!(tk, Tk::Bin | Tk::ExampleBin) { - log::trace!(" excluding, is not executable"); - return true; - } - } - - let target = targets_cache.entry(*root) - .or_insert_with(|| target_for_root(root)); - - let ct = determine_crate_types(cfg, art, target, tk.clone(), ck).collect::>(); - - let is_good = art.filenames.len() == ct.len() && - !ct.iter().any(|(_, ct)| ct.is_none()); - if is_good { - // save resolved crate-types: - let ct = ct.into_iter() - .filter_map(|(p, ct)| ct.map(|ct| (p.to_owned(), ct))); - crate_types_cache.extend(ct); - } - - need_remove_roots && !is_good - }) - .inspect(|r| { - let p = r.package_id().name(); - let t = r.node().target().name.as_str(); - log::trace!(" excluded: {p}::{t} {:?}", match r.node().unit().platform - { - CompileKind::Host => "host", - CompileKind::Target(ref kind) => kind.short_name(), - }) - }) - .count(); + let tk = root.node().target().kind(); + let ck = root.node().unit().platform; + + log::trace!(" check {} {}", tk.description(), match ck { + CompileKind::Host => "host", + CompileKind::Target(ref kind) => kind.short_name(), + }); + + if reserved_roots.contains(root) { + log::trace!(" excluding, reserved root"); + return true; + } + + { + use cargo::core::TargetKind as Tk; + if executable && !matches!(tk, Tk::Bin | Tk::ExampleBin) { + log::trace!(" excluding, is not executable"); + return true; + } + } + + let target = targets_cache.entry(*root) + .or_insert_with(|| target_for_root(root)); + + let ct = + determine_crate_types(cfg, art, target, tk.clone(), ck).collect::>(); + + let is_good = + art.filenames.len() == ct.len() && !ct.iter().any(|(_, ct)| ct.is_none()); + if is_good { + // save resolved crate-types: + let ct = ct.into_iter() + .filter_map(|(p, ct)| ct.map(|ct| (p.to_owned(), ct))); + crate_types_cache.extend(ct); + } + + need_remove_roots && !is_good + }) + .inspect(|r| { + let p = r.package_id().name(); + let t = r.node().target().name.as_str(); + log::trace!(" excluded: {p}::{t} {:?}", match r.node().unit().platform { + CompileKind::Host => "host", + CompileKind::Target(ref kind) => kind.short_name(), + }) + }) + .count(); if removed > 0 { log::trace!(" excluded: {removed}, now roots: {}", roots.len()); @@ -337,7 +337,7 @@ pub fn build(cfg: &Config, tree: &MetaDeps) -> CargoResult> { let ck_exact = ck_name.iter().copied().find(|ck| { comps.iter() - .all(|(_num, first)| matches!(first, Some(s) if *s == *ck)) + .all(|(_num, first)| matches!(first, Some(s) if *s == *ck)) }); let removed = if let Some(ck) = ck_exact { @@ -594,18 +594,19 @@ fn map_artifacts<'cargo, 'cfg, 't>(tree: &'t MetaDeps<'cfg>, artifacts.filter(|art| matches!(art.target.kind, TK::Lib(_) | TK::Bin | TK::Example)) .filter_map(move |art| { - let findings = tree.roots() - .iter() - .filter(|r| { - let unit = r.node().unit(); - unit.package_id == art.package_id && - unit.target.name.as_str() == art.target.name.as_str() && - unit.target.kind() == art.target.kind() && - unit.target.crate_types == art.target.crate_types && - Some(unit.target.src_path.as_str().into()) == art.target.src_path - }) - .inspect(|r| log::trace!("root for artifact found: {:?} {r}", art.target.crate_types)) - .collect::>(); + let findings = + tree.roots() + .iter() + .filter(|r| { + let unit = r.node().unit(); + unit.package_id == art.package_id && + unit.target.name.as_str() == art.target.name.as_str() && + unit.target.kind() == art.target.kind() && + unit.target.crate_types == art.target.crate_types && + Some(unit.target.src_path.as_str().into()) == art.target.src_path + }) + .inspect(|r| log::trace!("root for artifact found: {:?} {r}", art.target.crate_types)) + .collect::>(); (!findings.is_empty()).then_some((art, findings)) }) .filter(|(_, roots)| !roots.is_empty()) diff --git a/cargo/src/config.rs b/cargo/src/config.rs index 8345693e..adccf8d4 100644 --- a/cargo/src/config.rs +++ b/cargo/src/config.rs @@ -154,12 +154,13 @@ impl<'cfg> Config<'cfg> { pub fn gcc(&self) -> CargoResult<&ArmToolchain> { self.gcc.try_get_or_create(|| { - let res = (!self.no_gcc).then(|| { - self.gcc_path.as_ref().map_or_else(ArmToolchain::try_new, |p| { - Gcc::try_new_exact_path(p).and_then(ArmToolchain::try_new_with) - }) - }) - .ok_or_else(|| anyhow::anyhow!("Attempt to get arm-gcc but 'no-gcc' is set"))??; + let res = + (!self.no_gcc).then(|| { + self.gcc_path.as_ref().map_or_else(ArmToolchain::try_new, |p| { + Gcc::try_new_exact_path(p).and_then(ArmToolchain::try_new_with) + }) + }) + .ok_or_else(|| anyhow::anyhow!("Attempt to get arm-gcc but 'no-gcc' is set"))??; Ok(res) }) } diff --git a/cargo/src/init/mod.rs b/cargo/src/init/mod.rs index 485247ae..f367df4f 100644 --- a/cargo/src/init/mod.rs +++ b/cargo/src/init/mod.rs @@ -337,9 +337,10 @@ fn cargo_config>(config: &Config, path: P) -> CargoResult<()> { // default if !config.create_full_config { // target[].rustflags: - let rustflags: Vec = Rustflags::rustflags_bin_playdate().iter() - .map(|s| toml::Value::String(s.to_string())) - .collect(); + let rustflags: Vec = + Rustflags::rustflags_bin_playdate().iter() + .map(|s| toml::Value::String(s.to_string())) + .collect(); let mut target_table = toml::Table::new(); target_table.insert("rustflags".into(), rustflags.into()); diff --git a/cargo/src/package/mod.rs b/cargo/src/package/mod.rs index f2e71e91..7f49c660 100644 --- a/cargo/src/package/mod.rs +++ b/cargo/src/package/mod.rs @@ -87,7 +87,7 @@ pub fn build_all(config: &'_ Config, unit.platform == products[0].ck && unit.target.crate_types.contains(&products[0].src_ct) && unit.target.name == products[0].name) - .then_some((r, Some(arts))) + .then_some((r, Some(arts))) }) .or_else(|| { assets.tree diff --git a/support/device/Cargo.toml b/support/device/Cargo.toml index 4182813c..8b2d2d25 100644 --- a/support/device/Cargo.toml +++ b/support/device/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "playdate-device" -version = "0.2.12" +version = "0.2.13" readme = "README.md" description = "Cross-platform interface Playdate device, async & blocking." keywords = ["playdate", "usb", "serial"] diff --git a/support/device/src/mount/win.rs b/support/device/src/mount/win.rs index 03006674..aa226007 100644 --- a/support/device/src/mount/win.rs +++ b/support/device/src/mount/win.rs @@ -56,8 +56,8 @@ pub mod unmount { fn unmount_blocking(&self) -> Result<(), Error> { #[cfg(feature = "eject")] let res = unmount_eject(&self).or_else(|err| { - winapi::unmount(self.letter).map_err(|err2| Error::chain(err2, [err])) - }); + winapi::unmount(self.letter).map_err(|err2| Error::chain(err2, [err])) + }); #[cfg(not(feature = "eject"))] let res = winapi::unmount(self.letter); @@ -92,12 +92,12 @@ pub mod unmount { #[cfg(feature = "eject")] let fut = lazy(|_| unmount_eject(&self)).or_else(|err| { - lazy(|_| { - winapi::unmount(self.letter).map_err(|err2| { - Error::chain(err2, [err]) - }) - }) - }); + lazy(|_| { + winapi::unmount(self.letter).map_err(|err2| { + Error::chain(err2, [err]) + }) + }) + }); #[cfg(not(feature = "eject"))] let fut = lazy(|_| winapi::unmount(self.letter)); diff --git a/support/device/src/usb/mod.rs b/support/device/src/usb/mod.rs index 630a6303..c2aaf424 100644 --- a/support/device/src/usb/mod.rs +++ b/support/device/src/usb/mod.rs @@ -294,10 +294,11 @@ impl Interface { // TODO: attach data to the pool let written = comp.data.actual_length(); let data = comp.data.reuse(); - let s = std::str::from_utf8(&data).map(Cow::Borrowed) - .unwrap_or_else(|_| { - Cow::Owned(hex::encode_upper(&data)) - }); + let s = + std::str::from_utf8(&data).map(Cow::Borrowed) + .unwrap_or_else(|_| { + Cow::Owned(hex::encode_upper(&data)) + }); trace!("sent, resp: ({written}) '{s}'"); comp.status.map(|_| written) })