1
Fork 0

Rollup merge of #69435 - anyska:cell-replace, r=Centril

Replace uses of Cell::get + Cell::set with Cell::replace.
This commit is contained in:
Dylan DPC 2020-02-24 20:10:18 +01:00 committed by GitHub
commit 726a025c65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 10 deletions

View file

@ -64,8 +64,7 @@ thread_local! {
/// calling the same query. /// calling the same query.
pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R { pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R {
NO_QUERIES.with(|no_queries| { NO_QUERIES.with(|no_queries| {
let old = no_queries.get(); let old = no_queries.replace(true);
no_queries.set(true);
let result = f(); let result = f();
no_queries.set(old); no_queries.set(old);
result result
@ -78,8 +77,7 @@ pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R {
/// so this variable disables that check. /// so this variable disables that check.
pub fn with_forced_impl_filename_line<F: FnOnce() -> R, R>(f: F) -> R { pub fn with_forced_impl_filename_line<F: FnOnce() -> R, R>(f: F) -> R {
FORCE_IMPL_FILENAME_LINE.with(|force| { FORCE_IMPL_FILENAME_LINE.with(|force| {
let old = force.get(); let old = force.replace(true);
force.set(true);
let result = f(); let result = f();
force.set(old); force.set(old);
result result
@ -89,8 +87,7 @@ pub fn with_forced_impl_filename_line<F: FnOnce() -> R, R>(f: F) -> R {
/// Adds the `crate::` prefix to paths where appropriate. /// Adds the `crate::` prefix to paths where appropriate.
pub fn with_crate_prefix<F: FnOnce() -> R, R>(f: F) -> R { pub fn with_crate_prefix<F: FnOnce() -> R, R>(f: F) -> R {
SHOULD_PREFIX_WITH_CRATE.with(|flag| { SHOULD_PREFIX_WITH_CRATE.with(|flag| {
let old = flag.get(); let old = flag.replace(true);
flag.set(true);
let result = f(); let result = f();
flag.set(old); flag.set(old);
result result

View file

@ -730,8 +730,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
where where
F: FnOnce(&Self) -> R, F: FnOnce(&Self) -> R,
{ {
let flag = self.in_snapshot.get(); let flag = self.in_snapshot.replace(false);
self.in_snapshot.set(false);
let result = func(self); let result = func(self);
self.in_snapshot.set(flag); self.in_snapshot.set(flag);
result result
@ -740,8 +739,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> { fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> {
debug!("start_snapshot()"); debug!("start_snapshot()");
let in_snapshot = self.in_snapshot.get(); let in_snapshot = self.in_snapshot.replace(true);
self.in_snapshot.set(true);
let mut inner = self.inner.borrow_mut(); let mut inner = self.inner.borrow_mut();
CombinedSnapshot { CombinedSnapshot {