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/std/src/thread/local.rs | |
| 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/std/src/thread/local.rs')
| -rw-r--r-- | library/std/src/thread/local.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index d1213e2f166..34d30a259ee 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -435,6 +435,7 @@ impl<T: 'static> LocalKey<Cell<T>> { /// assert_eq!(X.replace(3), 2); /// ``` #[stable(feature = "local_key_cell_methods", since = "1.73.0")] + #[rustc_confusables("swap")] pub fn replace(&'static self, value: T) -> T { self.with(|cell| cell.replace(value)) } @@ -606,6 +607,7 @@ impl<T: 'static> LocalKey<RefCell<T>> { /// X.with_borrow(|v| assert_eq!(*v, vec![1, 2, 3])); /// ``` #[stable(feature = "local_key_cell_methods", since = "1.73.0")] + #[rustc_confusables("swap")] pub fn replace(&'static self, value: T) -> T { self.with(|cell| cell.replace(value)) } |
