Closed
Description
Given the following code
#![feature(auto_traits)]
auto trait Foo {
fn g(&self);
}
trait Bar {
fn f(&self) {
self.g();
}
}
fn main() {}
The current output is:
error[E0380]: auto traits cannot have associated items
--> src/main.rs:4:8
|
3 | auto trait Foo {
| --- auto trait cannot have associated items
4 | fn g(&self);
| ---^-------- help: remove these associated items
error[E0554]: `#![feature]` may not be used on the stable release channel
--> src/main.rs:1:1
|
1 | #![feature(auto_traits)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0599]: the method `g` exists for reference `&Self`, but its trait bounds were not satisfied
--> src/main.rs:9:14
|
9 | self.g();
| ^
|
note: trait bound `&Self: Foo` was not satisfied
= note: the following trait bounds were not satisfied:
`Self: Foo`
which is required by `&Self: Foo`
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `g`, perhaps you need to add a supertrait for it:
|
7 | trait Bar: Foo {
| +++++
Some errors have detailed explanations: E0380, E0554, E0599.
For more information about an error, try `rustc --explain E0380`.
error: could not compile `playground` due to 3 previous errors
The second error is not reasonable, since we don't allow associated items in auto trait.
Ideally the output should look like:
error[E0599]: no method named `g` found for reference `&Self` in the current scope
--> ./p/e.rs:9:14
|
9 | self.g();
|