diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index 2c62034c6e87..83cfa027cc3d 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -702,7 +702,7 @@ fn compress(&mut self, mut outcome_cb: impl FnMut(&O)) { self.apply_rewrites(&node_rewrites); } - node_rewrites.truncate(0); + node_rewrites.clear(); self.reused_node_vec = node_rewrites; } diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 71a8e081146e..a575630a0503 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -349,7 +349,7 @@ fn process_obligation( &mut self, pending_obligation: &mut PendingPredicateObligation<'tcx>, ) -> ProcessResult, FulfillmentErrorCode<'tcx>> { - pending_obligation.stalled_on.truncate(0); + pending_obligation.stalled_on.clear(); let obligation = &mut pending_obligation.obligation; diff --git a/library/std/src/io/buffered/tests.rs b/library/std/src/io/buffered/tests.rs index 6ad4158b9290..e335d8afdc48 100644 --- a/library/std/src/io/buffered/tests.rs +++ b/library/std/src/io/buffered/tests.rs @@ -391,16 +391,16 @@ fn test_read_until() { let mut v = Vec::new(); reader.read_until(0, &mut v).unwrap(); assert_eq!(v, [0]); - v.truncate(0); + v.clear(); reader.read_until(2, &mut v).unwrap(); assert_eq!(v, [1, 2]); - v.truncate(0); + v.clear(); reader.read_until(1, &mut v).unwrap(); assert_eq!(v, [1]); - v.truncate(0); + v.clear(); reader.read_until(8, &mut v).unwrap(); assert_eq!(v, [0]); - v.truncate(0); + v.clear(); reader.read_until(9, &mut v).unwrap(); assert_eq!(v, []); } @@ -429,13 +429,13 @@ fn test_read_line() { let mut s = String::new(); reader.read_line(&mut s).unwrap(); assert_eq!(s, "a\n"); - s.truncate(0); + s.clear(); reader.read_line(&mut s).unwrap(); assert_eq!(s, "b\n"); - s.truncate(0); + s.clear(); reader.read_line(&mut s).unwrap(); assert_eq!(s, "c"); - s.truncate(0); + s.clear(); reader.read_line(&mut s).unwrap(); assert_eq!(s, ""); } diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs index b22988d4a8a9..a56359dae765 100644 --- a/library/std/src/io/tests.rs +++ b/library/std/src/io/tests.rs @@ -17,10 +17,10 @@ fn read_until() { let mut v = Vec::new(); assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 3); assert_eq!(v, b"123"); - v.truncate(0); + v.clear(); assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 1); assert_eq!(v, b"3"); - v.truncate(0); + v.clear(); assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 0); assert_eq!(v, []); } @@ -80,10 +80,10 @@ fn read_line() { let mut v = String::new(); assert_eq!(buf.read_line(&mut v).unwrap(), 3); assert_eq!(v, "12\n"); - v.truncate(0); + v.clear(); assert_eq!(buf.read_line(&mut v).unwrap(), 1); assert_eq!(v, "\n"); - v.truncate(0); + v.clear(); assert_eq!(buf.read_line(&mut v).unwrap(), 0); assert_eq!(v, ""); } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 0b2b5f7e58f4..c0a77ef0b05c 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1364,7 +1364,7 @@ fn _push(&mut self, path: &Path) { // absolute `path` replaces `self` if need_clear { - self.inner.truncate(0); + self.inner.clear(); // verbatim paths need . and .. removed } else if comps.prefix_verbatim() && !path.inner.is_empty() { diff --git a/library/std/src/sys/args/uefi.rs b/library/std/src/sys/args/uefi.rs index 02dada382eff..edf6f6873f8d 100644 --- a/library/std/src/sys/args/uefi.rs +++ b/library/std/src/sys/args/uefi.rs @@ -93,7 +93,7 @@ fn parse_lp_cmd_line(code_units: &[u16]) -> Option> { // If not `in_quotes`, a space or tab ends the argument. SPACE if !in_quotes => { ret_val.push(OsString::from(&cur[..])); - cur.truncate(0); + cur.clear(); // Skip whitespace. while code_units_iter.next_if_eq(&Ok(SPACE)).is_some() {} diff --git a/library/std/src/sys/args/windows.rs b/library/std/src/sys/args/windows.rs index 3c6995e37278..bd26db7fea55 100644 --- a/library/std/src/sys/args/windows.rs +++ b/library/std/src/sys/args/windows.rs @@ -106,7 +106,7 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>( // If not `in_quotes`, a space or tab ends the argument. SPACE | TAB if !in_quotes => { ret_val.push(OsString::from_wide(&cur[..])); - cur.truncate(0); + cur.clear(); // Skip whitespace. code_units.advance_while(|w| w == SPACE || w == TAB); diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index 6534902e0940..8dfac2e3abb2 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -191,7 +191,7 @@ fn run_debuginfo_gdb_test(&self) { let mut stdout = BufReader::new(adb.stdout.take().unwrap()); let mut line = String::new(); loop { - line.truncate(0); + line.clear(); stdout.read_line(&mut line).unwrap(); if line.starts_with("Listening on port 5039") { break; diff --git a/src/tools/remote-test-server/src/main.rs b/src/tools/remote-test-server/src/main.rs index b4d30289cabb..cc8edfcdac61 100644 --- a/src/tools/remote-test-server/src/main.rs +++ b/src/tools/remote-test-server/src/main.rs @@ -211,12 +211,12 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf let mut args = Vec::new(); while t!(reader.read_until(0, &mut arg)) > 1 { args.push(t!(str::from_utf8(&arg[..arg.len() - 1])).to_string()); - arg.truncate(0); + arg.clear(); } // Next we'll get a bunch of env vars in pairs delimited by 0s as well let mut env = Vec::new(); - arg.truncate(0); + arg.clear(); while t!(reader.read_until(0, &mut arg)) > 1 { let key_len = arg.len() - 1; let val_len = t!(reader.read_until(0, &mut arg)) - 1; @@ -227,7 +227,7 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf let val = t!(str::from_utf8(val)).to_string(); env.push((key, val)); } - arg.truncate(0); + arg.clear(); } // The section of code from here down to where we drop the lock is going to