-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Upgrade to Rust Edition 2024 #17967
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
Upgrade to Rust Edition 2024 #17967
Conversation
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
removing the controversial tag, this PR is already done and almost ready, let's not block on that as we don't have an SME matching this PR |
Co-Authored-By: François Mockers <francois.mockers@vleue.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! And today I learned about repeat_n
and div_ceil
.
panic!("Observer triggered after being despawned.") | ||
}) | ||
.id(); | ||
let system: fn(Trigger<OnAdd, A>) = |_| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think these would be clearer as named functions. Converting to a fn
pointer adds a layer of indirection and wouldn't work if it took system params.
... But we don't have params here, and we hardly need to worry about an extra indirect jump when calling a function that always panics, so it's really not important. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! I'm just going to leave it as-is because I definitely would prefer that we actually support |...| -> !
closures as systems. It'll make the eventual PR that adds that support more explicit in its benefits too.
@bushrat011899 this has some conflicts from #17840. Could you resolve them? |
@mockersf Merged and CI is green! |
@mockersf Issue was caused by the use of I don't have a setup locally for checking this resolves the issue in CI, but it should be clear to merge now. |
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1996 if you'd like to help out. |
…raits (#18804) # Objective After #17967, closures which always panic no longer satisfy various Bevy traits. Principally, this affects observers, systems and commands. While this may seem pointless (systems which always panic are kind of useless), it is distinctly annoying when using the `todo!` macro, or when writing tests that should panic. Fixes #18778. ## Solution - Add failing tests to demonstrate the problem - Add the trick from [`never_say_never`](https://docs.rs/never-say-never/latest/never_say_never/) to name the `!` type on stable Rust - Write looots of docs explaining what the heck is going on and why we've done this terrible thing ## To do Unfortunately I couldn't figure out how to avoid conflicting impls, and I am out of time for today, the week and uh the week after that. Vacation! If you feel like finishing this for me, please submit PRs to my branch and I can review and press the button for it while I'm off. Unless you're Cart, in which case you have write permissions to my branch! - [ ] fix for commands - [ ] fix for systems - [ ] fix for observers - [ ] revert bevyengine/bevy-website#2092 ## Testing I've added a compile test for these failure cases and a few adjacent non-failing cases (with explicit return types). --------- Co-authored-by: Carter Anderson <mcanders1@gmail.com>
…raits (#18804) # Objective After #17967, closures which always panic no longer satisfy various Bevy traits. Principally, this affects observers, systems and commands. While this may seem pointless (systems which always panic are kind of useless), it is distinctly annoying when using the `todo!` macro, or when writing tests that should panic. Fixes #18778. ## Solution - Add failing tests to demonstrate the problem - Add the trick from [`never_say_never`](https://docs.rs/never-say-never/latest/never_say_never/) to name the `!` type on stable Rust - Write looots of docs explaining what the heck is going on and why we've done this terrible thing ## To do Unfortunately I couldn't figure out how to avoid conflicting impls, and I am out of time for today, the week and uh the week after that. Vacation! If you feel like finishing this for me, please submit PRs to my branch and I can review and press the button for it while I'm off. Unless you're Cart, in which case you have write permissions to my branch! - [ ] fix for commands - [ ] fix for systems - [ ] fix for observers - [ ] revert bevyengine/bevy-website#2092 ## Testing I've added a compile test for these failure cases and a few adjacent non-failing cases (with explicit return types). --------- Co-authored-by: Carter Anderson <mcanders1@gmail.com>
…raits (bevyengine#18804) # Objective After bevyengine#17967, closures which always panic no longer satisfy various Bevy traits. Principally, this affects observers, systems and commands. While this may seem pointless (systems which always panic are kind of useless), it is distinctly annoying when using the `todo!` macro, or when writing tests that should panic. Fixes bevyengine#18778. ## Solution - Add failing tests to demonstrate the problem - Add the trick from [`never_say_never`](https://docs.rs/never-say-never/latest/never_say_never/) to name the `!` type on stable Rust - Write looots of docs explaining what the heck is going on and why we've done this terrible thing ## To do Unfortunately I couldn't figure out how to avoid conflicting impls, and I am out of time for today, the week and uh the week after that. Vacation! If you feel like finishing this for me, please submit PRs to my branch and I can review and press the button for it while I'm off. Unless you're Cart, in which case you have write permissions to my branch! - [ ] fix for commands - [ ] fix for systems - [ ] fix for observers - [ ] revert bevyengine/bevy-website#2092 ## Testing I've added a compile test for these failure cases and a few adjacent non-failing cases (with explicit return types). --------- Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Objective
Solution
Testing
Summary of Changes
Documentation Indentation
When using lists in documentation, proper indentation is now linted for. This means subsequent lines within the same list item must start at the same indentation level as the item.
Implicit
!
to()
Conversion!
(the never return type, returned bypanic!
, etc.) no longer implicitly converts to()
. This is particularly painful for systems withtodo!
orpanic!
statements, as they will no longer be functions returning()
(orResult<()>
), making them invalid systems for functions likeadd_systems
. The ideal fix would be to accept functions returning!
(or rather, not returning), but this is blocked on the stabilisation of the!
type itself, which is not done.The "simple" fix would be to add an explicit
-> ()
to system signatures (e.g.,|| { todo!() }
becomes|| -> () { todo!() }
). However, this is also banned, as there is an existing lint which (IMO, incorrectly) marks this as an unnecessary annotation.So, the "fix" (read: workaround) is to put these kinds of
|| -> ! { ... }
closuers into variables and give the variable an explicit type (e.g.,fn()
).Temporary Variable Lifetimes
The order in which temporary variables are dropped has changed. The simple fix here is usually to just assign temporaries to a named variable before use.
gen
is a keywordWe can no longer use the name
gen
as it is reserved for a future generator syntax. This involved replacing uses of the namegen
withr#gen
(the raw-identifier syntax).Formatting has changed
Use statements have had the order of imports changed, causing a substantial +/-3,000 diff when applied. For now, I have opted-out of this change by amending
rustfmt.toml
This preserves the original formatting for now, reducing the size of this PR. It would be a simple followup to update this to 2024 and run
cargo fmt
.New
use<>
Opt-Out SyntaxLifetimes are now implicitly included in RPIT types. There was a handful of instances where it needed to be added to satisfy the borrow checker, but there may be more cases where it should be added to avoid breakages in user code.
MyUnitStruct { .. }
is an invalid patternPreviously, you could match against unit structs (and unit enum variants) with a
{ .. }
destructuring. This is no longer valid.Pretty much every use of
ref
andmut
are gonePattern binding has changed to the point where these terms are largely unused now. They still serve a purpose, but it is far more niche now.
iter::repeat(...).take(...)
is badNew lint recommends using the more explicit
iter::repeat_n(..., ...)
instead.Migration Guide
The lifetimes of functions using return-position impl-trait (RPIT) are likely more conservative than they had been previously. If you encounter lifetime issues with such a function, please create an issue to investigate the addition of
+ use<...>
.Notes