diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-02-07 02:35:49 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-02-22 18:04:55 +0000 |
| commit | e5b3c7ef1439fa946b3ba49a3bbbadc34d801a84 (patch) | |
| tree | 2b675ebf917a7c6175bb27774c9d84bfb5ed43dd /library/alloc/src/collections/vec_deque | |
| parent | 933a05bd0ba91caf219222e5f61d1c92d141ff61 (diff) | |
| download | rust-e5b3c7ef1439fa946b3ba49a3bbbadc34d801a84.tar.gz rust-e5b3c7ef1439fa946b3ba49a3bbbadc34d801a84.zip | |
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
Diffstat (limited to 'library/alloc/src/collections/vec_deque')
| -rw-r--r-- | library/alloc/src/collections/vec_deque/mod.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index bcba6525fda..c35bab5ef66 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -1209,6 +1209,7 @@ impl<T, A: Allocator> VecDeque<T, A> { /// assert_eq!(deque.len(), 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_confusables("length", "size")] pub fn len(&self) -> usize { self.len } @@ -1491,6 +1492,7 @@ impl<T, A: Allocator> VecDeque<T, A> { /// assert_eq!(d.front(), Some(&1)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_confusables("first")] pub fn front(&self) -> Option<&T> { self.get(0) } @@ -1535,6 +1537,7 @@ impl<T, A: Allocator> VecDeque<T, A> { /// assert_eq!(d.back(), Some(&2)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_confusables("last")] pub fn back(&self) -> Option<&T> { self.get(self.len.wrapping_sub(1)) } @@ -1654,6 +1657,7 @@ impl<T, A: Allocator> VecDeque<T, A> { /// assert_eq!(3, *buf.back().unwrap()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_confusables("push", "put", "append")] pub fn push_back(&mut self, value: T) { if self.is_full() { self.grow(); @@ -1813,6 +1817,7 @@ impl<T, A: Allocator> VecDeque<T, A> { /// assert_eq!(buf, [1, 3]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_confusables("delete", "take")] pub fn remove(&mut self, index: usize) -> Option<T> { if self.len <= index { return None; |
