Stream: t-compiler

Topic: #64252 arbitrary self type suggestions


davidtwco (Oct 01 2019 at 14:36, on Zulip):

@centril just wanted to confirm that you aren't working on this?

centril (Oct 01 2019 at 14:37, on Zulip):

@davidtwco I gave it a look at decided it was becoming too complicated at the time

centril (Oct 01 2019 at 14:37, on Zulip):

but we can talk if you want about it

centril (Oct 01 2019 at 14:37, on Zulip):

not working on it tho

centril (Oct 01 2019 at 14:37, on Zulip):

(https://github.com/rust-lang/rust/pull/64910 should land first)

davidtwco (Oct 01 2019 at 14:38, on Zulip):

I threw something together locally if you don't mind me working on it.

centril (Oct 01 2019 at 14:39, on Zulip):

oh, already? interesting

centril (Oct 01 2019 at 14:39, on Zulip):

r? me if you want

davidtwco (Oct 01 2019 at 14:39, on Zulip):

Sure.

centril (Oct 01 2019 at 14:39, on Zulip):

Are you just making changes in fn parse_self_param?

davidtwco (Oct 01 2019 at 14:40, on Zulip):

@centril https://github.com/rust-lang/rust/pull/64959

centril (Oct 01 2019 at 14:44, on Zulip):

that was quick :D -- will have a look later tonight

centril (Oct 01 2019 at 14:44, on Zulip):

from the outset it seems a much cleaner approach than the throw-away stuff I had

centril (Oct 01 2019 at 14:47, on Zulip):

@davidtwco looking at self: i32... did you consider a more semantic approach with .parse_ty() and then checking whether the type would be applicable as a self: SelfTy parameter?

davidtwco (Oct 01 2019 at 14:48, on Zulip):

I thought about it, but wasn't sure that it made sense for the parser to do that - would just have added a lot of complexity.

davidtwco (Oct 01 2019 at 14:48, on Zulip):

I made the suggestion MaybeIncorrect for cases like that.

centril (Oct 01 2019 at 14:49, on Zulip):

it's OK in the parser in recovery branches if it is reasonably hidden away from main happy-path logic but I think you're right that even so it would be a lot of complexity (you'd need a visitor and such)

davidtwco (Oct 01 2019 at 14:49, on Zulip):

I don't know if it's required for the arbitrary self type to contain Self - could there be some trait implementation on i32 that takes a self: i32 correctly?

centril (Oct 01 2019 at 14:50, on Zulip):

The stable subset requires Box<Self>, Rc<Self>, Arc<Self>, Self, &Self, &mut Self and some stuff about Pin

centril (Oct 01 2019 at 14:50, on Zulip):

but notably Self need not syntactically occur

centril (Oct 01 2019 at 14:50, on Zulip):

it could be a type alias to the type, iirc

centril (Oct 01 2019 at 14:50, on Zulip):

but as a heuristic it works

davidtwco (Oct 01 2019 at 14:52, on Zulip):

Sure. It's an improvement we could do in a follow-up if we really wanted, I think this is a reasonable improvement to land first.

centril (Oct 01 2019 at 14:52, on Zulip):

One could do something dumber tho: Use a visitor that looks for Path with kw::SelfUpper as the identifier

centril (Oct 01 2019 at 14:52, on Zulip):

@davidtwco yeah agreed on that

Last update: Nov 22 2019 at 04:30UTC