Stream: wg-async-foundations

Topic: pin-self


nikomatsakis (Jun 26 2019 at 19:57, on Zulip):

So @Taylor Cramer, @centril, @eddyb: I'm trying to do my long-promised write-up for https://github.com/rust-lang/rust/pull/61207. As far as I can tell, our current behavior is pretty conservative -- I took some notes here. Is there a particular pattern that works which we are concerned about? I'm going back through our minutes to try and figure that out -- or is the sole concern that things which would be convenient don't work presently?

centril (Jun 26 2019 at 20:31, on Zulip):

I'll have a look in a bit

Taylor Cramer (Jun 26 2019 at 21:27, on Zulip):

@nikomatsakis yes, this: https://github.com/rust-lang/rust/pull/60944#issuecomment-493915865

Taylor Cramer (Jun 26 2019 at 21:27, on Zulip):

is a thing which does work but I wouldn't expect it to if it doesn't also work for Pin<&mut Self>

Taylor Cramer (Jun 26 2019 at 21:28, on Zulip):

which then caused the whole round of confusion when eddy was suggesting this extension: https://github.com/rust-lang/rust/pull/60944#issuecomment-494722365

nikomatsakis (Jun 27 2019 at 00:01, on Zulip):

@Taylor Cramer ok thanks -- although that particular example is unstable.

nikomatsakis (Jun 27 2019 at 00:03, on Zulip):

but yes it is behaving oddly

nikomatsakis (Jun 27 2019 at 00:08, on Zulip):

ok, I see, but if you use Pin, then it does compile, and that is bad

eddyb (Jun 27 2019 at 12:40, on Zulip):

wanna see something fun? (and I suppose ironic)

eddyb (Jun 27 2019 at 12:40, on Zulip):

I changed the elision rules to only allow literal Self not Foo (assuming a method of impl Foo {...}) to get the special &self-like treatment, and I have only 2 failures in libcore

eddyb (Jun 27 2019 at 12:40, on Zulip):

https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L447

eddyb (Jun 27 2019 at 12:40, on Zulip):

https://github.com/rust-lang/rust/blob/master/src/libcore/pin.rs#L484

eddyb (Jun 27 2019 at 12:41, on Zulip):

for some reason all of those methods are written as self: &Pin<T> or self: &mut Pin<T>

eddyb (Jun 27 2019 at 12:43, on Zulip):

in the entire codebase, that file has the only examples of &self or &mut self written out like that

eddyb (Jun 27 2019 at 12:44, on Zulip):

it's those 2 plus the set method

eddyb (Jun 27 2019 at 12:45, on Zulip):

and the only self: &(mut )?Self is in core::fmt in a write_fmt method that has mut self: &mut Self, presumably making self point to something else (as mut &mut self is syntactically invalid)

eddyb (Jun 27 2019 at 12:47, on Zulip):

tests have a bunch of examples of self: &Foo and self: &mut Bar, of course

eddyb (Jun 27 2019 at 13:18, on Zulip):

but only one (run-pass) test seems to fails when I run the tests, anyway

eddyb (Jun 27 2019 at 13:21, on Zulip):

@nikomatsakis opened https://github.com/rust-lang/rust/pull/62181 for crater purposes

Taylor Cramer (Jun 27 2019 at 18:09, on Zulip):

@eddyb can you explain why those examples needed to be changed?

Taylor Cramer (Jun 27 2019 at 18:09, on Zulip):

the elision being used there is "syntactic" in the way I would read it

centril (Jun 27 2019 at 18:36, on Zulip):

Well it's semantic in the sense that it requires context not provided by the function signature itself

centril (Jun 27 2019 at 18:36, on Zulip):

to determine whether something is the Self type or not

centril (Jun 27 2019 at 18:37, on Zulip):

But I can live with that :slight_smile:

eddyb (Jun 28 2019 at 13:03, on Zulip):

yeah @centril is right. also, this is just for @nikomatsakis, I doubt we'll actually make a breaking change here

eddyb (Jun 28 2019 at 13:04, on Zulip):

like, @nikomatsakis wanted to know what breakage would result if we required writing self: &Self or &self in order to apply the elision special-case

nikomatsakis (Jul 02 2019 at 16:47, on Zulip):

I doubt we'll actually make a breaking change here

I am curious -- the current rules are ... pretty ad-hoc, as well, in that they consider "the current struct" (regardless of parameters etc) to be "self enough". But the most I would expect is to deprecate that behavior and encourage manual annotation.

Last update: Nov 18 2019 at 01:25UTC