Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d3dd34a

Browse files
committedJul 15, 2024
Auto merge of rust-lang#127757 - workingjubilee:rollup-4dbks5r, r=workingjubilee
Rollup of 3 pull requests Successful merges: - rust-lang#127712 (Windows: Remove some unnecessary type aliases) - rust-lang#127744 (std: `#![deny(unsafe_op_in_unsafe_fn)]` in platform-independent code) - rust-lang#127750 (Make os/windows and pal/windows default to `#![deny(unsafe_op_in_unsafe_fn)]`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents adeb79d + 476d399 commit d3dd34a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+307
-292
lines changed
 

‎library/std/src/sync/mpmc/array.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ impl<T> Channel<T> {
200200
return Err(msg);
201201
}
202202

203-
let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>);
204-
205203
// Write the message into the slot and update the stamp.
206-
slot.msg.get().write(MaybeUninit::new(msg));
207-
slot.stamp.store(token.array.stamp, Ordering::Release);
204+
unsafe {
205+
let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>);
206+
slot.msg.get().write(MaybeUninit::new(msg));
207+
slot.stamp.store(token.array.stamp, Ordering::Release);
208+
}
208209

209210
// Wake a sleeping receiver.
210211
self.receivers.notify();
@@ -291,11 +292,14 @@ impl<T> Channel<T> {
291292
return Err(());
292293
}
293294

294-
let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>);
295-
296295
// Read the message from the slot and update the stamp.
297-
let msg = slot.msg.get().read().assume_init();
298-
slot.stamp.store(token.array.stamp, Ordering::Release);
296+
let msg = unsafe {
297+
let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>);
298+
299+
let msg = slot.msg.get().read().assume_init();
300+
slot.stamp.store(token.array.stamp, Ordering::Release);
301+
msg
302+
};
299303

300304
// Wake a sleeping sender.
301305
self.senders.notify();
@@ -471,7 +475,7 @@ impl<T> Channel<T> {
471475
false
472476
};
473477

474-
self.discard_all_messages(tail);
478+
unsafe { self.discard_all_messages(tail) };
475479
disconnected
476480
}
477481

‎library/std/src/sync/mpmc/counter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<C> Sender<C> {
6363
disconnect(&self.counter().chan);
6464

6565
if self.counter().destroy.swap(true, Ordering::AcqRel) {
66-
drop(Box::from_raw(self.counter));
66+
drop(unsafe { Box::from_raw(self.counter) });
6767
}
6868
}
6969
}
@@ -116,7 +116,7 @@ impl<C> Receiver<C> {
116116
disconnect(&self.counter().chan);
117117

118118
if self.counter().destroy.swap(true, Ordering::AcqRel) {
119-
drop(Box::from_raw(self.counter));
119+
drop(unsafe { Box::from_raw(self.counter) });
120120
}
121121
}
122122
}
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.