diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-01-14 20:18:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-14 23:18:58 -0500 |
commit | d5634164cb86771fc279468cbb93e311c1ad3089 (patch) | |
tree | 2878a536acdb5106e48488e640cd78dfa2b5893a /runtime | |
parent | efcbfd5206fcdfac55c26a7133c04dd330d047b9 (diff) |
chore: use rustfmt imports_granularity option (#17421)
Closes https://github.com/denoland/deno/issues/2699
Closes https://github.com/denoland/deno/issues/2347
Uses unstable rustfmt features. Since dprint invokes `rustfmt` we do not
need to switch the cargo toolchain to nightly. Do we care about
formatting stability of our codebase across Rust versions? (I don't)
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/colors.rs | 17 | ||||
-rw-r--r-- | runtime/fs_util.rs | 3 | ||||
-rw-r--r-- | runtime/ops/fs.rs | 11 | ||||
-rw-r--r-- | runtime/ops/io.rs | 9 | ||||
-rw-r--r-- | runtime/ops/os/mod.rs | 3 | ||||
-rw-r--r-- | runtime/ops/process.rs | 3 | ||||
-rw-r--r-- | runtime/ops/runtime.rs | 12 | ||||
-rw-r--r-- | runtime/ops/signal.rs | 14 | ||||
-rw-r--r-- | runtime/ops/tty.rs | 3 | ||||
-rw-r--r-- | runtime/ops/web_worker/sync_fetch.rs | 3 | ||||
-rw-r--r-- | runtime/permissions/mod.rs | 3 | ||||
-rw-r--r-- | runtime/web_worker.rs | 3 |
12 files changed, 60 insertions, 24 deletions
diff --git a/runtime/colors.rs b/runtime/colors.rs index cc15a8e8d..c978e19c3 100644 --- a/runtime/colors.rs +++ b/runtime/colors.rs @@ -4,11 +4,22 @@ use atty; use once_cell::sync::Lazy; use std::fmt; use std::io::Write; -use termcolor::Color::{Ansi256, Black, Blue, Cyan, Green, Red, White, Yellow}; -use termcolor::{Ansi, ColorSpec, WriteColor}; +use termcolor::Ansi; +use termcolor::Color::Ansi256; +use termcolor::Color::Black; +use termcolor::Color::Blue; +use termcolor::Color::Cyan; +use termcolor::Color::Green; +use termcolor::Color::Red; +use termcolor::Color::White; +use termcolor::Color::Yellow; +use termcolor::ColorSpec; +use termcolor::WriteColor; #[cfg(windows)] -use termcolor::{BufferWriter, ColorChoice}; +use termcolor::BufferWriter; +#[cfg(windows)] +use termcolor::ColorChoice; static NO_COLOR: Lazy<bool> = Lazy::new(|| std::env::var_os("NO_COLOR").is_some()); diff --git a/runtime/fs_util.rs b/runtime/fs_util.rs index 05ce0b67a..1a01a0e05 100644 --- a/runtime/fs_util.rs +++ b/runtime/fs_util.rs @@ -5,7 +5,8 @@ use deno_core::error::AnyError; pub use deno_core::normalize_path; use std::env::current_dir; use std::io::Error; -use std::path::{Path, PathBuf}; +use std::path::Path; +use std::path::PathBuf; /// Similar to `std::fs::canonicalize()` but strips UNC prefixes on Windows. pub fn canonicalize_path(path: &Path) -> Result<PathBuf, Error> { diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index 2f62e143b..342b0e35d 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -679,7 +679,9 @@ fn op_chown_sync( #[cfg(unix)] { use crate::errors::get_nix_error_class; - use nix::unistd::{chown, Gid, Uid}; + use nix::unistd::chown; + use nix::unistd::Gid; + use nix::unistd::Uid; let nix_uid = uid.map(Uid::from_raw); let nix_gid = gid.map(Gid::from_raw); chown(&path, nix_uid, nix_gid).map_err(|err| { @@ -717,7 +719,9 @@ async fn op_chown_async( #[cfg(unix)] { use crate::errors::get_nix_error_class; - use nix::unistd::{chown, Gid, Uid}; + use nix::unistd::chown; + use nix::unistd::Gid; + use nix::unistd::Uid; let nix_uid = uid.map(Uid::from_raw); let nix_gid = gid.map(Gid::from_raw); chown(&path, nix_uid, nix_gid).map_err(|err| { @@ -1488,7 +1492,8 @@ fn op_symlink_sync( } #[cfg(not(unix))] { - use std::os::windows::fs::{symlink_dir, symlink_file}; + use std::os::windows::fs::symlink_dir; + use std::os::windows::fs::symlink_file; match _type { Some(ty) => match ty.as_ref() { diff --git a/runtime/ops/io.rs b/runtime/ops/io.rs index 43016395e..4c727f452 100644 --- a/runtime/ops/io.rs +++ b/runtime/ops/io.rs @@ -35,10 +35,11 @@ use tokio::process; use std::os::unix::io::FromRawFd; #[cfg(windows)] -use { - std::os::windows::io::FromRawHandle, - winapi::um::{processenv::GetStdHandle, winbase}, -}; +use std::os::windows::io::FromRawHandle; +#[cfg(windows)] +use winapi::um::processenv::GetStdHandle; +#[cfg(windows)] +use winapi::um::winbase; // Store the stdio fd/handles in global statics in order to keep them // alive for the duration of the application since the last handle/fd diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs index fec7629f5..c35d4fc9e 100644 --- a/runtime/ops/os/mod.rs +++ b/runtime/ops/os/mod.rs @@ -3,7 +3,8 @@ use super::utils::into_string; use crate::permissions::PermissionsContainer; use crate::worker::ExitCode; -use deno_core::error::{type_error, AnyError}; +use deno_core::error::type_error; +use deno_core::error::AnyError; use deno_core::op; use deno_core::url::Url; use deno_core::v8; diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 75d9cfdc9..eebf7e7af 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -294,7 +294,8 @@ async fn op_run_status( #[cfg(unix)] pub fn kill(pid: i32, signal: &str) -> Result<(), AnyError> { let signo = super::signal::signal_str_to_int(signal)?; - use nix::sys::signal::{kill as unix_kill, Signal}; + use nix::sys::signal::kill as unix_kill; + use nix::sys::signal::Signal; use nix::unistd::Pid; let sig = Signal::try_from(signo)?; unix_kill(Pid::from_raw(pid), Option::Some(sig)).map_err(AnyError::from) diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs index b97741acc..70814e3b8 100644 --- a/runtime/ops/runtime.rs +++ b/runtime/ops/runtime.rs @@ -44,12 +44,14 @@ pub fn ppid() -> i64 { // - MIT license use std::mem; use winapi::shared::minwindef::DWORD; - use winapi::um::handleapi::{CloseHandle, INVALID_HANDLE_VALUE}; + use winapi::um::handleapi::CloseHandle; + use winapi::um::handleapi::INVALID_HANDLE_VALUE; use winapi::um::processthreadsapi::GetCurrentProcessId; - use winapi::um::tlhelp32::{ - CreateToolhelp32Snapshot, Process32First, Process32Next, PROCESSENTRY32, - TH32CS_SNAPPROCESS, - }; + use winapi::um::tlhelp32::CreateToolhelp32Snapshot; + use winapi::um::tlhelp32::Process32First; + use winapi::um::tlhelp32::Process32Next; + use winapi::um::tlhelp32::PROCESSENTRY32; + use winapi::um::tlhelp32::TH32CS_SNAPPROCESS; // SAFETY: winapi calls unsafe { // Take a snapshot of system processes, one of which is ours diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs index 0af9a5c44..ddee1fb5d 100644 --- a/runtime/ops/signal.rs +++ b/runtime/ops/signal.rs @@ -16,9 +16,19 @@ use std::cell::RefCell; use std::rc::Rc; #[cfg(unix)] -use tokio::signal::unix::{signal, Signal, SignalKind}; +use tokio::signal::unix::signal; +#[cfg(unix)] +use tokio::signal::unix::Signal; +#[cfg(unix)] +use tokio::signal::unix::SignalKind; +#[cfg(windows)] +use tokio::signal::windows::ctrl_break; +#[cfg(windows)] +use tokio::signal::windows::ctrl_c; +#[cfg(windows)] +use tokio::signal::windows::CtrlBreak; #[cfg(windows)] -use tokio::signal::windows::{ctrl_break, ctrl_c, CtrlBreak, CtrlC}; +use tokio::signal::windows::CtrlC; pub fn init() -> Extension { Extension::builder("deno_signal") diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs index d022a43dc..739b84ab3 100644 --- a/runtime/ops/tty.rs +++ b/runtime/ops/tty.rs @@ -60,7 +60,8 @@ fn op_stdin_set_raw( { use std::os::windows::io::AsRawHandle; use winapi::shared::minwindef::FALSE; - use winapi::um::{consoleapi, handleapi}; + use winapi::um::consoleapi; + use winapi::um::handleapi; if cbreak { return Err(deno_core::error::not_supported()); diff --git a/runtime/ops/web_worker/sync_fetch.rs b/runtime/ops/web_worker/sync_fetch.rs index 69adec051..a9a893572 100644 --- a/runtime/ops/web_worker/sync_fetch.rs +++ b/runtime/ops/web_worker/sync_fetch.rs @@ -12,7 +12,8 @@ use deno_fetch::reqwest; use deno_web::BlobStore; use deno_websocket::DomExceptionNetworkError; use hyper::body::Bytes; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; +use serde::Serialize; use tokio::task::JoinHandle; // TODO(andreubotella) Properly parse the MIME type diff --git a/runtime/permissions/mod.rs b/runtime/permissions/mod.rs index 5424a3f36..494e603a3 100644 --- a/runtime/permissions/mod.rs +++ b/runtime/permissions/mod.rs @@ -20,7 +20,8 @@ use once_cell::sync::Lazy; use std::collections::HashSet; use std::fmt; use std::hash::Hash; -use std::path::{Path, PathBuf}; +use std::path::Path; +use std::path::PathBuf; use std::str::FromStr; use std::string::ToString; use std::sync::Arc; diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 5424860db..079e772b6 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -243,7 +243,8 @@ impl WebWorkerHandle { /// This function will set the termination signal, close the message channel, /// and schedule to terminate the isolate after two seconds. pub fn terminate(self) { - use std::thread::{sleep, spawn}; + use std::thread::sleep; + use std::thread::spawn; use std::time::Duration; let schedule_termination = |