1
Fork 0

Implement use associated items of traits

This commit is contained in:
Frank King 2024-12-25 14:54:49 +08:00
parent 4e5fec2f1e
commit 5079acc060
21 changed files with 374 additions and 42 deletions

View file

@ -1,19 +1,19 @@
Attempt was made to import an unimportable value. This can happen when trying
to import a method from a trait.
Attempt was made to import an unimportable type. This can happen when trying
to import a type from a trait.
Erroneous code example:
```compile_fail,E0253
mod foo {
pub trait MyTrait {
fn do_something();
type SomeType;
}
}
use foo::MyTrait::do_something;
// error: `do_something` is not directly importable
use foo::MyTrait::SomeType;
// error: `SomeType` is not directly importable
fn main() {}
```
It's invalid to directly import methods belonging to a trait or concrete type.
It's invalid to directly import types belonging to a trait.