Convert more usages over
This commit is contained in:
parent
8a3797b736
commit
636f5e6d11
30 changed files with 44 additions and 48 deletions
|
@ -770,8 +770,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, we merge `self` and `other` into a sorted sequence in linear time.
|
// First, we merge `self` and `other` into a sorted sequence in linear time.
|
||||||
let self_iter = mem::replace(self, BTreeMap::new()).into_iter();
|
let self_iter = mem::take(self).into_iter();
|
||||||
let other_iter = mem::replace(other, BTreeMap::new()).into_iter();
|
let other_iter = mem::take(other).into_iter();
|
||||||
let iter = MergeIter {
|
let iter = MergeIter {
|
||||||
left: self_iter.peekable(),
|
left: self_iter.peekable(),
|
||||||
right: other_iter.peekable(),
|
right: other_iter.peekable(),
|
||||||
|
|
|
@ -708,7 +708,7 @@ impl<T> LinkedList<T> {
|
||||||
let len = self.len();
|
let len = self.len();
|
||||||
assert!(at <= len, "Cannot split off at a nonexistent index");
|
assert!(at <= len, "Cannot split off at a nonexistent index");
|
||||||
if at == 0 {
|
if at == 0 {
|
||||||
return mem::replace(self, Self::new());
|
return mem::take(self);
|
||||||
} else if at == len {
|
} else if at == len {
|
||||||
return Self::new();
|
return Self::new();
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ impl ToOwned for str {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_into(&self, target: &mut String) {
|
fn clone_into(&self, target: &mut String) {
|
||||||
let mut b = mem::replace(target, String::new()).into_bytes();
|
let mut b = mem::take(target).into_bytes();
|
||||||
self.as_bytes().clone_into(&mut b);
|
self.as_bytes().clone_into(&mut b);
|
||||||
*target = unsafe { String::from_utf8_unchecked(b) }
|
*target = unsafe { String::from_utf8_unchecked(b) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1278,8 +1278,8 @@ impl<'a> LoweringContext<'a> {
|
||||||
let was_in_loop_condition = self.is_in_loop_condition;
|
let was_in_loop_condition = self.is_in_loop_condition;
|
||||||
self.is_in_loop_condition = false;
|
self.is_in_loop_condition = false;
|
||||||
|
|
||||||
let catch_scopes = mem::replace(&mut self.catch_scopes, Vec::new());
|
let catch_scopes = mem::take(&mut self.catch_scopes);
|
||||||
let loop_scopes = mem::replace(&mut self.loop_scopes, Vec::new());
|
let loop_scopes = mem::take(&mut self.loop_scopes);
|
||||||
let ret = f(self);
|
let ret = f(self);
|
||||||
self.catch_scopes = catch_scopes;
|
self.catch_scopes = catch_scopes;
|
||||||
self.loop_scopes = loop_scopes;
|
self.loop_scopes = loop_scopes;
|
||||||
|
|
|
@ -364,7 +364,7 @@ where
|
||||||
// been fully instantiated and hence the set of scopes we have
|
// been fully instantiated and hence the set of scopes we have
|
||||||
// doesn't matter -- just to be sure, put an empty vector
|
// doesn't matter -- just to be sure, put an empty vector
|
||||||
// in there.
|
// in there.
|
||||||
let old_a_scopes = ::std::mem::replace(pair.vid_scopes(self), vec![]);
|
let old_a_scopes = ::std::mem::take(pair.vid_scopes(self));
|
||||||
|
|
||||||
// Relate the generalized kind to the original one.
|
// Relate the generalized kind to the original one.
|
||||||
let result = pair.relate_generalized_ty(self, generalized_ty);
|
let result = pair.relate_generalized_ty(self, generalized_ty);
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||||
|
|
||||||
/// Trait queries just want to pass back type obligations "as is"
|
/// Trait queries just want to pass back type obligations "as is"
|
||||||
pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionObligation<'tcx>)> {
|
pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionObligation<'tcx>)> {
|
||||||
::std::mem::replace(&mut *self.region_obligations.borrow_mut(), vec![])
|
::std::mem::take(&mut *self.region_obligations.borrow_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process the region obligations that must be proven (during
|
/// Process the region obligations that must be proven (during
|
||||||
|
|
|
@ -410,7 +410,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
|
||||||
*any_unifications = false;
|
*any_unifications = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem::replace(data, RegionConstraintData::default())
|
mem::take(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data(&self) -> &RegionConstraintData<'tcx> {
|
pub fn data(&self) -> &RegionConstraintData<'tcx> {
|
||||||
|
|
|
@ -1375,7 +1375,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
|
||||||
|
|
||||||
let outer_ec = mem::replace(&mut self.expr_and_pat_count, 0);
|
let outer_ec = mem::replace(&mut self.expr_and_pat_count, 0);
|
||||||
let outer_cx = self.cx;
|
let outer_cx = self.cx;
|
||||||
let outer_ts = mem::replace(&mut self.terminating_scopes, FxHashSet::default());
|
let outer_ts = mem::take(&mut self.terminating_scopes);
|
||||||
self.terminating_scopes.insert(body.value.hir_id.local_id);
|
self.terminating_scopes.insert(body.value.hir_id.local_id);
|
||||||
|
|
||||||
if let Some(root_id) = self.cx.root_id {
|
if let Some(root_id) = self.cx.root_id {
|
||||||
|
|
|
@ -18,7 +18,7 @@ use errors::{Applicability, DiagnosticBuilder};
|
||||||
use rustc_macros::HashStable;
|
use rustc_macros::HashStable;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::mem::replace;
|
use std::mem::{replace, take};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
@ -441,7 +441,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||||
|
|
||||||
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
fn visit_nested_body(&mut self, body: hir::BodyId) {
|
||||||
// Each body has their own set of labels, save labels.
|
// Each body has their own set of labels, save labels.
|
||||||
let saved = replace(&mut self.labels_in_fn, vec![]);
|
let saved = take(&mut self.labels_in_fn);
|
||||||
let body = self.tcx.hir().body(body);
|
let body = self.tcx.hir().body(body);
|
||||||
extract_labels(self, body);
|
extract_labels(self, body);
|
||||||
self.with(
|
self.with(
|
||||||
|
@ -1405,9 +1405,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
||||||
lifetime_uses,
|
lifetime_uses,
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
let labels_in_fn = replace(&mut self.labels_in_fn, vec![]);
|
let labels_in_fn = take(&mut self.labels_in_fn);
|
||||||
let xcrate_object_lifetime_defaults =
|
let xcrate_object_lifetime_defaults = take(&mut self.xcrate_object_lifetime_defaults);
|
||||||
replace(&mut self.xcrate_object_lifetime_defaults, DefIdMap::default());
|
|
||||||
let mut this = LifetimeContext {
|
let mut this = LifetimeContext {
|
||||||
tcx: *tcx,
|
tcx: *tcx,
|
||||||
map: map,
|
map: map,
|
||||||
|
|
|
@ -205,8 +205,8 @@ impl<'a> LlvmArchiveBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_with_llvm(&mut self, kind: ArchiveKind) -> io::Result<()> {
|
fn build_with_llvm(&mut self, kind: ArchiveKind) -> io::Result<()> {
|
||||||
let removals = mem::replace(&mut self.removals, Vec::new());
|
let removals = mem::take(&mut self.removals);
|
||||||
let mut additions = mem::replace(&mut self.additions, Vec::new());
|
let mut additions = mem::take(&mut self.additions);
|
||||||
let mut strings = Vec::new();
|
let mut strings = Vec::new();
|
||||||
let mut members = Vec::new();
|
let mut members = Vec::new();
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_args(&mut self) -> Vec<OsString> {
|
pub fn take_args(&mut self) -> Vec<OsString> {
|
||||||
mem::replace(&mut self.args, Vec::new())
|
mem::take(&mut self.args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
|
/// Returns a `true` if we're pretty sure that this'll blow OS spawn limits,
|
||||||
|
|
|
@ -1345,12 +1345,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
||||||
assert!(!started_lto);
|
assert!(!started_lto);
|
||||||
started_lto = true;
|
started_lto = true;
|
||||||
|
|
||||||
let needs_fat_lto =
|
let needs_fat_lto = mem::take(&mut needs_fat_lto);
|
||||||
mem::replace(&mut needs_fat_lto, Vec::new());
|
let needs_thin_lto = mem::take(&mut needs_thin_lto);
|
||||||
let needs_thin_lto =
|
let import_only_modules = mem::take(&mut lto_import_only_modules);
|
||||||
mem::replace(&mut needs_thin_lto, Vec::new());
|
|
||||||
let import_only_modules =
|
|
||||||
mem::replace(&mut lto_import_only_modules, Vec::new());
|
|
||||||
|
|
||||||
for (work, cost) in generate_lto_work(&cgcx, needs_fat_lto,
|
for (work, cost) in generate_lto_work(&cgcx, needs_fat_lto,
|
||||||
needs_thin_lto, import_only_modules) {
|
needs_thin_lto, import_only_modules) {
|
||||||
|
|
|
@ -275,7 +275,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||||
mbcx.analyze_results(&mut state); // entry point for DataflowResultsConsumer
|
mbcx.analyze_results(&mut state); // entry point for DataflowResultsConsumer
|
||||||
|
|
||||||
// Convert any reservation warnings into lints.
|
// Convert any reservation warnings into lints.
|
||||||
let reservation_warnings = mem::replace(&mut mbcx.reservation_warnings, Default::default());
|
let reservation_warnings = mem::take(&mut mbcx.reservation_warnings);
|
||||||
for (_, (place, span, location, bk, borrow)) in reservation_warnings {
|
for (_, (place, span, location, bk, borrow)) in reservation_warnings {
|
||||||
let mut initial_diag =
|
let mut initial_diag =
|
||||||
mbcx.report_conflicting_borrow(location, (&place, span), bk, &borrow);
|
mbcx.report_conflicting_borrow(location, (&place, span), bk, &borrow);
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
candidate: &mut Candidate<'pat, 'tcx>) {
|
candidate: &mut Candidate<'pat, 'tcx>) {
|
||||||
// repeatedly simplify match pairs until fixed point is reached
|
// repeatedly simplify match pairs until fixed point is reached
|
||||||
loop {
|
loop {
|
||||||
let match_pairs = mem::replace(&mut candidate.match_pairs, vec![]);
|
let match_pairs = mem::take(&mut candidate.match_pairs);
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
for match_pair in match_pairs {
|
for match_pair in match_pairs {
|
||||||
match self.simplify_match_pair(match_pair, candidate) {
|
match self.simplify_match_pair(match_pair, candidate) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl DefUseAnalysis {
|
||||||
self.clear();
|
self.clear();
|
||||||
|
|
||||||
let mut finder = DefUseFinder {
|
let mut finder = DefUseFinder {
|
||||||
info: mem::replace(&mut self.info, IndexVec::new()),
|
info: mem::take(&mut self.info),
|
||||||
};
|
};
|
||||||
finder.visit_body(body);
|
finder.visit_body(body);
|
||||||
self.info = finder.info
|
self.info = finder.info
|
||||||
|
|
|
@ -946,7 +946,7 @@ impl<'a> Resolver<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let macro_resolutions =
|
let macro_resolutions =
|
||||||
mem::replace(&mut *module.multi_segment_macro_resolutions.borrow_mut(), Vec::new());
|
mem::take(&mut *module.multi_segment_macro_resolutions.borrow_mut());
|
||||||
for (mut path, path_span, kind, parent_scope, initial_res) in macro_resolutions {
|
for (mut path, path_span, kind, parent_scope, initial_res) in macro_resolutions {
|
||||||
// FIXME: Path resolution will ICE if segment IDs present.
|
// FIXME: Path resolution will ICE if segment IDs present.
|
||||||
for seg in &mut path { seg.id = None; }
|
for seg in &mut path { seg.id = None; }
|
||||||
|
@ -973,7 +973,7 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let macro_resolutions =
|
let macro_resolutions =
|
||||||
mem::replace(&mut *module.single_segment_macro_resolutions.borrow_mut(), Vec::new());
|
mem::take(&mut *module.single_segment_macro_resolutions.borrow_mut());
|
||||||
for (ident, kind, parent_scope, initial_binding) in macro_resolutions {
|
for (ident, kind, parent_scope, initial_binding) in macro_resolutions {
|
||||||
match self.early_resolve_ident_in_lexical_scope(ident, ScopeSet::Macro(kind),
|
match self.early_resolve_ident_in_lexical_scope(ident, ScopeSet::Macro(kind),
|
||||||
&parent_scope, true, true, ident.span) {
|
&parent_scope, true, true, ident.span) {
|
||||||
|
@ -998,7 +998,7 @@ impl<'a> Resolver<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let builtin_attrs = mem::replace(&mut *module.builtin_attrs.borrow_mut(), Vec::new());
|
let builtin_attrs = mem::take(&mut *module.builtin_attrs.borrow_mut());
|
||||||
for (ident, parent_scope) in builtin_attrs {
|
for (ident, parent_scope) in builtin_attrs {
|
||||||
let _ = self.early_resolve_ident_in_lexical_scope(
|
let _ = self.early_resolve_ident_in_lexical_scope(
|
||||||
ident, ScopeSet::Macro(MacroKind::Attr), &parent_scope, true, true, ident.span
|
ident, ScopeSet::Macro(MacroKind::Attr), &parent_scope, true, true, ident.span
|
||||||
|
|
|
@ -682,7 +682,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
|
||||||
let mut prev_num_indeterminates = self.indeterminate_imports.len() + 1;
|
let mut prev_num_indeterminates = self.indeterminate_imports.len() + 1;
|
||||||
while self.indeterminate_imports.len() < prev_num_indeterminates {
|
while self.indeterminate_imports.len() < prev_num_indeterminates {
|
||||||
prev_num_indeterminates = self.indeterminate_imports.len();
|
prev_num_indeterminates = self.indeterminate_imports.len();
|
||||||
for import in mem::replace(&mut self.indeterminate_imports, Vec::new()) {
|
for import in mem::take(&mut self.indeterminate_imports) {
|
||||||
match self.resolve_import(&import) {
|
match self.resolve_import(&import) {
|
||||||
true => self.determined_imports.push(import),
|
true => self.determined_imports.push(import),
|
||||||
false => self.indeterminate_imports.push(import),
|
false => self.indeterminate_imports.push(import),
|
||||||
|
|
|
@ -970,9 +970,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||||
|
|
||||||
debug!("pick: actual search failed, assemble diagnotics");
|
debug!("pick: actual search failed, assemble diagnotics");
|
||||||
|
|
||||||
let static_candidates = mem::replace(&mut self.static_candidates, vec![]);
|
let static_candidates = mem::take(&mut self.static_candidates);
|
||||||
let private_candidate = self.private_candidate.take();
|
let private_candidate = self.private_candidate.take();
|
||||||
let unsatisfied_predicates = mem::replace(&mut self.unsatisfied_predicates, vec![]);
|
let unsatisfied_predicates = mem::take(&mut self.unsatisfied_predicates);
|
||||||
|
|
||||||
// things failed, so lets look at all traits, for diagnostic purposes now:
|
// things failed, so lets look at all traits, for diagnostic purposes now:
|
||||||
self.reset();
|
self.reset();
|
||||||
|
|
|
@ -4408,7 +4408,7 @@ pub fn enter_impl_trait<F, R>(cx: &DocContext<'_>, f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce() -> R,
|
F: FnOnce() -> R,
|
||||||
{
|
{
|
||||||
let old_bounds = mem::replace(&mut *cx.impl_trait_bounds.borrow_mut(), Default::default());
|
let old_bounds = mem::take(&mut *cx.impl_trait_bounds.borrow_mut());
|
||||||
let r = f();
|
let r = f();
|
||||||
assert!(cx.impl_trait_bounds.borrow().is_empty());
|
assert!(cx.impl_trait_bounds.borrow().is_empty());
|
||||||
*cx.impl_trait_bounds.borrow_mut() = old_bounds;
|
*cx.impl_trait_bounds.borrow_mut() = old_bounds;
|
||||||
|
|
|
@ -131,7 +131,7 @@ pub fn ty_params(mut params: Vec<clean::GenericParamDef>) -> Vec<clean::GenericP
|
||||||
for param in &mut params {
|
for param in &mut params {
|
||||||
match param.kind {
|
match param.kind {
|
||||||
clean::GenericParamDefKind::Type { ref mut bounds, .. } => {
|
clean::GenericParamDefKind::Type { ref mut bounds, .. } => {
|
||||||
*bounds = ty_bounds(mem::replace(bounds, Vec::new()));
|
*bounds = ty_bounds(mem::take(bounds));
|
||||||
}
|
}
|
||||||
_ => panic!("expected only type parameters"),
|
_ => panic!("expected only type parameters"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -660,7 +660,7 @@ pub fn run(mut krate: clean::Crate,
|
||||||
deref_trait_did,
|
deref_trait_did,
|
||||||
deref_mut_trait_did,
|
deref_mut_trait_did,
|
||||||
owned_box_did,
|
owned_box_did,
|
||||||
masked_crates: mem::replace(&mut krate.masked_crates, Default::default()),
|
masked_crates: mem::take(&mut krate.masked_crates),
|
||||||
param_names: external_param_names,
|
param_names: external_param_names,
|
||||||
aliases: Default::default(),
|
aliases: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn collapse(doc_strings: &mut Vec<DocFragment>) {
|
||||||
let mut docs = vec![];
|
let mut docs = vec![];
|
||||||
let mut last_frag: Option<DocFragment> = None;
|
let mut last_frag: Option<DocFragment> = None;
|
||||||
|
|
||||||
for frag in replace(doc_strings, vec![]) {
|
for frag in take(doc_strings) {
|
||||||
if let Some(mut curr_frag) = last_frag.take() {
|
if let Some(mut curr_frag) = last_frag.take() {
|
||||||
let curr_kind = curr_frag.kind();
|
let curr_kind = curr_frag.kind();
|
||||||
let new_kind = frag.kind();
|
let new_kind = frag.kind();
|
||||||
|
|
|
@ -364,7 +364,7 @@ fn continue_panic_fmt(info: &PanicInfo<'_>) -> ! {
|
||||||
|
|
||||||
unsafe impl<'a> BoxMeUp for PanicPayload<'a> {
|
unsafe impl<'a> BoxMeUp for PanicPayload<'a> {
|
||||||
fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
|
fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
|
||||||
let contents = mem::replace(self.fill(), String::new());
|
let contents = mem::take(self.fill());
|
||||||
Box::into_raw(Box::new(contents))
|
Box::into_raw(Box::new(contents))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,7 @@ impl<T> Packet<T> {
|
||||||
// needs to be careful to destroy the data *outside* of the lock to
|
// needs to be careful to destroy the data *outside* of the lock to
|
||||||
// prevent deadlock.
|
// prevent deadlock.
|
||||||
let _data = if guard.cap != 0 {
|
let _data = if guard.cap != 0 {
|
||||||
mem::replace(&mut guard.buf.buf, Vec::new())
|
mem::take(&mut guard.buf.buf)
|
||||||
} else {
|
} else {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
};
|
};
|
||||||
|
|
|
@ -342,7 +342,7 @@ impl<'a> Drop for AsyncPipe<'a> {
|
||||||
// If anything here fails, there's not really much we can do, so we leak
|
// If anything here fails, there's not really much we can do, so we leak
|
||||||
// the buffer/OVERLAPPED pointers to ensure we're at least memory safe.
|
// the buffer/OVERLAPPED pointers to ensure we're at least memory safe.
|
||||||
if self.pipe.cancel_io().is_err() || self.result().is_err() {
|
if self.pipe.cancel_io().is_err() || self.result().is_err() {
|
||||||
let buf = mem::replace(self.dst, Vec::new());
|
let buf = mem::take(self.dst);
|
||||||
let overlapped = Box::new(unsafe { mem::zeroed() });
|
let overlapped = Box::new(unsafe { mem::zeroed() });
|
||||||
let overlapped = mem::replace(&mut self.overlapped, overlapped);
|
let overlapped = mem::replace(&mut self.overlapped, overlapped);
|
||||||
mem::forget((buf, overlapped));
|
mem::forget((buf, overlapped));
|
||||||
|
|
|
@ -307,7 +307,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
} else {
|
} else {
|
||||||
self.resolve_imports();
|
self.resolve_imports();
|
||||||
if undetermined_invocations.is_empty() { break }
|
if undetermined_invocations.is_empty() { break }
|
||||||
invocations = mem::replace(&mut undetermined_invocations, Vec::new());
|
invocations = mem::take(&mut undetermined_invocations);
|
||||||
force = !mem::replace(&mut progress, false);
|
force = !mem::replace(&mut progress, false);
|
||||||
continue
|
continue
|
||||||
};
|
};
|
||||||
|
|
|
@ -249,7 +249,7 @@ pub fn transcribe(
|
||||||
quoted::TokenTree::Delimited(mut span, delimited) => {
|
quoted::TokenTree::Delimited(mut span, delimited) => {
|
||||||
span = span.apply_mark(cx.current_expansion.mark);
|
span = span.apply_mark(cx.current_expansion.mark);
|
||||||
stack.push(Frame::Delimited { forest: delimited, idx: 0, span });
|
stack.push(Frame::Delimited { forest: delimited, idx: 0, span });
|
||||||
result_stack.push(mem::replace(&mut result, Vec::new()));
|
result_stack.push(mem::take(&mut result));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing much to do here. Just push the token to the result, being careful to
|
// Nothing much to do here. Just push the token to the result, being careful to
|
||||||
|
|
|
@ -7699,7 +7699,7 @@ impl<'a> Parser<'a> {
|
||||||
let mut tokens = Vec::new();
|
let mut tokens = Vec::new();
|
||||||
let prev_collecting = match self.token_cursor.frame.last_token {
|
let prev_collecting = match self.token_cursor.frame.last_token {
|
||||||
LastToken::Collecting(ref mut list) => {
|
LastToken::Collecting(ref mut list) => {
|
||||||
Some(mem::replace(list, Vec::new()))
|
Some(mem::take(list))
|
||||||
}
|
}
|
||||||
LastToken::Was(ref mut last) => {
|
LastToken::Was(ref mut last) => {
|
||||||
tokens.extend(last.take());
|
tokens.extend(last.take());
|
||||||
|
@ -7717,7 +7717,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
// Pull out the tokens that we've collected from the call to `f` above.
|
// Pull out the tokens that we've collected from the call to `f` above.
|
||||||
let mut collected_tokens = match *last_token {
|
let mut collected_tokens = match *last_token {
|
||||||
LastToken::Collecting(ref mut v) => mem::replace(v, Vec::new()),
|
LastToken::Collecting(ref mut v) => mem::take(v),
|
||||||
LastToken::Was(_) => panic!("our vector went away?"),
|
LastToken::Was(_) => panic!("our vector went away?"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -120,8 +120,8 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
|
||||||
// We don't want to recurse into anything other than mods, since
|
// We don't want to recurse into anything other than mods, since
|
||||||
// mods or tests inside of functions will break things
|
// mods or tests inside of functions will break things
|
||||||
if let ast::ItemKind::Mod(mut module) = item.node {
|
if let ast::ItemKind::Mod(mut module) = item.node {
|
||||||
let tests = mem::replace(&mut self.tests, Vec::new());
|
let tests = mem::take(&mut self.tests);
|
||||||
let tested_submods = mem::replace(&mut self.tested_submods, Vec::new());
|
let tested_submods = mem::take(&mut self.tested_submods);
|
||||||
noop_visit_mod(&mut module, self);
|
noop_visit_mod(&mut module, self);
|
||||||
let tests = mem::replace(&mut self.tests, tests);
|
let tests = mem::replace(&mut self.tests, tests);
|
||||||
let tested_submods = mem::replace(&mut self.tested_submods, tested_submods);
|
let tested_submods = mem::replace(&mut self.tested_submods, tested_submods);
|
||||||
|
|
|
@ -3608,7 +3608,7 @@ fn nocomment_mir_line(line: &str) -> &str {
|
||||||
|
|
||||||
fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
|
fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
|
||||||
use crate::read2::read2;
|
use crate::read2::read2;
|
||||||
use std::mem::replace;
|
use std::mem::take;
|
||||||
|
|
||||||
const HEAD_LEN: usize = 160 * 1024;
|
const HEAD_LEN: usize = 160 * 1024;
|
||||||
const TAIL_LEN: usize = 256 * 1024;
|
const TAIL_LEN: usize = 256 * 1024;
|
||||||
|
@ -3632,7 +3632,7 @@ fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let tail = bytes.split_off(new_len - TAIL_LEN).into_boxed_slice();
|
let tail = bytes.split_off(new_len - TAIL_LEN).into_boxed_slice();
|
||||||
let head = replace(bytes, Vec::new());
|
let head = take(bytes);
|
||||||
let skipped = new_len - HEAD_LEN - TAIL_LEN;
|
let skipped = new_len - HEAD_LEN - TAIL_LEN;
|
||||||
ProcOutput::Abbreviated {
|
ProcOutput::Abbreviated {
|
||||||
head,
|
head,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue