Skip to content

Commit

Permalink
refactor: remove redundant qualification of symbols in Rust (#15201)
Browse files Browse the repository at this point in the history
  • Loading branch information
orvitpng authored Jul 14, 2022
1 parent 1a7259b commit dbf5e95
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 33 deletions.
3 changes: 1 addition & 2 deletions cli/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use deno_graph::ModuleKind;
use deno_graph::ResolutionError;
use std::collections::HashSet;
use std::fmt;
use std::result;
use std::sync::Arc;
use std::time::Instant;

Expand All @@ -47,7 +46,7 @@ use std::time::Instant;
pub struct Stats(pub Vec<(String, u32)>);

impl<'de> Deserialize<'de> for Stats {
fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
Expand Down
6 changes: 3 additions & 3 deletions cli/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct DebouncedReceiver {
// and so we store this state on the struct to ensure we don't
// lose items if a `recv()` never completes
received_items: HashSet<PathBuf>,
receiver: mpsc::UnboundedReceiver<Vec<PathBuf>>,
receiver: UnboundedReceiver<Vec<PathBuf>>,
}

impl DebouncedReceiver {
Expand All @@ -55,7 +55,7 @@ impl DebouncedReceiver {
}

loop {
tokio::select! {
select! {
items = self.receiver.recv() => {
self.received_items.extend(items?);
}
Expand Down Expand Up @@ -255,7 +255,7 @@ where
/// changes. For example, in the case where we would like to bundle, then `operation` would
/// have the logic for it like bundling the code.
pub async fn watch_func2<T: Clone, O, F>(
mut paths_to_watch_receiver: mpsc::UnboundedReceiver<Vec<PathBuf>>,
mut paths_to_watch_receiver: UnboundedReceiver<Vec<PathBuf>>,
mut operation: O,
operation_args: T,
print_config: PrintConfig,
Expand Down
2 changes: 1 addition & 1 deletion cli/fmt_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn format_maybe_source_line(
if column_number as usize > source_line.len() {
return format!(
"\n{} Couldn't format source line: Column {} is out of bounds (source may have changed at runtime)",
crate::colors::yellow("Warning"), column_number,
yellow("Warning"), column_number,
);
}

Expand Down
2 changes: 1 addition & 1 deletion cli/fs_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ where
{
let mut prepared = vec![];

let root_path = std::env::current_dir()?;
let root_path = current_dir()?;
for path in include {
let lowercase_path = path.to_lowercase();
if lowercase_path.starts_with("http://")
Expand Down
40 changes: 18 additions & 22 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn create_web_worker_callback(
source_map_getter: Some(Box::new(ps.clone())),
worker_type: args.worker_type,
maybe_inspector_server,
get_error_class_fn: Some(&crate::errors::get_error_class_name),
get_error_class_fn: Some(&errors::get_error_class_name),
blob_store: ps.blob_store.clone(),
broadcast_channel: ps.broadcast_channel.clone(),
shared_array_buffer_store: Some(ps.shared_array_buffer_store.clone()),
Expand Down Expand Up @@ -255,7 +255,7 @@ pub fn create_main_worker(
maybe_inspector_server,
should_break_on_first_statement,
module_loader,
get_error_class_fn: Some(&crate::errors::get_error_class_name),
get_error_class_fn: Some(&errors::get_error_class_name),
origin_storage_dir,
blob_store: ps.blob_store.clone(),
broadcast_channel: ps.broadcast_channel.clone(),
Expand Down Expand Up @@ -363,23 +363,23 @@ fn print_cache_info(

pub fn get_types(unstable: bool) -> String {
let mut types = vec![
crate::tsc::DENO_NS_LIB,
crate::tsc::DENO_CONSOLE_LIB,
crate::tsc::DENO_URL_LIB,
crate::tsc::DENO_WEB_LIB,
crate::tsc::DENO_FETCH_LIB,
crate::tsc::DENO_WEBGPU_LIB,
crate::tsc::DENO_WEBSOCKET_LIB,
crate::tsc::DENO_WEBSTORAGE_LIB,
crate::tsc::DENO_CRYPTO_LIB,
crate::tsc::DENO_BROADCAST_CHANNEL_LIB,
crate::tsc::DENO_NET_LIB,
crate::tsc::SHARED_GLOBALS_LIB,
crate::tsc::WINDOW_LIB,
tsc::DENO_NS_LIB,
tsc::DENO_CONSOLE_LIB,
tsc::DENO_URL_LIB,
tsc::DENO_WEB_LIB,
tsc::DENO_FETCH_LIB,
tsc::DENO_WEBGPU_LIB,
tsc::DENO_WEBSOCKET_LIB,
tsc::DENO_WEBSTORAGE_LIB,
tsc::DENO_CRYPTO_LIB,
tsc::DENO_BROADCAST_CHANNEL_LIB,
tsc::DENO_NET_LIB,
tsc::SHARED_GLOBALS_LIB,
tsc::WINDOW_LIB,
];

if unstable {
types.push(crate::tsc::UNSTABLE_NS_LIB);
types.push(tsc::UNSTABLE_NS_LIB);
}

types.join("\n")
Expand Down Expand Up @@ -1317,13 +1317,9 @@ fn setup_panic_hook() {
eprintln!("reproduction steps and re-run with the RUST_BACKTRACE=1 env");
eprintln!("var set and include the backtrace in your report.");
eprintln!();
eprintln!(
"Platform: {} {}",
std::env::consts::OS,
std::env::consts::ARCH
);
eprintln!("Platform: {} {}", env::consts::OS, env::consts::ARCH);
eprintln!("Version: {}", version::deno());
eprintln!("Args: {:?}", std::env::args().collect::<Vec<_>>());
eprintln!("Args: {:?}", env::args().collect::<Vec<_>>());
eprintln!();
orig_hook(panic_info);
std::process::exit(1);
Expand Down
4 changes: 2 additions & 2 deletions cli/proc_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ impl ProcState {
self.options.resolve_ts_config_for_emit(config_type)?;

if let Some(ignored_options) = ts_config_result.maybe_ignored_options {
log::warn!("{}", ignored_options);
warn!("{}", ignored_options);
}

// start type checking if necessary
Expand Down Expand Up @@ -626,7 +626,7 @@ impl ProcState {
};

Ok(
deno_graph::create_graph(
create_graph(
roots,
false,
maybe_imports,
Expand Down
2 changes: 1 addition & 1 deletion cli/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub async fn run(
cpu_count: std::thread::available_parallelism()
.map(|p| p.get())
.unwrap_or(1),
debug_flag: metadata.log_level.map_or(false, |l| l == log::Level::Debug),
debug_flag: metadata.log_level.map_or(false, |l| l == Level::Debug),
enable_testing_features: false,
location: metadata.location,
no_color: !colors::use_color(),
Expand Down
2 changes: 1 addition & 1 deletion cli/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ mod tests {

#[test]
fn test_compiler_snapshot() {
let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
let mut js_runtime = JsRuntime::new(RuntimeOptions {
startup_snapshot: Some(compiler_snapshot()),
..Default::default()
});
Expand Down

0 comments on commit dbf5e95

Please sign in to comment.