From 11b1b3a24f743de97dd2623f7dd424b376b50402 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 24 Nov 2023 08:15:47 -0800 Subject: [PATCH] delete methods deprecated in 0.12 (#10693) ## Changelog - delete methods deprecated in 0.12 --- crates/bevy_app/src/app.rs | 11 - crates/bevy_asset/src/path.rs | 4 - crates/bevy_ecs/README.md | 2 +- crates/bevy_ecs/src/event.rs | 48 +--- crates/bevy_ecs/src/lib.rs | 4 - crates/bevy_ecs/src/query/par_iter.rs | 13 -- .../bevy_ecs/src/reflect/entity_commands.rs | 2 +- crates/bevy_ecs/src/removal_detection.rs | 16 +- crates/bevy_ecs/src/schedule/schedule.rs | 7 - crates/bevy_ecs/src/system/function_system.rs | 2 +- crates/bevy_ecs/src/system/mod.rs | 220 ------------------ crates/bevy_ecs/src/system/system_param.rs | 2 +- crates/bevy_reflect/src/reflect.rs | 18 -- 13 files changed, 9 insertions(+), 340 deletions(-) diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index ee2b431996fee..a169cda57fca8 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -421,17 +421,6 @@ impl App { self } - /// Configures a system set in the default schedule, adding the set if it does not exist. - #[deprecated(since = "0.12.0", note = "Please use `configure_sets` instead.")] - #[track_caller] - pub fn configure_set( - &mut self, - schedule: impl ScheduleLabel, - set: impl IntoSystemSetConfigs, - ) -> &mut Self { - self.configure_sets(schedule, set) - } - /// Configures a collection of system sets in the default schedule, adding any sets that do not exist. #[track_caller] pub fn configure_sets( diff --git a/crates/bevy_asset/src/path.rs b/crates/bevy_asset/src/path.rs index db2c48fb88b0d..44e1ebb212dca 100644 --- a/crates/bevy_asset/src/path.rs +++ b/crates/bevy_asset/src/path.rs @@ -597,10 +597,6 @@ impl Typed for AssetPath<'static> { } } impl Reflect for AssetPath<'static> { - #[inline] - fn type_name(&self) -> &str { - ::core::any::type_name::() - } #[inline] fn get_represented_type_info(&self) -> Option<&'static TypeInfo> { Some(::type_info()) diff --git a/crates/bevy_ecs/README.md b/crates/bevy_ecs/README.md index 2763970807961..f23b02092a2e4 100644 --- a/crates/bevy_ecs/README.md +++ b/crates/bevy_ecs/README.md @@ -300,7 +300,7 @@ fn writer(mut writer: EventWriter) { } fn reader(mut reader: EventReader) { - for event in reader.iter() { + for event in reader.read() { } } ``` diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index 222c6101ceee4..ef594fcf00f53 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -131,12 +131,12 @@ struct EventInstance { /// events.send(MyEvent { value: 1 }); /// /// // somewhere else: read the events -/// for event in reader.iter(&events) { +/// for event in reader.read(&events) { /// assert_eq!(event.value, 1) /// } /// /// // events are only processed once per reader -/// assert_eq!(reader.iter(&events).count(), 0); +/// assert_eq!(reader.read(&events).count(), 0); /// ``` /// /// # Details @@ -421,25 +421,11 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { self.reader.read(&self.events) } - /// Iterates over the events this [`EventReader`] has not seen yet. This updates the - /// [`EventReader`]'s event counter, which means subsequent event reads will not include events - /// that happened before now. - #[deprecated = "use `.read()` instead."] - pub fn iter(&mut self) -> EventIterator<'_, E> { - self.reader.read(&self.events) - } - /// Like [`read`](Self::read), except also returning the [`EventId`] of the events. pub fn read_with_id(&mut self) -> EventIteratorWithId<'_, E> { self.reader.read_with_id(&self.events) } - /// Like [`iter`](Self::iter), except also returning the [`EventId`] of the events. - #[deprecated = "use `.read_with_id() instead."] - pub fn iter_with_id(&mut self) -> EventIteratorWithId<'_, E> { - self.reader.read_with_id(&self.events) - } - /// Determines the number of events available to be read from this [`EventReader`] without consuming any. pub fn len(&self) -> usize { self.reader.len(&self.events) @@ -472,8 +458,8 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> { /// Consumes all available events. /// - /// This means these events will not appear in calls to [`EventReader::iter()`] or - /// [`EventReader::iter_with_id()`] and [`EventReader::is_empty()`] will return `true`. + /// This means these events will not appear in calls to [`EventReader::read()`] or + /// [`EventReader::read_with_id()`] and [`EventReader::is_empty()`] will return `true`. /// /// For usage, see [`EventReader::is_empty()`]. pub fn clear(&mut self) { @@ -583,23 +569,11 @@ impl ManualEventReader { self.read_with_id(events).without_id() } - /// See [`EventReader::iter`] - #[deprecated = "use `.read()` instead."] - pub fn iter<'a>(&'a mut self, events: &'a Events) -> EventIterator<'a, E> { - self.read_with_id(events).without_id() - } - /// See [`EventReader::read_with_id`] pub fn read_with_id<'a>(&'a mut self, events: &'a Events) -> EventIteratorWithId<'a, E> { EventIteratorWithId::new(self, events) } - /// See [`EventReader::iter_with_id`] - #[deprecated = "use `.read_with_id() instead."] - pub fn iter_with_id<'a>(&'a mut self, events: &'a Events) -> EventIteratorWithId<'a, E> { - EventIteratorWithId::new(self, events) - } - /// See [`EventReader::len`] pub fn len(&self, events: &Events) -> usize { // The number of events in this reader is the difference between the most recent event @@ -636,13 +610,6 @@ pub struct EventIterator<'a, E: Event> { iter: EventIteratorWithId<'a, E>, } -/// An iterator that yields any unread events from an [`EventReader`] or [`ManualEventReader`]. -/// -/// This is a type alias for [`EventIterator`], which used to be called `ManualEventIterator`. -/// This type alias will be removed in the next release of bevy, so you should use [`EventIterator`] directly instead. -#[deprecated = "This type has been renamed to `EventIterator`."] -pub type ManualEventIterator<'a, E> = EventIterator<'a, E>; - impl<'a, E: Event> Iterator for EventIterator<'a, E> { type Item = &'a E; fn next(&mut self) -> Option { @@ -683,13 +650,6 @@ pub struct EventIteratorWithId<'a, E: Event> { unread: usize, } -/// An iterator that yields any unread events (and their IDs) from an [`EventReader`] or [`ManualEventReader`]. -/// -/// This is a type alias for [`EventIteratorWithId`], which used to be called `ManualEventIteratorWithId`. -/// This type alias will be removed in the next release of bevy, so you should use [`EventIteratorWithId`] directly instead. -#[deprecated = "This type has been renamed to `EventIteratorWithId`."] -pub type ManualEventIteratorWithId<'a, E> = EventIteratorWithId<'a, E>; - impl<'a, E: Event> EventIteratorWithId<'a, E> { /// Creates a new iterator that yields any `events` that have not yet been seen by `reader`. pub fn new(reader: &'a mut ManualEventReader, events: &'a Events) -> Self { diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index f4e644506f982..ad8ba9b39a51f 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -28,10 +28,6 @@ pub mod prelude { #[doc(hidden)] #[cfg(feature = "bevy_reflect")] pub use crate::reflect::{AppTypeRegistry, ReflectComponent, ReflectResource}; - #[allow(deprecated)] - pub use crate::system::adapter::{ - self as system_adapter, dbg, error, ignore, info, unwrap, warn, - }; #[doc(hidden)] pub use crate::{ bundle::Bundle, diff --git a/crates/bevy_ecs/src/query/par_iter.rs b/crates/bevy_ecs/src/query/par_iter.rs index 97165883694f8..1454b6ef51648 100644 --- a/crates/bevy_ecs/src/query/par_iter.rs +++ b/crates/bevy_ecs/src/query/par_iter.rs @@ -156,19 +156,6 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryParIter<'w, 's, Q, F> { } } - /// Runs `func` on each query result in parallel. - /// - /// # Panics - /// If the [`ComputeTaskPool`] is not initialized. If using this from a query that is being - /// initialized and run from the ECS scheduler, this should never panic. - /// - /// [`ComputeTaskPool`]: bevy_tasks::ComputeTaskPool - #[inline] - #[deprecated = "use `.for_each(...)` instead."] - pub fn for_each_mut) + Send + Sync + Clone>(self, func: FN) { - self.for_each(func); - } - #[cfg(all(not(target = "wasm32"), feature = "multi-threaded"))] fn get_batch_size(&self, thread_count: usize) -> usize { if self.batching_strategy.batch_size_limits.is_empty() { diff --git a/crates/bevy_ecs/src/reflect/entity_commands.rs b/crates/bevy_ecs/src/reflect/entity_commands.rs index f0856da378d52..c99690ffa2e35 100644 --- a/crates/bevy_ecs/src/reflect/entity_commands.rs +++ b/crates/bevy_ecs/src/reflect/entity_commands.rs @@ -127,7 +127,7 @@ pub trait ReflectCommandExt { /// // ComponentA or ComponentB. No matter which component is in the resource though, /// // we can attempt to remove any component of that same type from an entity. /// commands.entity(prefab.entity) - /// .remove_reflect(prefab.component.type_name().to_owned()); + /// .remove_reflect(prefab.component.reflect_type_path().to_owned()); /// } /// /// ``` diff --git a/crates/bevy_ecs/src/removal_detection.rs b/crates/bevy_ecs/src/removal_detection.rs index 26f8fd1c53ec0..3bfed91935643 100644 --- a/crates/bevy_ecs/src/removal_detection.rs +++ b/crates/bevy_ecs/src/removal_detection.rs @@ -128,7 +128,7 @@ impl RemovedComponentEvents { /// # #[derive(Component)] /// # struct MyComponent; /// fn react_on_removal(mut removed: RemovedComponents) { -/// removed.iter().for_each(|removed_entity| println!("{:?}", removed_entity)); +/// removed.read().for_each(|removed_entity| println!("{:?}", removed_entity)); /// } /// # bevy_ecs::system::assert_is_system(react_on_removal); /// ``` @@ -208,14 +208,6 @@ impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> { .map(RemovedComponentEntity::into) } - /// Iterates over the events this [`RemovedComponents`] has not seen yet. This updates the - /// [`RemovedComponents`]'s event counter, which means subsequent event reads will not include events - /// that happened before now. - #[deprecated = "use `.read()` instead."] - pub fn iter(&mut self) -> RemovedIter<'_> { - self.read() - } - /// Like [`read`](Self::read), except also returning the [`EventId`] of the events. pub fn read_with_id(&mut self) -> RemovedIterWithId<'_> { self.reader_mut_with_events() @@ -225,12 +217,6 @@ impl<'w, 's, T: Component> RemovedComponents<'w, 's, T> { .map(map_id_events) } - /// Like [`iter`](Self::iter), except also returning the [`EventId`] of the events. - #[deprecated = "use `.read_with_id()` instead."] - pub fn iter_with_id(&mut self) -> RemovedIterWithId<'_> { - self.read_with_id() - } - /// Determines the number of removal events available to be read from this [`RemovedComponents`] without consuming any. pub fn len(&self) -> usize { self.events() diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 8d65f61119e61..c5012f8f1491b 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -232,13 +232,6 @@ impl Schedule { self } - /// Configures a system set in this schedule, adding it if it does not exist. - #[deprecated(since = "0.12.0", note = "Please use `configure_sets` instead.")] - #[track_caller] - pub fn configure_set(&mut self, set: impl IntoSystemSetConfigs) -> &mut Self { - self.configure_sets(set) - } - /// Configures a collection of system sets in this schedule, adding them if they does not exist. #[track_caller] pub fn configure_sets(&mut self, sets: impl IntoSystemSetConfigs) -> &mut Self { diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 5b6b68d7859e2..02f1db9cb80b9 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -156,7 +156,7 @@ impl SystemMeta { /// world.resource_scope(|world, mut cached_state: Mut| { /// let mut event_reader = cached_state.event_state.get_mut(world); /// -/// for events in event_reader.iter() { +/// for events in event_reader.read() { /// println!("Hello World!"); /// } /// }); diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index a8578ae3d4357..c50798d623097 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -232,226 +232,6 @@ impl IntoSystem for T { /// ``` pub struct In(pub In); -/// A collection of common adapters for [piping](crate::system::PipeSystem) the result of a system. -#[deprecated = "this form of system adapter has been deprecated in favor of `system.map(...)`"] -pub mod adapter { - use crate::system::In; - use bevy_utils::tracing; - use std::fmt::Debug; - - /// Converts a regular function into a system adapter. - /// - /// # Examples - /// ``` - /// use bevy_ecs::prelude::*; - /// - /// fn return1() -> u64 { 1 } - /// - /// return1 - /// .pipe(system_adapter::new(u32::try_from)) - /// .pipe(system_adapter::unwrap) - /// .pipe(print); - /// - /// fn print(In(x): In) { - /// println!("{x:?}"); - /// } - /// ``` - #[deprecated = "use `.map(...)` instead"] - pub fn new(mut f: impl FnMut(T) -> U) -> impl FnMut(In) -> U { - move |In(x)| f(x) - } - - /// System adapter that unwraps the `Ok` variant of a [`Result`]. - /// This is useful for fallible systems that should panic in the case of an error. - /// - /// There is no equivalent adapter for [`Option`]. Instead, it's best to provide - /// an error message and convert to a `Result` using `ok_or{_else}`. - /// - /// # Examples - /// - /// Panicking on error - /// - /// ``` - /// use bevy_ecs::prelude::*; - /// - /// // Building a new schedule/app... - /// let mut sched = Schedule::default(); - /// sched.add_systems( - /// // Panic if the load system returns an error. - /// load_save_system.pipe(system_adapter::unwrap) - /// ) - /// // ... - /// # ; - /// # let mut world = World::new(); - /// # sched.run(&mut world); - /// - /// // A system which may fail irreparably. - /// fn load_save_system() -> Result<(), std::io::Error> { - /// let save_file = open_file("my_save.json")?; - /// dbg!(save_file); - /// Ok(()) - /// } - /// # fn open_file(name: &str) -> Result<&'static str, std::io::Error> - /// # { Ok("hello world") } - /// ``` - #[deprecated = "use `.map(Result::unwrap)` instead"] - pub fn unwrap(In(res): In>) -> T { - res.unwrap() - } - - /// System adapter that utilizes the [`bevy_utils::tracing::info!`] macro to print system information. - /// - /// # Examples - /// - /// ``` - /// use bevy_ecs::prelude::*; - /// - /// // Building a new schedule/app... - /// let mut sched = Schedule::default(); - /// sched.add_systems( - /// // Prints system information. - /// data_pipe_system.pipe(system_adapter::info) - /// ) - /// // ... - /// # ; - /// # let mut world = World::new(); - /// # sched.run(&mut world); - /// - /// // A system that returns a String output. - /// fn data_pipe_system() -> String { - /// "42".to_string() - /// } - /// ``` - #[deprecated = "use `.map(bevy_utils::info)` instead"] - pub fn info(In(data): In) { - tracing::info!("{:?}", data); - } - - /// System adapter that utilizes the [`bevy_utils::tracing::debug!`] macro to print the output of a system. - /// - /// # Examples - /// - /// ``` - /// use bevy_ecs::prelude::*; - /// - /// // Building a new schedule/app... - /// let mut sched = Schedule::default(); - /// sched.add_systems( - /// // Prints debug data from system. - /// parse_message_system.pipe(system_adapter::dbg) - /// ) - /// // ... - /// # ; - /// # let mut world = World::new(); - /// # sched.run(&mut world); - /// - /// // A system that returns a Result output. - /// fn parse_message_system() -> Result { - /// Ok("42".parse()?) - /// } - /// ``` - #[deprecated = "use `.map(bevy_utils::dbg)` instead"] - pub fn dbg(In(data): In) { - tracing::debug!("{:?}", data); - } - - /// System adapter that utilizes the [`bevy_utils::tracing::warn!`] macro to print the output of a system. - /// - /// # Examples - /// - /// ``` - /// use bevy_ecs::prelude::*; - /// - /// // Building a new schedule/app... - /// # let mut sched = Schedule::default(); - /// sched.add_systems( - /// // Prints system warning if system returns an error. - /// warning_pipe_system.pipe(system_adapter::warn) - /// ) - /// // ... - /// # ; - /// # let mut world = World::new(); - /// # sched.run(&mut world); - /// - /// // A system that returns a Result<(), String> output. - /// fn warning_pipe_system() -> Result<(), String> { - /// Err("Got to rusty?".to_string()) - /// } - /// ``` - #[deprecated = "use `.map(bevy_utils::warn)` instead"] - pub fn warn(In(res): In>) { - if let Err(warn) = res { - tracing::warn!("{:?}", warn); - } - } - - /// System adapter that utilizes the [`bevy_utils::tracing::error!`] macro to print the output of a system. - /// - /// # Examples - /// - /// ``` - /// use bevy_ecs::prelude::*; - /// // Building a new schedule/app... - /// let mut sched = Schedule::default(); - /// sched.add_systems( - /// // Prints system error if system fails. - /// parse_error_message_system.pipe(system_adapter::error) - /// ) - /// // ... - /// # ; - /// # let mut world = World::new(); - /// # sched.run(&mut world); - /// - /// // A system that returns a Result<())> output. - /// fn parse_error_message_system() -> Result<(), String> { - /// Err("Some error".to_owned()) - /// } - /// ``` - #[deprecated = "use `.map(bevy_utils::error)` instead"] - pub fn error(In(res): In>) { - if let Err(error) = res { - tracing::error!("{:?}", error); - } - } - - /// System adapter that ignores the output of the previous system in a pipe. - /// This is useful for fallible systems that should simply return early in case of an `Err`/`None`. - /// - /// # Examples - /// - /// Returning early - /// - /// ``` - /// use bevy_ecs::prelude::*; - /// - /// // Marker component for an enemy entity. - /// #[derive(Component)] - /// struct Monster; - /// - /// // Building a new schedule/app... - /// # let mut sched = Schedule::default(); sched - /// .add_systems( - /// // If the system fails, just move on and try again next frame. - /// fallible_system.pipe(system_adapter::ignore) - /// ) - /// // ... - /// # ; - /// # let mut world = World::new(); - /// # sched.run(&mut world); - /// - /// // A system which may return early. It's more convenient to use the `?` operator for this. - /// fn fallible_system( - /// q: Query> - /// ) -> Option<()> { - /// let monster_id = q.iter().next()?; - /// println!("Monster entity is {monster_id:?}"); - /// Some(()) - /// } - /// ``` - #[deprecated = "use `.map(std::mem::drop)` instead"] - pub fn ignore(In(_): In) {} -} - /// Ensure that a given function is a [system](System). /// /// This should be used when writing doc examples, diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 2b5d73d1ccfe0..47d42c29069cf 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -322,7 +322,7 @@ fn assert_component_access_compatibility( /// &World, /// )>, /// ) { -/// for event in set.p0().iter() { +/// for event in set.p0().read() { /// // ... /// # let _event = event; /// } diff --git a/crates/bevy_reflect/src/reflect.rs b/crates/bevy_reflect/src/reflect.rs index d36fd5db94f21..458022566baa5 100644 --- a/crates/bevy_reflect/src/reflect.rs +++ b/crates/bevy_reflect/src/reflect.rs @@ -73,24 +73,6 @@ pub enum ReflectOwned { /// [derive macro]: bevy_reflect_derive::Reflect /// [crate-level documentation]: crate pub trait Reflect: DynamicTypePath + Any + Send + Sync { - /// Returns the type path of the underlying type. - /// - /// This type path will either be found through [`get_represented_type_info`] - /// or taken from a [`TypePath`] implementation if the former isn't available. - /// - /// This method is deprecated; please consider migrating to one of the above methods. - /// - /// [`get_represented_type_info`]: Reflect::get_represented_type_info - #[deprecated( - since = "0.12.0", - note = "view the method documentation to find alternatives to this method." - )] - fn type_name(&self) -> &str { - self.get_represented_type_info() - .map(|info| info.type_path()) - .unwrap_or_else(|| self.reflect_type_path()) - } - /// Returns the [`TypeInfo`] of the type _represented_ by this value. /// /// For most types, this will simply return their own `TypeInfo`.