Skip to content

Cleanup unneeded lifetimes in bevy_asset#15546

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
kristoff3r:asset-lifetime-cleanup
Sep 30, 2024
Merged

Cleanup unneeded lifetimes in bevy_asset#15546
alice-i-cecile merged 1 commit intobevyengine:mainfrom
kristoff3r:asset-lifetime-cleanup

Conversation

@kristoff3r
Copy link
Copy Markdown
Contributor

@kristoff3r kristoff3r commented Sep 30, 2024

Objective

Fixes #15541

A bunch of lifetimes were added during the Assets V2 rework, but after moving to async traits in #12550 they can be elided. That PR mentions that this might be the case, but apparently it wasn't followed up on at the time.

I ended up grepping for <'a and finding a similar case in bevy_reflect which I also fixed. (edit: that one was needed apparently)

Note that elided lifetimes are unstable in impl Trait. If that gets stabilized then we can elide even more.

Solution

Remove the extra lifetimes.

Testing

Everything still compiles. If I have messed something up there is a small risk that some user code stops compiling, but all the examples still work at least.


Migration Guide

The traits AssetLoader, AssetSaver and Process traits from bevy_asset now use elided lifetimes. If you implement these then remove the named lifetime.

@kristoff3r kristoff3r force-pushed the asset-lifetime-cleanup branch 2 times, most recently from d0a3521 to 8cc475f Compare September 30, 2024 20:24
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy 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 S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Sep 30, 2024
@alice-i-cecile
Copy link
Copy Markdown
Member

I love these changes: I'm largely going to let you fight CI here and let you two hash out what can and can't be done ;)

@kristoff3r kristoff3r force-pushed the asset-lifetime-cleanup branch 2 times, most recently from da89e3f to a54b6ac Compare September 30, 2024 20:39
@kristoff3r kristoff3r force-pushed the asset-lifetime-cleanup branch from a54b6ac to 2b61a99 Compare September 30, 2024 20:52
@kristoff3r
Copy link
Copy Markdown
Contributor Author

I love these changes: I'm largely going to let you fight CI here and let you two hash out what can and can't be done ;)

I'm done fighting now, there was some give and take so let's call it a draw.

@alice-i-cecile alice-i-cecile added S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Sep 30, 2024
Copy link
Copy Markdown
Contributor

@aecsocket aecsocket left a comment

Choose a reason for hiding this comment

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

Nice and straightforward, I found a few more places where you can get rid of lifetimes

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 30, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 30, 2024
Merged via the queue into bevyengine:main with commit 73af2b7 Sep 30, 2024
@kristoff3r kristoff3r deleted the asset-lifetime-cleanup branch September 30, 2024 22:13
robtfm pushed a commit to robtfm/bevy that referenced this pull request Oct 4, 2024
# Objective

Fixes bevyengine#15541

A bunch of lifetimes were added during the Assets V2 rework, but after
moving to async traits in bevyengine#12550 they can be elided. That PR mentions
that this might be the case, but apparently it wasn't followed up on at
the time.

~~I ended up grepping for `<'a` and finding a similar case in
`bevy_reflect` which I also fixed.~~ (edit: that one was needed
apparently)

Note that elided lifetimes are unstable in `impl Trait`. If that gets
stabilized then we can elide even more.

## Solution

Remove the extra lifetimes.

## Testing

Everything still compiles. If I have messed something up there is a
small risk that some user code stops compiling, but all the examples
still work at least.

---

## Migration Guide

The traits `AssetLoader`, `AssetSaver` and `Process` traits from
`bevy_asset` now use elided lifetimes. If you implement these then
remove the named lifetime.
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-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AssetServer lifetimes can probably be simplified

4 participants