Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"exec": {
"associations": "**/*.rs",
"rustfmt": "rustfmt"
"rustfmt": "rustfmt --config imports_granularity=item"
},
"includes": [
"**/*.{ts,tsx,js,jsx,json,md,toml,rs}"
Expand Down
6 changes: 4 additions & 2 deletions bench_util/benches/op_baseline.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 4 additions & 1 deletion bench_util/profiling.rs
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
5 changes: 4 additions & 1 deletion cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![];
Expand Down
3 changes: 2 additions & 1 deletion cli/args/flags_allow_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 8 additions & 3 deletions cli/bench/http.rs
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 6 additions & 1 deletion cli/cache/deno_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cli/lsp/semantic_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion cli/napi/sym/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion cli/tests/integration/fmt_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion cli/tests/integration/inspector_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cli/tests/integration/repl_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion cli/tests/integration/upgrade_tests.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 3 additions & 1 deletion cli/tools/coverage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use std::io::{self};
use std::io;

Maybe this should be reported to rustfmt 👀

Copy link
Member Author

@littledivy littledivy Jan 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From rust-lang/rustfmt#4681

Note that use crate::lexer; and use crate::lexer::{self}; are not actually equivalent: The latter only imports the lexer module, while the former looks in all namespaces, so it can import up to 3 items at once, e.g. a function, a module and a macro of the same name.


Also rust-lang/rustfmt#5398

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just use std::io; works in this case though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that this was auto merging, but we can “fix” these as we see them in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

use std::path::PathBuf;
use text_lines::TextLines;
use uuid::Uuid;
Expand Down
8 changes: 6 additions & 2 deletions cli/tools/repl/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion cli/util/diff.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 2 additions & 1 deletion cli/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,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;
Expand Down
4 changes: 3 additions & 1 deletion core/extensions.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
3 changes: 2 additions & 1 deletion core/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion core/ops_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion core/ops_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 2 additions & 1 deletion core/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,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 {
Expand Down
3 changes: 2 additions & 1 deletion ext/fetch/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ext/ffi/turbocall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ext/flash/sendfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


pub struct SendFile {
pub io: (RawFd, RawFd),
Expand Down
6 changes: 4 additions & 2 deletions ext/flash/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion ext/http/benches/compressible.rs
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion ext/url/benches/url_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion ext/web/benches/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion ext/web/benches/timers_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion ext/web/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions ext/web/message_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions ops/attrs.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions ops/deno.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Loading