From d5a505e0c6f3434109bf5d8aacacd8279add847c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 21 Jul 2025 10:30:43 -0700 Subject: [PATCH] Update to Rust 2024 --- .github/workflows/main.yml | 2 +- Cargo.toml | 4 ++-- guide/src/guide/installation.md | 2 +- src/book/book.rs | 4 +--- src/book/mod.rs | 2 +- src/config.rs | 9 ++++++--- src/renderer/html_handlebars/static_files.rs | 8 ++++---- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ce056cd..18b4b82e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: - name: msrv os: ubuntu-22.04 # sync MSRV with docs: guide/src/guide/installation.md and Cargo.toml - rust: 1.82.0 + rust: 1.85.0 target: x86_64-unknown-linux-gnu name: ${{ matrix.name }} steps: diff --git a/Cargo.toml b/Cargo.toml index 3ac37343..4e2f2251 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ missing_docs = "warn" rust_2018_idioms = "warn" [workspace.package] -edition = "2021" +edition = "2024" license = "MPL-2.0" repository = "https://github.com/rust-lang/mdBook" -rust-version = "1.82.0" # Keep in sync with installation.md and .github/workflows/main.yml +rust-version = "1.85.0" # Keep in sync with installation.md and .github/workflows/main.yml [package] name = "mdbook" diff --git a/guide/src/guide/installation.md b/guide/src/guide/installation.md index 61bb2731..72beb50f 100644 --- a/guide/src/guide/installation.md +++ b/guide/src/guide/installation.md @@ -20,7 +20,7 @@ To make it easier to run, put the path to the binary into your `PATH`. To build the `mdbook` executable from source, you will first need to install Rust and Cargo. Follow the instructions on the [Rust installation page]. -mdBook currently requires at least Rust version 1.82. +mdBook currently requires at least Rust version 1.85. Once you have installed Rust, the following command can be used to build and install mdBook: diff --git a/src/book/book.rs b/src/book/book.rs index fe71fbb2..72efa989 100644 --- a/src/book/book.rs +++ b/src/book/book.rs @@ -252,9 +252,7 @@ fn load_summary_item + Clone>( ) -> Result { match item { SummaryItem::Separator => Ok(BookItem::Separator), - SummaryItem::Link(ref link) => { - load_chapter(link, src_dir, parent_names).map(BookItem::Chapter) - } + SummaryItem::Link(link) => load_chapter(link, src_dir, parent_names).map(BookItem::Chapter), SummaryItem::PartTitle(title) => Ok(BookItem::PartTitle(title.clone())), } } diff --git a/src/book/mod.rs b/src/book/mod.rs index da88767a..dffac05f 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -611,7 +611,7 @@ fn preprocessor_should_run( let key = format!("preprocessor.{}.renderers", preprocessor.name()); let renderer_name = renderer.name(); - if let Some(Value::Array(ref explicit_renderers)) = cfg.get(&key) { + if let Some(Value::Array(explicit_renderers)) = cfg.get(&key) { return explicit_renderers .iter() .filter_map(Value::as_str) diff --git a/src/config.rs b/src/config.rs index 3fe16929..41290436 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1144,7 +1144,8 @@ mod tests { assert!(cfg.get(key).is_none()); let encoded_key = encode_env_var(key); - env::set_var(encoded_key, value); + // TODO: This is unsafe, and should be rewritten to use a process. + unsafe { env::set_var(encoded_key, value) }; cfg.update_from_env(); @@ -1164,7 +1165,8 @@ mod tests { assert!(cfg.get(key).is_none()); let encoded_key = encode_env_var(key); - env::set_var(encoded_key, value_str); + // TODO: This is unsafe, and should be rewritten to use a process. + unsafe { env::set_var(encoded_key, value_str) }; cfg.update_from_env(); @@ -1183,7 +1185,8 @@ mod tests { assert_ne!(cfg.book.title, Some(should_be.clone())); - env::set_var("MDBOOK_BOOK__TITLE", &should_be); + // TODO: This is unsafe, and should be rewritten to use a process. + unsafe { env::set_var("MDBOOK_BOOK__TITLE", &should_be) }; cfg.update_from_env(); assert_eq!(cfg.book.title, Some(should_be)); diff --git a/src/renderer/html_handlebars/static_files.rs b/src/renderer/html_handlebars/static_files.rs index e1531f42..ac205415 100644 --- a/src/renderer/html_handlebars/static_files.rs +++ b/src/renderer/html_handlebars/static_files.rs @@ -172,7 +172,7 @@ impl StaticFiles { use std::io::Read; for static_file in &mut self.static_files { match static_file { - StaticFile::Builtin { + &mut StaticFile::Builtin { ref mut filename, ref data, } => { @@ -193,7 +193,7 @@ impl StaticFiles { } } } - StaticFile::Additional { + &mut StaticFile::Additional { ref mut filename, ref input_location, } => { @@ -263,8 +263,8 @@ impl StaticFiles { write_file(destination, filename, &data)?; } StaticFile::Additional { - ref input_location, - ref filename, + input_location, + filename, } => { let output_location = destination.join(filename); debug!(