Skip to content

Commit 726a025

Browse files
authored
Rollup merge of #69435 - anyska:cell-replace, r=Centril
Replace uses of Cell::get + Cell::set with Cell::replace.
2 parents eda4489 + 0445574 commit 726a025

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/librustc/ty/print/pretty.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ thread_local! {
6464
/// calling the same query.
6565
pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R {
6666
NO_QUERIES.with(|no_queries| {
67-
let old = no_queries.get();
68-
no_queries.set(true);
67+
let old = no_queries.replace(true);
6968
let result = f();
7069
no_queries.set(old);
7170
result
@@ -78,8 +77,7 @@ pub fn with_no_queries<F: FnOnce() -> R, R>(f: F) -> R {
7877
/// so this variable disables that check.
7978
pub fn with_forced_impl_filename_line<F: FnOnce() -> R, R>(f: F) -> R {
8079
FORCE_IMPL_FILENAME_LINE.with(|force| {
81-
let old = force.get();
82-
force.set(true);
80+
let old = force.replace(true);
8381
let result = f();
8482
force.set(old);
8583
result
@@ -89,8 +87,7 @@ pub fn with_forced_impl_filename_line<F: FnOnce() -> R, R>(f: F) -> R {
8987
/// Adds the `crate::` prefix to paths where appropriate.
9088
pub fn with_crate_prefix<F: FnOnce() -> R, R>(f: F) -> R {
9189
SHOULD_PREFIX_WITH_CRATE.with(|flag| {
92-
let old = flag.get();
93-
flag.set(true);
90+
let old = flag.replace(true);
9491
let result = f();
9592
flag.set(old);
9693
result

src/librustc_infer/infer/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
730730
where
731731
F: FnOnce(&Self) -> R,
732732
{
733-
let flag = self.in_snapshot.get();
734-
self.in_snapshot.set(false);
733+
let flag = self.in_snapshot.replace(false);
735734
let result = func(self);
736735
self.in_snapshot.set(flag);
737736
result
@@ -740,8 +739,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
740739
fn start_snapshot(&self) -> CombinedSnapshot<'a, 'tcx> {
741740
debug!("start_snapshot()");
742741

743-
let in_snapshot = self.in_snapshot.get();
744-
self.in_snapshot.set(true);
742+
let in_snapshot = self.in_snapshot.replace(true);
745743

746744
let mut inner = self.inner.borrow_mut();
747745
CombinedSnapshot {

0 commit comments

Comments
 (0)