Skip to content

Commit 410f3c4

Browse files
Use disqualified for B0001 (bevyengine#16623)
# Objective Fix bevyengine#16553
1 parent e77efcc commit 410f3c4

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

crates/bevy_ecs/src/query/access.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::storage::SparseSetIndex;
33
use crate::world::World;
44
use core::{fmt, fmt::Debug, marker::PhantomData};
55
use derive_more::derive::From;
6+
use disqualified::ShortName;
67
use fixedbitset::FixedBitSet;
78

89
/// A wrapper struct to make Debug representations of [`FixedBitSet`] easier
@@ -888,18 +889,22 @@ impl AccessConflicts {
888889
pub(crate) fn format_conflict_list(&self, world: &World) -> String {
889890
match self {
890891
AccessConflicts::All => String::new(),
891-
AccessConflicts::Individual(indices) => format!(
892-
" {}",
893-
indices
894-
.ones()
895-
.map(|index| world
896-
.components
897-
.get_info(ComponentId::get_sparse_set_index(index))
898-
.unwrap()
899-
.name())
900-
.collect::<Vec<&str>>()
901-
.join(", ")
902-
),
892+
AccessConflicts::Individual(indices) => indices
893+
.ones()
894+
.map(|index| {
895+
format!(
896+
"{}",
897+
ShortName(
898+
world
899+
.components
900+
.get_info(ComponentId::get_sparse_set_index(index))
901+
.unwrap()
902+
.name()
903+
)
904+
)
905+
})
906+
.collect::<Vec<_>>()
907+
.join(", "),
903908
}
904909
}
905910

crates/bevy_ecs/src/system/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ mod tests {
15731573

15741574
#[test]
15751575
#[should_panic(
1576-
expected = "error[B0001]: Query<bevy_ecs::world::entity_ref::EntityMut, ()> in system bevy_ecs::system::tests::assert_world_and_entity_mut_system_does_conflict::system accesses component(s) in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001"
1576+
expected = "error[B0001]: Query<EntityMut, ()> in system bevy_ecs::system::tests::assert_world_and_entity_mut_system_does_conflict::system accesses component(s) in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001"
15771577
)]
15781578
fn assert_world_and_entity_mut_system_does_conflict() {
15791579
fn system(_query: &World, _q2: Query<EntityMut>) {}
@@ -1582,7 +1582,7 @@ mod tests {
15821582

15831583
#[test]
15841584
#[should_panic(
1585-
expected = "error[B0001]: Query<bevy_ecs::world::entity_ref::EntityMut, ()> in system bevy_ecs::system::tests::assert_entity_ref_and_entity_mut_system_does_conflict::system accesses component(s) in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001"
1585+
expected = "error[B0001]: Query<EntityMut, ()> in system bevy_ecs::system::tests::assert_entity_ref_and_entity_mut_system_does_conflict::system accesses component(s) in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001"
15861586
)]
15871587
fn assert_entity_ref_and_entity_mut_system_does_conflict() {
15881588
fn system(_query: Query<EntityRef>, _q2: Query<EntityMut>) {}
@@ -1591,7 +1591,7 @@ mod tests {
15911591

15921592
#[test]
15931593
#[should_panic(
1594-
expected = "error[B0001]: Query<bevy_ecs::world::entity_ref::EntityMut, ()> in system bevy_ecs::system::tests::assert_entity_mut_system_does_conflict::system accesses component(s) in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001"
1594+
expected = "error[B0001]: Query<EntityMut, ()> in system bevy_ecs::system::tests::assert_entity_mut_system_does_conflict::system accesses component(s) in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001"
15951595
)]
15961596
fn assert_entity_mut_system_does_conflict() {
15971597
fn system(_query: Query<EntityMut>, _q2: Query<EntityMut>) {}

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use core::{
2828
marker::PhantomData,
2929
ops::{Deref, DerefMut},
3030
};
31+
use disqualified::ShortName;
3132

3233
use super::Populated;
3334
use variadics_please::all_tuples;
@@ -354,7 +355,7 @@ fn assert_component_access_compatibility(
354355
return;
355356
}
356357
let accesses = conflicts.format_conflict_list(world);
357-
panic!("error[B0001]: Query<{query_type}, {filter_type}> in system {system_name} accesses component(s){accesses} in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001");
358+
panic!("error[B0001]: Query<{}, {}> in system {system_name} accesses component(s){accesses} in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/b0001", ShortName(query_type), ShortName(filter_type));
358359
}
359360

360361
// SAFETY: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If

0 commit comments

Comments
 (0)