-
Notifications
You must be signed in to change notification settings - Fork 20
Add builtin implementation for std targets. #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me but I am no expert on CS. Maybe @adamgreig could review?
I noticed now that there is no MSRV notice or CI job at all here.
Being such a foundational crate I think we should have one, even if it is 1.63.
It's definitely not a breaking change if there was none before, right? 😉
Added 1.63 MSRV notice to the README.
😂 It's not breaking anyway because 1.63 is only actually required if you enable the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small suggestions, but in general looks good to me.
Thanks @reitermarkus for the review, I've incorporated the feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add this feature to the test CI workflow?
|
I didn't because it runs the doctests showing how to set an impl, which then fails duplicate symbol errors because there's also the std impl. IMO it should be fine since there are no tests other than the doctests anyway.
Actually, we can also set the flag before acquiring the mutex. This way it's symmetric! :)
Done
SGTM. Documented MSRV as 1.54 without |
For some reason 1.54 doesn't like
|
For some reason 1.54 doesn't like it. ``` error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 0 --> src/lib.rs:123:1 | 123 | pub struct RestoreState(RawRestoreState); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ needs exactly one non-zero-sized field, but has 0 ```
I think it's because |
Yeah, but that was fine in 1.63 🤷 Either way, I think not having it is fine, it's very unlikely it'll result in worse code. Ssee #20 (comment) |
Hmm, you can gate the doctest code with something like: # #[cfg(not(feature = "std"))]
# {
// ... actual doctest code
# } |
Done (it's slightly abominable, but works...) |
Thanks for the updates, LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, thank you everybody!
bors r+
👎 Rejected by code reviews |
Ach, @reitermarkus could you review this again? |
bors r+ |
👎 Rejected by code reviews |
ugh, why does a "neutral" review with comments count as "rejected"? |
bors r+ |
👎 Rejected by code reviews |
901: Update to critical-section 1.0, atomic-polyfill 1.0 r=Dirbaio a=Dirbaio TODO - [x] Wait for cortex-m 0.7.6 release rust-embedded/cortex-m#449 - [x] ~~Wait for defmt-rtt 0.4 release knurling-rs/defmt#689 we're still going to use defmt 0.3 for now, which will use the `critical-section` 0.2 default impl, which works. - [x] Wait for critical-secton `std` impl rust-embedded/critical-section#22 Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This adds an
std
Cargo feature that enables a critical-section implementation forstd
.IMO this is the only impl that we should have "builtin". Rust's
std
is essentially "stable forever" so the impl won't need breaking changes, and it should work soundly on all targets wherestd
is supported.Note this uses Rust 1.63's "const Mutex::new()", so this makes our MSRV effectively that for std targets. I think it should be acceptable.