diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index da9afdd2ca37b..663e1ac915dbf 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -378,6 +378,7 @@ impl String { /// ``` /// let s = String::new(); /// ``` + #[must_use = "newly created String must be used"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_string_new")] diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 690cbcb559bbf..312aad361041e 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -320,6 +320,7 @@ impl Vec { /// # #![allow(unused_mut)] /// let mut vec: Vec = Vec::new(); /// ``` + #[must_use = "newly created vector must be used"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_vec_new")]