Prefer os-unix prelude over importing everything separately

This commit is contained in:
Henrik Hørlück Berg 2023-08-06 14:56:30 +02:00 committed by Johannes Altmanninger
parent 131e249b0c
commit 0844247b43
10 changed files with 10 additions and 18 deletions

View File

@ -1,4 +1,4 @@
use std::os::unix::prelude::OsStrExt; use std::os::unix::prelude::*;
use super::prelude::*; use super::prelude::*;
use crate::common::{get_executable_path, str2wcstring}; use crate::common::{get_executable_path, str2wcstring};

View File

@ -10,7 +10,7 @@ mod test_expressions {
}; };
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::collections::HashMap; use std::collections::HashMap;
use std::os::unix::fs::{FileTypeExt, MetadataExt, PermissionsExt}; use std::os::unix::prelude::*;
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
pub(super) enum Token { pub(super) enum Token {

View File

@ -26,8 +26,7 @@ use std::env;
use std::ffi::{CStr, CString, OsString}; use std::ffi::{CStr, CString, OsString};
use std::mem; use std::mem;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::os::fd::{AsRawFd, RawFd}; use std::os::unix::prelude::*;
use std::os::unix::prelude::OsStringExt;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use std::sync::atomic::{AtomicI32, AtomicU32, Ordering}; use std::sync::atomic::{AtomicI32, AtomicU32, Ordering};
@ -1923,8 +1922,6 @@ pub(crate) use assert_is_locked;
/// bullet-proof and that's OK. /// bullet-proof and that's OK.
pub fn is_console_session() -> bool { pub fn is_console_session() -> bool {
static IS_CONSOLE_SESSION: Lazy<bool> = Lazy::new(|| { static IS_CONSOLE_SESSION: Lazy<bool> = Lazy::new(|| {
use std::os::unix::ffi::OsStrExt;
const PATH_MAX: usize = libc::PATH_MAX as usize; const PATH_MAX: usize = libc::PATH_MAX as usize;
let mut tty_name = [0u8; PATH_MAX]; let mut tty_name = [0u8; PATH_MAX];
unsafe { unsafe {

View File

@ -1,4 +1,4 @@
use std::os::fd::{AsRawFd, RawFd}; use std::os::unix::prelude::*;
use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};

View File

@ -1,5 +1,5 @@
use libc::c_int; use libc::c_int;
use std::os::unix::io::RawFd; use std::os::unix::prelude::*;
pub use fd_readable_set_t as FdReadableSet; pub use fd_readable_set_t as FdReadableSet;

View File

@ -7,7 +7,7 @@ use libc::{fcntl, F_GETFL, F_SETFL, O_CLOEXEC, O_NONBLOCK};
use nix::unistd; use nix::unistd;
use std::ffi::CStr; use std::ffi::CStr;
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::os::unix::prelude::*;
pub const PIPE_ERROR: &wstr = L!("An error occurred while setting up pipe"); pub const PIPE_ERROR: &wstr = L!("An error occurred while setting up pipe");

View File

@ -4,7 +4,7 @@ use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharToFFI; use crate::wchar_ffi::WCharToFFI;
use libc::c_int; use libc::c_int;
use std::io::Write; use std::io::Write;
use std::os::unix::io::{FromRawFd, IntoRawFd}; use std::os::unix::prelude::*;
use std::sync::atomic::{AtomicI32, Ordering}; use std::sync::atomic::{AtomicI32, Ordering};
#[rustfmt::skip::macros(category)] #[rustfmt::skip::macros(category)]

View File

@ -15,8 +15,7 @@ use libc::{EACCES, ENOENT, ENOTDIR, F_OK, X_OK};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::io::{ErrorKind, Write}; use std::io::{ErrorKind, Write};
use std::os::unix::ffi::OsStrExt; use std::os::unix::prelude::*;
use std::os::unix::prelude::MetadataExt;
/// Returns the user configuration directory for fish. If the directory or one of its parents /// Returns the user configuration directory for fish. If the directory or one of its parents
/// doesn't exist, they are first created. /// doesn't exist, they are first created.

View File

@ -1,10 +1,7 @@
use crate::wutil::{wstat, wstr}; use crate::wutil::{wstat, wstr};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::fs::{File, Metadata}; use std::fs::{File, Metadata};
use std::os::fd::RawFd; use std::os::unix::prelude::*;
use std::os::fd::{FromRawFd, IntoRawFd};
use std::os::unix::fs::MetadataExt;
/// Struct for representing a file's inode. We use this to detect and avoid symlink loops, among /// Struct for representing a file's inode. We use this to detect and avoid symlink loops, among
/// other things. While an inode / dev pair is sufficient to distinguish co-existing files, Linux /// other things. While an inode / dev pair is sufficient to distinguish co-existing files, Linux

View File

@ -23,8 +23,7 @@ pub(crate) use printf::sprintf;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fs::{self, canonicalize}; use std::fs::{self, canonicalize};
use std::io::{self, Write}; use std::io::{self, Write};
use std::os::fd::{FromRawFd, IntoRawFd, RawFd}; use std::os::unix::prelude::*;
use std::os::unix::prelude::{OsStrExt, OsStringExt};
pub use wcstoi::*; pub use wcstoi::*;
use widestring_suffix::widestrs; use widestring_suffix::widestrs;