Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ impl<O: ForestObligation> ObligationForest<O> {
self.apply_rewrites(&node_rewrites);
}

node_rewrites.truncate(0);
node_rewrites.clear();
self.reused_node_vec = node_rewrites;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
&mut self,
pending_obligation: &mut PendingPredicateObligation<'tcx>,
) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
pending_obligation.stalled_on.truncate(0);
pending_obligation.stalled_on.clear();

let obligation = &mut pending_obligation.obligation;

Expand Down
14 changes: 7 additions & 7 deletions library/std/src/io/buffered/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, []);
}
Expand Down Expand Up @@ -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, "");
}
Expand Down
8 changes: 4 additions & 4 deletions library/std/src/io/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, []);
}
Expand Down Expand Up @@ -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, "");
}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ impl PathBuf {

// 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() {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/args/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn parse_lp_cmd_line(code_units: &[u16]) -> Option<Vec<OsString>> {
// 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() {}
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/args/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/runtest/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl TestCx<'_> {
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;
Expand Down
6 changes: 3 additions & 3 deletions src/tools/remote-test-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Loading