Skip to content

Commit 0b3a51b

Browse files
BD103mockersf
authored andcommitted
Add #[deprecated(since = "0.16.0", ...)] to items missing it (#18702)
- The `#[deprecated]` attributes supports a `since` field, which documents in which version an item was deprecated. This field is visible in `rustdoc`. - We inconsistently use `since` throughout the project. For an example of what `since` renders as, take a look at `ChildOf::get()`: ```rust /// The parent entity of this child entity. pub fn get(&self) -> Entity { self.0 } ``` ![image](https://github.com/user-attachments/assets/2ea5d8c9-2eab-430a-9a1c-421f315ff123) - Add `since = "0.16.0"` to all `#[deprecated]` attributes that do not already use it. - Add an example of deprecating a struct with the `since` field in the migration guide document. I would appreciate if this could be included in 0.16's release, as its a low-risk documentation improvement that is valuable for the release, but I'd understand if this was cut. You can use `cargo doc` to inspect the rendered form of `#[deprecated(since = "0.16.0", ...)]`.
1 parent c9fb956 commit 0b3a51b

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

crates/bevy_asset/src/handle.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ impl<T: Asset> Clone for Handle<T> {
150150

151151
impl<A: Asset> Handle<A> {
152152
/// Create a new [`Handle::Weak`] with the given [`u128`] encoding of a [`Uuid`].
153-
#[deprecated = "use the `weak_handle!` macro with a UUID string instead"]
153+
#[deprecated(
154+
since = "0.16.0",
155+
note = "use the `weak_handle!` macro with a UUID string instead"
156+
)]
154157
pub const fn weak_from_u128(value: u128) -> Self {
155158
Handle::Weak(AssetId::Uuid {
156159
uuid: Uuid::from_u128(value),

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ impl Hash for Entity {
244244
}
245245

246246
#[deprecated(
247+
since = "0.16.0",
247248
note = "This is exclusively used with the now deprecated `Entities::alloc_at_without_replacement`."
248249
)]
249250
pub(crate) enum AllocAtWithoutReplacement {
@@ -694,6 +695,7 @@ impl Entities {
694695
/// Returns the location of the entity currently using the given ID, if any. Location should be
695696
/// written immediately.
696697
#[deprecated(
698+
since = "0.16.0",
697699
note = "This can cause extreme performance problems when used after freeing a large number of entities and requesting an arbitrary entity. See #18054 on GitHub."
698700
)]
699701
pub fn alloc_at(&mut self, entity: Entity) -> Option<EntityLocation> {
@@ -728,6 +730,7 @@ impl Entities {
728730
///
729731
/// Returns the location of the entity currently using the given ID, if any.
730732
#[deprecated(
733+
since = "0.16.0",
731734
note = "This can cause extreme performance problems when used after freeing a large number of entities and requesting an arbitrary entity. See #18054 on GitHub."
732735
)]
733736
#[expect(

crates/bevy_ecs/src/system/query.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,10 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
15321532
/// - [`get_many`](Self::get_many) for the non-panicking version.
15331533
#[inline]
15341534
#[track_caller]
1535-
#[deprecated(note = "Use `get_many` instead and handle the Result.")]
1535+
#[deprecated(
1536+
since = "0.16.0",
1537+
note = "Use `get_many` instead and handle the Result."
1538+
)]
15361539
pub fn many<const N: usize>(&self, entities: [Entity; N]) -> [ROQueryItem<'_, D>; N] {
15371540
match self.get_many(entities) {
15381541
Ok(items) => items,
@@ -1929,7 +1932,10 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
19291932
/// - [`many`](Self::many) to get read-only query items.
19301933
#[inline]
19311934
#[track_caller]
1932-
#[deprecated(note = "Use `get_many_mut` instead and handle the Result.")]
1935+
#[deprecated(
1936+
since = "0.16.0",
1937+
note = "Use `get_many_mut` instead and handle the Result."
1938+
)]
19331939
pub fn many_mut<const N: usize>(&mut self, entities: [Entity; N]) -> [D::Item<'_>; N] {
19341940
match self.get_many_mut(entities) {
19351941
Ok(items) => items,
@@ -1993,7 +1999,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
19931999
}
19942000

19952001
/// A deprecated alias for [`single`](Self::single).
1996-
#[deprecated(note = "Please use `single` instead")]
2002+
#[deprecated(since = "0.16.0", note = "Please use `single` instead")]
19972003
pub fn get_single(&self) -> Result<ROQueryItem<'_, D>, QuerySingleError> {
19982004
self.single()
19992005
}
@@ -2028,7 +2034,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> Query<'w, 's, D, F> {
20282034
}
20292035

20302036
/// A deprecated alias for [`single_mut`](Self::single_mut).
2031-
#[deprecated(note = "Please use `single_mut` instead")]
2037+
#[deprecated(since = "0.16.0", note = "Please use `single_mut` instead")]
20322038
pub fn get_single_mut(&mut self) -> Result<D::Item<'_>, QuerySingleError> {
20332039
self.single_mut()
20342040
}

crates/bevy_ecs/src/world/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,7 @@ impl World {
22532253
/// ```
22542254
#[track_caller]
22552255
#[deprecated(
2256+
since = "0.16.0",
22562257
note = "This can cause extreme performance problems when used with lots of arbitrary free entities. See #18054 on GitHub."
22572258
)]
22582259
pub fn insert_or_spawn_batch<I, B>(&mut self, iter: I) -> Result<(), Vec<Entity>>
@@ -2272,6 +2273,7 @@ impl World {
22722273
/// as a command.
22732274
#[inline]
22742275
#[deprecated(
2276+
since = "0.16.0",
22752277
note = "This can cause extreme performance problems when used with lots of arbitrary free entities. See #18054 on GitHub."
22762278
)]
22772279
pub(crate) fn insert_or_spawn_batch_with_caller<I, B>(

0 commit comments

Comments
 (0)