mirror of
https://github.com/denoland/deno
synced 2024-11-05 18:45:24 +00:00
Clippy fixes
This commit is contained in:
parent
efbe44eb33
commit
b735155712
4 changed files with 41 additions and 42 deletions
|
@ -147,7 +147,7 @@ fn lazy_start(parent_state: Arc<IsolateState>) -> CompilerShared {
|
||||||
);
|
);
|
||||||
match worker_result {
|
match worker_result {
|
||||||
Ok(worker) => {
|
Ok(worker) => {
|
||||||
let rid = worker.resource.rid.clone();
|
let rid = worker.resource.rid;
|
||||||
// create oneshot channels and use the sender to pass back
|
// create oneshot channels and use the sender to pass back
|
||||||
// results from worker future
|
// results from worker future
|
||||||
let (err_sender, err_receiver) =
|
let (err_sender, err_receiver) =
|
||||||
|
@ -198,7 +198,7 @@ pub fn compile_sync(
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
module_meta_data: &ModuleMetaData,
|
module_meta_data: &ModuleMetaData,
|
||||||
) -> ModuleMetaData {
|
) -> ModuleMetaData {
|
||||||
let is_worker = parent_state.is_worker.clone();
|
let is_worker = parent_state.is_worker;
|
||||||
let shared = lazy_start(parent_state);
|
let shared = lazy_start(parent_state);
|
||||||
|
|
||||||
let (local_sender, local_receiver) =
|
let (local_sender, local_receiver) =
|
||||||
|
@ -206,12 +206,12 @@ pub fn compile_sync(
|
||||||
|
|
||||||
// Just some extra scoping to keep things clean
|
// Just some extra scoping to keep things clean
|
||||||
{
|
{
|
||||||
let compiler_rid = shared.rid.clone();
|
let compiler_rid = shared.rid;
|
||||||
let module_meta_data_ = module_meta_data.clone();
|
let module_meta_data_ = module_meta_data.clone();
|
||||||
let req_msg = req(specifier, referrer, is_worker);
|
let req_msg = req(specifier, referrer, is_worker);
|
||||||
let sender_arc = Arc::new(Some(local_sender));
|
let sender_arc = Arc::new(Some(local_sender));
|
||||||
let specifier_ = specifier.clone().to_string();
|
let specifier_ = specifier.to_string();
|
||||||
let referrer_ = referrer.clone().to_string();
|
let referrer_ = referrer.to_string();
|
||||||
|
|
||||||
let mut runtime = C_RUNTIME.lock().unwrap();
|
let mut runtime = C_RUNTIME.lock().unwrap();
|
||||||
runtime.spawn(lazy(move || {
|
runtime.spawn(lazy(move || {
|
||||||
|
@ -242,35 +242,36 @@ pub fn compile_sync(
|
||||||
);
|
);
|
||||||
let res_msg = res_msg_option.unwrap();
|
let res_msg = res_msg_option.unwrap();
|
||||||
let res_json = std::str::from_utf8(&res_msg).unwrap();
|
let res_json = std::str::from_utf8(&res_msg).unwrap();
|
||||||
let sender = Arc::get_mut(&mut result_sender_arc).unwrap().take();
|
let sender = Arc::get_mut(&mut result_sender_arc)
|
||||||
let sender = sender.unwrap();
|
.unwrap()
|
||||||
Ok(
|
.take()
|
||||||
sender
|
.unwrap();
|
||||||
.send(Ok(match serde_json::from_str::<serde_json::Value>(
|
sender
|
||||||
res_json,
|
.send(Ok(match serde_json::from_str::<serde_json::Value>(
|
||||||
) {
|
res_json,
|
||||||
Ok(serde_json::Value::Object(map)) => ModuleMetaData {
|
) {
|
||||||
module_name: module_meta_data_.module_name.clone(),
|
Ok(serde_json::Value::Object(map)) => ModuleMetaData {
|
||||||
module_redirect_source_name: module_meta_data_
|
module_name: module_meta_data_.module_name.clone(),
|
||||||
.module_redirect_source_name
|
module_redirect_source_name: module_meta_data_
|
||||||
.clone(),
|
.module_redirect_source_name
|
||||||
filename: module_meta_data_.filename.clone(),
|
.clone(),
|
||||||
media_type: module_meta_data_.media_type,
|
filename: module_meta_data_.filename.clone(),
|
||||||
source_code: module_meta_data_.source_code.clone(),
|
media_type: module_meta_data_.media_type,
|
||||||
maybe_output_code: match map["outputCode"].as_str() {
|
source_code: module_meta_data_.source_code.clone(),
|
||||||
Some(str) => Some(str.as_bytes().to_owned()),
|
maybe_output_code: match map["outputCode"].as_str() {
|
||||||
_ => None,
|
Some(str) => Some(str.as_bytes().to_owned()),
|
||||||
},
|
_ => None,
|
||||||
maybe_output_code_filename: None,
|
|
||||||
maybe_source_map: match map["sourceMap"].as_str() {
|
|
||||||
Some(str) => Some(str.as_bytes().to_owned()),
|
|
||||||
_ => None,
|
|
||||||
},
|
|
||||||
maybe_source_map_filename: None,
|
|
||||||
},
|
},
|
||||||
_ => panic!("error decoding compiler response"),
|
maybe_output_code_filename: None,
|
||||||
})).unwrap(),
|
maybe_source_map: match map["sourceMap"].as_str() {
|
||||||
)
|
Some(str) => Some(str.as_bytes().to_owned()),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
|
maybe_source_map_filename: None,
|
||||||
|
},
|
||||||
|
_ => panic!("error decoding compiler response"),
|
||||||
|
})).expect("send failed");
|
||||||
|
Ok(())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1848,7 +1848,7 @@ fn op_create_worker(
|
||||||
) {
|
) {
|
||||||
Ok(worker) => {
|
Ok(worker) => {
|
||||||
let mut workers_tl = parent_state.workers.lock().unwrap();
|
let mut workers_tl = parent_state.workers.lock().unwrap();
|
||||||
let rid = worker.resource.rid.clone();
|
let rid = worker.resource.rid;
|
||||||
workers_tl.insert(rid, worker.shared());
|
workers_tl.insert(rid, worker.shared());
|
||||||
let builder = &mut FlatBufferBuilder::new();
|
let builder = &mut FlatBufferBuilder::new();
|
||||||
let msg_inner = msg::CreateWorkerRes::create(
|
let msg_inner = msg::CreateWorkerRes::create(
|
||||||
|
|
|
@ -146,7 +146,7 @@ pub fn spawn<B: WorkerBehavior + 'static>(
|
||||||
|
|
||||||
let init_result = match init {
|
let init_result = match init {
|
||||||
WorkerInit::Script(script) => match worker.execute(&script) {
|
WorkerInit::Script(script) => match worker.execute(&script) {
|
||||||
Ok(v) => Ok(v),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => Err(RustOrJsError::Js(e)),
|
Err(e) => Err(RustOrJsError::Js(e)),
|
||||||
},
|
},
|
||||||
WorkerInit::Module(specifier) => {
|
WorkerInit::Module(specifier) => {
|
||||||
|
@ -211,8 +211,7 @@ mod tests {
|
||||||
resource_.close();
|
resource_.close();
|
||||||
debug!("workers.rs after resource close");
|
debug!("workers.rs after resource close");
|
||||||
if let Err(err) = r {
|
if let Err(err) = r {
|
||||||
eprintln!("{}", JSErrorColor(&err).to_string());
|
panic!("{}", JSErrorColor(&err).to_string());
|
||||||
assert!(false)
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
@ -260,8 +259,7 @@ mod tests {
|
||||||
resource_.close();
|
resource_.close();
|
||||||
debug!("workers.rs after resource close");
|
debug!("workers.rs after resource close");
|
||||||
if let Err(err) = r {
|
if let Err(err) = r {
|
||||||
eprintln!("{}", JSErrorColor(&err).to_string());
|
panic!("{}", JSErrorColor(&err).to_string());
|
||||||
assert!(false)
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
|
|
|
@ -168,17 +168,17 @@ mod tests {
|
||||||
assert_eq!(q.size(), 3);
|
assert_eq!(q.size(), 3);
|
||||||
|
|
||||||
let r = q.shift().unwrap();
|
let r = q.shift().unwrap();
|
||||||
assert_eq!(r.as_ref(), vec![1, 2, 3, 4, 5].as_slice());
|
assert_eq!(r, vec![1, 2, 3, 4, 5].as_slice());
|
||||||
assert_eq!(q.num_records(), 3);
|
assert_eq!(q.num_records(), 3);
|
||||||
assert_eq!(q.size(), 2);
|
assert_eq!(q.size(), 2);
|
||||||
|
|
||||||
let r = q.shift().unwrap();
|
let r = q.shift().unwrap();
|
||||||
assert_eq!(r.as_ref(), vec![6, 7].as_slice());
|
assert_eq!(r, vec![6, 7].as_slice());
|
||||||
assert_eq!(q.num_records(), 3);
|
assert_eq!(q.num_records(), 3);
|
||||||
assert_eq!(q.size(), 1);
|
assert_eq!(q.size(), 1);
|
||||||
|
|
||||||
let r = q.shift().unwrap();
|
let r = q.shift().unwrap();
|
||||||
assert_eq!(r.as_ref(), vec![8, 9, 10, 11].as_slice());
|
assert_eq!(r, vec![8, 9, 10, 11].as_slice());
|
||||||
assert_eq!(q.num_records(), 0);
|
assert_eq!(q.num_records(), 0);
|
||||||
assert_eq!(q.size(), 0);
|
assert_eq!(q.size(), 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue