about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-24 20:33:53 +0000
committerbors <bors@rust-lang.org>2020-03-24 20:33:53 +0000
commit02046a5d402c789c006d0da7662f800fe3c45faf (patch)
tree298c6737ad0555e0d2ebdfffcb91c18f5fa77dfc /src/liballoc
parent2dcf54f564c6d8bbf48960fb9aaec88a0e2e062a (diff)
parentbf1ad2229fc635434c3f5d61db8feb1e7e33f861 (diff)
downloadrust-02046a5d402c789c006d0da7662f800fe3c45faf.tar.gz
rust-02046a5d402c789c006d0da7662f800fe3c45faf.zip
Auto merge of #70371 - Centril:rollup-ywi1vo3, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #70023 (clean up E0436 explanation)
 - #70234 (#[track_caller] on core::ops::{Index, IndexMut}.)
 - #70241 (Miri: move ModifiedStatic to ConstEval errors)
 - #70342 (IoSlice/IoSliceMut should be Send and Sync)
 - #70350 (Request "-Z unstable-options" for unstable options)
 - #70355 (Clean up E0454)
 - #70359 (must_use on split_off)
 - #70368 (Mark hotplug_codegen_backend as ignore-stage1)

Failed merges:

r? @ghost
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/collections/vec_deque.rs1
-rw-r--r--src/liballoc/string.rs1
-rw-r--r--src/liballoc/tests/string.rs4
3 files changed, 4 insertions, 2 deletions
diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs
index 9d56f17700a..69284fbf1b3 100644
--- a/src/liballoc/collections/vec_deque.rs
+++ b/src/liballoc/collections/vec_deque.rs
@@ -1876,6 +1876,7 @@ impl<T> VecDeque<T> {
     /// assert_eq!(buf2, [2, 3]);
     /// ```
     #[inline]
+    #[must_use = "use `.truncate()` if you don't need the other half"]
     #[stable(feature = "split_off", since = "1.4.0")]
     pub fn split_off(&mut self, at: usize) -> Self {
         let len = self.len();
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 0e48f1548e6..7c89d38caa4 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -1461,6 +1461,7 @@ impl String {
     /// ```
     #[inline]
     #[stable(feature = "string_split_off", since = "1.16.0")]
+    #[must_use = "use `.truncate()` if you don't need the other half"]
     pub fn split_off(&mut self, at: usize) -> String {
         assert!(self.is_char_boundary(at));
         let other = self.vec.split_off(at);
diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs
index 08859b2b24b..d2f09eb4a75 100644
--- a/src/liballoc/tests/string.rs
+++ b/src/liballoc/tests/string.rs
@@ -266,14 +266,14 @@ fn test_split_off_empty() {
 fn test_split_off_past_end() {
     let orig = "Hello, world!";
     let mut split = String::from(orig);
-    split.split_off(orig.len() + 1);
+    let _ = split.split_off(orig.len() + 1);
 }
 
 #[test]
 #[should_panic]
 fn test_split_off_mid_char() {
     let mut orig = String::from("山");
-    orig.split_off(1);
+    let _ = orig.split_off(1);
 }
 
 #[test]