Skip to content

Rust 2024 edition is ignored for code examples #2556

@StefanSalewski

Description

@StefanSalewski

Problem

As discussed in the Forum, mdbook seems to ignore new restrictions required by the new Rust 2024 edition:

Some days ago, I started porting the books's examples to Rust 2024 -- actually it is more testing with Rust 2024, as most examples should be compatible.

For that, I edited book.toml:

[rust]
edition = "2024"

and rebuild the book with "mdbook clean; mdbook build" and shipped it with rsync.

The strange thing is, that the FFI example runs fine when clicking the run button, but when I copy it into Rust's playground (which uses now Rust 2024 as default) compile fails, because extern needs now an unsafe block. If I switch playground to 2021 edition, it works.

My only explanation is currently, that mdbook masks 2024 internally still ?

Steps

$ cat book.toml
[book]
authors = ["S. Salewski"]
language = "en"
multilingual = false
src = "src"
title = "Rust for C-Programmers"
[rust]
edition = "2024"
[output.html.playground]
editable = true
[output.html]
git-repository-url = "https://github.com/StefanSalewski/Rust_for_C-Programmers"
smart-punctuation = true
[output.html.print]
enable = true # include support for printable output
page-break = true # insert page-break after each chapter

mdbook build

$ rsync -r book ...

firefox https://rust-for-c-programmers.salewskis.de/ch25/25_6_calling_c_functions_ffi.html

Click the "run" button (runs, while it should fail to compile as in the playground with 2024 edition)

Possible Solution(s)

Fix it.

Notes

The same with Chromium web browser.

Version

$ mdbook --version
mdbook v0.4.45

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: A bug, incorrect or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions