Skip to content

Commit 54aab38

Browse files
committed
Make String a must_use type
1 parent 360a372 commit 54aab38

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/alloc/src/string.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ use crate::vec::Vec;
275275
#[derive(PartialOrd, Eq, Ord)]
276276
#[cfg_attr(not(test), rustc_diagnostic_item = "string_type")]
277277
#[stable(feature = "rust1", since = "1.0.0")]
278+
#[must_use = "unused allocation might not be optimized out by compiler"]
278279
pub struct String {
279280
vec: Vec<u8>,
280281
}

0 commit comments

Comments
 (0)