Skip to content

Commit d4da7cd

Browse files
committed
Silence, linter.
1 parent 9e5cce7 commit d4da7cd

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub unsafe fn efree(ptr: *mut u8) {
5858
0,
5959
std::ptr::null_mut(),
6060
0,
61-
)
61+
);
6262
} else {
6363
#[allow(clippy::used_underscore_items)]
6464
_efree(ptr.cast::<c_void>());

src/zend/globals.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Types related to the PHP executor, sapi and process globals.
22
3-
use parking_lot::{ArcRwLockReadGuard, ArcRwLockWriteGuard, RawRwLock, RwLock};
3+
use parking_lot::{lock_api, ArcRwLockReadGuard, ArcRwLockWriteGuard, RawRwLock, RwLock};
44
use std::collections::HashMap;
55
use std::ffi::CStr;
66
use std::ops::{Deref, DerefMut};
@@ -47,6 +47,7 @@ impl ExecutorGlobals {
4747
/// # Panics
4848
///
4949
/// * If static executor globals are not set
50+
#[must_use]
5051
pub fn get() -> GlobalReadGuard<Self> {
5152
// SAFETY: PHP executor globals are statically declared therefore should never
5253
// return an invalid pointer.
@@ -55,7 +56,7 @@ impl ExecutorGlobals {
5556

5657
cfg_if::cfg_if! {
5758
if #[cfg(php_zts)] {
58-
let guard = lock::GLOBALS_LOCK.with(|l| l.read_arc());
59+
let guard = lock::GLOBALS_LOCK.with(lock_api::RwLock::read_arc);
5960
} else {
6061
let guard = lock::GLOBALS_LOCK.read_arc();
6162
}
@@ -75,6 +76,7 @@ impl ExecutorGlobals {
7576
/// # Panics
7677
///
7778
/// * If static executor globals are not set
79+
#[must_use]
7880
pub fn get_mut() -> GlobalWriteGuard<Self> {
7981
// SAFETY: PHP executor globals are statically declared therefore should never
8082
// return an invalid pointer.
@@ -83,7 +85,7 @@ impl ExecutorGlobals {
8385

8486
cfg_if::cfg_if! {
8587
if #[cfg(php_zts)] {
86-
let guard = lock::GLOBALS_LOCK.with(|l| l.write_arc());
88+
let guard = lock::GLOBALS_LOCK.with(parking_lot::lock_api::RwLock::write_arc);
8789
} else {
8890
let guard = lock::GLOBALS_LOCK.write_arc();
8991
}
@@ -237,6 +239,7 @@ impl CompilerGlobals {
237239
/// # Panics
238240
///
239241
/// * If static executor globals are not set
242+
#[must_use]
240243
pub fn get() -> GlobalReadGuard<Self> {
241244
// SAFETY: PHP compiler globals are statically declared therefore should never
242245
// return an invalid pointer.
@@ -245,7 +248,7 @@ impl CompilerGlobals {
245248

246249
cfg_if::cfg_if! {
247250
if #[cfg(php_zts)] {
248-
let guard = lock::GLOBALS_LOCK.with(|l| l.read_arc());
251+
let guard = lock::GLOBALS_LOCK.with(lock_api::RwLock::read_arc);
249252
} else {
250253
let guard = lock::GLOBALS_LOCK.read_arc();
251254
}
@@ -265,6 +268,7 @@ impl CompilerGlobals {
265268
/// # Panics
266269
///
267270
/// * If static compiler globals are not set
271+
#[must_use]
268272
pub fn get_mut() -> GlobalWriteGuard<Self> {
269273
// SAFETY: PHP compiler globals are statically declared therefore should never
270274
// return an invalid pointer.
@@ -273,7 +277,7 @@ impl CompilerGlobals {
273277

274278
cfg_if::cfg_if! {
275279
if #[cfg(php_zts)] {
276-
let guard = lock::GLOBALS_LOCK.with(|l| l.write_arc());
280+
let guard = lock::GLOBALS_LOCK.with(parking_lot::lock_api::RwLock::write_arc);
277281
} else {
278282
let guard = lock::GLOBALS_LOCK.write_arc();
279283
}
@@ -339,14 +343,15 @@ impl ProcessGlobals {
339343
/// Attempting to retrieve the globals while already holding the global
340344
/// guard will lead to a deadlock. Dropping the globals guard will release
341345
/// the lock.
346+
#[must_use]
342347
pub fn get() -> GlobalReadGuard<Self> {
343348
// SAFETY: PHP executor globals are statically declared therefore should never
344349
// return an invalid pointer.
345350
let globals = unsafe { &*ext_php_rs_process_globals() };
346351

347352
cfg_if::cfg_if! {
348353
if #[cfg(php_zts)] {
349-
let guard = lock::PROCESS_GLOBALS_LOCK.with(|l| l.read_arc());
354+
let guard = lock::PROCESS_GLOBALS_LOCK.with(lock_api::RwLock::read_arc);
350355
} else {
351356
let guard = lock::PROCESS_GLOBALS_LOCK.read_arc();
352357
}
@@ -362,14 +367,15 @@ impl ProcessGlobals {
362367
/// Attempting to retrieve the globals while already holding the global
363368
/// guard will lead to a deadlock. Dropping the globals guard will release
364369
/// the lock.
370+
#[must_use]
365371
pub fn get_mut() -> GlobalWriteGuard<Self> {
366372
// SAFETY: PHP executor globals are statically declared therefore should never
367373
// return an invalid pointer.
368374
let globals = unsafe { &mut *ext_php_rs_process_globals() };
369375

370376
cfg_if::cfg_if! {
371377
if #[cfg(php_zts)] {
372-
let guard = lock::PROCESS_GLOBALS_LOCK.with(|l| l.write_arc());
378+
let guard = lock::PROCESS_GLOBALS_LOCK.with(parking_lot::lock_api::RwLock::write_arc);
373379
} else {
374380
let guard = lock::PROCESS_GLOBALS_LOCK.write_arc();
375381
}
@@ -506,14 +512,15 @@ impl SapiGlobals {
506512
/// Attempting to retrieve the globals while already holding the global
507513
/// guard will lead to a deadlock. Dropping the globals guard will release
508514
/// the lock.
515+
#[must_use]
509516
pub fn get() -> GlobalReadGuard<Self> {
510517
// SAFETY: PHP executor globals are statically declared therefore should never
511518
// return an invalid pointer.
512519
let globals = unsafe { &*ext_php_rs_sapi_globals() };
513520

514521
cfg_if::cfg_if! {
515522
if #[cfg(php_zts)] {
516-
let guard = lock::SAPI_GLOBALS_LOCK.with(|l| l.read_arc());
523+
let guard = lock::SAPI_GLOBALS_LOCK.with(lock_api::RwLock::read_arc);
517524
} else {
518525
let guard = lock::SAPI_GLOBALS_LOCK.read_arc();
519526
}
@@ -529,14 +536,15 @@ impl SapiGlobals {
529536
/// Attempting to retrieve the globals while already holding the global
530537
/// guard will lead to a deadlock. Dropping the globals guard will release
531538
/// the lock.
539+
#[must_use]
532540
pub fn get_mut() -> GlobalWriteGuard<Self> {
533541
// SAFETY: PHP executor globals are statically declared therefore should never
534542
// return an invalid pointer.
535543
let globals = unsafe { &mut *ext_php_rs_sapi_globals() };
536544

537545
cfg_if::cfg_if! {
538546
if #[cfg(php_zts)] {
539-
let guard = lock::SAPI_GLOBALS_LOCK.with(|l| l.write_arc());
547+
let guard = lock::SAPI_GLOBALS_LOCK.with(parking_lot::lock_api::RwLock::write_arc);
540548
} else {
541549
let guard = lock::SAPI_GLOBALS_LOCK.write_arc();
542550
}
@@ -769,6 +777,7 @@ impl FileGlobals {
769777
/// # Panics
770778
///
771779
/// * If static file globals are not set
780+
#[must_use]
772781
pub fn get() -> GlobalReadGuard<Self> {
773782
// SAFETY: PHP executor globals are statically declared therefore should never
774783
// return an invalid pointer.
@@ -777,7 +786,7 @@ impl FileGlobals {
777786

778787
cfg_if::cfg_if! {
779788
if #[cfg(php_zts)] {
780-
let guard = lock::FILE_GLOBALS_LOCK.with(|l| l.read_arc());
789+
let guard = lock::FILE_GLOBALS_LOCK.with(lock_api::RwLock::read_arc);
781790
} else {
782791
let guard = lock::FILE_GLOBALS_LOCK.read_arc();
783792
}
@@ -793,14 +802,15 @@ impl FileGlobals {
793802
/// Attempting to retrieve the globals while already holding the global
794803
/// guard will lead to a deadlock. Dropping the globals guard will release
795804
/// the lock.
805+
#[must_use]
796806
pub fn get_mut() -> GlobalWriteGuard<Self> {
797807
// SAFETY: PHP executor globals are statically declared therefore should never
798808
// return an invalid pointer.
799809
let globals = unsafe { &mut *ext_php_rs_file_globals() };
800810

801811
cfg_if::cfg_if! {
802812
if #[cfg(php_zts)] {
803-
let guard = lock::FILE_GLOBALS_LOCK.with(|l| l.write_arc());
813+
let guard = lock::FILE_GLOBALS_LOCK.with(parking_lot::lock_api::RwLock::write_arc);
804814
} else {
805815
let guard = lock::FILE_GLOBALS_LOCK.write_arc();
806816
}

0 commit comments

Comments
 (0)