Skip to content

Commit

Permalink
Replace uses of Cell::get + Cell::set with Cell::replace.
Browse files Browse the repository at this point in the history
  • Loading branch information
anyska committed Feb 24, 2020
1 parent d9a328a commit 0445574
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 3 additions & 6 deletions src/librustc/ty/print/pretty.rs
Expand Up @@ -64,8 +64,7 @@ thread_local! {
/// calling the same query.
pub fn with_no_queries<F: FnOnce() -> 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
Expand All @@ -78,8 +77,7 @@ pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R {
/// so this variable disables that check.
pub fn with_forced_impl_filename_line<F: FnOnce() -> 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
Expand All @@ -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.
pub fn with_crate_prefix<F: FnOnce() -> 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
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_infer/infer/mod.rs
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 0445574

Please sign in to comment.