Skip to content

Commit c867a2a

Browse files
committed
fix(clippy): fix new clippy findings
Some clippy findings were ignored as they require further investigation. Those findings are marked with a comment and will be tracked in #461. Refs: #461
1 parent 688201a commit c867a2a

File tree

10 files changed

+32
-12
lines changed

10 files changed

+32
-12
lines changed

crates/cli/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ enum Args {
9090
Stubs(Stubs),
9191
}
9292

93+
#[allow(clippy::struct_excessive_bools)]
9394
#[derive(Parser)]
9495
struct Install {
9596
/// Changes the path that the extension is copied to. This will not

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
system = "x86_64-linux";
1818
overlays = [ (import rust-overlay) ];
1919
pkgs = import nixpkgs { inherit system overlays; };
20-
php-dev = pkgs.php.unwrapped.dev;
20+
php = pkgs.php.buildEnv { embedSupport = true; };
21+
php-dev = php.unwrapped.dev;
2122
in
2223
{
2324
devShells.${system} = {
@@ -32,7 +33,7 @@
3233
nativeBuildInputs = [ pkgs.rust-bin.stable.latest.default ];
3334

3435
shellHook = ''
35-
export LIBCLANG_PATH="''$LIBCLANG_PATH ${pkgs.libclang.lib}/lib"
36+
export LIBCLANG_PATH="${pkgs.libclang.lib}/lib"
3637
'';
3738
};
3839
};

src/embed/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ impl Embed {
103103
};
104104

105105
unsafe {
106-
zend_stream_init_filename(&mut file_handle, path.as_ptr());
106+
zend_stream_init_filename(&raw mut file_handle, path.as_ptr());
107107
}
108108

109-
let exec_result = try_catch(|| unsafe { php_execute_script(&mut file_handle) });
109+
let exec_result = try_catch(|| unsafe { php_execute_script(&raw mut file_handle) });
110110

111111
match exec_result {
112112
Err(_) => Err(EmbedError::CatchError),
@@ -208,7 +208,7 @@ impl Embed {
208208
let exec_result = try_catch(|| unsafe {
209209
zend_eval_string(
210210
cstr.as_ptr().cast::<c_char>(),
211-
&mut result,
211+
&raw mut result,
212212
c"run".as_ptr().cast(),
213213
)
214214
});

src/types/array.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ impl ZendHashTable {
215215
/// ht.insert("test", "hello world");
216216
/// assert_eq!(ht.get("test").and_then(|zv| zv.str()), Some("hello world"));
217217
/// ```
218+
// TODO: Verify if this is safe to use, as it allows mutating the
219+
// hashtable while only having a reference to it. #461
220+
#[allow(clippy::mut_from_ref)]
218221
#[must_use]
219222
pub fn get_mut(&self, key: &'_ str) -> Option<&mut Zval> {
220223
let str = CString::new(key).ok()?;
@@ -270,6 +273,9 @@ impl ZendHashTable {
270273
/// ht.push(100);
271274
/// assert_eq!(ht.get_index(0).and_then(|zv| zv.long()), Some(100));
272275
/// ```
276+
// TODO: Verify if this is safe to use, as it allows mutating the
277+
// hashtable while only having a reference to it. #461
278+
#[allow(clippy::mut_from_ref)]
273279
#[must_use]
274280
pub fn get_index_mut(&self, key: u64) -> Option<&mut Zval> {
275281
unsafe { zend_hash_index_find(self, key).as_mut() }

src/types/class_object.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ impl<T: RegisteredClass> ZendClassObject<T> {
173173
Self::internal_from_zend_obj(std)
174174
}
175175

176+
// TODO: Verify if this is safe to use, as it allows mutating the
177+
// hashtable while only having a reference to it. #461
178+
#[allow(clippy::mut_from_ref)]
176179
fn internal_from_zend_obj(std: &zend_object) -> Option<&mut Self> {
177180
let std = ptr::from_ref(std).cast::<c_char>();
178181
let ptr = unsafe {

src/types/zval.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ impl Zval {
261261

262262
/// Returns a mutable reference to the zval if it is an internal indirect
263263
/// reference.
264+
// TODO: Verify if this is safe to use, as it allows mutating the
265+
// hashtable while only having a reference to it. #461
266+
#[allow(clippy::mut_from_ref)]
264267
#[must_use]
265268
pub fn indirect_mut(&self) -> Option<&mut Zval> {
266269
if self.is_indirect() {

src/zend/class.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ impl ClassEntry {
113113
/// Returns the iterator for the class for a specific instance
114114
///
115115
/// Returns [`None`] if there is no associated iterator for the class.
116+
// TODO: Verify if this is safe to use, as it allows mutating the
117+
// hashtable while only having a reference to it. #461
118+
#[allow(clippy::mut_from_ref)]
116119
#[must_use]
117120
pub fn get_iterator<'a>(&self, zval: &'a Zval, by_ref: bool) -> Option<&'a mut ZendIterator> {
118121
let ptr: *const Self = self;

src/zend/globals.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ impl ExecutorGlobals {
105105
}
106106

107107
/// Attempts to retrieve the global functions hash table as mutable.
108+
// TODO: Verify if this is safe to use, as it allows mutating the
109+
// hashtable while only having a reference to it. #461
110+
#[allow(clippy::mut_from_ref)]
108111
#[must_use]
109112
pub fn function_table_mut(&self) -> Option<&mut ZendHashTable> {
110113
unsafe { self.function_table.as_mut() }

src/zend/try_catch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ mod tests {
195195

196196
let _ = try_catch(|| {
197197
let mut result = "foo".to_string();
198-
ptr = &mut result;
198+
ptr = &raw mut result;
199199

200200
unsafe {
201201
bailout();

0 commit comments

Comments
 (0)