Skip to content

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

Closed
@Noratrieb

Description

@Noratrieb

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.

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions