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 | |
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)
65 files changed, 301 insertions, 126 deletions
diff --git a/.dprint.json b/.dprint.json index 4c792e4db..2cc83f3ec 100644 --- a/.dprint.json +++ b/.dprint.json @@ -11,7 +11,7 @@ }, "exec": { "associations": "**/*.rs", - "rustfmt": "rustfmt" + "rustfmt": "rustfmt --config imports_granularity=item" }, "includes": [ "**/*.{ts,tsx,js,jsx,json,md,toml,rs}" diff --git a/bench_util/benches/op_baseline.rs b/bench_util/benches/op_baseline.rs index f8ae32b35..8ed678b88 100644 --- a/bench_util/benches/op_baseline.rs +++ b/bench_util/benches/op_baseline.rs @@ -1,8 +1,10 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. +use deno_bench_util::bench_js_async; +use deno_bench_util::bench_js_sync; use deno_bench_util::bench_or_profile; -use deno_bench_util::bencher::{benchmark_group, Bencher}; -use deno_bench_util::{bench_js_async, bench_js_sync}; +use deno_bench_util::bencher::benchmark_group; +use deno_bench_util::bencher::Bencher; use deno_core::op; use deno_core::Extension; diff --git a/bench_util/profiling.rs b/bench_util/profiling.rs index bd65e3274..3bdda072b 100644 --- a/bench_util/profiling.rs +++ b/bench_util/profiling.rs @@ -1,5 +1,8 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use bencher::{DynBenchFn, StaticBenchFn, TestDescAndFn, TestOpts}; +use bencher::DynBenchFn; +use bencher::StaticBenchFn; +use bencher::TestDescAndFn; +use bencher::TestOpts; pub fn is_profiling() -> bool { std::env::var("PROFILING").is_ok() diff --git a/cli/args/flags.rs b/cli/args/flags.rs index ef1aedce4..903f93639 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -2401,7 +2401,10 @@ fn completions_parse( mut app: clap::Command, ) { use clap_complete::generate; - use clap_complete::shells::{Bash, Fish, PowerShell, Zsh}; + use clap_complete::shells::Bash; + use clap_complete::shells::Fish; + use clap_complete::shells::PowerShell; + use clap_complete::shells::Zsh; use clap_complete_fig::Fig; let mut buf: Vec<u8> = vec![]; diff --git a/cli/args/flags_allow_net.rs b/cli/args/flags_allow_net.rs index 38a4ac83a..bf189132a 100644 --- a/cli/args/flags_allow_net.rs +++ b/cli/args/flags_allow_net.rs @@ -64,7 +64,8 @@ pub fn parse(paths: Vec<String>) -> clap::Result<Vec<String>> { #[cfg(test)] mod bare_port_tests { - use super::{BarePort, ParsePortError}; + use super::BarePort; + use super::ParsePortError; #[test] fn bare_port_parsed() { diff --git a/cli/bench/http.rs b/cli/bench/http.rs index 7c416f93c..585574e2d 100644 --- a/cli/bench/http.rs +++ b/cli/bench/http.rs @@ -1,11 +1,16 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use std::sync::atomic::{AtomicU16, Ordering}; -use std::{collections::HashMap, path::Path, process::Command, time::Duration}; +use std::collections::HashMap; +use std::path::Path; +use std::process::Command; +use std::sync::atomic::AtomicU16; +use std::sync::atomic::Ordering; +use std::time::Duration; use super::Result; -pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult}; +pub use test_util::parse_wrk_output; +pub use test_util::WrkOutput as HttpBenchmarkResult; // Some of the benchmarks in this file have been renamed. In case the history // somehow gets messed up: // "node_http" was once called "node" diff --git a/cli/cache/deno_dir.rs b/cli/cache/deno_dir.rs index e802aaacb..86f3e00b5 100644 --- a/cli/cache/deno_dir.rs +++ b/cli/cache/deno_dir.rs @@ -184,7 +184,12 @@ mod dirs { use std::os::windows::ffi::OsStringExt; use std::path::PathBuf; use winapi::shared::winerror; - use winapi::um::{combaseapi, knownfolders, shlobj, shtypes, winbase, winnt}; + use winapi::um::combaseapi; + use winapi::um::knownfolders; + use winapi::um::shlobj; + use winapi::um::shtypes; + use winapi::um::winbase; + use winapi::um::winnt; fn known_folder(folder_id: shtypes::REFKNOWNFOLDERID) -> Option<PathBuf> { // SAFETY: winapi calls diff --git a/cli/lsp/semantic_tokens.rs b/cli/lsp/semantic_tokens.rs index 8ed0ab201..772327a66 100644 --- a/cli/lsp/semantic_tokens.rs +++ b/cli/lsp/semantic_tokens.rs @@ -5,7 +5,8 @@ // and https://github.com/microsoft/vscode/blob/main/src/vs/workbench/api/common/extHostTypes.ts // for the SemanticTokensBuilder implementation. -use std::ops::{Index, IndexMut}; +use std::ops::Index; +use std::ops::IndexMut; use tower_lsp::lsp_types::SemanticToken; use tower_lsp::lsp_types::SemanticTokenModifier; use tower_lsp::lsp_types::SemanticTokenType; diff --git a/cli/napi/sym/README.md b/cli/napi/sym/README.md index b3e2ab43b..de08a8e17 100644 --- a/cli/napi/sym/README.md +++ b/cli/napi/sym/README.md @@ -8,7 +8,10 @@ A proc_macro for Deno's Node-API implementation. It does the following things: - Maps `deno_napi::Result` to raw `napi_result`. ```rust -use deno_napi::{napi_value, Env, Error, Result}; +use deno_napi::napi_value; +use deno_napi::Env; +use deno_napi::Error; +use deno_napi::Result; #[napi_sym::napi_sym] fn napi_get_boolean( diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs index 5c21b2b7d..144c2b56c 100644 --- a/cli/tests/integration/fmt_tests.rs +++ b/cli/tests/integration/fmt_tests.rs @@ -126,7 +126,8 @@ fn fmt_ignore_unexplicit_files() { #[test] fn fmt_auto_ignore_git_and_node_modules() { - use std::fs::{create_dir_all, File}; + use std::fs::create_dir_all; + use std::fs::File; use std::io::Write; use std::path::PathBuf; fn create_bad_json(t: PathBuf) { diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs index af1325d64..e291c17bb 100644 --- a/cli/tests/integration/inspector_tests.rs +++ b/cli/tests/integration/inspector_tests.rs @@ -211,7 +211,8 @@ fn assert_stderr( } fn inspect_flag_with_unique_port(flag_prefix: &str) -> String { - use std::sync::atomic::{AtomicU16, Ordering}; + use std::sync::atomic::AtomicU16; + use std::sync::atomic::Ordering; static PORT: AtomicU16 = AtomicU16::new(9229); let port = PORT.fetch_add(1, Ordering::Relaxed); format!("{}=127.0.0.1:{}", flag_prefix, port) diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index df31ee98b..af9fce187 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -602,7 +602,8 @@ fn lexical_scoped_variable() { #[test] fn missing_deno_dir() { - use std::fs::{read_dir, remove_dir_all}; + use std::fs::read_dir; + use std::fs::remove_dir_all; const DENO_DIR: &str = "nonexistent"; let test_deno_dir = test_util::testdata_path().join(DENO_DIR); let (out, err) = util::run_and_collect_output( diff --git a/cli/tests/integration/upgrade_tests.rs b/cli/tests/integration/upgrade_tests.rs index 2822bc8de..f4eaa03c9 100644 --- a/cli/tests/integration/upgrade_tests.rs +++ b/cli/tests/integration/upgrade_tests.rs @@ -1,6 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use std::process::{Command, Stdio}; +use std::process::Command; +use std::process::Stdio; use test_util as util; use test_util::TempDir; diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index cbb2bd9cc..056ed4ab4 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -24,7 +24,9 @@ use regex::Regex; use std::fs; use std::fs::File; use std::io::BufWriter; -use std::io::{self, Error, Write}; +use std::io::Error; +use std::io::Write; +use std::io::{self}; use std::path::PathBuf; use text_lines::TextLines; use uuid::Uuid; diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs index a40b6fcd1..9957d1eaf 100644 --- a/cli/tools/repl/editor.rs +++ b/cli/tools/repl/editor.rs @@ -18,15 +18,19 @@ use rustyline::validate::ValidationResult; use rustyline::validate::Validator; use rustyline::Cmd; use rustyline::CompletionType; +use rustyline::ConditionalEventHandler; use rustyline::Config; use rustyline::Context; use rustyline::Editor; +use rustyline::Event; +use rustyline::EventContext; use rustyline::EventHandler; use rustyline::KeyCode; use rustyline::KeyEvent; use rustyline::Modifiers; -use rustyline::{ConditionalEventHandler, Event, EventContext, RepeatCount}; -use rustyline_derive::{Helper, Hinter}; +use rustyline::RepeatCount; +use rustyline_derive::Helper; +use rustyline_derive::Hinter; use std::borrow::Cow; use std::path::PathBuf; use std::sync::atomic::AtomicBool; diff --git a/cli/util/diff.rs b/cli/util/diff.rs index 3dbe8a6ff..817ddfd89 100644 --- a/cli/util/diff.rs +++ b/cli/util/diff.rs @@ -1,7 +1,8 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use crate::colors; -use dissimilar::{diff as difference, Chunk}; +use dissimilar::diff as difference; +use dissimilar::Chunk; use std::fmt::Write as _; /// Print diff of the same file_path, before and after formatting. diff --git a/cli/worker.rs b/cli/worker.rs index e34c65d66..b6ebd7930 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -729,7 +729,8 @@ fn create_web_worker_callback( #[cfg(test)] mod tests { use super::*; - use deno_core::{resolve_url_or_path, FsModuleLoader}; + use deno_core::resolve_url_or_path; + use deno_core::FsModuleLoader; use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel; use deno_runtime::deno_web::BlobStore; use deno_runtime::permissions::Permissions; diff --git a/core/extensions.rs b/core/extensions.rs index 437621c0e..2cb16b125 100644 --- a/core/extensions.rs +++ b/core/extensions.rs @@ -1,7 +1,9 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use crate::OpState; use anyhow::Error; -use std::{cell::RefCell, rc::Rc, task::Context}; +use std::cell::RefCell; +use std::rc::Rc; +use std::task::Context; use v8::fast_api::FastFunction; pub type SourcePair = (&'static str, &'static str); diff --git a/core/modules.rs b/core/modules.rs index 917649c85..8a79143f0 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -1190,7 +1190,8 @@ mod tests { use std::future::Future; use std::io; use std::path::PathBuf; - use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::atomic::AtomicUsize; + use std::sync::atomic::Ordering; use std::sync::Arc; // deno_ops macros generate code assuming deno_core in scope. mod deno_core { diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index 905496025..184e942b7 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -13,7 +13,9 @@ use crate::ZeroCopyBuf; use anyhow::Error; use deno_ops::op; use std::cell::RefCell; -use std::io::{stderr, stdout, Write}; +use std::io::stderr; +use std::io::stdout; +use std::io::Write; use std::rc::Rc; pub(crate) fn init_builtins() -> Extension { diff --git a/core/ops_metrics.rs b/core/ops_metrics.rs index 7daeaab19..c0b8abb51 100644 --- a/core/ops_metrics.rs +++ b/core/ops_metrics.rs @@ -2,7 +2,8 @@ use crate::serde::Serialize; use crate::OpId; -use std::cell::{RefCell, RefMut}; +use std::cell::RefCell; +use std::cell::RefMut; // TODO(@AaronO): split into AggregateMetrics & PerOpMetrics #[derive(Clone, Default, Debug, Serialize)] diff --git a/core/runtime.rs b/core/runtime.rs index 0a5404fa1..2f818c7f8 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -2593,7 +2593,8 @@ pub mod tests { use std::ops::FnOnce; use std::pin::Pin; use std::rc::Rc; - use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::atomic::AtomicUsize; + use std::sync::atomic::Ordering; use std::sync::Arc; // deno_ops macros generate code assuming deno_core in scope. mod deno_core { diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index b4c12fcbc..4a19650cb 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -31,7 +31,8 @@ use deno_core::ResourceId; use deno_core::ZeroCopyBuf; use deno_tls::rustls::RootCertStore; use deno_tls::Proxy; -use http::{header::CONTENT_LENGTH, Uri}; +use http::header::CONTENT_LENGTH; +use http::Uri; use reqwest::header::HeaderMap; use reqwest::header::HeaderName; use reqwest::header::HeaderValue; diff --git a/ext/ffi/turbocall.rs b/ext/ffi/turbocall.rs index 079743c16..1eb1655e1 100644 --- a/ext/ffi/turbocall.rs +++ b/ext/ffi/turbocall.rs @@ -1917,7 +1917,8 @@ mod tests { mod x64_windows { use std::ops::Deref; - use dynasmrt::{dynasm, DynasmApi}; + use dynasmrt::dynasm; + use dynasmrt::DynasmApi; use super::super::Win64; use super::symbol; diff --git a/ext/flash/sendfile.rs b/ext/flash/sendfile.rs index 92e8f2bb7..18dc3a39d 100644 --- a/ext/flash/sendfile.rs +++ b/ext/flash/sendfile.rs @@ -5,7 +5,8 @@ use std::future::Future; use std::io; use std::os::unix::io::RawFd; use std::pin::Pin; -use std::task::{self, Poll}; +use std::task::Poll; +use std::task::{self}; pub struct SendFile { pub io: (RawFd, RawFd), diff --git a/ext/flash/socket.rs b/ext/flash/socket.rs index 77881d536..27906e74e 100644 --- a/ext/flash/socket.rs +++ b/ext/flash/socket.rs @@ -2,9 +2,11 @@ use std::cell::UnsafeCell; use std::future::Future; -use std::io::{Read, Write}; +use std::io::Read; +use std::io::Write; use std::pin::Pin; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; +use std::sync::Mutex; use deno_core::error::AnyError; use mio::net::TcpStream; diff --git a/ext/http/benches/compressible.rs b/ext/http/benches/compressible.rs index 634b1dae6..85c131ea9 100644 --- a/ext/http/benches/compressible.rs +++ b/ext/http/benches/compressible.rs @@ -1,5 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use bencher::{benchmark_group, benchmark_main, Bencher}; +use bencher::benchmark_group; +use bencher::benchmark_main; +use bencher::Bencher; use deno_http::compressible::is_content_compressible; fn compressible_simple_hit(b: &mut Bencher) { diff --git a/ext/url/benches/url_ops.rs b/ext/url/benches/url_ops.rs index 2bf113f54..5a5997fc8 100644 --- a/ext/url/benches/url_ops.rs +++ b/ext/url/benches/url_ops.rs @@ -2,7 +2,8 @@ use deno_bench_util::bench_js_sync; use deno_bench_util::bench_or_profile; -use deno_bench_util::bencher::{benchmark_group, Bencher}; +use deno_bench_util::bencher::benchmark_group; +use deno_bench_util::bencher::Bencher; use deno_core::Extension; diff --git a/ext/web/benches/encoding.rs b/ext/web/benches/encoding.rs index 01fba9e66..254ea4455 100644 --- a/ext/web/benches/encoding.rs +++ b/ext/web/benches/encoding.rs @@ -2,7 +2,8 @@ use deno_bench_util::bench_js_sync; use deno_bench_util::bench_or_profile; -use deno_bench_util::bencher::{benchmark_group, Bencher}; +use deno_bench_util::bencher::benchmark_group; +use deno_bench_util::bencher::Bencher; use deno_core::Extension; use deno_web::BlobStore; diff --git a/ext/web/benches/timers_ops.rs b/ext/web/benches/timers_ops.rs index 024d52360..b28b1ae1d 100644 --- a/ext/web/benches/timers_ops.rs +++ b/ext/web/benches/timers_ops.rs @@ -2,7 +2,8 @@ use deno_bench_util::bench_js_async; use deno_bench_util::bench_or_profile; -use deno_bench_util::bencher::{benchmark_group, Bencher}; +use deno_bench_util::bencher::benchmark_group; +use deno_bench_util::bencher::Bencher; use deno_core::Extension; use deno_web::BlobStore; diff --git a/ext/web/blob.rs b/ext/web/blob.rs index e4ba93a2f..b43b3d17b 100644 --- a/ext/web/blob.rs +++ b/ext/web/blob.rs @@ -13,7 +13,8 @@ use deno_core::op; use deno_core::parking_lot::Mutex; use deno_core::url::Url; use deno_core::ZeroCopyBuf; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; +use serde::Serialize; use uuid::Uuid; use crate::Location; diff --git a/ext/web/message_port.rs b/ext/web/message_port.rs index f287fc82d..47ebdabf7 100644 --- a/ext/web/message_port.rs +++ b/ext/web/message_port.rs @@ -8,10 +8,13 @@ use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::op; +use deno_core::CancelFuture; +use deno_core::CancelHandle; use deno_core::DetachedBuffer; -use deno_core::{CancelFuture, Resource}; -use deno_core::{CancelHandle, OpState}; -use deno_core::{RcRef, ResourceId}; +use deno_core::OpState; +use deno_core::RcRef; +use deno_core::Resource; +use deno_core::ResourceId; use serde::Deserialize; use serde::Serialize; use tokio::sync::mpsc::unbounded_channel; diff --git a/ops/attrs.rs b/ops/attrs.rs index 93fbb05ff..a76cfddf6 100644 --- a/ops/attrs.rs +++ b/ops/attrs.rs @@ -1,9 +1,11 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use syn::{ - parse::{Parse, ParseStream}, - punctuated::Punctuated, - Error, Ident, Result, Token, -}; +use syn::parse::Parse; +use syn::parse::ParseStream; +use syn::punctuated::Punctuated; +use syn::Error; +use syn::Ident; +use syn::Result; +use syn::Token; #[derive(Copy, Clone, Debug, Default)] pub struct Attributes { diff --git a/ops/deno.rs b/ops/deno.rs index 710fd430f..73f4c0611 100644 --- a/ops/deno.rs +++ b/ops/deno.rs @@ -1,8 +1,10 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. #![cfg(not(test))] -use proc_macro2::{Span, TokenStream}; -use proc_macro_crate::{crate_name, FoundCrate}; +use proc_macro2::Span; +use proc_macro2::TokenStream; +use proc_macro_crate::crate_name; +use proc_macro_crate::FoundCrate; use quote::quote; use syn::Ident; diff --git a/ops/fast_call.rs b/ops/fast_call.rs index ce7a28210..9384761a1 100644 --- a/ops/fast_call.rs +++ b/ops/fast_call.rs @@ -1,13 +1,25 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. //! Code generation for V8 fast calls. -use pmutil::{q, Quote, ToTokensExt}; -use proc_macro2::{Span, TokenStream}; +use pmutil::q; +use pmutil::Quote; +use pmutil::ToTokensExt; +use proc_macro2::Span; +use proc_macro2::TokenStream; use quote::quote; -use syn::{ - parse_quote, punctuated::Punctuated, token::Comma, GenericParam, Generics, - Ident, ItemFn, ItemImpl, Path, PathArguments, PathSegment, Type, TypePath, -}; +use syn::parse_quote; +use syn::punctuated::Punctuated; +use syn::token::Comma; +use syn::GenericParam; +use syn::Generics; +use syn::Ident; +use syn::ItemFn; +use syn::ItemImpl; +use syn::Path; +use syn::PathArguments; +use syn::PathSegment; +use syn::Type; +use syn::TypePath; use crate::optimizer::FastValue; use crate::optimizer::Optimizer; diff --git a/ops/lib.rs b/ops/lib.rs index c16893366..5b215ed70 100644 --- a/ops/lib.rs +++ b/ops/lib.rs @@ -2,15 +2,24 @@ use attrs::Attributes; use once_cell::sync::Lazy; -use optimizer::{BailoutReason, Optimizer}; +use optimizer::BailoutReason; +use optimizer::Optimizer; use proc_macro::TokenStream; -use proc_macro2::{Span, TokenStream as TokenStream2}; -use quote::{quote, ToTokens}; +use proc_macro2::Span; +use proc_macro2::TokenStream as TokenStream2; +use quote::quote; +use quote::ToTokens; use regex::Regex; -use syn::{ - parse, parse_macro_input, punctuated::Punctuated, token::Comma, FnArg, - GenericParam, Ident, ItemFn, Lifetime, LifetimeDef, -}; +use syn::parse; +use syn::parse_macro_input; +use syn::punctuated::Punctuated; +use syn::token::Comma; +use syn::FnArg; +use syn::GenericParam; +use syn::Ident; +use syn::ItemFn; +use syn::Lifetime; +use syn::LifetimeDef; mod attrs; mod deno; @@ -747,7 +756,8 @@ fn exclude_lifetime_params( #[cfg(test)] mod tests { - use crate::{Attributes, Op}; + use crate::Attributes; + use crate::Op; use std::path::PathBuf; #[testing_macros::fixture("optimizer_tests/**/*.rs")] diff --git a/ops/optimizer.rs b/ops/optimizer.rs index 3f22a867b..1a6172b67 100644 --- a/ops/optimizer.rs +++ b/ops/optimizer.rs @@ -5,15 +5,28 @@ use std::collections::BTreeMap; use std::fmt::Debug; use std::fmt::Formatter; -use pmutil::{q, Quote}; +use pmutil::q; +use pmutil::Quote; use proc_macro2::TokenStream; -use syn::{ - parse_quote, punctuated::Punctuated, token::Colon2, - AngleBracketedGenericArguments, FnArg, GenericArgument, PatType, Path, - PathArguments, PathSegment, ReturnType, Signature, Type, TypePath, TypePtr, - TypeReference, TypeSlice, TypeTuple, -}; +use syn::parse_quote; +use syn::punctuated::Punctuated; +use syn::token::Colon2; +use syn::AngleBracketedGenericArguments; +use syn::FnArg; +use syn::GenericArgument; +use syn::PatType; +use syn::Path; +use syn::PathArguments; +use syn::PathSegment; +use syn::ReturnType; +use syn::Signature; +use syn::Type; +use syn::TypePath; +use syn::TypePtr; +use syn::TypeReference; +use syn::TypeSlice; +use syn::TypeTuple; use crate::Op; @@ -678,7 +691,8 @@ fn double_segment( #[cfg(test)] mod tests { use super::*; - use crate::{Attributes, Op}; + use crate::Attributes; + use crate::Op; use std::path::PathBuf; use syn::parse_quote; 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 = diff --git a/serde_v8/benches/de.rs b/serde_v8/benches/de.rs index 306374043..9cd2da689 100644 --- a/serde_v8/benches/de.rs +++ b/serde_v8/benches/de.rs @@ -1,9 +1,12 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use bencher::{benchmark_group, benchmark_main, Bencher}; +use bencher::benchmark_group; +use bencher::benchmark_main; +use bencher::Bencher; use serde::Deserialize; -use serde_v8::utils::{js_exec, v8_do}; +use serde_v8::utils::js_exec; +use serde_v8::utils::v8_do; use serde_v8::ByteString; #[derive(Debug, Deserialize, PartialEq)] diff --git a/serde_v8/benches/ser.rs b/serde_v8/benches/ser.rs index 37951c7f0..83274fae3 100644 --- a/serde_v8/benches/ser.rs +++ b/serde_v8/benches/ser.rs @@ -1,5 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use bencher::{benchmark_group, benchmark_main, Bencher}; +use bencher::benchmark_group; +use bencher::benchmark_main; +use bencher::Bencher; use serde::Serialize; diff --git a/serde_v8/de.rs b/serde_v8/de.rs index c3bea36a4..15a90a13d 100644 --- a/serde_v8/de.rs +++ b/serde_v8/de.rs @@ -1,15 +1,23 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use serde::de::{self, SeqAccess as _, Visitor}; +use serde::de::SeqAccess as _; +use serde::de::Visitor; +use serde::de::{self}; use serde::Deserialize; -use crate::error::{Error, Result}; -use crate::keys::{v8_struct_key, KeyCache}; +use crate::error::Error; +use crate::error::Result; +use crate::keys::v8_struct_key; +use crate::keys::KeyCache; +use crate::magic; +use crate::magic::transl8::visit_magic; use crate::magic::transl8::FromV8; -use crate::magic::transl8::{visit_magic, MagicType}; +use crate::magic::transl8::MagicType; use crate::payload::ValueType; -use crate::{ - magic, ByteString, DetachedBuffer, StringOrBuffer, U16String, ZeroCopyBuf, -}; +use crate::ByteString; +use crate::DetachedBuffer; +use crate::StringOrBuffer; +use crate::U16String; +use crate::ZeroCopyBuf; pub struct Deserializer<'a, 'b, 's> { input: v8::Local<'a, v8::Value>, diff --git a/serde_v8/error.rs b/serde_v8/error.rs index 38a67489f..fd763bb1e 100644 --- a/serde_v8/error.rs +++ b/serde_v8/error.rs @@ -1,7 +1,9 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use std::fmt::{self, Display}; +use std::fmt::Display; +use std::fmt::{self}; -use serde::{de, ser}; +use serde::de; +use serde::ser; pub type Result<T> = std::result::Result<T, Error>; diff --git a/serde_v8/lib.rs b/serde_v8/lib.rs index e2ec1015d..c15ca715a 100644 --- a/serde_v8/lib.rs +++ b/serde_v8/lib.rs @@ -8,8 +8,12 @@ mod ser; mod serializable; pub mod utils; -pub use de::{from_v8, from_v8_cached, to_utf8, Deserializer}; -pub use error::{Error, Result}; +pub use de::from_v8; +pub use de::from_v8_cached; +pub use de::to_utf8; +pub use de::Deserializer; +pub use error::Error; +pub use error::Result; pub use keys::KeyCache; pub use magic::buffer::ZeroCopyBuf; pub use magic::bytestring::ByteString; @@ -18,5 +22,7 @@ pub use magic::string_or_buffer::StringOrBuffer; pub use magic::u16string::U16String; pub use magic::Global; pub use magic::Value; -pub use ser::{to_v8, Serializer}; -pub use serializable::{Serializable, SerializablePkg}; +pub use ser::to_v8; +pub use ser::Serializer; +pub use serializable::Serializable; +pub use serializable::SerializablePkg; diff --git a/serde_v8/magic/bytestring.rs b/serde_v8/magic/bytestring.rs index 92a0dba40..77771698f 100644 --- a/serde_v8/magic/bytestring.rs +++ b/serde_v8/magic/bytestring.rs @@ -1,5 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use super::transl8::{FromV8, ToV8}; +use super::transl8::FromV8; +use super::transl8::ToV8; use crate::magic::transl8::impl_magic; use crate::Error; use smallvec::SmallVec; diff --git a/serde_v8/magic/string_or_buffer.rs b/serde_v8/magic/string_or_buffer.rs index e3347255e..b7f6724b8 100644 --- a/serde_v8/magic/string_or_buffer.rs +++ b/serde_v8/magic/string_or_buffer.rs @@ -1,6 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use super::buffer::ZeroCopyBuf; -use super::transl8::{FromV8, ToV8}; +use super::transl8::FromV8; +use super::transl8::ToV8; use crate::magic::transl8::impl_magic; use crate::Error; use std::ops::Deref; diff --git a/serde_v8/magic/u16string.rs b/serde_v8/magic/u16string.rs index 11554738a..57e3fd0f6 100644 --- a/serde_v8/magic/u16string.rs +++ b/serde_v8/magic/u16string.rs @@ -2,7 +2,10 @@ use crate::Error; -use super::transl8::{impl_magic, impl_wrapper, FromV8, ToV8}; +use super::transl8::impl_magic; +use super::transl8::impl_wrapper; +use super::transl8::FromV8; +use super::transl8::ToV8; impl_wrapper!( pub struct U16String(Vec<u16>); diff --git a/serde_v8/ser.rs b/serde_v8/ser.rs index 67b0d6f68..834efa78a 100644 --- a/serde_v8/ser.rs +++ b/serde_v8/ser.rs @@ -5,13 +5,20 @@ use serde::ser::Serialize; use std::cell::RefCell; use std::ops::DerefMut; -use crate::error::{Error, Result}; +use crate::error::Error; +use crate::error::Result; use crate::keys::v8_struct_key; +use crate::magic; +use crate::magic::transl8::opaque_deref_mut; +use crate::magic::transl8::opaque_recv; +use crate::magic::transl8::MagicType; +use crate::magic::transl8::ToV8; use crate::magic::transl8::MAGIC_FIELD; -use crate::magic::transl8::{opaque_deref_mut, opaque_recv, MagicType, ToV8}; -use crate::{ - magic, ByteString, DetachedBuffer, StringOrBuffer, U16String, ZeroCopyBuf, -}; +use crate::ByteString; +use crate::DetachedBuffer; +use crate::StringOrBuffer; +use crate::U16String; +use crate::ZeroCopyBuf; type JsValue<'s> = v8::Local<'s, v8::Value>; type JsResult<'s> = Result<JsValue<'s>>; diff --git a/serde_v8/tests/de.rs b/serde_v8/tests/de.rs index c492a6018..b487b394e 100644 --- a/serde_v8/tests/de.rs +++ b/serde_v8/tests/de.rs @@ -1,10 +1,13 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use serde::{Deserialize, Deserializer}; +use serde::Deserialize; +use serde::Deserializer; -use serde_v8::utils::{js_exec, v8_do}; +use serde_v8::utils::js_exec; +use serde_v8::utils::v8_do; use serde_v8::ByteString; use serde_v8::Error; -use serde_v8::{U16String, ZeroCopyBuf}; +use serde_v8::U16String; +use serde_v8::ZeroCopyBuf; #[derive(Debug, Deserialize, PartialEq)] struct MathOp { diff --git a/serde_v8/tests/magic.rs b/serde_v8/tests/magic.rs index 54adc6c83..8ae163784 100644 --- a/serde_v8/tests/magic.rs +++ b/serde_v8/tests/magic.rs @@ -1,7 +1,9 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -use serde::{Deserialize, Serialize}; +use serde::Deserialize; +use serde::Serialize; -use serde_v8::utils::{js_exec, v8_do}; +use serde_v8::utils::js_exec; +use serde_v8::utils::v8_do; use serde_v8::Result; #[derive(Deserialize)] diff --git a/serde_v8/tests/ser.rs b/serde_v8/tests/ser.rs index 9e6c7c2e7..485a3ad6f 100644 --- a/serde_v8/tests/ser.rs +++ b/serde_v8/tests/ser.rs @@ -1,7 +1,8 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use serde::Serialize; use serde_json::json; -use serde_v8::utils::{js_exec, v8_do}; +use serde_v8::utils::js_exec; +use serde_v8::utils::v8_do; #[derive(Debug, Serialize, PartialEq)] struct MathOp { diff --git a/test_napi/src/async.rs b/test_napi/src/async.rs index 0df4990ab..51e6edac9 100644 --- a/test_napi/src/async.rs +++ b/test_napi/src/async.rs @@ -6,7 +6,8 @@ use crate::napi_new_property; use napi_sys::Status::napi_ok; use napi_sys::ValueType::napi_function; use napi_sys::*; -use std::os::raw::{c_char, c_void}; +use std::os::raw::c_char; +use std::os::raw::c_void; use std::ptr; pub struct Baton { diff --git a/test_napi/src/object_wrap.rs b/test_napi/src/object_wrap.rs index 493cb05b3..5a6e36589 100644 --- a/test_napi/src/object_wrap.rs +++ b/test_napi/src/object_wrap.rs @@ -5,7 +5,8 @@ use crate::napi_get_callback_info; use crate::napi_new_property; use napi_sys::ValueType::napi_number; use napi_sys::*; -use std::os::raw::{c_char, c_void}; +use std::os::raw::c_char; +use std::os::raw::c_void; use std::ptr; pub struct NapiObject { diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index ce1d15d4b..5781f434b 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -1610,7 +1610,8 @@ impl HttpServerCount { .spawn() .expect("failed to execute test_server"); let stdout = test_server.stdout.as_mut().unwrap(); - use std::io::{BufRead, BufReader}; + use std::io::BufRead; + use std::io::BufReader; let lines = BufReader::new(stdout).lines(); // Wait for all the servers to report being ready. diff --git a/test_util/src/lsp.rs b/test_util/src/lsp.rs index 46bda4bb7..465e2a9ba 100644 --- a/test_util/src/lsp.rs +++ b/test_util/src/lsp.rs @@ -14,8 +14,9 @@ use regex::Regex; use serde::de; use serde::Deserialize; use serde::Serialize; +use serde_json::json; +use serde_json::to_value; use serde_json::Value; -use serde_json::{json, to_value}; use std::io; use std::io::Write; use std::path::Path; |