diff options
| author | the8472 <the8472@users.noreply.github.com> | 2021-10-12 14:53:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-12 14:53:10 +0200 |
| commit | a1bdd48106cdb3f9888a564aaa6aa0daef843d64 (patch) | |
| tree | 14619a3abc63f02560b824c03ec68f466cc78bd6 /library/alloc/src/rc.rs | |
| parent | 4ce1ce1f7672c52ce32cd429bb21a12653e2b605 (diff) | |
| parent | c3f0577002b5c158c63dab92476d94af954086f1 (diff) | |
| download | rust-a1bdd48106cdb3f9888a564aaa6aa0daef843d64.tar.gz rust-a1bdd48106cdb3f9888a564aaa6aa0daef843d64.zip | |
Rollup merge of #89796 - jkugelman:must-use-non-mutating-verb-methods, r=joshtriplett
Add #[must_use] to non-mutating verb methods These are methods that could be misconstrued to mutate their input, similar to #89694. I gave each one a different custom message. I wrote that `upgrade` and `downgrade` don't modify the input pointers. Logically they don't, but technically they do... Parent issue: #89692 r? ```@joshtriplett```
Diffstat (limited to 'library/alloc/src/rc.rs')
| -rw-r--r-- | library/alloc/src/rc.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index eba75d4dd69..493cf3117ed 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2230,6 +2230,8 @@ impl<T: ?Sized> Weak<T> { /// /// assert!(weak_five.upgrade().is_none()); /// ``` + #[must_use = "this returns a new `Rc`, \ + without modifying the original weak pointer"] #[stable(feature = "rc_weak", since = "1.4.0")] pub fn upgrade(&self) -> Option<Rc<T>> { let inner = self.inner()?; |
