-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does &self
still desugar to self: &Self
?
#211
Comments
I don't think Does this fail:
Or does it just not let you call it as a method? |
That fixes it. However, a question on Reddit highlights a case where being explicit with Doesn't work because of lifetimes: struct S { x: int }
impl Add<S, S> for S {
fn add(self: &S, other: &S) -> S {
S { x: self.x + other.x }
}
} This works: impl Add<S, S> for S {
fn add<'a>(self: &'a S, other: &S) -> S {
S { x: self.x + other.x }
}
} If this behavior is easy to explain, it might be worth explaining. Seems kinda weird. |
Maybe |
From what I can tell, the primary section of the parser that handles this case is There's a nested function Thus, the sugared syntax is all contained within
However, in @mdinger's example above, I'm not entirely sure how |
So, what's the result here? I think this is more of a Rust quesiton, and not something really actionable, yes? |
I think an okay approach here would be to change the wording from:
To:
As it was, it's technically worded correctly but slightly misleading. |
It'd probably be good to file a rust bug for |
Looks like this RFC might fix this: rust-lang/rfcs#522 |
That RFC was implemented, so this should be fine. |
The methods example (or here) says that
&self
desugars toself: &Self
but if you desugar it, it no longer compiles. Is the desugaring still true? If so, these should be updated.Here are the examples listed which fail when desugared:
Also fails when desugared:
Fails when desugared:
The text was updated successfully, but these errors were encountered: