From b3655a36018586399987fc9408e904f05ba00593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Mon, 11 Mar 2024 18:53:38 +0100 Subject: [PATCH] fix deprecations from toml_edit (#12421) # Objective - `toml_edit` released a new patch that deprecates `Document` - this warns when Bevy builds, and CI deny warns ## Solution - fix deprecation warnings --- crates/bevy_macro_utils/Cargo.toml | 4 +++- crates/bevy_macro_utils/src/bevy_manifest.rs | 6 +++--- tools/build-templated-pages/Cargo.toml | 4 +++- tools/build-templated-pages/src/examples.rs | 6 +++--- tools/build-templated-pages/src/features.rs | 4 ++-- tools/example-showcase/Cargo.toml | 4 +++- tools/example-showcase/src/main.rs | 4 ++-- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/crates/bevy_macro_utils/Cargo.toml b/crates/bevy_macro_utils/Cargo.toml index acf1a996a6..6dc67396bb 100644 --- a/crates/bevy_macro_utils/Cargo.toml +++ b/crates/bevy_macro_utils/Cargo.toml @@ -9,7 +9,9 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [dependencies] -toml_edit = { version = "0.22", default-features = false, features = ["parse"] } +toml_edit = { version = "0.22.7", default-features = false, features = [ + "parse", +] } syn = "2.0" quote = "1.0" rustc-hash = "1.0" diff --git a/crates/bevy_macro_utils/src/bevy_manifest.rs b/crates/bevy_macro_utils/src/bevy_manifest.rs index 88ef781546..f06b46abac 100644 --- a/crates/bevy_macro_utils/src/bevy_manifest.rs +++ b/crates/bevy_macro_utils/src/bevy_manifest.rs @@ -2,11 +2,11 @@ extern crate proc_macro; use proc_macro::TokenStream; use std::{env, path::PathBuf}; -use toml_edit::{Document, Item}; +use toml_edit::{DocumentMut, Item}; /// The path to the `Cargo.toml` file for the Bevy project. pub struct BevyManifest { - manifest: Document, + manifest: DocumentMut, } impl Default for BevyManifest { @@ -25,7 +25,7 @@ impl Default for BevyManifest { let manifest = std::fs::read_to_string(path.clone()).unwrap_or_else(|_| { panic!("Unable to read cargo manifest: {}", path.display()) }); - manifest.parse::().unwrap_or_else(|_| { + manifest.parse::().unwrap_or_else(|_| { panic!("Failed to parse cargo manifest: {}", path.display()) }) }) diff --git a/tools/build-templated-pages/Cargo.toml b/tools/build-templated-pages/Cargo.toml index d98a6084d7..5b0e5e1eff 100644 --- a/tools/build-templated-pages/Cargo.toml +++ b/tools/build-templated-pages/Cargo.toml @@ -10,7 +10,9 @@ license = "MIT OR Apache-2.0" workspace = true [dependencies] -toml_edit = { version = "0.22", default-features = false, features = ["parse"] } +toml_edit = { version = "0.22.7", default-features = false, features = [ + "parse", +] } tera = "1.15" serde = { version = "1.0", features = ["derive"] } bitflags = "2.3" diff --git a/tools/build-templated-pages/src/examples.rs b/tools/build-templated-pages/src/examples.rs index db942da289..8c3f41d48e 100644 --- a/tools/build-templated-pages/src/examples.rs +++ b/tools/build-templated-pages/src/examples.rs @@ -3,7 +3,7 @@ use std::{cmp::Ordering, fs::File}; use hashbrown::HashMap; use serde::Serialize; use tera::{Context, Tera}; -use toml_edit::Document; +use toml_edit::DocumentMut; use crate::Command; @@ -40,7 +40,7 @@ impl PartialOrd for Example { fn parse_examples(panic_on_missing: bool) -> Vec { let manifest_file = std::fs::read_to_string("Cargo.toml").unwrap(); - let manifest = manifest_file.parse::().unwrap(); + let manifest = manifest_file.parse::().unwrap(); let metadatas = manifest .get("package") .unwrap() @@ -83,7 +83,7 @@ fn parse_examples(panic_on_missing: bool) -> Vec { fn parse_categories() -> HashMap, String> { let manifest_file = std::fs::read_to_string("Cargo.toml").unwrap(); - let manifest = manifest_file.parse::().unwrap(); + let manifest = manifest_file.parse::().unwrap(); manifest .get("package") .unwrap() diff --git a/tools/build-templated-pages/src/features.rs b/tools/build-templated-pages/src/features.rs index 6efdfb5660..9ab11161a0 100644 --- a/tools/build-templated-pages/src/features.rs +++ b/tools/build-templated-pages/src/features.rs @@ -2,7 +2,7 @@ use std::{cmp::Ordering, fs::File}; use serde::Serialize; use tera::{Context, Tera}; -use toml_edit::Document; +use toml_edit::DocumentMut; use crate::Command; @@ -27,7 +27,7 @@ impl PartialOrd for Feature { fn parse_features(panic_on_missing: bool) -> Vec { let manifest_file = std::fs::read_to_string("Cargo.toml").unwrap(); - let manifest = manifest_file.parse::().unwrap(); + let manifest = manifest_file.parse::().unwrap(); let features = manifest["features"].as_table().unwrap(); let default: Vec<_> = features diff --git a/tools/example-showcase/Cargo.toml b/tools/example-showcase/Cargo.toml index fad94139e1..184a002c0f 100644 --- a/tools/example-showcase/Cargo.toml +++ b/tools/example-showcase/Cargo.toml @@ -13,5 +13,7 @@ workspace = true xshell = "0.2" clap = { version = "4.0", features = ["derive"] } ron = "0.8" -toml_edit = { version = "0.22", default-features = false, features = ["parse"] } +toml_edit = { version = "0.22.7", default-features = false, features = [ + "parse", +] } pbr = "1.1" diff --git a/tools/example-showcase/src/main.rs b/tools/example-showcase/src/main.rs index cabdd973f2..64279f0bad 100644 --- a/tools/example-showcase/src/main.rs +++ b/tools/example-showcase/src/main.rs @@ -14,7 +14,7 @@ use std::{ use clap::{error::ErrorKind, CommandFactory, Parser, ValueEnum}; use pbr::ProgressBar; -use toml_edit::Document; +use toml_edit::DocumentMut; use xshell::{cmd, Shell}; #[derive(Parser, Debug)] @@ -661,7 +661,7 @@ header_message = \"Examples ({})\" fn parse_examples() -> Vec { let manifest_file = fs::read_to_string("Cargo.toml").unwrap(); - let manifest = manifest_file.parse::().unwrap(); + let manifest = manifest_file.parse::().unwrap(); let metadatas = manifest .get("package") .unwrap()