-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Deprecate static mut
#3560
base: master
Are you sure you want to change the base?
Deprecate static mut
#3560
Conversation
static mut
" RFCstatic mut
Thanks for the RFC! I see that a key point here is that C FFI is suggested to use
Is there any way that we can make this compatibility / migration easier for everyone? |
Hi David, I personally thought the comments were sufficient, but I'll add a dedicated example when I have time. Speaking of The ultimate tool we have to ease migration is an excellent migration guide, but it's also generally good practice to have a The output of |
Given the RFC proposes edition-gating the warning, as long as |
Ah, that's of course the answer, I had not considered that PyO3's migration pathway will be to not change anything until MSRV is bumped past 2024 edition. And as you say, as long as |
Wait, are you not mandated to be able to use future edition crate versions? |
It seems to me that deprecation is relatively uncontroversial but removal may not be. The only thing this RFC has to say about it is:
I think there is a reason: to maintain backwards compatibility. I mean, not even outright bad and error-prone APIs like What about a deprecation lint that in Rust 2024 is warn by default, and in Rust 2027 and later is deny by default? This is practically the same as a removal, but with a escape hatch. Maybe the RFC could list this as an alternative. This covers the case where someone has perfectly sound and working |
Hi Elias, I don't understand exactly what it is that you're trying to escape hatch here. Could you please clarify? Also, |
I think their final paragraph says exactly the case:
As to standard library vs language, it actually doesn't matter. A break is a break, and people don't care much about splitting hairs once their code is broken. |
Oh, I'd assumed the standard library and the language would have different policies for breaking things. If the case we want to escape hatch is not wanting to port your code to use interior mutability for any reason then we can add the attribute described as an option in the RFC where: pub static mut MY_STATIC: Ty = ...;
// becomes
#[legacy_static_mut]
pub static MY_STATIC: Ty = ...; This is easily |
I don't understand this question? Each crate defines its own edition. |
I would prefer to simply deprecate it across all editions and leave possible 2027 removal as something to be decided on the next edition. This fits with our general strategy, which is that we try to make behavior across editions as uniform as we can. TL;DR the reason to deprecate in an edition (to me) is if the solution is only present in 1 edition. If the solution applies in all editions (and I think it does), then let's do it uniformly. The question then is:
|
Good point about deprecation. I'll make that clear in the RFC. About removal, yeah, we can remove that from this RFC and make another one in 2026 or so, the result is (hopefully) the same. As discussed in the RFC, As for We don't have any actual code yet so no crater runs but I did some code searches and there's a lot of |
We discussed this in the T-lang triage meeting today. Our consensus was in favor of what @nikomatsakis described here. We would like to see the proposal modified to specify making this lint fire on all editions subject to first ensuring that we have stabilized and made available the replacement solutions that people will need. We agreed that Rust 2024 would be too early to make this a hard error and that we might consider it for later editions. High level, this is something we've discussed for some time and something that we're interested in doing. Thanks @dyslexicsteak for putting together a concrete proposal here. |
Alright, understood. Shall I modify the PR name and to reflect a reduction of the RFC's scope i.e. removal left as an encouraged future possibility but not an integral part of the RFC? |
Reading the discussion around this RFC, I've been wondering: why can't the already-implemented rust-lang/rust#117556 (deprecating In a world where the only way to reference a What makes raw-pointer-only |
My take is that although after reducing its potency by deprecating references to it it becomes similar to Removing wholly can be discussed later on, as I'm most likely reducing the scope of this RFC to exclude that and relegate it to a future possibility. |
Yes. I went ahead and removed the "remove" part. Feel free to edit further if we can be more clear.
It seems likely to me that this question will come up in further lang team discussion. It would be valuable, I would suggest @dyslexicsteak, for this proposed RFC to discuss and analyze this point in considerable detail (i.e. extending further your brief remarks above). |
You still need to clean the body of RFC from "removal part" and maybe insert part of them into "future possibilities" |
No, I'm working on it. |
…precate-static-mut.md Reduce RFC scope and change text to reflect that
Rectify a quoting error
@rustbot labels -A-edition-2024 +A-maybe-next-edition We discussed the timeline of edition items in the lang meeting today, and this didn't make the list, so it seems unlikely this will happen for Rust 2024. We'll keep this in mind for future editions. Thanks to everyone working on this and providing helpful feedback here. |
Hello, I want to note that at the moment we cannot replace all use cases of #![feature(sync_unsafe_cell)]
use std::cell::SyncUnsafeCell;
static mut FOO: &'static mut i32 = unsafe { &mut BAR };
static mut BAR: i32 = 3;
static FOO_W: SyncUnsafeCell<&'static mut i32> = SyncUnsafeCell::new(unsafe { &mut *BAR_W.get() });
static BAR_W: SyncUnsafeCell<i32> = SyncUnsafeCell::new(3);
|
Yes, no problem. This can wait until |
Pre-RFC on IRLO.
Results from research survey to inform discussion with respect to perception of the feature. (JS required)
Rendered