{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/55786","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/55786/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/55786/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/55786/events","html_url":"https://github.com/rust-lang/rust/issues/55786","id":378779926,"node_id":"MDU6SXNzdWUzNzg3Nzk5MjY=","number":55786,"title":"[Stabilization] Stablize using some arbitrary self types defined in std","user":{"login":"withoutboats","id":9063376,"node_id":"MDQ6VXNlcjkwNjMzNzY=","avatar_url":"https://avatars2.githubusercontent.com/u/9063376?v=4","gravatar_id":"","url":"https://api.github.com/users/withoutboats","html_url":"https://github.com/withoutboats","followers_url":"https://api.github.com/users/withoutboats/followers","following_url":"https://api.github.com/users/withoutboats/following{/other_user}","gists_url":"https://api.github.com/users/withoutboats/gists{/gist_id}","starred_url":"https://api.github.com/users/withoutboats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/withoutboats/subscriptions","organizations_url":"https://api.github.com/users/withoutboats/orgs","repos_url":"https://api.github.com/users/withoutboats/repos","events_url":"https://api.github.com/users/withoutboats/events{/privacy}","received_events_url":"https://api.github.com/users/withoutboats/received_events","type":"User","site_admin":false},"labels":[{"id":211668019,"node_id":"MDU6TGFiZWwyMTE2NjgwMTk=","url":"https://api.github.com/repos/rust-lang/rust/labels/T-lang","name":"T-lang","color":"bfd4f2","default":false},{"id":919710011,"node_id":"MDU6TGFiZWw5MTk3MTAwMTE=","url":"https://api.github.com/repos/rust-lang/rust/labels/disposition-merge","name":"disposition-merge","color":"008800","default":false},{"id":923282386,"node_id":"MDU6TGFiZWw5MjMyODIzODY=","url":"https://api.github.com/repos/rust-lang/rust/labels/finished-final-comment-period","name":"finished-final-comment-period","color":"f9e189","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":25,"created_at":"2018-11-08T15:22:13Z","updated_at":"2018-12-28T00:19:12Z","closed_at":"2018-12-22T04:21:38Z","author_association":"CONTRIBUTOR","body":"Feature name: `arbitrary_self_types`\r\nStabilization target: 1.32.0\r\nTracking issue: #44874\r\nRelated RFCs: rust-lang/rfcs#2362\r\n\r\nThis is a proposal to stabilize a subset of the `arbitrary_self_types` feature,\r\nmaking it possible on stable to use valid \"arbitrary\" self types that have been\r\ndefined in the standard library, but not to define your own new self types.\r\n\r\n## Stabilized feature or APIs\r\n\r\nToday, only the following types are allowed as self types unless the user uses\r\nthe `arbitrary_self_types` flag:\r\n\r\n* `Self`\r\n* `&Self`\r\n* `&mut Self`\r\n* `Box<Self>`\r\n\r\nWe've long desired to extend this set to all pointer types defined in std, and\r\n(ideally) to arbitrary user defined pointer types. For quite a while now, the\r\nability to create user defined self types has existed on nightly under the\r\n`arbitrary_self_types` flag; in this stabilization, we propose to stabilize the\r\nextension of self types to all the relevant pointer types defined in std ~and\r\ntheir compositions~, while leaving the ability to create your own self types\r\nunstable for now while we iterate on the exact requirements.\r\n\r\nThe new self types that will be enabled by this stabilization are:\r\n\r\n* ~`*const Self`~\r\n* ~`*mut Self`~\r\n* `Rc<Self>`\r\n* `Arc<Self>`\r\n* `Pin<P>` where `P` is another type in this set.\r\n* ~The composition of any members in this set (e.g. `&Box<Self>`,\r\n  `Pin<&mut Rc<Self>>`).~\r\n\r\nAdditionally, all of these receiver types except for `Self` are object safe, in\r\nthe sense that they can be used as the receivers of object-safe trait methods.\r\n\r\n### ~Object safety of raw pointer types~\r\n\r\n~By making pointers object-safe, we have introduced an additional requirement on\r\nraw pointers: a wide raw pointer must contain valid metadata, even if the\r\ndata pointer is null or dangling. That is, a `*const dyn Trait` must have\r\na metadata pointer pointing to a valid vtable for `Trait`.~\r\n\r\n~As an alternative, we could possibly restrict this to only allowing raw\r\npointers as the receiver types for unsafe methods, and validity of the metadata\r\npointer would be an invariant the caller would be expected to uphold.~\r\n\r\n### Non-`Deref` pointer types\r\n\r\nLibrary defined pointer types can only be receiver types if they implement\r\n`Deref` currently. This excludes certain std pointer types that don't implement\r\n`Deref`, because they could be dangling:\r\n\r\n* `NonNull<Self>`\r\n* `rc::Weak<Self>`\r\n* `sync::Weak<Self>`\r\n\r\nThis stabilization is forward compatible with someday supporting these pointers\r\nas receiver types as we continue to iterate on the requirements of defining\r\narbitrary self types.\r\n\r\n### Magic traits involved\r\n\r\nIt's worth noting that currently the implementation of this functionality\r\ninvolves the intersection of several ops traits:\r\n\r\n* `Deref` - a self type must be deref, transitively targeting `Self`\r\n* `CoerceUnsized`\r\n* `DispatchFromDyn` - this and the previous are necessary for object safe\r\n* (potentially) `Receiver` - a private trait in std used to limit stabilization\r\n  only to these std traits\r\n\r\nThe interaction of this feature with these traits is *not* made stable as a\r\npart of this proposal. The traits listed that are still unstable remain\r\nunstable. We still have flexibility to iterate on the exact requirements on\r\narbitrary self types so long as those requirements include all of the types I\r\nhave enumerated previously.\r\n\r\n## Implementation changes prior to stabilization\r\n\r\n- [ ] `Receiver` trait to limit stable self types to those defined in std\r\n  (@mikeyhew is working on this)\r\n\r\n- [ ] Adjust documentation and diagnostics to note the additional valid\r\n  receiver types defined in std, instead of only the 4 accepted today\r\n\r\n## Connected features and larger milestones\r\n\r\nA trait making use of this feature is the `Future` trait, which is still\r\nunstable under the `futures_api` feature:\r\n\r\n```rust\r\ntrait Future {\r\n    type Output;\r\n    fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output>;\r\n}\r\n```\r\n\r\nBefore we can stabilize this trait, we need to stabilize the ability to\r\nimplement traits using `Pin<&mut Self>` as a receiver type: hence, this\r\nstabilization. Stabilizing the `futures_api` feature is a high priority because\r\nit is a blocker for stabilizing the async/await syntax, which makes nonblocking\r\nIO much more ergonomic for Rust.\r\n\r\ncc @mikeyhew"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/450260088","html_url":"https://github.com/rust-lang/rust/issues/55786#issuecomment-450260088","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/55786","id":450260088,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDI2MDA4OA==","user":{"login":"Centril","id":855702,"node_id":"MDQ6VXNlcjg1NTcwMg==","avatar_url":"https://avatars2.githubusercontent.com/u/855702?v=4","gravatar_id":"","url":"https://api.github.com/users/Centril","html_url":"https://github.com/Centril","followers_url":"https://api.github.com/users/Centril/followers","following_url":"https://api.github.com/users/Centril/following{/other_user}","gists_url":"https://api.github.com/users/Centril/gists{/gist_id}","starred_url":"https://api.github.com/users/Centril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Centril/subscriptions","organizations_url":"https://api.github.com/users/Centril/orgs","repos_url":"https://api.github.com/users/Centril/repos","events_url":"https://api.github.com/users/Centril/events{/privacy}","received_events_url":"https://api.github.com/users/Centril/received_events","type":"User","site_admin":false},"created_at":"2018-12-28T00:19:12Z","updated_at":"2018-12-28T00:19:12Z","author_association":"CONTRIBUTOR","body":"> Is there anyone who *doesn't* want compositions? If not, @withoutboats, could you please add compositions back for stabilization?\r\n\r\nFor the purposes of rfcbot, please create a new stabilization issue + report for compositions if y'all want to add that back."}}
{"actor":{"display_login":"Centril"}}