Skip to content

Commit ac66827

Browse files
committed
remove mlua references from codegen
1 parent 0d9afb8 commit ac66827

File tree

8 files changed

+11
-43
lines changed

8 files changed

+11
-43
lines changed

crates/bevy_api_gen/Cargo.bootstrap.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# Cargo.toml file used for bootstrapping of mlua and other dependencies which need to be included in every crate for analysis
1+
# Cargo.toml file used for bootstrapping of bms and other dependencies which need to be included in every crate for analysis
22
[package]
33
name = "bevy_analyzer_deps_bootstrap"
44
version = "0.1.0"
55
edition = "2021"
66

77
[dependencies]
8-
mlua = { version = "0.10", features = ["lua54", "vendored", "send", "macros"] }
98
bevy_mod_scripting_core = { path = "{{BMS_CORE_PATH}}" }
109
bevy_reflect = { version = "0.15.0", features = [
1110
"bevy",

crates/bevy_api_gen/src/bin/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use log::{debug, error, info};
1515
use strum::VariantNames;
1616
use tera::Context;
1717

18-
const BOOTSTRAP_DEPS: [&str; 3] = ["mlua", "bevy_reflect", "bevy_mod_scripting_core"];
18+
const BOOTSTRAP_DEPS: [&str; 2] = ["bevy_reflect", "bevy_mod_scripting_core"];
1919

2020
fn main() {
2121
// parse this here to early exit on wrong args

crates/bevy_api_gen/src/context.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ pub(crate) const DEF_PATHS_BMS_INTO_SCRIPT: [&str; 2] = [
9090
"bindings::function::into::IntoScript",
9191
];
9292

93-
pub(crate) const DEF_PATHS_FROM_LUA: [&str; 2] = ["value::FromLuaMulti", "mlua::FromLuaMulti"];
94-
pub(crate) const DEF_PATHS_INTO_LUA: [&str; 2] = ["value::IntoLuaMulti", "mlua::IntoLuaMulti"];
9593
pub(crate) const DEF_PATHS_REFLECT: [&str; 2] =
9694
["bevy_reflect::PartialReflect", "reflect::PartialReflect"];
9795
pub(crate) const DEF_PATHS_GET_TYPE_REGISTRATION: [&str; 2] = [
@@ -124,8 +122,6 @@ pub(crate) const STD_SOURCE_TRAITS: [&str; 14] = [
124122
/// A collection of common traits stored for quick access.
125123
#[derive(Default)]
126124
pub(crate) struct CachedTraits {
127-
pub(crate) mlua_from_lua_multi: Option<DefId>,
128-
pub(crate) mlua_into_lua_multi: Option<DefId>,
129125
pub(crate) bms_into_script: Option<DefId>,
130126
pub(crate) bms_from_script: Option<DefId>,
131127
pub(crate) bevy_reflect_reflect: Option<DefId>,
@@ -140,10 +136,6 @@ impl CachedTraits {
140136
self.bms_into_script.is_some() && self.bms_from_script.is_some()
141137
}
142138

143-
pub(crate) fn has_all_mlua_traits(&self) -> bool {
144-
self.mlua_from_lua_multi.is_some() && self.mlua_into_lua_multi.is_some()
145-
}
146-
147139
pub(crate) fn has_all_bevy_traits(&self) -> bool {
148140
self.bevy_reflect_reflect.is_some() && self.bevy_reflect_get_type_registration.is_some()
149141
}

crates/bevy_api_gen/src/modifying_file_loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl FileLoader for ModifyingFileLoader {
2828
RealFileLoader.read_file(path).map(|mut f| {
2929
// we make it pub so in case we are re-exporting this crate we won't run into private re-export issues
3030

31-
for crate_ in &["bevy_reflect", "mlua", "bevy_mod_scripting_core"] {
31+
for crate_ in &["bevy_reflect", "bevy_mod_scripting_core"] {
3232
if !f.contains(&format!("extern crate {crate_}")) {
3333
if f.contains(&format!("pub use {crate_}")) {
3434
f.push_str(&format!(

crates/bevy_api_gen/src/passes/cache_traits.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use rustc_hir::def_id::LOCAL_CRATE;
33
use rustc_span::Symbol;
44

55
use crate::{
6-
Args, BevyCtxt, DEF_PATHS_BMS_FROM_SCRIPT, DEF_PATHS_BMS_INTO_SCRIPT, DEF_PATHS_FROM_LUA,
7-
DEF_PATHS_GET_TYPE_REGISTRATION, DEF_PATHS_INTO_LUA, DEF_PATHS_REFLECT, STD_SOURCE_TRAITS,
6+
Args, BevyCtxt, DEF_PATHS_BMS_FROM_SCRIPT, DEF_PATHS_BMS_INTO_SCRIPT,
7+
DEF_PATHS_GET_TYPE_REGISTRATION, DEF_PATHS_REFLECT, STD_SOURCE_TRAITS,
88
};
99

1010
/// Finds and caches relevant traits, if they cannot be found throws an ICE
@@ -13,13 +13,7 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
1313

1414
for trait_did in tcx.all_traits() {
1515
let def_path_str = tcx.def_path_str(trait_did);
16-
if DEF_PATHS_FROM_LUA.contains(&def_path_str.as_str()) {
17-
trace!("found FromLuaMulti trait def id: {trait_did:?}");
18-
ctxt.cached_traits.mlua_from_lua_multi = Some(trait_did);
19-
} else if DEF_PATHS_INTO_LUA.contains(&def_path_str.as_str()) {
20-
trace!("found ToLuaMulti trait def id: {trait_did:?}");
21-
ctxt.cached_traits.mlua_into_lua_multi = Some(trait_did);
22-
} else if DEF_PATHS_REFLECT.contains(&def_path_str.as_str()) {
16+
if DEF_PATHS_REFLECT.contains(&def_path_str.as_str()) {
2317
trace!("found Reflect trait def id: {trait_did:?}");
2418
ctxt.cached_traits.bevy_reflect_reflect = Some(trait_did);
2519
} else if DEF_PATHS_GET_TYPE_REGISTRATION.contains(&def_path_str.as_str()) {
@@ -46,13 +40,6 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
4640
)
4741
}
4842

49-
if !ctxt.cached_traits.has_all_mlua_traits() {
50-
panic!(
51-
"Could not find all mlua traits in crate: {}, did bootstrapping go wrong?",
52-
tcx.crate_name(LOCAL_CRATE)
53-
)
54-
}
55-
5643
if !ctxt.cached_traits.has_all_bevy_traits() {
5744
panic!(
5845
"Could not find all reflect traits in crate: {}, did bootstrapping go wrong?",

crates/bevy_api_gen/src/passes/find_methods_and_fields.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,7 @@ fn type_is_supported_as_non_proxy_arg<'tcx>(
376376
ty: Ty<'tcx>,
377377
) -> bool {
378378
trace!("Checking type is supported as non proxy arg: '{ty:?}' with param_env: '{param_env:?}'");
379-
impls_trait(
380-
tcx,
381-
param_env,
382-
ty,
383-
cached_traits.mlua_from_lua_multi.unwrap(),
384-
)
379+
impls_trait(tcx, param_env, ty, cached_traits.bms_from_script.unwrap())
385380
}
386381

387382
/// Checks if the type can be used directly as a lua function output
@@ -398,12 +393,7 @@ fn type_is_supported_as_non_proxy_return_val<'tcx>(
398393
}
399394
}
400395

401-
impls_trait(
402-
tcx,
403-
param_env,
404-
ty,
405-
cached_traits.mlua_into_lua_multi.unwrap(),
406-
)
396+
impls_trait(tcx, param_env, ty, cached_traits.bms_into_script.unwrap())
407397
}
408398

409399
pub(crate) fn impls_trait<'tcx>(

crates/bevy_api_gen/src/passes/find_trait_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ pub(crate) fn find_trait_impls(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
3333
// filter out types which have impls both ways
3434
let retaining = type_impl_of_trait(
3535
tcx,
36-
ctxt.cached_traits.mlua_from_lua_multi.unwrap(),
36+
ctxt.cached_traits.bms_from_script.unwrap(),
3737
reflect_ty_did,
3838
)
3939
.is_empty()
4040
|| type_impl_of_trait(
4141
tcx,
42-
ctxt.cached_traits.mlua_into_lua_multi.unwrap(),
42+
ctxt.cached_traits.bms_into_script.unwrap(),
4343
reflect_ty_did,
4444
)
4545
.is_empty();

crates/bevy_api_gen/src/passes/write_meta.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_hir::def_id::LOCAL_CRATE;
22

33
use crate::{Args, BevyCtxt, Meta, ProxyMeta, META_VERSION};
44

5-
/// Finds and caches relevant mlua traits, if they cannot be found throws an ICE
5+
/// Finds and caches relevant traits, if they cannot be found throws an ICE
66
pub(crate) fn write_meta(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
77
let tcx = &ctxt.tcx;
88

0 commit comments

Comments
 (0)