-
Notifications
You must be signed in to change notification settings - Fork 12.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
Arbitrary self types v2: pointers feature gate. #129664
Arbitrary self types v2: pointers feature gate. #129664
Conversation
r? @wesleywiser but don't review it yet until I'm sure it passes tests |
This comment has been minimized.
This comment has been minimized.
The main `arbitrary_self_types` feature gate will shortly be reused for a new version of arbitrary self types which we are amending per [this RFC](https://github.com/rust-lang/rfcs/blob/master/text/3519-arbitrary-self-types-v2.md). The main amendments are: * _do_ support `self` types which can't safely implement `Deref` * do _not_ support generic `self` types * do _not_ support raw pointers as `self` types. This PR relates to the last of those bullet points: this strips pointer support from the current `arbitrary_self_types` feature. We expect this to cause some amount of breakage for crates using this unstable feature to allow raw pointer self types. If that's the case, we want to know about it, and we want crate authors to know of the upcoming changes. For now, this can be resolved by adding the new `arbitrary_self_types_pointers` feature to such crates. If we determine that use of raw pointers as self types is common, then we may maintain that as an unstable feature even if we come to stabilize the rest of the `arbitrary_self_types` support in future. If we don't hear that this PR is causing breakage, then perhaps we don't need it at all, even behind an unstable feature gate. [Tracking issue](rust-lang#44874) This is [step 4 of the plan outlined here](rust-lang#44874 (comment))
6f31b93
to
e77eb04
Compare
The Miri subtree was changed cc @rust-lang/miri |
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.
Just a few minor suggestions 🙂
Looking at results for If you concur, I'm happy to r+! |
This comment was marked as resolved.
This comment was marked as resolved.
OK, I've been told that it's pretty expensive to do a crater run and not all that useful for nightly-only breakage, so I'll take the r+ then! |
We're right at the beginning of the release cycle so if there is unexpected, widespread breakage we have plenty of time to fix or revert before beta branches so I think this is the appropriate time to: @bors r+ |
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#101339 (enable -Zrandomize-layout in debug CI builds ) - rust-lang#120736 (rustdoc: add header map to the table of contents) - rust-lang#127021 (Add target support for RTEMS Arm) - rust-lang#128928 (CI: rfl: add more tools and steps) - rust-lang#129584 (warn the user if the upstream master branch is old) - rust-lang#129664 (Arbitrary self types v2: pointers feature gate.) - rust-lang#129752 (Make supertrait and implied predicates queries defaulted) - rust-lang#129918 (Update docs of `missing_abi` lint) - rust-lang#129919 (Stabilize `waker_getters`) - rust-lang#129925 (remove deprecated option `rust.split-debuginfo`) Failed merges: - rust-lang#129789 (rustdoc: use strategic boxing to shrink `clean::Item`) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#101339 (enable -Zrandomize-layout in debug CI builds ) - rust-lang#120736 (rustdoc: add header map to the table of contents) - rust-lang#127021 (Add target support for RTEMS Arm) - rust-lang#128928 (CI: rfl: add more tools and steps) - rust-lang#129584 (warn the user if the upstream master branch is old) - rust-lang#129664 (Arbitrary self types v2: pointers feature gate.) - rust-lang#129752 (Make supertrait and implied predicates queries defaulted) - rust-lang#129918 (Update docs of `missing_abi` lint) - rust-lang#129919 (Stabilize `waker_getters`) - rust-lang#129925 (remove deprecated option `rust.split-debuginfo`) Failed merges: - rust-lang#129789 (rustdoc: use strategic boxing to shrink `clean::Item`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129664 - adetaylor:arbitrary-self-types-pointers-feature-gate, r=wesleywiser Arbitrary self types v2: pointers feature gate. The main `arbitrary_self_types` feature gate will shortly be reused for a new version of arbitrary self types which we are amending per [this RFC](https://github.com/rust-lang/rfcs/blob/master/text/3519-arbitrary-self-types-v2.md). The main amendments are: * _do_ support `self` types which can't safely implement `Deref` * do _not_ support generic `self` types * do _not_ support raw pointers as `self` types. This PR relates to the last of those bullet points: this strips pointer support from the current `arbitrary_self_types` feature. We expect this to cause some amount of breakage for crates using this unstable feature to allow raw pointer self types. If that's the case, we want to know about it, and we want crate authors to know of the upcoming changes. For now, this can be resolved by adding the new `arbitrary_self_types_pointers` feature to such crates. If we determine that use of raw pointers as self types is common, then we may maintain that as an unstable feature even if we come to stabilize the rest of the `arbitrary_self_types` support in future. If we don't hear that this PR is causing breakage, then perhaps we don't need it at all, even behind an unstable feature gate. [Tracking issue](rust-lang#44874) This is [step 4 of the plan outlined here](rust-lang#44874 (comment))
Phew, panic over. It's because I was doing a completely gross hack in autocxx to work around the absence of arbitrary self types, and it's expected that it broke. In case anyone else hits the same thing, the gross hack was: // CppRef<T> is some smart pointer type
impl<'a, T: ?Sized> Deref for CppRef<'a, T> {
type Target = *const T; // note the pointer type here
#[inline]
fn deref(&self) -> &Self::Target {
// contents don't matter
}
} This hack tricked the deref algorithm to jumping from |
This broke crossmist. crossmist needs to serialize and deserialize objects all the time, including While serializing through Crucially, this is only valid if pointers are used, not references, because references can't be dangling or null. There are ways to workaround this, e.g. by using ZSTs or adding a I think the breakage is going to be more significant than expected and I hope arbitrary_self_types_pointers is not removed. |
@purplesyringa thanks for the report, good to know. First off, from my side, there's no particular pressure to remove Maybe your use-case could be accommodated using "regular" |
Sure, I just saw this in the OP and thought I should weigh in to prevent this outcome:
Wrapping the fat pointer in a newtype is fine, the more troublesome part is object safety. The method |
|
It might work, thanks! |
The main
arbitrary_self_types
feature gate will shortly be reused for a new version of arbitrary self types which we are amending per this RFC. The main amendments are:self
types which can't safely implementDeref
self
typesself
types.This PR relates to the last of those bullet points: this strips pointer support from the current
arbitrary_self_types
feature. We expect this to cause some amount of breakage for crates using this unstable feature to allow raw pointer self types. If that's the case, we want to know about it, and we want crate authors to know of the upcoming changes.For now, this can be resolved by adding the new
arbitrary_self_types_pointers
feature to such crates. If we determine that use of raw pointers as self types is common, then we may maintain that as an unstable feature even if we come to stabilize the rest of thearbitrary_self_types
support in future. If we don't hear that this PR is causing breakage, then perhaps we don't need it at all, even behind an unstable feature gate.Tracking issue
This is step 4 of the plan outlined here