mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 16:19:12 -05:00
Fix clippy warnings
This commit is contained in:
parent
90c2b10f47
commit
8477daa8b9
9 changed files with 22 additions and 27 deletions
|
@ -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,
|
||||
|
|
|
@ -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))]
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue