Skip to content
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

rustc suggests invalid syntax for missing method on impl Trait parameter #63706

Closed
euclio opened this issue Aug 19, 2019 · 0 comments
Closed

rustc suggests invalid syntax for missing method on impl Trait parameter #63706

euclio opened this issue Aug 19, 2019 · 0 comments

Comments

@euclio
Copy link
Contributor

@euclio euclio commented Aug 19, 2019

Given:

trait Foo {}

trait Bar {
    fn hello(&mut self) {}
}

fn test(foo: &mut impl Foo) {
    foo.hello();
}

rustc outputs:

error[E0599]: no method named `hello` found for type `&mut impl Foo` in the current scope
 --> src/lib.rs:8:9
  |
8 |     foo.hello();
  |         ^^^^^
  |
  = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `hello`, perhaps you need to restrict type parameter `impl Foo` with it:
  |
7 | fn test(foo: &mut impl Foo: Bar + {
  |                   ^^^^^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants