mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
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)
This commit is contained in:
parent
efcbfd5206
commit
d5634164cb
65 changed files with 301 additions and 126 deletions
|
@ -11,7 +11,7 @@
|
|||
},
|
||||
"exec": {
|
||||
"associations": "**/*.rs",
|
||||
"rustfmt": "rustfmt"
|
||||
"rustfmt": "rustfmt --config imports_granularity=item"
|
||||
},
|
||||
"includes": [
|
||||
"**/*.{ts,tsx,js,jsx,json,md,toml,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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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![];
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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"
|
||||
|
|
7
cli/cache/deno_dir.rs
vendored
7
cli/cache/deno_dir.rs
vendored
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
12
ops/attrs.rs
12
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 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
26
ops/lib.rs
26
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")]
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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, ctrl_c, CtrlBreak, CtrlC};
|
||||
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::CtrlC;
|
||||
|
||||
pub fn init() -> Extension {
|
||||
Extension::builder("deno_signal")
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -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>;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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>);
|
||||
|
|
|
@ -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>>;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue