Description
This is a part of the new region syntax in #4846, but it has proven hard enough that I am making a separate issue for it. The goal is to change the meaning of a method like:
impl<'self> Foo<'self> {
fn foo(&self, ...) {...}
}
so that instead of being roughly equivalent to a function like:
impl<'self> Foo<'self> {
fn foo(self: &'self Foo<'self>, ...) {...}
}
it is instead equivalent to:
impl<'self> Foo<'self> {
fn foo(self: &Foo<'self>, ...) {...}
}
There are several reasons for this. One is the poor interaction with &mut self
that I explained in this e-mail message. The other is that it is more consistent with the treatment of other parameters and it scales better to the case where impls may have more than one type parameter. The final one is that the current rules are kind of... bizarre in terms of their implications for the underlying type system.
For example, consider a case where the impl
type does not have any lifetime parameters itself:
impl Foo {
fn foo(&self, ...) {...}
}
Here there is no lifetime 'self
. The current treatment here is a bit dodgy and kind of frightening to me.
I have an in-progress patch but there are lots of sides to this issue and it's not yet ready to land.