-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
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. |
I've marked this PR as controversial because there is active debate around whether this should be done crate-by-crate, or some other approach. I don't believe the goal of using Rust 2024 is controversial at all. |
Co-Authored-By: François Mockers <francois.mockers@vleue.com>
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. |
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