Skip to content
Merged
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
5 changes: 5 additions & 0 deletions crates/bevy_gltf/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![forbid(unsafe_code)]
#![deny(
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
reason = "See #17111; To be removed once all crates are in-line with these attributes"
)]
#![doc(
html_logo_url = "https://bevyengine.org/assets/icon.png",
html_favicon_url = "https://bevyengine.org/assets/icon.png"
Expand Down
48 changes: 40 additions & 8 deletions crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,10 @@ async fn load_gltf<'a, 'b, 'c>(
ReadOutputs::MorphTargetWeights(weights) => {
let weights: Vec<f32> = weights.into_f32().collect();
if keyframe_timestamps.len() == 1 {
#[allow(clippy::unnecessary_map_on_constructor)]
#[expect(
clippy::unnecessary_map_on_constructor,
reason = "While the mapping is unnecessary, it is much more readable at this level of indentation. Additionally, mapping makes it more consistent with the other branches."
)]
Some(ConstantCurve::new(Interval::EVERYWHERE, weights))
.map(WeightsCurve)
.map(VariableCurve::new)
Expand Down Expand Up @@ -1368,7 +1371,10 @@ fn warn_on_differing_texture_transforms(
}

/// Loads a glTF node.
#[allow(clippy::result_large_err)]
#[expect(
clippy::result_large_err,
reason = "`GltfError` is only barely past the threshold for large errors."
)]
fn load_node(
gltf_node: &Node,
world_builder: &mut WorldChildBuilder,
Expand Down Expand Up @@ -1723,7 +1729,10 @@ fn texture_handle(load_context: &mut LoadContext, texture: &gltf::Texture) -> Ha
///
/// This is a low-level function only used when the `gltf` crate has no support
/// for an extension, forcing us to parse its texture references manually.
#[allow(dead_code)]
#[cfg(any(
feature = "pbr_anisotropy_texture",
feature = "pbr_multi_layer_material_textures"
))]
fn texture_handle_from_info(
load_context: &mut LoadContext,
document: &Document,
Expand Down Expand Up @@ -1806,7 +1815,10 @@ fn texture_address_mode(gltf_address_mode: &WrappingMode) -> ImageAddressMode {
}

/// Maps the `primitive_topology` form glTF to `wgpu`.
#[allow(clippy::result_large_err)]
#[expect(
clippy::result_large_err,
reason = "`GltfError` is only barely past the threshold for large errors."
)]
fn get_primitive_topology(mode: Mode) -> Result<PrimitiveTopology, GltfError> {
match mode {
Mode::Points => Ok(PrimitiveTopology::PointList),
Expand Down Expand Up @@ -1876,7 +1888,10 @@ struct GltfTreeIterator<'a> {
}

impl<'a> GltfTreeIterator<'a> {
#[allow(clippy::result_large_err)]
#[expect(
clippy::result_large_err,
reason = "`GltfError` is only barely past the threshold for large errors."
)]
fn try_new(gltf: &'a gltf::Gltf) -> Result<Self, GltfError> {
let nodes = gltf.nodes().collect::<Vec<_>>();

Expand Down Expand Up @@ -2088,7 +2103,14 @@ struct ClearcoatExtension {
}

impl ClearcoatExtension {
#[allow(unused_variables)]
#[expect(
clippy::allow_attributes,
reason = "`unused_variables` is not always linted"
)]
#[allow(
unused_variables,
reason = "Depending on what features are used to compile this crate, certain parameters may end up unused."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add feature gates to parameters. This is a usability improvement for callers using those feature combinations.

Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClearcoatExtension (the struct this lint is in) is not a public struct, and this method is only called in one place; thus, there wouldn't be much of a point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im general, if the values at the call-sites aren't needed, it means that the caller can do less work to prepare arguments for the function. See how we festure gate render and text within bevy-ui. I'll approve this since it doesn't need to be addressed in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Yeah, even if we wanted to feature-gate it, I feel like that'd be work for a different PR.

)]
fn parse(
load_context: &mut LoadContext,
document: &Document,
Expand Down Expand Up @@ -2171,7 +2193,14 @@ struct AnisotropyExtension {
}

impl AnisotropyExtension {
#[allow(unused_variables)]
#[expect(
clippy::allow_attributes,
reason = "`unused_variables` is not always linted"
)]
#[allow(
unused_variables,
reason = "Depending on what features are used to compile this crate, certain parameters may end up unused."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add feature gates to parameters. This would be a usability improvement for callers using those feature combinations.

Copy link
Contributor Author

@LikeLakers2 LikeLakers2 Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnisotropyExtension (the struct this lint is in) is not a public struct, and this method is only called in one place; thus, there wouldn't be much of a point.

)]
fn parse(
load_context: &mut LoadContext,
document: &Document,
Expand Down Expand Up @@ -2305,7 +2334,10 @@ mod test {
}

fn load_gltf_into_app(gltf_path: &str, gltf: &str) -> App {
#[expect(unused)]
#[expect(
dead_code,
reason = "This struct is used to keep the handle alive. As such, we have no need to handle the handle directly."
)]
#[derive(Resource)]
struct GltfHandle(Handle<Gltf>);

Expand Down
Loading