Skip to content

Commit 688201a

Browse files
authored
Merge pull request #460 from kakserpom/chore_clippy
2 parents 25f6928 + d4fc01b commit 688201a

File tree

15 files changed

+66
-60
lines changed

15 files changed

+66
-60
lines changed

src/builders/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl ClassBuilder {
303303

304304
let class = unsafe {
305305
zend_register_internal_class_ex(
306-
&mut self.ce,
306+
&raw mut self.ce,
307307
match self.extends {
308308
Some((ptr, _)) => ptr::from_ref(ptr()).cast_mut(),
309309
None => std::ptr::null_mut(),

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(non_upper_case_globals)]
44
#![allow(non_camel_case_types)]
55
#![allow(non_snake_case)]
6+
#![warn(clippy::pedantic)]
67
#![cfg_attr(docs, feature(doc_cfg))]
78
#![cfg_attr(windows, feature(abi_vectorcall))]
89

src/types/array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl ZendHashTable {
378378
V: IntoZval,
379379
{
380380
let mut val = val.into_zval(false)?;
381-
unsafe { zend_hash_str_update(self, CString::new(key)?.as_ptr(), key.len(), &mut val) };
381+
unsafe { zend_hash_str_update(self, CString::new(key)?.as_ptr(), key.len(), &raw mut val) };
382382
val.release();
383383
Ok(())
384384
}
@@ -416,7 +416,7 @@ impl ZendHashTable {
416416
V: IntoZval,
417417
{
418418
let mut val = val.into_zval(false)?;
419-
unsafe { zend_hash_index_update(self, key, &mut val) };
419+
unsafe { zend_hash_index_update(self, key, &raw mut val) };
420420
val.release();
421421
Ok(())
422422
}
@@ -453,7 +453,7 @@ impl ZendHashTable {
453453
V: IntoZval,
454454
{
455455
let mut val = val.into_zval(false)?;
456-
unsafe { zend_hash_next_index_insert(self, &mut val) };
456+
unsafe { zend_hash_next_index_insert(self, &raw mut val) };
457457
val.release();
458458

459459
Ok(())
@@ -534,7 +534,7 @@ impl ZendHashTable {
534534
/// }
535535
#[inline]
536536
#[must_use]
537-
pub fn values(&self) -> Values {
537+
pub fn values(&self) -> Values<'_> {
538538
Values::new(self)
539539
}
540540

@@ -559,7 +559,7 @@ impl ZendHashTable {
559559
/// }
560560
#[inline]
561561
#[must_use]
562-
pub fn iter(&self) -> Iter {
562+
pub fn iter(&self) -> Iter<'_> {
563563
self.into_iter()
564564
}
565565
}

src/types/callable.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ impl<'a> ZendCallable<'a> {
131131
let result = unsafe {
132132
#[allow(clippy::used_underscore_items)]
133133
_call_user_function_impl(
134-
std::ptr::null_mut(),
134+
ptr::null_mut(),
135135
ptr::from_ref(self.0.as_ref()).cast_mut(),
136-
&mut retval,
136+
&raw mut retval,
137137
len.try_into()?,
138138
packed.as_ptr().cast_mut(),
139-
std::ptr::null_mut(),
139+
ptr::null_mut(),
140140
)
141141
};
142142

src/types/class_object.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ impl<T: RegisteredClass> ZendClassObject<T> {
115115
.as_mut()
116116
.expect("Failed to allocate for new Zend object");
117117

118-
zend_object_std_init(&mut obj.std, ce);
119-
object_properties_init(&mut obj.std, ce);
118+
zend_object_std_init(&raw mut obj.std, ce);
119+
object_properties_init(&raw mut obj.std, ce);
120120

121121
// SAFETY: `obj` is non-null and well aligned as it is a reference.
122122
// As the data in `obj.obj` is uninitialized, we don't want to drop
123123
// the data, but directly override it.
124-
ptr::write(&mut obj.obj, val);
124+
ptr::write(&raw mut obj.obj, val);
125125

126126
obj.std.handlers = meta.handlers();
127127
ZBox::from_raw(obj)
@@ -239,7 +239,7 @@ unsafe impl<T: RegisteredClass> ZBoxable for ZendClassObject<T> {
239239
// SAFETY: All constructors guarantee that `self` contains a valid pointer.
240240
// Further, all constructors guarantee that the `std` field of
241241
// `ZendClassObject` will be initialized.
242-
unsafe { ext_php_rs_zend_object_release(&mut self.std) }
242+
unsafe { ext_php_rs_zend_object_release(&raw mut self.std) }
243243
}
244244
}
245245

@@ -276,7 +276,7 @@ impl<T: RegisteredClass + Clone> Clone for ZBox<ZendClassObject<T>> {
276276
// therefore we can dereference both safely.
277277
unsafe {
278278
let mut new = ZendClassObject::new((***self).clone());
279-
zend_objects_clone_members(&mut new.std, (&raw const self.std).cast_mut());
279+
zend_objects_clone_members(&raw mut new.std, (&raw const self.std).cast_mut());
280280
new
281281
}
282282
}

src/types/iterable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Iterable<'_> {
1919
/// May return None if a Traversable cannot be rewound.
2020
// TODO: Check iter not returning iterator
2121
#[allow(clippy::iter_not_returning_iterator)]
22-
pub fn iter(&mut self) -> Option<Iter> {
22+
pub fn iter(&mut self) -> Option<Iter<'_>> {
2323
match self {
2424
Iterable::Array(array) => Some(Iter::Array(array.iter())),
2525
Iterable::Traversable(traversable) => Some(Iter::Traversable(traversable.iter()?)),

src/types/iterator.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl ZendIterator {
2323
/// iterator cannot be rewound.
2424
// TODO: Check iter not returning iterator
2525
#[allow(clippy::iter_not_returning_iterator)]
26-
pub fn iter(&mut self) -> Option<Iter> {
26+
pub fn iter(&mut self) -> Option<Iter<'_>> {
2727
self.index = 0;
2828

2929
if self.rewind() {
@@ -39,7 +39,7 @@ impl ZendIterator {
3939
/// `\Iterator` interface. see <https://www.php.net/manual/en/iterator.valid.php>
4040
pub fn valid(&mut self) -> bool {
4141
if let Some(valid) = unsafe { (*self.funcs).valid } {
42-
let valid = unsafe { valid(&mut *self) == ZEND_RESULT_CODE_SUCCESS };
42+
let valid = unsafe { valid(&raw mut *self) == ZEND_RESULT_CODE_SUCCESS };
4343

4444
if ExecutorGlobals::has_exception() {
4545
return false;
@@ -63,7 +63,7 @@ impl ZendIterator {
6363
pub fn rewind(&mut self) -> bool {
6464
if let Some(rewind) = unsafe { (*self.funcs).rewind } {
6565
unsafe {
66-
rewind(&mut *self);
66+
rewind(&raw mut *self);
6767
}
6868
}
6969

@@ -82,7 +82,7 @@ impl ZendIterator {
8282
pub fn move_forward(&mut self) -> bool {
8383
if let Some(move_forward) = unsafe { (*self.funcs).move_forward } {
8484
unsafe {
85-
move_forward(&mut *self);
85+
move_forward(&raw mut *self);
8686
}
8787
}
8888

@@ -97,7 +97,7 @@ impl ZendIterator {
9797
/// , [`None`] otherwise.
9898
pub fn get_current_data<'a>(&mut self) -> Option<&'a Zval> {
9999
let get_current_data = unsafe { (*self.funcs).get_current_data }?;
100-
let value = unsafe { &*get_current_data(&mut *self) };
100+
let value = unsafe { &*get_current_data(&raw mut *self) };
101101

102102
if ExecutorGlobals::has_exception() {
103103
return None;
@@ -117,7 +117,7 @@ impl ZendIterator {
117117
let mut key = Zval::new();
118118

119119
unsafe {
120-
get_current_key(&mut *self, &mut key);
120+
get_current_key(&raw mut *self, &raw mut key);
121121
}
122122

123123
if ExecutorGlobals::has_exception() {

src/types/object.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl ZendObject {
179179

180180
unsafe {
181181
let res = zend_hash_str_find_ptr_lc(
182-
&(*self.ce).function_table,
182+
&raw const (*self.ce).function_table,
183183
name.as_ptr().cast::<c_char>(),
184184
name.len(),
185185
)
@@ -193,7 +193,7 @@ impl ZendObject {
193193
res,
194194
ptr::from_ref(self).cast_mut(),
195195
self.ce,
196-
&mut retval,
196+
&raw mut retval,
197197
len.try_into()?,
198198
packed.as_ptr().cast_mut(),
199199
std::ptr::null_mut(),
@@ -230,10 +230,10 @@ impl ZendObject {
230230
let zv = unsafe {
231231
self.handlers()?.read_property.ok_or(Error::InvalidScope)?(
232232
self.mut_ptr(),
233-
&mut *name,
233+
&raw mut *name,
234234
1,
235-
std::ptr::null_mut(),
236-
&mut rv,
235+
ptr::null_mut(),
236+
&raw mut rv,
237237
)
238238
.as_ref()
239239
}
@@ -260,9 +260,9 @@ impl ZendObject {
260260
unsafe {
261261
self.handlers()?.write_property.ok_or(Error::InvalidScope)?(
262262
self,
263-
&mut *name,
264-
&mut value,
265-
std::ptr::null_mut(),
263+
&raw mut *name,
264+
&raw mut value,
265+
ptr::null_mut(),
266266
)
267267
.as_ref()
268268
}
@@ -289,7 +289,7 @@ impl ZendObject {
289289
Ok(unsafe {
290290
self.handlers()?.has_property.ok_or(Error::InvalidScope)?(
291291
self.mut_ptr(),
292-
&mut *name,
292+
&raw mut *name,
293293
query as _,
294294
std::ptr::null_mut(),
295295
)
@@ -440,10 +440,10 @@ impl FromZendObject<'_> for String {
440440
(*obj.ce).__tostring,
441441
ptr::from_ref(obj).cast_mut(),
442442
obj.ce,
443-
&mut ret,
443+
&raw mut ret,
444444
0,
445-
std::ptr::null_mut(),
446-
std::ptr::null_mut(),
445+
ptr::null_mut(),
446+
ptr::null_mut(),
447447
);
448448
}
449449

src/types/zval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl Zval {
291291

292292
/// Returns the value of the zval if it is callable.
293293
#[must_use]
294-
pub fn callable(&self) -> Option<ZendCallable> {
294+
pub fn callable(&self) -> Option<ZendCallable<'_>> {
295295
// The Zval is checked if it is callable in the `new` function.
296296
ZendCallable::new(self).ok()
297297
}
@@ -309,7 +309,7 @@ impl Zval {
309309
/// Returns an iterable over the zval if it is an array or traversable. (is
310310
/// iterable)
311311
#[must_use]
312-
pub fn iterable(&self) -> Option<Iterable> {
312+
pub fn iterable(&self) -> Option<Iterable<'_>> {
313313
if self.is_iterable() {
314314
Iterable::from_zval(self)
315315
} else {

src/zend/class.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ impl ClassEntry {
2727
ExecutorGlobals::get().class_table()?;
2828
let mut name = ZendStr::new(name, false);
2929

30-
unsafe { crate::ffi::zend_lookup_class_ex(&mut *name, std::ptr::null_mut(), 0).as_ref() }
30+
unsafe {
31+
crate::ffi::zend_lookup_class_ex(&raw mut *name, std::ptr::null_mut(), 0).as_ref()
32+
}
3133
}
3234

3335
/// Creates a new [`ZendObject`], returned inside an [`ZBox<ZendObject>`]

0 commit comments

Comments
 (0)