Skip to content

Commit 39935a7

Browse files
committed
dump all traits to help debug
1 parent 517c82e commit 39935a7

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

crates/bevy_api_gen/src/passes/cache_traits.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
use log::trace;
22
use rustc_hir::def_id::LOCAL_CRATE;
3+
use rustc_middle::ty::TyCtxt;
34
use rustc_span::Symbol;
45

56
use crate::{
67
Args, BevyCtxt, DEF_PATHS_BMS_FROM_SCRIPT, DEF_PATHS_BMS_INTO_SCRIPT,
78
DEF_PATHS_GET_TYPE_REGISTRATION, DEF_PATHS_REFLECT, STD_SOURCE_TRAITS,
89
};
910

11+
fn dump_traits(tcx: &TyCtxt) -> String{
12+
let mut buffer = String::new();
13+
for t in tcx.all_traits() {
14+
buffer.push_str(&tcx.def_path_str(t));
15+
}
16+
buffer
17+
}
18+
1019
/// Finds and caches relevant traits, if they cannot be found throws an ICE
1120
pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
1221
let tcx = &ctxt.tcx;
@@ -35,15 +44,17 @@ pub(crate) fn cache_traits(ctxt: &mut BevyCtxt<'_>, _args: &Args) -> bool {
3544

3645
if !ctxt.cached_traits.has_all_bms_traits() {
3746
panic!(
38-
"Could not find all bms traits in crate: {}",
39-
tcx.crate_name(LOCAL_CRATE)
47+
"Could not find all bms traits in crate: {}. Available traits: {}",
48+
tcx.crate_name(LOCAL_CRATE),
49+
dump_traits(tcx)
4050
)
4151
}
4252

4353
if !ctxt.cached_traits.has_all_bevy_traits() {
4454
panic!(
45-
"Could not find all reflect traits in crate: {}, did bootstrapping go wrong?",
46-
tcx.crate_name(LOCAL_CRATE)
55+
"Could not find all reflect traits in crate: {}, did bootstrapping go wrong?. Available traits: {}",
56+
tcx.crate_name(LOCAL_CRATE),
57+
dump_traits(tcx)
4758
)
4859
}
4960

0 commit comments

Comments
 (0)