diff --git a/src/ansi.rs b/src/ansi.rs index 47bf6c9419..e25a8257d4 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -25,7 +25,7 @@ pub fn strip_ansi_codes(s: &str) -> Cow { } pub fn use_color() -> bool { - *NO_COLOR == false + !(*NO_COLOR) } pub fn red_bold(s: String) -> impl fmt::Display { diff --git a/src/js_errors.rs b/src/js_errors.rs index bc7f376830..dccda0e5d2 100644 --- a/src/js_errors.rs +++ b/src/js_errors.rs @@ -115,7 +115,7 @@ impl fmt::Display for JSError { s.push(' '); } } - write!(f, "{}\n", ansi::red_bold(s))?; + writeln!(f, "{}", ansi::red_bold(s))?; } } } @@ -193,7 +193,7 @@ impl StackFrame { Some(StackFrame { line: line - 1, column: column - 1, - script_name: script_name, + script_name, function_name, is_eval, is_constructor, @@ -227,8 +227,8 @@ impl StackFrame { let orig_source = sm.sources[original.source as usize].clone(); ( orig_source, - original.original_line as i64, - original.original_column as i64, + i64::from(original.original_line), + i64::from(original.original_column), ) } }, diff --git a/src/ops.rs b/src/ops.rs index b30473eb6d..82d79fc2f2 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -184,11 +184,11 @@ fn op_now( assert_eq!(data.len(), 0); let start = SystemTime::now(); let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap(); - let time = since_the_epoch.as_secs() as u64 * 1000 - + since_the_epoch.subsec_millis() as u64; + let time = since_the_epoch.as_secs() * 1000 + + u64::from(since_the_epoch.subsec_millis()); let builder = &mut FlatBufferBuilder::new(); - let inner = msg::NowRes::create(builder, &msg::NowResArgs { time: time }); + let inner = msg::NowRes::create(builder, &msg::NowResArgs { time }); ok_future(serialize_response( base.cmd_id(), builder, @@ -327,7 +327,6 @@ fn op_code_fetch( filename: Some(builder.create_string(&out.filename)), media_type: out.media_type, source_code: Some(builder.create_string(&out.source_code)), - ..Default::default() }; let inner = msg::CodeFetchRes::create(builder, &msg_args); Ok(serialize_response( @@ -622,9 +621,15 @@ fn op_chmod( #[cfg(any(unix))] { // We need to use underscore to compile in Windows. - #[cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))] + #[cfg_attr( + feature = "cargo-clippy", + allow(clippy::used_underscore_binding) + )] let mut permissions = _metadata.permissions(); - #[cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))] + #[cfg_attr( + feature = "cargo-clippy", + allow(clippy::used_underscore_binding) + )] permissions.set_mode(_mode); fs::set_permissions(&path, permissions)?; }