Closed
Description
If you try to implement a trait, but accidentally implement a non-static method as static, rustc gives a error message for any use of self
in the body of the function (with and without explicit self
) rather than for the conflict in static-ness.
test-static-self.rs:7:8: 7:12 error: unresolved name: self
test-static-self.rs:7 self
^~~~
error: aborting due to previous error
Testcase:
trait A {
fn a(self) -> int;
}
impl int : A {
static fn a(self) -> int {
self
}
}
fn main() {}
If there are no references to self
in the body, rustc gives the more useful error: method 'a' is declared as static in its impl, but not in its trait
.