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 · Fixed by #63811
Closed

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

euclio opened this issue Aug 19, 2019 · 0 comments · Fixed by #63811
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@euclio
Copy link
Contributor

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 + {
  |                   ^^^^^^^^^^^^^^^
@jonas-schievink jonas-schievink added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 19, 2019
@bors bors closed this as completed in 4cae33a Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants