Skip to content

Commit c059aec

Browse files
bors[bot]taiki-e
andauthored
Merge #877
877: Bump MSRV to Rust 1.38 r=taiki-e a=taiki-e It was released [nearly 3 years ago](https://blog.rust-lang.org/2019/09/26/Rust-1.38.0.html) and meets our MSRV policy. This allows using const_in_array_repeat_expressions (rust-lang/rust#49147) and `<pointer>.cast()`. Co-authored-by: Taiki Endo <[email protected]>
2 parents 99b14b1 + 6ac1232 commit c059aec

File tree

27 files changed

+89
-157
lines changed

27 files changed

+89
-157
lines changed

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.36"
1+
msrv = "1.38"

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
include:
33-
- rust: 1.36.0
33+
- rust: '1.38'
3434
os: ubuntu-latest
35-
- rust: 1.36.0
35+
- rust: '1.38'
3636
os: windows-latest
3737
- rust: stable
3838
os: ubuntu-latest
@@ -75,7 +75,7 @@ jobs:
7575
fail-fast: false
7676
matrix:
7777
rust:
78-
- 1.36.0
78+
- '1.38'
7979
- nightly
8080
runs-on: ubuntu-latest
8181
steps:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "crossbeam"
66
# - Create "crossbeam-X.Y.Z" git tag
77
version = "0.8.1"
88
edition = "2018"
9-
rust-version = "1.36"
9+
rust-version = "1.38"
1010
license = "MIT OR Apache-2.0"
1111
repository = "https://github.com/crossbeam-rs/crossbeam"
1212
homepage = "https://github.com/crossbeam-rs/crossbeam"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam#license)
88
https://crates.io/crates/crossbeam)
99
[![Documentation](https://docs.rs/crossbeam/badge.svg)](
1010
https://docs.rs/crossbeam)
11-
[![Rust 1.36+](https://img.shields.io/badge/rust-1.36+-lightgray.svg)](
11+
[![Rust 1.38+](https://img.shields.io/badge/rust-1.38+-lightgray.svg)](
1212
https://www.rust-lang.org)
1313
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.com/invite/JXYwgWZ)
1414

@@ -94,7 +94,7 @@ crossbeam = "0.8"
9494

9595
Crossbeam supports stable Rust releases going back at least six months,
9696
and every time the minimum supported Rust version is increased, a new minor
97-
version is released. Currently, the minimum supported Rust version is 1.36.
97+
version is released. Currently, the minimum supported Rust version is 1.38.
9898

9999
## Contributing
100100

crossbeam-channel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "crossbeam-channel"
66
# - Create "crossbeam-channel-X.Y.Z" git tag
77
version = "0.5.5"
88
edition = "2018"
9-
rust-version = "1.36"
9+
rust-version = "1.38"
1010
license = "MIT OR Apache-2.0"
1111
repository = "https://github.com/crossbeam-rs/crossbeam"
1212
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel"

crossbeam-channel/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel#license)
88
https://crates.io/crates/crossbeam-channel)
99
[![Documentation](https://docs.rs/crossbeam-channel/badge.svg)](
1010
https://docs.rs/crossbeam-channel)
11-
[![Rust 1.36+](https://img.shields.io/badge/rust-1.36+-lightgray.svg)](
11+
[![Rust 1.38+](https://img.shields.io/badge/rust-1.38+-lightgray.svg)](
1212
https://www.rust-lang.org)
1313
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.com/invite/JXYwgWZ)
1414

@@ -48,7 +48,7 @@ crossbeam-channel = "0.5"
4848

4949
Crossbeam Channel supports stable Rust releases going back at least six months,
5050
and every time the minimum supported Rust version is increased, a new minor
51-
version is released. Currently, the minimum supported Rust version is 1.36.
51+
version is released. Currently, the minimum supported Rust version is 1.38.
5252

5353
## License
5454

crossbeam-channel/src/flavors/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl<T> Channel<T> {
216216
return Err(msg);
217217
}
218218

219-
let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>);
219+
let slot: &Slot<T> = &*token.array.slot.cast::<Slot<T>>();
220220

221221
// Write the message into the slot and update the stamp.
222222
slot.msg.get().write(MaybeUninit::new(msg));
@@ -307,7 +307,7 @@ impl<T> Channel<T> {
307307
return Err(());
308308
}
309309

310-
let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>);
310+
let slot: &Slot<T> = &*token.array.slot.cast::<Slot<T>>();
311311

312312
// Read the message from the slot and update the stamp.
313313
let msg = slot.msg.get().read().assume_init();

crossbeam-channel/src/flavors/list.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ struct Slot<T> {
4949
}
5050

5151
impl<T> Slot<T> {
52+
const UNINIT: Self = Self {
53+
msg: UnsafeCell::new(MaybeUninit::uninit()),
54+
state: AtomicUsize::new(0),
55+
};
56+
5257
/// Waits until a message is written into the slot.
5358
fn wait_write(&self) {
5459
let backoff = Backoff::new();
@@ -72,13 +77,10 @@ struct Block<T> {
7277
impl<T> Block<T> {
7378
/// Creates an empty block.
7479
fn new() -> Block<T> {
75-
// SAFETY: This is safe because:
76-
// [1] `Block::next` (AtomicPtr) may be safely zero initialized.
77-
// [2] `Block::slots` (Array) may be safely zero initialized because of [3, 4].
78-
// [3] `Slot::msg` (UnsafeCell) may be safely zero initialized because it
79-
// holds a MaybeUninit.
80-
// [4] `Slot::state` (AtomicUsize) may be safely zero initialized.
81-
unsafe { MaybeUninit::zeroed().assume_init() }
80+
Self {
81+
next: AtomicPtr::new(ptr::null_mut()),
82+
slots: [Slot::UNINIT; BLOCK_CAP],
83+
}
8284
}
8385

8486
/// Waits until the next pointer is set.
@@ -283,7 +285,7 @@ impl<T> Channel<T> {
283285
}
284286

285287
// Write the message into the slot.
286-
let block = token.list.block as *mut Block<T>;
288+
let block = token.list.block.cast::<Block<T>>();
287289
let offset = token.list.offset;
288290
let slot = (*block).slots.get_unchecked(offset);
289291
slot.msg.get().write(MaybeUninit::new(msg));

crossbeam-channel/src/flavors/zero.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<T> Channel<T> {
190190
// heap-allocated packet.
191191
packet.wait_ready();
192192
let msg = packet.msg.get().replace(None).unwrap();
193-
drop(Box::from_raw(token.zero.0 as *mut Packet<T>));
193+
drop(Box::from_raw(token.zero.0.cast::<Packet<T>>()));
194194
Ok(msg)
195195
}
196196
}
@@ -409,15 +409,15 @@ impl<T> SelectHandle for Receiver<'_, T> {
409409
let mut inner = self.0.inner.lock().unwrap();
410410
inner
411411
.receivers
412-
.register_with_packet(oper, packet as *mut (), cx);
412+
.register_with_packet(oper, packet.cast::<()>(), cx);
413413
inner.senders.notify();
414414
inner.senders.can_select() || inner.is_disconnected
415415
}
416416

417417
fn unregister(&self, oper: Operation) {
418418
if let Some(operation) = self.0.inner.lock().unwrap().receivers.unregister(oper) {
419419
unsafe {
420-
drop(Box::from_raw(operation.packet as *mut Packet<T>));
420+
drop(Box::from_raw(operation.packet.cast::<Packet<T>>()));
421421
}
422422
}
423423
}
@@ -459,15 +459,15 @@ impl<T> SelectHandle for Sender<'_, T> {
459459
let mut inner = self.0.inner.lock().unwrap();
460460
inner
461461
.senders
462-
.register_with_packet(oper, packet as *mut (), cx);
462+
.register_with_packet(oper, packet.cast::<()>(), cx);
463463
inner.receivers.notify();
464464
inner.receivers.can_select() || inner.is_disconnected
465465
}
466466

467467
fn unregister(&self, oper: Operation) {
468468
if let Some(operation) = self.0.inner.lock().unwrap().senders.unregister(oper) {
469469
unsafe {
470-
drop(Box::from_raw(operation.packet as *mut Packet<T>));
470+
drop(Box::from_raw(operation.packet.cast::<Packet<T>>()));
471471
}
472472
}
473473
}

crossbeam-deque/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ name = "crossbeam-deque"
66
# - Create "crossbeam-deque-X.Y.Z" git tag
77
version = "0.8.1"
88
edition = "2018"
9-
rust-version = "1.36"
9+
rust-version = "1.38"
1010
license = "MIT OR Apache-2.0"
1111
repository = "https://github.com/crossbeam-rs/crossbeam"
1212
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-deque"

0 commit comments

Comments
 (0)