1
Fork 0

Add rustc_confusables annotations to some stdlib APIs

Help with common API confusion, like asking for `push` when the data structure really has `append`.

```
error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope
  --> $DIR/rustc_confusables_std_cases.rs:17:7
   |
LL |     x.size();
   |       ^^^^
   |
help: you might have meant to use `len`
   |
LL |     x.len();
   |       ~~~
help: there is a method with a similar name
   |
LL |     x.resize();
   |       ~~~~~~
```

#59450
This commit is contained in:
Esteban Küber 2024-02-07 02:35:49 +00:00
parent 933a05bd0b
commit e5b3c7ef14
20 changed files with 180 additions and 29 deletions

View file

@ -1270,6 +1270,7 @@ impl PathBuf {
/// assert_eq!(path, PathBuf::from("/etc"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_confusables("append", "put")]
pub fn push<P: AsRef<Path>>(&mut self, path: P) {
self._push(path.as_ref())
}