-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
static_mut_refs: Automatic edition migration #123061
Comments
Here's what @scottmcm earlier had to say about this:
|
Yeah, this is a case of "please use this opportunity to carefully review your code, based on today's understanding of how references work". There's no sensible automatic migration. |
Yeah indeed edition changes are required to have automatic migrations implemented, but this is not a change where such automatic migration is easy to do (unlike say Maybe that policy should be evolved into: if the API/pattern is UB-prone and easy to misuse, it is okay to not offer automatic edition migrations. |
Forgive me if this has been suggested before, but is there room for a I'm imagining that something like this: static mut X: i32 = 0;
let _y = unsafe { &mut X }; Could be transformed into this: static mut X: i32 = 0;
let _y = unsafe {
// TODO: this was rewritten by `cargo fix`, and needs to be manually audited.
// See [https://github.com/rust-lang/rust/issues/114447] for more information.
&mut *std::ptr::addr_of_mut!(X)
}; |
We're not necessarily going to add any specific migration lints here as we want people to carefully review any code that is affected by this. So let's go ahead and close this as we'll be willing to mark this as ready for Rust 2024 without any lints here. |
#117556 implemented the
static_mut_refs
change for the 2024 Edition. However, the migration code is marked as maybe-incorrect, which prevents automatic migration. Is it possible to have an automatic migration for this change? If theaddr_of!
change is unlikely to work (see #123059), what is the scope of manual migration? How many crates will be affected by this change?If this has a very widespread impact, we should be very certain that we want to move forward without that migration.
The text was updated successfully, but these errors were encountered: