-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Beta Regression: cannot reference Self from where clause for inherent impl #24944
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Specifically, the error message one gets (at least with my beta build) is:
|
However, this may be deliberate. At least, I don't remember what the rules are about when In other words, one can certainly workaround this issue by writing the above
|
No way, this is definitely wrong. |
@bombless there's a difference nonetheless between a poor error message and an (unintentional) regression in the compiler itself. I'm trying to identify exactly what this is. |
It is according to rust-lang/rfcs#522. |
@Stebalien it is (what) according to rust-lang/rfcs#522 ? Supposed to be allowed? Behaving as specified? Update: In particular, there is plenty of wiggle room in rust-lang/rfcs#522 as written. It just says "When used inside an impl ..." without formally defining what "inside an impl" actually means, and thus a reasonable person might think it means "inside the curly braces associated with the impl" Having said that, I am inclined to infer that you meant that RFC 522 is supposed to imply that this usage of |
This is just the standard error message you get when you try to use fn foo(_: Self) {} |
IMHO, it should be allowed. |
@pnkfelix it was not deliberate. I don't really have an opinion on whether it is right or wrong as stands, I guess if you can write a bound on the concrete version of |
triage: I-nominated I want to figure out how important it is to fix this. I suspect we can get away with just treating it as "just a bug" -- that is, I have not found a way to utilize it in a way that it would be a breaking-change to fix it. For example, something like this, where trait A { fn foo(&self) { } }
struct S;
struct T;
impl A for S { }
impl S {
fn foo(&self) {
impl T where Self: A { }
}
} |
triage: P-medium |
Triage: these examples still error, though with slightly different messages. |
Re-nominating: The issue description compiles, though as far as I can tell, it probably shouldn't, since trait Foo {
fn foo(&self);
}
struct Bar<T>(T);
impl<T> Bar<T> where Self: Foo {}
fn main() {} |
Behaving as expected. At some point we decided that |
The following code compiles with
rustc 1.0.0-beta (9854143cb 2015-04-02) (built 2015-04-02)
but does not compile withrustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)
The text was updated successfully, but these errors were encountered: