summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/compiler.rs2
-rw-r--r--cli/deno_dir.rs14
-rw-r--r--cli/flags.rs2
-rw-r--r--cli/http_util.rs80
-rw-r--r--cli/ops.rs2
-rw-r--r--cli/permissions.rs4
6 files changed, 55 insertions, 49 deletions
diff --git a/cli/compiler.rs b/cli/compiler.rs
index bd9cc4c64..4fb2105a9 100644
--- a/cli/compiler.rs
+++ b/cli/compiler.rs
@@ -143,7 +143,7 @@ fn lazy_start(parent_state: ThreadSafeState) -> ResourceId {
}).map_err(|_| ())
}));
rid
- }).clone()
+ }).to_owned()
}
fn req(specifier: &str, referrer: &str, cmd_id: u32) -> Buf {
diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs
index 1d69046d3..b0af7b04c 100644
--- a/cli/deno_dir.rs
+++ b/cli/deno_dir.rs
@@ -579,8 +579,8 @@ fn fetch_remote_source_async(
),
|(
dir,
- maybe_initial_module_name,
- maybe_initial_filename,
+ mut maybe_initial_module_name,
+ mut maybe_initial_filename,
module_name,
filename,
)| {
@@ -595,8 +595,6 @@ fn fetch_remote_source_async(
.map_err(DenoError::from);
match resolve_result {
Ok((new_module_name, new_filename)) => {
- let mut maybe_initial_module_name = maybe_initial_module_name;
- let mut maybe_initial_filename = maybe_initial_filename;
if maybe_initial_module_name.is_none() {
maybe_initial_module_name = Some(module_name.clone());
maybe_initial_filename = Some(filename.clone());
@@ -623,7 +621,11 @@ fn fetch_remote_source_async(
// Write file and create .headers.json for the file.
deno_fs::write_file(&p, &source, 0o666)?;
{
- save_source_code_headers(&filename, maybe_content_type.clone(), None);
+ save_source_code_headers(
+ &filename,
+ maybe_content_type.clone(),
+ None,
+ );
}
// Check if this file is downloaded due to some old redirect request.
if maybe_initial_filename.is_some() {
@@ -834,7 +836,7 @@ fn save_source_code_headers(
value_map.insert(REDIRECT_TO.to_string(), json!(redirect_to.unwrap()));
}
// Only save to file when there is actually data.
- if value_map.len() > 0 {
+ if !value_map.is_empty() {
let _ = serde_json::to_string(&value_map).map(|s| {
// It is possible that we need to create file
// with parent folders not yet created.
diff --git a/cli/flags.rs b/cli/flags.rs
index 9f43b0b80..075394a55 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -101,7 +101,7 @@ pub fn set_flags(
NO_COLOR Set to disable color";
let clap_app = App::new("deno")
- .global_settings(&vec![AppSettings::ColorNever])
+ .global_settings(&[AppSettings::ColorNever])
.settings(&app_settings[..])
.after_help(env_variables_help)
.arg(
diff --git a/cli/http_util.rs b/cli/http_util.rs
index d04f18b1e..13d1ce45b 100644
--- a/cli/http_util.rs
+++ b/cli/http_util.rs
@@ -47,7 +47,7 @@ fn resolve_uri_from_location(base_uri: &Uri, location: &str) -> Uri {
// assuming path-noscheme | path-empty
let mut new_uri_parts = base_uri.clone().into_parts();
let base_uri_path_str = base_uri.path().to_owned();
- let segs: Vec<&str> = base_uri_path_str.rsplitn(2, "/").collect();
+ let segs: Vec<&str> = base_uri_path_str.rsplitn(2, '/').collect();
new_uri_parts.path_and_query = Some(
format!("{}/{}", segs.last().unwrap_or(&""), location)
.parse()
@@ -86,50 +86,54 @@ pub fn fetch_string_once(
client
.get(url.clone())
.map_err(DenoError::from)
- .and_then(move |response| -> Box<dyn Future<Item = FetchAttempt, Error = DenoError> + Send> {
- if response.status().is_redirection() {
- let location_string = response
- .headers()
- .get("location")
- .expect("url redirection should provide 'location' header")
- .to_str()
- .unwrap()
- .to_string();
- debug!("Redirecting to {}...", &location_string);
- let new_url = resolve_uri_from_location(&url, &location_string);
- // Boxed trait object turns out to be the savior for 2+ types yielding same results.
- return Box::new(
- future::ok(None).join3(
+ .and_then(
+ move |response| -> Box<
+ dyn Future<Item = FetchAttempt, Error = DenoError> + Send,
+ > {
+ if response.status().is_redirection() {
+ let location_string = response
+ .headers()
+ .get("location")
+ .expect("url redirection should provide 'location' header")
+ .to_str()
+ .unwrap()
+ .to_string();
+ debug!("Redirecting to {}...", &location_string);
+ let new_url = resolve_uri_from_location(&url, &location_string);
+ // Boxed trait object turns out to be the savior for 2+ types yielding same results.
+ return Box::new(future::ok(None).join3(
future::ok(None),
- future::ok(Some(FetchOnceResult::Redirect(new_url))
- ))
- );
- } else if response.status().is_client_error() || response.status().is_server_error() {
- return Box::new(future::err(
- errors::new(errors::ErrorKind::Other,
- format!("Import '{}' failed: {}", &url, response.status()))
+ future::ok(Some(FetchOnceResult::Redirect(new_url))),
));
- }
- let content_type = response
- .headers()
- .get(CONTENT_TYPE)
- .map(|content_type| content_type.to_str().unwrap().to_owned());
- let body = response
- .into_body()
- .concat2()
- .map(|body| String::from_utf8(body.to_vec()).ok())
- .map_err(DenoError::from);
- Box::new(body.join3(
- future::ok(content_type),
- future::ok(None)
- ))
- })
+ } else if response.status().is_client_error()
+ || response.status().is_server_error()
+ {
+ return Box::new(future::err(errors::new(
+ errors::ErrorKind::Other,
+ format!("Import '{}' failed: {}", &url, response.status()),
+ )));
+ }
+ let content_type = response
+ .headers()
+ .get(CONTENT_TYPE)
+ .map(|content_type| content_type.to_str().unwrap().to_owned());
+ let body = response
+ .into_body()
+ .concat2()
+ .map(|body| String::from_utf8(body.to_vec()).ok())
+ .map_err(DenoError::from);
+ Box::new(body.join3(future::ok(content_type), future::ok(None)))
+ },
+ )
.and_then(move |(maybe_code, maybe_content_type, maybe_redirect)| {
if let Some(redirect) = maybe_redirect {
future::ok(redirect)
} else {
// maybe_code should always contain code here!
- future::ok(FetchOnceResult::Code(maybe_code.unwrap(), maybe_content_type))
+ future::ok(FetchOnceResult::Code(
+ maybe_code.unwrap(),
+ maybe_content_type,
+ ))
}
})
}
diff --git a/cli/ops.rs b/cli/ops.rs
index baa159a68..ce8299136 100644
--- a/cli/ops.rs
+++ b/cli/ops.rs
@@ -214,7 +214,7 @@ fn op_now(
assert_eq!(data.len(), 0);
let seconds = state.start_time.elapsed().as_secs();
let mut subsec_nanos = state.start_time.elapsed().subsec_nanos();
- let reduced_time_precision = 2000000; // 2ms in nanoseconds
+ let reduced_time_precision = 2_000_000; // 2ms in nanoseconds
// If the permission is not enabled
// Round the nano result on 2 milliseconds
diff --git a/cli/permissions.rs b/cli/permissions.rs
index 6247cd0d1..84c2f0e17 100644
--- a/cli/permissions.rs
+++ b/cli/permissions.rs
@@ -268,7 +268,7 @@ impl DenoPermissions {
}
pub fn allows_high_precision(&self) -> bool {
- return self.allow_high_precision.is_allow();
+ self.allow_high_precision.is_allow()
}
pub fn revoke_run(&self) -> DenoResult<()> {
@@ -297,7 +297,7 @@ impl DenoPermissions {
}
pub fn revoke_high_precision(&self) -> DenoResult<()> {
self.allow_high_precision.revoke();
- return Ok(());
+ Ok(())
}
}