Use disqualified for B0001 (#16623)

# Objective

Fix #16553
This commit is contained in:
SpecificProtagonist 2024-12-03 20:51:50 +01:00 committed by GitHub
parent e77efcc8d7
commit 410f3c478a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 16 deletions

View file

@ -3,6 +3,7 @@ use crate::storage::SparseSetIndex;
use crate::world::World;
use core::{fmt, fmt::Debug, marker::PhantomData};
use derive_more::derive::From;
use disqualified::ShortName;
use fixedbitset::FixedBitSet;
/// A wrapper struct to make Debug representations of [`FixedBitSet`] easier
@ -888,18 +889,22 @@ impl AccessConflicts {
pub(crate) fn format_conflict_list(&self, world: &World) -> String {
match self {
AccessConflicts::All => String::new(),
AccessConflicts::Individual(indices) => format!(
" {}",
indices
.ones()
.map(|index| world
.components
.get_info(ComponentId::get_sparse_set_index(index))
.unwrap()
.name())
.collect::<Vec<&str>>()
.join(", ")
),
AccessConflicts::Individual(indices) => indices
.ones()
.map(|index| {
format!(
"{}",
ShortName(
world
.components
.get_info(ComponentId::get_sparse_set_index(index))
.unwrap()
.name()
)
)
})
.collect::<Vec<_>>()
.join(", "),
}
}

View file

@ -1573,7 +1573,7 @@ mod tests {
#[test]
#[should_panic(
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"
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"
)]
fn assert_world_and_entity_mut_system_does_conflict() {
fn system(_query: &World, _q2: Query<EntityMut>) {}
@ -1582,7 +1582,7 @@ mod tests {
#[test]
#[should_panic(
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"
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"
)]
fn assert_entity_ref_and_entity_mut_system_does_conflict() {
fn system(_query: Query<EntityRef>, _q2: Query<EntityMut>) {}
@ -1591,7 +1591,7 @@ mod tests {
#[test]
#[should_panic(
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"
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"
)]
fn assert_entity_mut_system_does_conflict() {
fn system(_query: Query<EntityMut>, _q2: Query<EntityMut>) {}

View file

@ -28,6 +28,7 @@ use core::{
marker::PhantomData,
ops::{Deref, DerefMut},
};
use disqualified::ShortName;
use super::Populated;
use variadics_please::all_tuples;
@ -354,7 +355,7 @@ fn assert_component_access_compatibility(
return;
}
let accesses = conflicts.format_conflict_list(world);
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");
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));
}
// SAFETY: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If