Skip to content

Commit 0753f50

Browse files
authored
chore: update rust edition to 2024 (#458)
1 parent 90e9189 commit 0753f50

File tree

86 files changed

+1080
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1080
-701
lines changed

.github/workflows/bevy_mod_scripting.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ jobs:
124124
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
125125
with:
126126
toolchain: stable
127-
override: true
127+
override: false
128+
- name: Print versions
129+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
130+
run: |
131+
echo "Rust version: $(rustc --version)"
132+
echo "Clippy version: $(cargo clippy --version)"
133+
echo "Active toolchain: $(rustup show active-toolchain)"
134+
continue-on-error: true
128135
- name: Rust Cache
129136
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
130137
uses: Swatinem/[email protected]

Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "bevy_mod_scripting"
33
version = "0.15.1"
44
authors = ["Maksymilian Mozolewski <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66
license = "MIT OR Apache-2.0"
77
description = "Multi language scripting in Bevy"
88
repository = "https://github.com/makspll/bevy_mod_scripting"
@@ -156,12 +156,7 @@ debug = true
156156
[[example]]
157157
name = "game_of_life"
158158
path = "examples/game_of_life.rs"
159-
required-features = [
160-
"lua54",
161-
"rhai",
162-
"bevy/file_watcher",
163-
"bevy/multi_threaded",
164-
]
159+
required-features = ["lua54", "rhai"]
165160

166161
[[example]]
167162
name = "docgen"

benches/benchmarks.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ use std::{collections::HashMap, path::PathBuf, sync::LazyLock, time::Duration};
55

66
use bevy::{
77
log::{
8-
tracing, tracing::span, tracing_subscriber, tracing_subscriber::layer::SubscriberExt, Level,
8+
Level, tracing, tracing::span, tracing_subscriber, tracing_subscriber::layer::SubscriberExt,
99
},
1010
reflect::Reflect,
1111
};
1212
use bevy_mod_scripting_core::bindings::{
1313
FromScript, IntoScript, Mut, Ref, ReflectReference, ScriptValue, Val,
1414
};
1515
use criterion::{
16-
criterion_main, measurement::Measurement, BatchSize, BenchmarkFilter, BenchmarkGroup, Criterion,
16+
BatchSize, BenchmarkFilter, BenchmarkGroup, Criterion, criterion_main, measurement::Measurement,
1717
};
1818
use regex::Regex;
1919
use script_integration_test_harness::{
2020
make_test_lua_plugin, make_test_rhai_plugin, perform_benchmark_with_generator,
2121
run_lua_benchmark, run_plugin_script_load_benchmark, run_rhai_benchmark,
2222
test_functions::rand::Rng,
2323
};
24-
use test_utils::{discover_all_tests, Test};
24+
use test_utils::{Test, discover_all_tests};
2525

2626
static ENABLE_PROFILING: LazyLock<bool> =
2727
LazyLock::new(|| std::env::var("ENABLE_PROFILING").is_ok());
@@ -147,7 +147,9 @@ fn script_benchmarks(criterion: &mut Criterion, filter: Option<Regex>) {
147147

148148
fn maybe_with_profiler(f: impl Fn(bool)) {
149149
if *ENABLE_PROFILING {
150-
println!("profiling enabled, make sure to run tracy. If using it across windows/WSL you can use something like `tracy-capture.exe -o output.tracy -a localhost` on windows");
150+
println!(
151+
"profiling enabled, make sure to run tracy. If using it across windows/WSL you can use something like `tracy-capture.exe -o output.tracy -a localhost` on windows"
152+
);
151153
// set global tracing subscriber so bevy doesn't set it itself first
152154
let subscriber = tracing_subscriber::Registry::default();
153155
let tracy_layer = tracing_tracy::TracyLayer::default();

build_scripts.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

crates/bevy_api_gen/Cargo.bootstrap.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[package]
33
name = "bevy_analyzer_deps_bootstrap"
44
version = "0.1.0"
5-
edition = "2021"
5+
edition = "2024"
66

77
[dependencies]
88
bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" }

crates/bevy_api_gen/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy_api_gen"
33
version = "0.6.0"
4-
edition = "2021"
4+
edition = "2024"
55
description = "Code generator tool for bevy"
66
license = "MIT OR Apache-2.0"
77
repository = "https://github.com/makspll/bevy_mod_scripting"
@@ -37,7 +37,6 @@ rustc_private = true
3737
[dependencies]
3838
log = "0.4"
3939
env_logger = "0.11"
40-
rustc_plugin = "0.12.0-nightly-2024-12-15"
4140
indexmap = "2"
4241
cargo_metadata = "0.18"
4342
serde_json = "1"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
22
components = ["clippy", "rust-src", "rustc-dev", "llvm-tools"]
3-
channel = "nightly-2024-12-15"
3+
channel = "nightly-2025-06-27"

crates/bevy_api_gen/src/args.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@ impl WorkspaceMeta {
249249
}
250250

251251
pub fn set_env(&self) {
252-
std::env::set_var(Self::CRATES_ENV_NAME, self.crates.join(","));
253-
std::env::set_var(Self::PLUGIN_DIR_NAME, &self.plugin_target_dir);
252+
unsafe { std::env::set_var(Self::CRATES_ENV_NAME, self.crates.join(",")) };
253+
unsafe { std::env::set_var(Self::PLUGIN_DIR_NAME, &self.plugin_target_dir) };
254254
if let Some(include_crates) = &self.include_crates {
255-
std::env::set_var(Self::INCLUDE_CRATES_ENV_NAME, include_crates.join(","));
255+
unsafe { std::env::set_var(Self::INCLUDE_CRATES_ENV_NAME, include_crates.join(",")) };
256256
}
257257
}
258258
}

crates/bevy_api_gen/src/bin/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![feature(rustc_private)]
2-
use bevy_api_gen::*;
2+
use bevy_api_gen::{driver::driver_main, *};
33

44
fn main() {
55
// initially set it to high so no logs are missed, but later when we parse the args we will set it to the correct level
6-
std::env::set_var("RUST_LOG", "trace");
6+
unsafe { std::env::set_var("RUST_LOG", "trace") };
77
env_logger::init();
8-
rustc_plugin::driver_main(BevyAnalyzer);
8+
driver_main(BevyAnalyzer);
99
}

crates/bevy_api_gen/src/bin/main.rs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::{
33
collections::HashMap,
44
env,
5-
fs::{create_dir_all, File},
5+
fs::{File, create_dir_all},
66
io::{BufRead, Write},
77
path::{Path, PathBuf},
88
process::{Command, Stdio},
@@ -22,7 +22,7 @@ fn main() {
2222
let args = Args::parse_from(env::args().skip(1));
2323

2424
if env::var("RUST_LOG").is_err() {
25-
env::set_var("RUST_LOG", args.verbose.get_rustlog_value());
25+
unsafe { env::set_var("RUST_LOG", args.verbose.get_rustlog_value()) };
2626
}
2727
env_logger::init();
2828

@@ -52,8 +52,9 @@ fn main() {
5252
);
5353

5454
info!(
55-
"Computing all transitive dependencies for enabled top-level features: {}",
56-
args.features.join(",")
55+
"Computing all transitive dependencies for enabled top-level features: {}. using default features: {}",
56+
args.features.join(","),
57+
!args.no_default_features
5758
);
5859

5960
let dependencies = feature_graph
@@ -99,7 +100,7 @@ fn main() {
99100
}
100101
bevy_api_gen::Command::ListTemplates => {
101102
for template in TemplateKind::VARIANTS {
102-
println!("{}", template);
103+
println!("{template}");
103104
}
104105
return;
105106
}
@@ -109,7 +110,7 @@ fn main() {
109110
api_name,
110111
} => {
111112
let tera = configure_tera("no_crate", &templates);
112-
info!("Collecting from: {}", output);
113+
info!("Collecting from: {output}");
113114
if !output.is_dir() {
114115
panic!("Output is not a directory");
115116
}
@@ -175,15 +176,17 @@ fn main() {
175176
.join(" ");
176177

177178
debug!("bootstrap paths: {bootstrap_rlibs:?}");
178-
env::set_var(
179-
"RUSTFLAGS",
180-
format!(
181-
"{} {} -L dependency={}",
182-
env::var("RUSTFLAGS").unwrap_or("".to_owned()),
183-
extern_args,
184-
bootstrap_rlibs.iter().next().unwrap().1.parent().unwrap()
185-
),
186-
);
179+
unsafe {
180+
env::set_var(
181+
"RUSTFLAGS",
182+
format!(
183+
"{} {} -L dependency={}",
184+
env::var("RUSTFLAGS").unwrap_or("".to_owned()),
185+
extern_args,
186+
bootstrap_rlibs.iter().next().unwrap().1.parent().unwrap()
187+
),
188+
)
189+
};
187190
} else {
188191
panic!("Could not find 'libmlua' artifact among bootstrap crate artifacts, stopping.");
189192
}
@@ -193,9 +196,9 @@ fn main() {
193196
debug!("RUSTFLAGS={}", env::var("RUSTFLAGS").unwrap_or_default());
194197

195198
// disable incremental compilation
196-
env::set_var("CARGO_INCREMENTAL", "0");
199+
unsafe { env::set_var("CARGO_INCREMENTAL", "0") };
197200

198-
rustc_plugin::cli_main(BevyAnalyzer);
201+
driver::cli_main(BevyAnalyzer);
199202

200203
// just making sure the temp dir lives until everything is done
201204
drop(temp_dir);
@@ -290,7 +293,7 @@ fn build_bootstrap(
290293
}
291294
}
292295
Err(e) => {
293-
panic!("Failed to wait on cargo build process: {}", e);
296+
panic!("Failed to wait on cargo build process: {e}");
294297
}
295298
}
296299

@@ -305,12 +308,11 @@ fn process_artifact(
305308
let file_name = artifact.file_name().unwrap_or_default();
306309
let lib_name = file_name.split('-').next().unwrap().strip_prefix("lib");
307310

308-
if let Some(lib_name) = lib_name {
309-
if BOOTSTRAP_DEPS.contains(&lib_name)
310-
&& artifact.extension().is_some_and(|ext| ext == "rlib")
311-
{
312-
bootstrap_rlibs.insert(lib_name.to_owned(), artifact);
313-
}
311+
if let Some(lib_name) = lib_name
312+
&& BOOTSTRAP_DEPS.contains(&lib_name)
313+
&& artifact.extension().is_some_and(|ext| ext == "rlib")
314+
{
315+
bootstrap_rlibs.insert(lib_name.to_owned(), artifact);
314316
}
315317
}
316318

0 commit comments

Comments
 (0)