Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy warnings #11123

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ impl Entities {
/// Reserve entity IDs concurrently.
///
/// Storage for entity generation and location is lazily allocated by calling [`flush`](Entities::flush).
#[allow(clippy::unnecessary_fallible_conversions)] // Because `IdCursor::try_from` may fail on 32-bit platforms.
pub fn reserve_entities(&self, count: u32) -> ReserveEntitiesIterator {
// Use one atomic subtract to grab a range of new IDs. The range might be
// entirely nonnegative, meaning all IDs come from the freelist, or entirely
Expand Down Expand Up @@ -627,6 +628,7 @@ impl Entities {
}

/// Ensure at least `n` allocations can succeed without reallocating.
#[allow(clippy::unnecessary_fallible_conversions)] // Because `IdCursor::try_from` may fail on 32-bit platforms.
pub fn reserve(&mut self, additional: u32) {
self.verify_flushed();

Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/query/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
}

/// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
/// iter() method, but cannot be chained like a normal [`Iterator`].
/// `iter()` method, but cannot be chained like a normal [`Iterator`].
///
/// This can only be called for read-only queries, see [`Self::for_each_mut`] for write-queries.
///
Expand Down Expand Up @@ -1024,7 +1024,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {
}

/// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
/// iter() method, but cannot be chained like a normal [`Iterator`].
/// `iter()` method, but cannot be chained like a normal [`Iterator`].
///
/// # Safety
///
Expand Down Expand Up @@ -1086,7 +1086,7 @@ impl<D: QueryData, F: QueryFilter> QueryState<D, F> {

/// Runs `func` on each query result in parallel for the given [`World`], where the last change and
/// the current change tick are given. This is faster than the equivalent
/// iter() method, but cannot be chained like a normal [`Iterator`].
/// `iter()` method, but cannot be chained like a normal [`Iterator`].
///
/// # Panics
/// The [`ComputeTaskPool`] is not initialized. If using this from a query that is being
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/storage/blob_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl BlobVec {
/// The removed element is replaced by the last element of the `BlobVec`.
///
/// # Safety
/// It is the caller's responsibility to ensure that `index` is < self.len()
/// It is the caller's responsibility to ensure that `index` is `< self.len()`.
#[inline]
pub unsafe fn swap_remove_and_drop_unchecked(&mut self, index: usize) {
debug_assert!(index < self.len());
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ fn load_material(
}

/// Loads a glTF node.
#[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_arguments, clippy::result_large_err)]
fn load_node(
gltf_node: &Node,
world_builder: &mut WorldChildBuilder,
Expand Down Expand Up @@ -1291,6 +1291,7 @@ fn texture_address_mode(gltf_address_mode: &WrappingMode) -> ImageAddressMode {
}

/// Maps the `primitive_topology` form glTF to `wgpu`.
#[allow(clippy::result_large_err)]
fn get_primitive_topology(mode: Mode) -> Result<PrimitiveTopology, GltfError> {
match mode {
Mode::Points => Ok(PrimitiveTopology::PointList),
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/src/impls/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ impl<T: FromReflect + Clone + TypePath> FromReflect for Cow<'static, [T]> {
for field in ref_list.iter() {
temp_vec.push(T::from_reflect(field)?);
}
temp_vec.try_into().ok()
Some(temp_vec.into())
} else {
None
}
Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ impl GridTrack {
.into()
}

/// Create a fit-content() grid track with fixed pixel limit
/// Create a `fit-content()` grid track with fixed pixel limit.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content_function>
pub fn fit_content_px<T: From<Self>>(limit: f32) -> T {
Expand All @@ -1046,7 +1046,7 @@ impl GridTrack {
.into()
}

/// Create a fit-content() grid track with percentage limit
/// Create a `fit-content()` grid track with percentage limit.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/fit-content_function>
pub fn fit_content_percent<T: From<Self>>(limit: f32) -> T {
Expand All @@ -1057,7 +1057,7 @@ impl GridTrack {
.into()
}

/// Create a minmax() grid track
/// Create a `minmax()` grid track.
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/minmax>
pub fn minmax<T: From<Self>>(min: MinTrackSizingFunction, max: MaxTrackSizingFunction) -> T {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ impl RepeatedGridTrack {
.into()
}

/// Create a repeating set of fit-content() grid tracks with fixed pixel limit
/// Create a repeating set of `fit-content()` grid tracks with fixed pixel limit
pub fn fit_content_px<T: From<Self>>(repetition: u16, limit: f32) -> T {
Self {
repetition: GridTrackRepetition::Count(repetition),
Expand All @@ -1207,7 +1207,7 @@ impl RepeatedGridTrack {
.into()
}

/// Create a repeating set of fit-content() grid tracks with percentage limit
/// Create a repeating set of `fit-content()` grid tracks with percentage limit
pub fn fit_content_percent<T: From<Self>>(repetition: u16, limit: f32) -> T {
Self {
repetition: GridTrackRepetition::Count(repetition),
Expand All @@ -1216,7 +1216,7 @@ impl RepeatedGridTrack {
.into()
}

/// Create a repeating set of minmax() grid track
/// Create a repeating set of `minmax()` grid track
pub fn minmax<T: From<Self>>(
repetition: impl Into<GridTrackRepetition>,
min: MinTrackSizingFunction,
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,8 @@ pub struct Hashed<V, H = FixedState> {
impl<V: Hash, H: BuildHasher + Default> Hashed<V, H> {
/// Pre-hashes the given value using the [`BuildHasher`] configured in the [`Hashed`] type.
pub fn new(value: V) -> Self {
let builder = H::default();
let mut hasher = builder.build_hasher();
value.hash(&mut hasher);
Self {
hash: hasher.finish(),
hash: H::default().hash_one(&value),
value,
marker: PhantomData,
}
Expand Down
15 changes: 6 additions & 9 deletions examples/3d/transmission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,12 @@ fn setup(

let plane_mesh = meshes.add(shape::Plane::from_size(2.0).into());

let cylinder_mesh = meshes.add(
Mesh::try_from(shape::Cylinder {
radius: 0.5,
height: 2.0,
resolution: 50,
segments: 1,
})
.unwrap(),
);
let cylinder_mesh = meshes.add(Mesh::from(shape::Cylinder {
radius: 0.5,
height: 2.0,
resolution: 50,
segments: 1,
}));

// Cube #1
commands.spawn((
Expand Down