Update book from edition 2018 to 2024 #100
Merged
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_mangleandexport_nameattributes.This commit bundles the following changes:
Cargo.tomlmanifests to use edition 2024.unsafeto theno_mangle,export_nameandlink_sectionattributes.unsafetoexternblocks, marking pure Rust functions assafe.core::intrinsicsand use a singleasm!instruction to trigger UDF. The reasoning behind this is thatcore::intrinsicsrequires nightly and is only meant to be used by the compiler. The assembly line achieves the same effect.cortex_m::interrupt::mutexas suggested by an existing TODO. This removes the need for some unsafe. Also use more recent versions of thecortex-mandcortex-m-semihostingcrates.rust_begin_unwindis in the__rustcmodule now.A follow up change will be created to move away from
.dataand.bsssection 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.