Improve warning for Send resources marked as non_send (#8000)
# Objective - Fixes unclear warning when `insert_non_send_resource` is called on a Send resource ## Solution - Add a message to the asssert statement that checks this --------- Co-authored-by: James Liu <contact@jamessliu.com>
This commit is contained in:
		
							parent
							
								
									882c86eee3
								
							
						
					
					
						commit
						65292fd559
					
				| @ -259,7 +259,7 @@ impl<const SEND: bool> Resources<SEND> { | |||||||
|     ///
 |     ///
 | ||||||
|     /// # Panics
 |     /// # Panics
 | ||||||
|     /// Will panic if `component_id` is not valid for the provided `components`
 |     /// Will panic if `component_id` is not valid for the provided `components`
 | ||||||
|     /// If `SEND` is false, this will panic if `component_id`'s `ComponentInfo` is not registered as being `Send` + `Sync`.
 |     /// If `SEND` is true, this will panic if `component_id`'s `ComponentInfo` is not registered as being `Send` + `Sync`.
 | ||||||
|     pub(crate) fn initialize_with( |     pub(crate) fn initialize_with( | ||||||
|         &mut self, |         &mut self, | ||||||
|         component_id: ComponentId, |         component_id: ComponentId, | ||||||
| @ -269,7 +269,11 @@ impl<const SEND: bool> Resources<SEND> { | |||||||
|         self.resources.get_or_insert_with(component_id, || { |         self.resources.get_or_insert_with(component_id, || { | ||||||
|             let component_info = components.get_info(component_id).unwrap(); |             let component_info = components.get_info(component_id).unwrap(); | ||||||
|             if SEND { |             if SEND { | ||||||
|                 assert!(component_info.is_send_and_sync()); |                 assert!( | ||||||
|  |                     component_info.is_send_and_sync(), | ||||||
|  |                     "Send + Sync resource {} initialized as non_send. It may have been inserted via World::insert_non_send_resource by accident. Try using World::insert_resource instead.", | ||||||
|  |                     component_info.name(), | ||||||
|  |                 ); | ||||||
|             } |             } | ||||||
|             ResourceData { |             ResourceData { | ||||||
|                 column: ManuallyDrop::new(Column::with_capacity(component_info, 1)), |                 column: ManuallyDrop::new(Column::with_capacity(component_info, 1)), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 NiseVoid
						NiseVoid