summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/examples/http_bench.rs3
-rw-r--r--core/js_errors.rs13
-rw-r--r--core/modules.rs15
3 files changed, 15 insertions, 16 deletions
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");
}
}