Skip to content

Commit d0efd94

Browse files
committed
chore: target nightly-2021-09-04
Replaces `guard::guard!` with the native `if let ... else` from <rust-lang/rfcs#3137> (still unstable).
1 parent 6597abf commit d0efd94

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "interlock"
33
version = "0.0.0"
44
authors = ["yvt <[email protected]>"]
55
license = "MIT/Apache-2.0"
6-
edition = "2018"
6+
edition = "2021"
77
readme = "README.md"
88
description = "Readers-writer locks optimized for interval locks"
99
categories = ["no-std"]
@@ -17,7 +17,6 @@ std = [
1717
]
1818

1919
[dependencies]
20-
guard = "0.5.1" # <https://github.com/rust-lang/rfcs/pull/1303> polyfill
2120
futures = { version = "0.3.16", default-features = false }
2221
pin-utils = "0.1.0"
2322
pin-project = "1.0.8"

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2021-08-29
1+
nightly-2021-09-04

src/core/rbtree.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use core::{
88
pin::Pin,
99
ptr::NonNull,
1010
};
11-
use guard::guard;
1211

1312
use super::{IntervalRwLockCore, LockCallback, UnlockCallback};
1413
use crate::utils::{
@@ -908,8 +907,8 @@ where
908907
// `Option<[NonNull<T>; 2]>`. If the result is `None`, return early.
909908
//
910909
// Safety: `*read_nodes` is safe to borrow
911-
guard!(let Some(mut read_nodes) = unsafe { option_array2_as_ptr(read_nodes_ptr) }
912-
else { return; });
910+
let Some(mut read_nodes) =( unsafe { option_array2_as_ptr(read_nodes_ptr) })
911+
else { return; };
913912

914913
// The range we are about to unlock
915914
// Safety: It's still safe to borrow
@@ -1014,7 +1013,8 @@ where
10141013
// If the result is `None`, return early.
10151014
//
10161015
// Safety: `*pending_node` is safe to borrow
1017-
guard!(let Some(mut write_node) = unsafe { option_as_ptr(write_node_ptr) } else { return; });
1016+
let Some(mut write_node) = (unsafe { option_as_ptr(write_node_ptr) })
1017+
else { return; };
10181018

10191019
let Range { start, mut end } = unsafe { write_node.as_ref().element.clone() };
10201020

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#![doc = include_str!("../README.md")]
22
#![no_std]
33
#![deny(unsafe_op_in_unsafe_fn)]
4+
#![allow(clippy::needless_return)] // <https://github.com/rust-lang/rust-clippy/issues/7637>
45
#![feature(const_fn_trait_bound)]
56
#![feature(array_methods)]
67
#![feature(never_type)]
78
#![feature(type_alias_impl_trait)]
89
#![feature(const_impl_trait)]
910
#![feature(slice_ptr_len)]
1011
#![feature(slice_ptr_get)]
12+
#![feature(let_else)] // <https://github.com/rust-lang/rust/issues/87335>
1113

1214
#[cfg(test)]
1315
extern crate std;

src/raw/local.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! The thread-unsafe (but faster) implementation.
22
use core::{ops::Range, pin::Pin};
3-
use guard::guard;
43
use pin_cell::PinCell;
54

65
use crate::{
@@ -27,11 +26,11 @@ fn deadlocked() -> ! {
2726
}
2827

2928
macro_rules! borrow_core {
30-
(let $p:pat = $self:ident.core) => {
31-
guard!(let Ok(mut core) = $self.project_ref().core.try_borrow_mut()
32-
else { core_is_not_reentrant(); });
33-
let $p = pin_cell::PinMut::as_mut(&mut core);
34-
};
29+
(let $p:pat = $self:ident.core) => {
30+
let Ok(mut core) = $self.project_ref().core.try_borrow_mut()
31+
else { core_is_not_reentrant(); };
32+
let $p = pin_cell::PinMut::as_mut(&mut core);
33+
};
3534
}
3635

3736
unsafe impl<Core: IntervalRwLockCore<InProgress = !>> RawIntervalRwLock

src/utils/rbtree.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use core::{
1616
mem::{replace, swap},
1717
ptr::NonNull,
1818
};
19-
use guard::guard;
2019

2120
#[cfg(not(debug_assertions))]
2221
use core::hint::unreachable_unchecked;
@@ -405,7 +404,7 @@ impl<Element, Summary: Clone> Node<Element, Summary> {
405404

406405
// If `parent` is `None`, the black height change propagated up to
407406
// the root
408-
guard!(let Some(mut parent) = node.as_ref().parent else { return; });
407+
let Some(mut parent) = node.as_ref().parent else { return; };
409408

410409
loop {
411410
// parent

0 commit comments

Comments
 (0)