From 0445574340f972ae892a6ef4589ba63756883a0a Mon Sep 17 00:00:00 2001 From: Ana-Maria Date: Mon, 24 Feb 2020 16:23:55 +0000 Subject: [PATCH] Replace uses of Cell::get + Cell::set with Cell::replace. --- src/librustc/ty/print/pretty.rs | 9 +++------ src/librustc_infer/infer/mod.rs | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 38442295636..0726bf30d3b 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -64,8 +64,7 @@ thread_local! { /// calling the same query. pub fn with_no_queries R, R>(f: F) -> R { NO_QUERIES.with(|no_queries| { - let old = no_queries.get(); - no_queries.set(true); + let old = no_queries.replace(true); let result = f(); no_queries.set(old); result @@ -78,8 +77,7 @@ pub fn with_no_queries R, R>(f: F) -> R { /// so this variable disables that check. pub fn with_forced_impl_filename_line R, R>(f: F) -> R { FORCE_IMPL_FILENAME_LINE.with(|force| { - let old = force.get(); - force.set(true); + let old = force.replace(true); let result = f(); force.set(old); result @@ -89,8 +87,7 @@ pub fn with_forced_impl_filename_line R, R>(f: F) -> R { /// Adds the `crate::` prefix to paths where appropriate. pub fn with_crate_prefix R, R>(f: F) -> R { SHOULD_PREFIX_WITH_CRATE.with(|flag| { - let old = flag.get(); - flag.set(true); + let old = flag.replace(true); let result = f(); flag.set(old); result diff --git a/src/librustc_infer/infer/mod.rs b/src/librustc_infer/infer/mod.rs index c9e58c2aa73..65f060deb46 100644 --- a/src/librustc_infer/infer/mod.rs +++ b/src/librustc_infer/infer/mod.rs @@ -730,8 +730,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { where F: FnOnce(&Self) -> R, { - let flag = self.in_snapshot.get(); - self.in_snapshot.set(false); + let flag = self.in_snapshot.replace(false); let result = func(self); self.in_snapshot.set(flag); result @@ -740,8 +739,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> { debug!("start_snapshot()"); - let in_snapshot = self.in_snapshot.get(); - self.in_snapshot.set(true); + let in_snapshot = self.in_snapshot.replace(true); let mut inner = self.inner.borrow_mut(); CombinedSnapshot {