Skip to content

Commit b30d41d

Browse files
authored
Rollup merge of rust-lang#89833 - jkugelman:must-use-rc-downgrade, r=joshtriplett
Add #[must_use] to Rc::downgrade Missed this in previous PR rust-lang#89796 (comment) Parent issue: rust-lang#89692 r? ``@joshtriplett``
2 parents ba05480 + 5bb99bb commit b30d41d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/alloc/src/rc.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
//! use std::rc::Rc;
4242
//!
4343
//! let my_rc = Rc::new(());
44-
//! Rc::downgrade(&my_rc);
44+
//! let my_weak = Rc::downgrade(&my_rc);
4545
//! ```
4646
//!
4747
//! `Rc<T>`'s implementations of traits like `Clone` may also be called using
@@ -889,6 +889,8 @@ impl<T: ?Sized> Rc<T> {
889889
///
890890
/// let weak_five = Rc::downgrade(&five);
891891
/// ```
892+
#[must_use = "this returns a new `Weak` pointer, \
893+
without modifying the original `Rc`"]
892894
#[stable(feature = "rc_weak", since = "1.4.0")]
893895
pub fn downgrade(this: &Self) -> Weak<T> {
894896
this.inner().inc_weak();

0 commit comments

Comments
 (0)