Skip to content

Conversation

Javier-varez
Copy link

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 and export_name attributes.

This commit bundles the following changes:

  • Update the CI workflow to work with Rust edition 2024 and remove the need for the nightly toolchain.
  • Adapt all Cargo.toml manifests to use edition 2024.
  • Update all disassemblies and vector table dumps after compiling with the 1.89 toolchain and edition 2024. This also adds instruction addresses to some of the disassemblies, since the text referred to them but they were not present (see the exceptions chapter and the asm chapter).
  • Add unsafe to the no_mangle, export_name and link_section attributes.
  • Add unsafe to extern blocks, marking pure Rust functions as safe.
  • Remove use of core::intrinsics and use a single asm! instruction to trigger UDF. The reasoning behind this is that core::intrinsics requires nightly and is only meant to be used by the compiler. The assembly line achieves the same effect.
  • Make sure all tests are executed (including the exception tests, which were disabled in the past).
  • Update the singleton example and tests to use cortex_m::interrupt::mutex as suggested by an existing TODO. This removes the need for some unsafe. Also use more recent versions of the cortex-m and cortex-m-semihosting crates.
  • rust_begin_unwind is in the __rustc module now.
  • Update text in most chapters to describe the new changes in edition 2024.

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.

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`
and `export_name` attributes.

This commit bundles the following changes:
- Update the CI workflow to work with Rust edition 2024 and remove the
  need for the nightly toolchain.
- Adapt all `Cargo.toml` manifests to use edition 2024.
- Update all disassemblies and vector table dumps after compiling with
  the 1.89 toolchain and edition 2024. This also adds instruction
  addresses to some of the disassemblies, since the text referred to
  them but they were not present (see the exceptions chapter and the asm
  chapter).
- Add `unsafe` to the `no_mangle`, `export_name` and `link_section`
  attributes.
- Add `unsafe` to `extern` blocks, marking pure Rust functions as `safe`.
- Remove use of `core::intrinsics` and use a single `asm!` instruction
  to trigger UDF. The reasoning behind this is that `core::intrinsics`
  requires nightly and is only meant to be used by the compiler. The
  assembly line achieves the same effect.
- Make sure all tests are executed (including the exception tests, which
  were disabled in the past).
- Update the singleton example and tests to use `cortex_m::interrupt::mutex`
  as suggested by an existing TODO. This removes the need for some
  unsafe. Also use more recent versions of the `cortex-m` and
  `cortex-m-semihosting` crates.
- `rust_begin_unwind` is in the `__rustc` module now.
- Update text in most chapters to describe the new changes in edition
  2024.

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.
@Javier-varez Javier-varez requested a review from a team as a code owner September 23, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant