Repository navigation
fix(widgets): forward portable-atomic feature to ratatui-widgets - #2822
Conversation
The ratatui portable-atomic feature only forwarded to ratatui-core, but ratatui-widgets imported alloc::sync::Arc unconditionally, which only exists on targets that support atomic pointers. Builds for targets like thumbv6m-none-eabi failed with E0432 even with the feature enabled. Gate the Arc import in block/shadow.rs behind the portable-atomic feature, backed by portable-atomic-util::Arc, and forward the feature from the ratatui facade crate. portable-atomic's Arc does not implement CoerceUnsized on stable Rust, so Shadow::custom erases the concrete effect type through a Box. Fixes #2767
kasuari 0.4.9 requires portable-atomic-util ^0.2.4, so the lower bound declared by ratatui-widgets must match for the minimal-versions CI job to resolve.
Only erase the effect type through a Box when the portable-atomic feature is enabled, since portable-atomic's Arc cannot coerce to a trait object on stable Rust. Builds without the feature keep the direct Arc::new and skip the extra allocation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2822 +/- ##
=====================================
Coverage 92.8% 92.8%
=====================================
Files 106 106
Lines 21668 21669 +1
=====================================
+ Hits 20117 20118 +1
Misses 1551 1551 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks Josh, both for the quick review and for nudging me to bring this back. The feature-flag catch made the default build cleaner too. |
|
Great to see this merged! Apologies if my earlier frustration caused either of you any distress, not my intent if so. Thanks to both! |
Hey, no problems - I think in general, we're all working out how to work in the new world of AI assisted reality of software development. I'm actually fairly bullish on AI assisted comms being reasonable, but it starts with some respect for the receiver. I think it's worth thinking of problems that are encountered along the way as places where both sides of that tension can learn from each other instead of places where we put up barriers to continued discourse. That is to say, I will use AI to communicate where it adds value. And I will make mistakes on that from time to time on working out that choice, but I'll also look for ways to correct those mistakes going forward. A hard line "no AI generated text in comms" policy that you're calling for in the issue elsewhere isn't aligned with my viewpoint on this. |
|
No worries at all, and thanks for closing yours in favor of this one. Appreciate you both. |
Carries over #2771, which I closed by mistake.
What
The
portable-atomicfeature onratatuinow also forwards toratatui-widgets, so builds for targets without native atomic pointers (for examplethumbv6m-none-eabion the RP2040) work with the documented setup.Root cause
ratatui'sportable-atomicfeature only forwarded toratatui-core.ratatui-widgetsstill importedalloc::sync::Arcunconditionally inblock/shadow.rs, andalloc::synconly exists when the target supports atomic pointers. Acargo check --target thumbv6m-none-eabiagainst a crate enablingratatui/portable-atomicfails with:The change
ratatui-widgetsgains aportable-atomicfeature backed by an optionalportable-atomic-utildependency, mirroring howratatui-corealready integrates portable-atomic through kasuari.block/shadow.rscfg-selects theArcimport:portable_atomic_util::Arcwhen the feature is on,alloc::sync::Arcotherwise.Arcdoes not implementCoerceUnsizedon stable Rust, so with the feature on,Shadow::customerases the concrete effect type through aBoxbefore converting toArc<dyn CellEffect>. Without it, the code keeps the plainArc::new. This keeps the same public API andClonebehavior on both paths.portable-atomicfeature onratatuinow forwards toratatui-widgets/portable-atomicin addition toratatui-core/portable-atomic.Verification
ratatui = { default-features = false, features = ["portable-atomic"] }plusportable-atomicwithcritical-section(the setup from the book's embedded chapter):cargo check --target thumbv6m-none-eabifails before this change with the E0432 above and passes after.cargo build --target x86_64-unknown-none -p ratatui-widgets(the repository's no-std CI job) passes.cargo xtask format --checkand the clippy gate pass locally, andcargo test --all-features -p ratatui-widgetspasses with no new failures. My local environment is Windows, so the unix-only crates (termion backend) could not be compiled locally.This PR was prepared with AI coding assistance and reviewed line by line.
Fixes #2767