Skip to content

Commit 5362a26

Browse files
committed
Fix CI issues
1 parent b97f915 commit 5362a26

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

crates/bevy_ecs/src/bundle/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl BundleInfo {
155155
self.id
156156
}
157157

158-
/// Returns the length of the explicit components part of the [contributed_components](Self::contributed_components) list.
158+
/// Returns the length of the explicit components part of the [`contributed_components`](Self::contributed_components) list.
159159
pub(super) fn explicit_components_len(&self) -> usize {
160160
self.contributed_components.len() - self.required_component_constructors.len()
161161
}

crates/bevy_ecs/src/component/required.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl RequiredComponents {
149149
///
150150
/// # Safety
151151
///
152-
/// - all other components in this [`RequiredComponents`] instance must have been registrated in `components`.
152+
/// - all other components in this [`RequiredComponents`] instance must have been registered in `components`.
153153
pub unsafe fn register<C: Component>(
154154
&mut self,
155155
components: &mut ComponentsRegistrator<'_>,
@@ -171,7 +171,7 @@ impl RequiredComponents {
171171
/// # Safety
172172
///
173173
/// - `component_id` must be a valid component in `components` for the type `C`;
174-
/// - all other components in this [`RequiredComponents`] instance must have been registrated in `components`.
174+
/// - all other components in this [`RequiredComponents`] instance must have been registered in `components`.
175175
pub unsafe fn register_by_id<C: Component>(
176176
&mut self,
177177
component_id: ComponentId,
@@ -198,7 +198,7 @@ impl RequiredComponents {
198198
/// # Safety
199199
///
200200
/// - `component_id` must be a valid component in `components`;
201-
/// - all other components in this [`RequiredComponents`] instance must have been registrated in `components`;
201+
/// - all other components in `self` must have been registered in `components`;
202202
/// - `constructor` must return a [`RequiredComponentConstructor`] that constructs a valid instance for the
203203
/// component with ID `component_id`.
204204
pub unsafe fn register_dynamic_with(
@@ -219,14 +219,17 @@ impl RequiredComponents {
219219
entry.insert(required_component.clone());
220220

221221
// Register inherited required components.
222+
// SAFETY:
223+
// - the caller guarantees all components that were in `self` have been registered in `components`;
224+
// - `component_id` has just been added, but is also guaranteed by the called to be valid in `components`.
222225
unsafe {
223226
Self::register_inherited_required_components_unchecked(
224227
&mut self.all,
225228
component_id,
226229
required_component,
227230
components,
228-
)
229-
};
231+
);
232+
}
230233

231234
true
232235
}
@@ -235,7 +238,7 @@ impl RequiredComponents {
235238
///
236239
/// # Safety
237240
///
238-
/// - all components in this [`RequiredComponents`] instance must have been registrated in `components`.
241+
/// - all components in `self` must have been registered in `components`.
239242
unsafe fn rebuild_inherited_required_components(&mut self, components: &Components) {
240243
// Clear `all`, we are re-initializing it.
241244
self.all.clear();
@@ -252,7 +255,7 @@ impl RequiredComponents {
252255
required_id,
253256
required_component.clone(),
254257
components,
255-
)
258+
);
256259
}
257260
}
258261
}
@@ -281,7 +284,7 @@ impl RequiredComponents {
281284
for (&inherited_id, inherited_required) in &info.required_components().all {
282285
// This is an inherited required component: insert it only if not already present.
283286
// By the invariants of `RequiredComponents`, `info.required_components().all` holds the required
284-
// components in a depth-first order, and this makes us store teh components in `self.all` also
287+
// components in a depth-first order, and this makes us store the components in `self.all` also
285288
// in depth-first order, as long as we don't overwrite existing ones.
286289
//
287290
// SAFETY:
@@ -426,7 +429,7 @@ impl Components {
426429
for &indirect_requiree in &new_requiree_components {
427430
// Extract the required components to avoid conflicting borrows. Remember to put this back before continuing!
428431
// SAFETY: `indirect_requiree` comes from `self`, so it must be valid.
429-
let mut required_components = std::mem::take(unsafe {
432+
let mut required_components = core::mem::take(unsafe {
430433
self.get_required_components_mut(indirect_requiree)
431434
.debug_checked_unwrap()
432435
});
@@ -474,7 +477,7 @@ impl Components {
474477
) {
475478
// Extract the required components to avoid conflicting borrows. Remember to put this back before returning!
476479
// SAFETY: The caller ensures that the `requiree` is valid.
477-
let mut required_components = std::mem::take(unsafe {
480+
let mut required_components = core::mem::take(unsafe {
478481
self.get_required_components_mut(requiree)
479482
.debug_checked_unwrap()
480483
});
@@ -537,7 +540,7 @@ pub(super) fn enforce_no_required_components_recursion(
537540

538541
#[cfg(test)]
539542
mod tests {
540-
use std::string::{String, ToString};
543+
use alloc::string::{String, ToString};
541544

542545
use crate::{
543546
bundle::Bundle,
@@ -1251,14 +1254,14 @@ mod tests {
12511254
#[test]
12521255
fn regression_19333() {
12531256
#[derive(Component)]
1254-
struct X(bool);
1257+
struct X(usize);
12551258

12561259
#[derive(Default, Component)]
1257-
#[require(X(false))]
1260+
#[require(X(0))]
12581261
struct Base;
12591262

12601263
#[derive(Default, Component)]
1261-
#[require(X(true), Base)]
1264+
#[require(X(1), Base)]
12621265
struct A;
12631266

12641267
#[derive(Default, Component)]
@@ -1271,7 +1274,7 @@ mod tests {
12711274

12721275
let mut w = World::new();
12731276

1274-
assert_eq!(w.spawn(B).get::<X>().unwrap().0, true);
1275-
assert_eq!(w.spawn(C).get::<X>().unwrap().0, true);
1277+
assert_eq!(w.spawn(B).get::<X>().unwrap().0, 1);
1278+
assert_eq!(w.spawn(C).get::<X>().unwrap().0, 1);
12761279
}
12771280
}

0 commit comments

Comments
 (0)