From eab3a31c5750013c53c0eb02adc976d6757dc9f7 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 2 Jul 2026 01:32:03 +0900 Subject: chore(lint): ban std::io::Read/Write, Any, Command use imports Extends no_banned_use to cover std::any::Any, std::io::Read/Write, and std::process::Command, and teaches the linter to allow `as _` imports so trait methods can still be brought into scope without binding the banned name. Fully qualifies all existing usages across the codebase. --- crates/shirabe-php-shim/src/fs.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'crates/shirabe-php-shim/src/fs.rs') diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index ba6eef6..e58623a 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -4,6 +4,7 @@ use crate::StreamBacking; use crate::StreamState; use crate::UnexpectedValueException; use indexmap::IndexMap; +use std::io::{Read as _, Write as _}; pub const PHP_EOL: &str = "\n"; @@ -329,7 +330,6 @@ pub fn fopen(file: &str, mode: &str) -> Result { /// PHP `fwrite()`. `length` caps the number of bytes written (`None` = whole string). /// Returns the byte count written, or `None` for PHP's `false`-on-failure. pub fn fwrite(stream: &PhpResource, data: &str, length: Option) -> Option { - use std::io::Write; let bytes = data.as_bytes(); let bytes = match length { Some(l) if l >= 0 => &bytes[..(l as usize).min(bytes.len())], @@ -360,7 +360,6 @@ pub fn fwrite(stream: &PhpResource, data: &str, length: Option) -> Option; from_utf8_lossy can corrupt /// binary reads (filesAreEqual / binary copy). pub fn fread(stream: &PhpResource, length: i64) -> Option { - use std::io::Read; let cap = length.max(0) as usize; match stream { PhpResource::Stdin => { @@ -482,7 +481,6 @@ fn fgets_read_line( /// PHP `fgetc()`: reads a single byte, or `None` at end-of-stream. /// TODO(phase-e): byte-string semantics — should return Vec. pub fn fgetc(stream: &PhpResource) -> Option { - use std::io::Read; let mut byte = [0u8; 1]; match stream { PhpResource::Stdin => { @@ -638,7 +636,6 @@ fn build_stat_map(size: u64, file_meta: Option<&std::fs::Metadata>) -> IndexMap< /// PHP `fflush()`. pub fn fflush(stream: &PhpResource) -> bool { - use std::io::Write; match stream { PhpResource::Stdin => true, PhpResource::Stdout => std::io::stdout().flush().is_ok(), @@ -848,7 +845,6 @@ pub fn file_put_contents(_path: &str, _data: &[u8]) -> Option { } pub fn file_put_contents3(_filename: &str, _data: &str, _flags: i64) -> Option { - use std::io::Write; // TODO(phase-d): the LOCK_EX and FILE_USE_INCLUDE_PATH flags are ignored; only FILE_APPEND is // honored. let append = _flags & FILE_APPEND != 0; -- cgit v1.3.1