Rollup merge of #100302 - compiler-errors:deref-path-methods, r=jackh726

Suggest associated method on deref types when path syntax method fails

Fixes #100278
This commit is contained in:
Matthias Krüger 2022-09-04 00:20:39 +02:00 committed by GitHub
commit bd9750fd2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 2 deletions

View file

@ -0,0 +1,6 @@
fn main() {
let vec = Vec::new();
Vec::contains(&vec, &0);
//~^ ERROR no function or associated item named `contains` found for struct `Vec<_, _>` in the current scope
//~| HELP the function `contains` is implemented on `[_]`
}

View file

@ -0,0 +1,14 @@
error[E0599]: no function or associated item named `contains` found for struct `Vec<_, _>` in the current scope
--> $DIR/deref-path-method.rs:3:10
|
LL | Vec::contains(&vec, &0);
| ^^^^^^^^ function or associated item not found in `Vec<_, _>`
|
help: the function `contains` is implemented on `[_]`
|
LL | <[_]>::contains(&vec, &0);
| ~~~~~
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.