Skip to content

Using non-existent associated method doesn't hint about deref #100278

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Noratrieb opened this issue Aug 8, 2022 · 1 comment · Fixed by #100302
Closed

Using non-existent associated method doesn't hint about deref #100278

Noratrieb opened this issue Aug 8, 2022 · 1 comment · Fixed by #100302
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Noratrieb
Copy link
Member

Noratrieb commented Aug 8, 2022

In #100227, someone was a little confused by <&[T]>::contains not being accessible asVec::<T>::contains.

Given the following code:

fn test() {
    let vec = Vec::new();
    Vec::contains(&vec, &0);
}

The current output is:

error[E0599]: no function or associated item named `contains` found for struct `Vec<_, _>` in the current scope
 --> src/lib.rs:3:10
  |
3 |     Vec::contains(&vec, &0);
  |          ^^^^^^^^ function or associated item not found in `Vec<_, _>`

For more information about this error, try `rustc --explain E0599`.

Ideally, it would add a note about the method being found on a type that Vec<_, _> can deref to.

@Noratrieb Noratrieb added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2022
@compiler-errors
Copy link
Member

@rustbot claim

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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