Repository navigation
Define CriticalSection, Mutex and Nr locally; make bare-metal optional - #713
Open
stephencox-inveya wants to merge 1 commit into
Open
stephencox-inveya wants to merge 1 commit into
stephencox-inveya wants to merge 1 commit into
Conversation
bare-metal 0.2 is deprecated (RUSTSEC-2026-0110). Copy the three items cortex-m re-exports from it into interrupt.rs and move the dependency behind a new, non-default bare-metal feature that restores the old re-exports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #651. Alternative to #656 that stays semver-compatible with 0.7.
Problem
cargo auditflags every cortex-m 0.7 user with RUSTSEC-2026-0110(
bare-metalis deprecated/archived). cortex-m 0.7 only uses three items fromit:
interrupt::{CriticalSection, Mutex, Nr}, re-exported. #656 removes them,which is breaking, so it waits for 0.8. Most of the ecosystem (embassy,
stm32-metapac, nrf-pac, panic-probe) depends on cortex-m 0.7 and cannot move
until 0.8 ships and they all migrate.
Change
cortex_m::interrupt(private
compatmodule, re-exported at the same paths). Same layout, samemethods, same
unsafe impl Sync for Mutex<T> where T: Send, samecompile-fail lifetime test (enable cache and drop target files #6).
bare-metalbecomes an optional dependency behind a new, non-defaultbare-metalfeature. With it on, the old re-exports come back unchanged.InterruptNumber's blanket impl now covers whicheverNris exported.Compatibility
Code that names these items through
cortex_m::interrupt::*is unaffected,and so is everything that calls
interrupt::free(the closure token's type isstill
cortex_m::interrupt::CriticalSection).Two cases change unless the user enables the
bare-metalfeature:cortex_m::interrupttokens withbare_metal::Mutex/bare_metal::CriticalSectiondirectly.bare_metal::Nrinstead ofInterruptNumber(svd2rust older than the 0.7-era output).
Both get the old behaviour back with
features = ["bare-metal"], so they havea one-line fix rather than a 0.8 migration. cargo-semver-checks against
v0.7.10 reported "no semver update required" (202 checks pass, host target; the tool cannot build rustdoc for thumbv* targets).
Testing
cargo test --all --exclude cortex-m-rt --exclude testsuite --features cortex-m/critical-section-single-core(with and withoutbare-metal)cargo clippy -D warningson thumbv6m, thumbv7em, thumbv8m.base, thumbv8m.main, both feature states(re-run on Rust 1.100.0: no clippy findings; Cargo 1.100 prints an unused-dependency warning for
bitfieldon thumbv6m/thumbv7em, whichmainprints too)nRF52833) builds with this patch, and
bare-metalleaves its Cargo.lock.Every image has the same function count and function sizes, and text+data
moves by at most 8 bytes (layout only).
This change was prepared with the help of an AI coding assistant (Claude). I reviewed and tested it.
🤖 Generated with Claude Code