Update book from edition 2018 to 2024 #100
Open
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.
This change updates the Embedonomicon to the new Rust edition 2024. Up until now, most of the book targeted the Rust edition 2018.
Edition 2024 brings a set of new features that remove the need for nightly toolchains. Another advantage is that it introduces the readers to the current language changes, like the unsafe
no_mangle
andexport_name
attributes.This commit bundles the following changes:
Cargo.toml
manifests to use edition 2024.unsafe
to theno_mangle
,export_name
andlink_section
attributes.unsafe
toextern
blocks, marking pure Rust functions assafe
.core::intrinsics
and use a singleasm!
instruction to trigger UDF. The reasoning behind this is thatcore::intrinsics
requires nightly and is only meant to be used by the compiler. The assembly line achieves the same effect.cortex_m::interrupt::mutex
as suggested by an existing TODO. This removes the need for some unsafe. Also use more recent versions of thecortex-m
andcortex-m-semihosting
crates.rust_begin_unwind
is in the__rustc
module now.A follow up change will be created to move away from
.data
and.bss
section initialization using Rust code. Most runtime crates have moved away from this due to certain soundness challenges, so the Embedonomicon should also inform about them.