-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking issue for pin ergonomics #130494
Copy link
Copy link
Labels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-pin_ergonomics`#![feature(pin_ergonomics)]``#![feature(pin_ergonomics)]`T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-pin_ergonomics`#![feature(pin_ergonomics)]``#![feature(pin_ergonomics)]`T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for Tracking Issue.
Projects
Status
Exploration
This is a tracking issue for work on pin ergonomics.
The feature gate for the issue is
#![feature(pin_ergonomics)].Design sketch
The basic pin projection rules that we're working toward are:
Alternative B:
T: Unpin,&pin mut Tand&mut Tcoerce to each other.struct,enum, orunion(?) defining a typeTis annotated with#[pin_v2](todo bikeshedding), then:&pin mut Tto&pin mut T.Uis allowed.T: Drop, theDropimpl must usefn drop(&pin mut self).Unpinare allowed onT.T, the pinning contract is upheld for all?Unpinfields ofT.(The rules apply likewise for
&pin const T.)Beyond pin projection, the basic overall idea of pin ergonomics is that
&pin mut T(and&pin const T) should be integrated in the same sense as&mut T, in that reborrowing works, autoref works, corresponding binding modes exist, and that the borrow checker will track and ensure that once a&pin mut Tis taken (even if no longer live) that we can't later get a&mut Tor moveT.Alternative A
The original proposal, now labeled Alternative A, was:
T: Unpin,&pin mut Tand&mut Tcoerce to each other.T: Drop + !Unpin, require theDropimpl forTto usefn drop(&pin mut self).&pin mut Tto&pin mut T.Uis allowed if eitherT: !UnpinorU: Unpin.These rules are factored differently (using coercions (see here) and the fact that we haven't stabilized negative impls yet), but have the same effect as the rules in Niko's otherwise similar MinPin proposal.
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 however not 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
&pin const/&pin mutconstructor syntax in nightly.&pin const/&pin muttype syntax in nightly.&pin (mut|const) Ttype position sugar #130635&pin const self/&pin mut selfargument syntax in nightly.&pin const selfand&pin mut selfsugars #135733&pin mut|const T#139751fn drop(&pin mut self).fn drop(&pin mut self)whenT: Drop + !Unpin.&pin (mut|const) Tand&(mut) TwhenT: Unpin.ForceUnpin<T>type.PinAPI.Unresolved Questions
Unpintrait (at least, the compiler usesis_unpinchecks in&pinhandling). That is a safe trait and hence cannot be deeply semantically meaningful. Is this coherent?Related
TODO.
cc @eholk @rust-lang/lang