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

Provide a hint about type parameter conflicting with a structure name #77391

Closed
KamilaBorowska opened this issue Oct 1, 2020 · 0 comments · Fixed by #98298
Closed

Provide a hint about type parameter conflicting with a structure name #77391

KamilaBorowska opened this issue Oct 1, 2020 · 0 comments · Fixed by #98298
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@KamilaBorowska
Copy link
Contributor

KamilaBorowska commented Oct 1, 2020

This is something I have seen on users.rust-lang.org: https://users.rust-lang.org/t/implementing-fn-for-a-struct-thats-stored-in-vector/10814

A following code in my opinion should provide a hint to remove <Hello>.

trait Trait {
    fn do_stuff(&self);
}

struct Hello;

impl Hello {
    fn method(&self) {}
}

impl<Hello> Trait for Vec<Hello> {
    fn do_stuff(&self) {
        self[0].method();
    }
}

Currently it provides the following error which is non-ideal:

error[E0599]: no method named `method` found for type parameter `Hello` in the current scope
  --> src/lib.rs:13:17
   |
13 |         self[0].method();
   |                 ^^^^^^ method not found in `Hello`
@Stupremee Stupremee added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Oct 1, 2020
@JohnTitor JohnTitor added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 1, 2020
@TaKO8Ki TaKO8Ki self-assigned this Mar 12, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jun 23, 2022
…ion, r=compiler-errors

Point to type parameter definition when not finding variant, method and associated item

fixes rust-lang#77391
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 25, 2022
…ion, r=compiler-errors

Point to type parameter definition when not finding variant, method and associated item

fixes rust-lang#77391
@bors bors closed this as completed in 8257ba2 Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. 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.

4 participants