mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Use Cell::take in a couple places
This commit is contained in:
parent
f121f094fe
commit
4ea83bfb3d
@ -497,7 +497,7 @@ impl Drop for WaiterQueue<'_> {
|
||||
let mut queue = (state_and_queue & !STATE_MASK) as *const Waiter;
|
||||
while !queue.is_null() {
|
||||
let next = (*queue).next;
|
||||
let thread = (*queue).thread.replace(None).unwrap();
|
||||
let thread = (*queue).thread.take().unwrap();
|
||||
(*queue).signaled.store(true, Ordering::Release);
|
||||
// ^- FIXME (maybe): This is another case of issue #55005
|
||||
// `store()` has a potentially dangling ref to `signaled`.
|
||||
|
@ -23,5 +23,5 @@ pub fn foo() {
|
||||
pub fn foo() -> usize {
|
||||
use std::cell::Cell;
|
||||
thread_local!(static A: Cell<Vec<u32>> = Cell::new(Vec::new()));
|
||||
A.try_with(|x| x.replace(Vec::new()).len()).unwrap_or(0)
|
||||
A.try_with(|x| x.take().len()).unwrap_or(0)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ struct MyType<'a>(Cell<Option<&'a mut MyType<'a>>>, PhantomPinned);
|
||||
impl<'a> Clone for &'a mut MyType<'a> {
|
||||
//~^ ERROR E0751
|
||||
fn clone(&self) -> &'a mut MyType<'a> {
|
||||
self.0.replace(None).unwrap()
|
||||
self.0.take().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ struct MyType<'a>(Cell<Option<&'a mut MyType<'a>>>, PhantomPinned);
|
||||
impl<'a> DerefMut for &'a MyType<'a> {
|
||||
//~^ ERROR E0751
|
||||
fn deref_mut(&mut self) -> &mut MyType<'a> {
|
||||
self.0.replace(None).unwrap()
|
||||
self.0.take().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user