Skip to content

Remove unused parts of AssetLoaders::find#23703

Open
greeble-dev wants to merge 4 commits intobevyengine:mainfrom
greeble-dev:asset-loaders-find-unused-extension-parameter
Open

Remove unused parts of AssetLoaders::find#23703
greeble-dev wants to merge 4 commits intobevyengine:mainfrom
greeble-dev:asset-loaders-find-unused-extension-parameter

Conversation

@greeble-dev
Copy link
Copy Markdown
Contributor

@greeble-dev greeble-dev commented Apr 7, 2026

Objective

AssetLoaders::find maps from various properties to an asset loader:

fn find(
    &self,
    type_name: Option<&str>,
    asset_type_id: Option<TypeId>,
    extension: Option<&str>,
    asset_path: Option<&AssetPath<'_>>,
) -> Option<MaybeAssetLoader> {

But in practice the type_name and extension parameters are always None, and the asset_path parameter is always Some.

Solution

This PR removes the unused parts:

 fn find(
     &self,
-    type_name: Option<&str>,
     asset_type_id: Option<TypeId>,
-    extension: Option<&str>,
-    asset_path: Option<&AssetPath<'_>>,
+    asset_path: &AssetPath<'_>,
 ) -> Option<MaybeAssetLoader> {

AssetLoaders::find is pub(crate), so this should not affect users.

I looked back at the original PR and couldn't spot any cases where these parameters were ever used. I'm not sure if that's an oversight or if they were intended for future use.

I also made matching changes to AssetLoaderError::MissingAssetLoaders. This is pub so technically should have a migration guide. I'm not entirely convinced that's necessary for such a trivial change, but happy to add one if requested.

 MissingAssetLoader {
-    loader_name: Option<String>,
     asset_type_id: Option<TypeId>,
-    extension: Option<String>,
-    asset_path: Option<String>,
+    asset_path: String,
 },

Testing

cargo test -p bevy_asset
cargo run --example asset_loading
cargo run --example asset_processing --features="file_watcher asset_processor"

@greeble-dev greeble-dev added A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 7, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Assets Apr 7, 2026
Copy link
Copy Markdown
Contributor

@andriyDev andriyDev left a comment

Choose a reason for hiding this comment

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

Nice! Funnily enough I think I made a similar change in one of my branches. Not sure where that ended up haha. Good to see this make it in though, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

2 participants