Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tracking issue for RFC 3519:arbitrary_self_types #44874

Open
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-arbitrary_self_types`#![feature(arbitrary_self_types)]`S-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.S-types-deferredStatus: Identified as a valid potential future enhancement that is not currently being worked onT-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.
@arielb1

Description

@arielb1

This is the tracking issue for RFC 3519: Arbitrary self types v2.

The feature gate for this issue is#![feature(arbitrary_self_types)].

About tracking issues

Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is howevernot meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Current plan is:

Unresolved Questions

None.

Notable for Stabilization

Related

Implementation history


(Below follows content that predated the accepted Arbitrary Self Types v2 RFC.)

Details
  • figure out the object safety situation
  • figure out the handling of inference variables behind raw pointers
  • decide whether we want safe virtual raw pointer methods

Object Safety

See#27941 (comment)

Handling of inference variables

Calling a method on*const _ could now pick impls of the form

implRandomType{fnfoo(*constSelf){}}

Because method dispatch wants to be "limited", this won't really work, and as with the existing situation on&_ we should be emitting an "the type of this value must be known in this context" error.

This feels like fairly standard inference breakage, but we need to check the impact of this before proceeding.

Safe virtual raw pointer methods

e.g. this is UB, so we might want to force the call<dyn Foo as Foo>::bar to be unsafe somehow - e.g. by not allowingdyn Foo to be object safe unlessbar was anunsafe fn

traitFoo{fnbar(self:*constSelf);}fnmain(){// creates a raw pointer with a garbage vtablelet foo:*constdynFoo =unsafe{ mem::transmute([0usize,0x1000usize])};// and call it    foo.bar();// this is UB}

However, even today you could UB in safe code withmem::size_of_val(foo) on the above code, so this might not be actually a problem.

More information

There's no reason theself syntax has to be restricted to&T,&mut T andBox<T>, we should allow for more types there, e.g.

traitMyStuff{fndo_async_task(self:Rc<Self>);}implMyStufffor(){fndo_async_task(self:Rc<Self>){// ...}}Rc::new(()).do_async_stuff();

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-arbitrary_self_types`#![feature(arbitrary_self_types)]`S-tracking-needs-summaryStatus: It's hard to tell what's been done and what hasn't! Someone should do some investigation.S-types-deferredStatus: Identified as a valid potential future enhancement that is not currently being worked onT-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp