diff options
-rw-r--r-- | cli/deno_dir.rs | 2 | ||||
-rw-r--r-- | cli/flags.rs | 6 | ||||
-rw-r--r-- | cli/ops.rs | 2 | ||||
-rw-r--r-- | cli/state.rs | 2 | ||||
-rw-r--r-- | cli/tokio_util.rs | 1 | ||||
-rw-r--r-- | cli/worker.rs | 5 | ||||
-rw-r--r-- | core/examples/http_bench.rs | 3 | ||||
-rw-r--r-- | core/js_errors.rs | 13 | ||||
-rw-r--r-- | core/modules.rs | 15 |
9 files changed, 22 insertions, 27 deletions
diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs index 69496b701..5dc9afed3 100644 --- a/cli/deno_dir.rs +++ b/cli/deno_dir.rs @@ -652,7 +652,7 @@ fn fetch_remote_source_async( filename: filename.to_string(), media_type: map_content_type( &p, - maybe_content_type.as_ref().map(|s| s.as_str()), + maybe_content_type.as_ref().map(String::as_str), ), source_code: source.as_bytes().to_owned(), maybe_output_code_filename: None, diff --git a/cli/flags.rs b/cli/flags.rs index 3fd3f91fb..3aac1ecc8 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -96,7 +96,7 @@ static ENV_VARIABLES_HELP: &str = "ENVIRONMENT VARIABLES: NO_COLOR Set to disable color"; fn create_cli_app<'a, 'b>() -> App<'a, 'b> { - let cli_app = App::new("deno") + App::new("deno") .bin_name("deno") .global_settings(&[AppSettings::ColorNever]) .settings(&[ @@ -194,9 +194,7 @@ fn create_cli_app<'a, 'b>() -> App<'a, 'b> { // AppSettings:AllowExternalSubcommand to treat it as an // entry point script SubCommand::with_name("<script>").about("Script to run"), - ); - - cli_app + ) } #[cfg_attr(feature = "cargo-clippy", allow(stutter))] diff --git a/cli/ops.rs b/cli/ops.rs index 5e2a62439..0ce9d97a4 100644 --- a/cli/ops.rs +++ b/cli/ops.rs @@ -295,7 +295,7 @@ fn op_start( let mut builder = FlatBufferBuilder::new(); let state = state; - let argv = state.argv.iter().map(|s| s.as_str()).collect::<Vec<_>>(); + let argv = state.argv.iter().map(String::as_str).collect::<Vec<_>>(); let argv_off = builder.create_vector_of_strings(argv.as_slice()); let cwd_path = std::env::current_dir().unwrap(); diff --git a/cli/state.rs b/cli/state.rs index 24f2f5053..9a74cbfa2 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -90,7 +90,7 @@ impl ThreadSafeState { argv_rest: Vec<String>, dispatch_selector: ops::OpSelector, ) -> Self { - let custom_root = env::var("DENO_DIR").map(|s| s.into()).ok(); + let custom_root = env::var("DENO_DIR").map(String::into).ok(); let (worker_in_tx, worker_in_rx) = async_mpsc::channel::<Buf>(1); let (worker_out_tx, worker_out_rx) = async_mpsc::channel::<Buf>(1); diff --git a/cli/tokio_util.rs b/cli/tokio_util.rs index bf27c39f0..5b975ff40 100644 --- a/cli/tokio_util.rs +++ b/cli/tokio_util.rs @@ -48,7 +48,6 @@ pub fn init<F>(f: F) where F: FnOnce(), { - use tokio_executor; let rt = tokio::runtime::Runtime::new().unwrap(); let mut executor = rt.executor(); let mut enter = tokio_executor::enter().expect("Multiple executors at once"); diff --git a/cli/worker.rs b/cli/worker.rs index c43dbf6ee..5a4299214 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -119,7 +119,7 @@ pub fn resolve_module_spec( // two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), or the // three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F // SOLIDUS (../), return failure. - if !specifier.starts_with("/") + if !specifier.starts_with('/') && !specifier.starts_with("./") && !specifier.starts_with("../") { @@ -158,8 +158,7 @@ impl Loader for Worker { type Error = DenoError; fn resolve(specifier: &str, referrer: &str) -> Result<String, Self::Error> { - resolve_module_spec(specifier, referrer) - .map_err(|url_err| DenoError::from(url_err)) + resolve_module_spec(specifier, referrer).map_err(DenoError::from) } /// Given an absolute url, load its source code. diff --git a/core/examples/http_bench.rs b/core/examples/http_bench.rs index e4598a7b3..7cacf79b0 100644 --- a/core/examples/http_bench.rs +++ b/core/examples/http_bench.rs @@ -61,6 +61,7 @@ impl Into<Buf> for Record { impl From<&[u8]> for Record { fn from(s: &[u8]) -> Record { + #[allow(clippy::cast_ptr_alignment)] let ptr = s.as_ptr() as *const i32; let ints = unsafe { std::slice::from_raw_parts(ptr, 4) }; Record { @@ -75,7 +76,7 @@ impl From<&[u8]> for Record { impl From<Buf> for Record { fn from(buf: Buf) -> Record { assert_eq!(buf.len(), 4 * 4); - //let byte_len = buf.len(); + #[allow(clippy::cast_ptr_alignment)] let ptr = Box::into_raw(buf) as *mut [i32; 4]; let ints: Box<[i32]> = unsafe { Box::from_raw(ptr) }; assert_eq!(ints.len(), 4); diff --git a/core/js_errors.rs b/core/js_errors.rs index dcd434e48..ca5cf8085 100644 --- a/core/js_errors.rs +++ b/core/js_errors.rs @@ -10,6 +10,7 @@ // It would require calling into Rust from Error.prototype.prepareStackTrace. use serde_json; +use serde_json::value::Value; use std::fmt; use std::str; @@ -214,12 +215,12 @@ impl JSError { let script_resource_name = obj .get("scriptResourceName") .and_then(|v| v.as_str().map(String::from)); - let line_number = obj.get("lineNumber").and_then(|v| v.as_i64()); - let start_position = obj.get("startPosition").and_then(|v| v.as_i64()); - let end_position = obj.get("endPosition").and_then(|v| v.as_i64()); - let error_level = obj.get("errorLevel").and_then(|v| v.as_i64()); - let start_column = obj.get("startColumn").and_then(|v| v.as_i64()); - let end_column = obj.get("endColumn").and_then(|v| v.as_i64()); + let line_number = obj.get("lineNumber").and_then(Value::as_i64); + let start_position = obj.get("startPosition").and_then(Value::as_i64); + let end_position = obj.get("endPosition").and_then(Value::as_i64); + let error_level = obj.get("errorLevel").and_then(Value::as_i64); + let start_column = obj.get("startColumn").and_then(Value::as_i64); + let end_column = obj.get("endColumn").and_then(Value::as_i64); let frames_v = &obj["frames"]; if !frames_v.is_array() { diff --git a/core/modules.rs b/core/modules.rs index f46ff5d74..3c74fe11d 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -202,7 +202,7 @@ impl<L: Loader> Future for RecursiveLoad<L> { return Ok(Async::NotReady); } - let root_id = self.root_id.unwrap().clone(); + let root_id = self.root_id.unwrap(); let mut loader = self.take_loader(); let (isolate, modules) = loader.isolate_and_modules(); let result = { @@ -460,13 +460,10 @@ mod tests { fn poll(&mut self) -> Poll<Self::Item, Self::Error> { self.counter += 1; - if self.url == "never_ready.js" { - // never_ready.js is never ready. + if self.url == "never_ready.js" + || (self.url == "slow.js" && self.counter < 2) + { return Ok(Async::NotReady); - } else if self.url == "slow.js" { - if self.counter < 2 { - return Ok(Async::NotReady); - } } match mock_source_code(&self.url) { Some(src) => Ok(Async::Ready(src.to_string())), @@ -560,7 +557,7 @@ mod tests { assert_eq!(modules.get_children(c_id), Some(&vec!["d.js".to_string()])); assert_eq!(modules.get_children(d_id), Some(&vec![])); } else { - assert!(false); + panic!("this shouldn't happen"); } } @@ -619,7 +616,7 @@ mod tests { ]) ); } else { - assert!(false); + panic!("this shouldn't happen"); } } |