-
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
#[may_dangle]
, a refined dropck escape hatch (tracking issue for RFC 1327)
#34761
Comments
…r=eddyb First step for rust-lang#34761
see also #28498 |
…sakis `#[may_dangle]` attribute `#[may_dangle]` attribute Second step of rust-lang#34761. Last big hurdle before we can work in earnest towards Allocator integration (rust-lang#32838) Note: I am not clear if this is *also* a syntax-breaking change that needs to be part of a breaking-batch.
…sakis `#[may_dangle]` attribute `#[may_dangle]` attribute Second step of rust-lang#34761. Last big hurdle before we can work in earnest towards Allocator integration (rust-lang#32838) Note: I am not clear if this is *also* a syntax-breaking change that needs to be part of a breaking-batch.
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]` CC rust-lang#34761 r? @pnkfelix
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]` CC rust-lang#34761 r? @pnkfelix
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]` CC rust-lang#34761 r? @pnkfelix
Deprecate `#[unsafe_destructor_blind_to_params]` CC rust-lang#34761 r? @pnkfelix
Update nomicon to describe `#[may_dangle]` CC rust-lang#34761 r? @pnkfelix
I have to say I find |
An issue that came up in the context of Josephine is asajeffrey/josephine#52. This is mainly an issue for the interaction between the drop checker and untagged unions (#32836 (comment)) but does have impact on the code guidelines for when The issue is the text "When used on a type, e.g. |
|
Is there anything I can help to stabilize this feature? |
I don't think we intend to stabilize |
Hello. I'm proposing out-of-lifetime references which may be a potential solution to this problem: https://internals.rust-lang.org/t/proposal-about-out-of-lifetime-references/11675/11. Please take a look and leave any feedback or suggestions! |
We have some new docs in the forge on |
It's been a few years, and it doesn't seem like there will be a proper solution for this problem any time soon. Maybe it's time to stabilze |
Trivial blocker. There doesn't seem to be any restriction on where |
I feel like for an unsafe escape hatch it's probably not a great idea to have a strong effect system situation? If you're using this you're already doing some unsafe tricky thing; the user is already in a situation where they can't prove safety to the compiler; asking them to prove safety seems suboptimal I also do agree that this should be stable; being able to implement a stable |
A workaround hack that can sometimes work is taking types of the form: pub struct MyAbstraction<'a, T> {
stuff: *const T,
more_stuff: bool,
even_more_stuff: usize,
marker: PhantomData<&'a T>,
} and turning them into this: pub struct MyAbstraction<'a, T> {
eyepatch: MyAbstractionEyepatchHack< T>,
marker: PhantomData<&'a T>,
}
struct MyAbstractionEyepatchHack<T> {
stuff: *const T,
more_stuff: bool,
even_more_stuff: usize,
} and implementing |
…piler-errors Check that `#[may_dangle]` is properly applied It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation. Tracking issue: rust-lang#34761 cc rust-lang#34761 (comment)
…piler-errors Check that `#[may_dangle]` is properly applied It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation. Tracking issue: rust-lang#34761 cc rust-lang#34761 (comment)
…piler-errors Check that `#[may_dangle]` is properly applied It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation. Tracking issue: rust-lang#34761 cc rust-lang#34761 (comment)
Rollup merge of rust-lang#129235 - GoldsteinE:check-may-dangle, r=compiler-errors Check that `#[may_dangle]` is properly applied It's only valid when applied to a type or lifetime parameter in `Drop` trait implementation. Tracking issue: rust-lang#34761 cc rust-lang#34761 (comment)
Nearly five years have passed since this comment. As far as I’m aware, there’ve been no proposed solution and no goal to make one. I think it’s safe to say by this point that unless some actions are deliberately taken, the status quo will remain indefinitely. I think this state of affairs is less than satisfactory. As of now, it’s impossible to properly implement collections outside of the standard library. This interacts poorly with std’s (completely reasonable) desire to remain lean and leave more complex features to the ecosystem. For example, #56167 was recently closed because one can just use hashbrown, but hashbrown can’t provide a proper dropck interaction on stable. You need to choose between accurate dropck and advanced collection features. I don’t think blocking this on figuring out effect system, a massive feature that’s not really planned, is reasonable. A different syntax (e.g. I think it’s time to at least reevaluate the decision to leave this perma-unstable (even if it results in “yes, we’re leaving this perma-unstable because {reasons}” from T-lang). For what it’s worth, I fixed the technical blocker highlighted by @camsteffen. |
I chatted in Zulip for a bit, so here’s the status of this as I understood it. The current version of
I’m not totally sure, but as far as I understand it means it’s blocked on t-lang. Here’re the Zulip threads: |
It's not fully blocked on t-lang -- it needs someone who's taking over that PR to suggest and explain the idea to t-lang. However, before doing that it'd probably be good to ask for a t-lang liaison to ensure the team has the bandwidth to consider the proposal. |
Tracking issue for rust-lang/rfcs#1327
generic_param_attrs
feature): Attributes on generic formals #34764#[may_dangle]
attribute for lifetime/type formal parameters onunsafe impl<...> Drop
(dropck_eyepatch
feature)#[unsafe_destructor_blind_to_params]
attribute in libstd with#[may_dangle]
Replace uses of#[unsafe_destructor_blind_to_params]
with#[may_dangle]
#38664#[may_dangle]
instead of#[unsafe_destructor_blind_to_params]
Update nomicon to describe#[may_dangle]
#39196#[unsafe_destructor_blind_to_params]
attribute (with warning cycle before removal).#[unsafe_destructor_blind_to_params]
#38970#[unsafe_destructor_blind_to_params]
with[may_dangle]
before we can actually remove the former.For docs explaining the feature, also see the forge.
The text was updated successfully, but these errors were encountered: