Skip to content

Commit

Permalink
Run cargo fmt after update
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlattimore committed Dec 8, 2018
1 parent 43cec3b commit ea2af3f
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 46 deletions.
3 changes: 2 additions & 1 deletion evcxr/src/cargo_metadata.rs
Expand Up @@ -81,7 +81,8 @@ mod tests {
library_names_from_metadata(
Path::new("/home/foo/project"),
include_str!("testdata/sample_metadata.json")
).unwrap(),
)
.unwrap(),
vec!["direct1", "direct2"]
);
}
Expand Down
3 changes: 2 additions & 1 deletion evcxr/src/errors.rs
Expand Up @@ -162,7 +162,8 @@ impl CompilationError {
return None;
}
child["message"].as_str().map(|s| s.to_owned())
}).collect()
})
.collect()
} else {
vec![]
}
Expand Down
6 changes: 4 additions & 2 deletions evcxr/src/eval_context.rs
Expand Up @@ -237,7 +237,8 @@ impl EvalContext {
CodeBlock::new()
.generated(
"evcxr_internal_runtime::send_text_plain(&format!(\"{:?}\",\n",
).user_code(stmt_code)
)
.user_code(stmt_code)
.generated("));"),
);
}
Expand Down Expand Up @@ -565,7 +566,8 @@ impl EvalContext {
// into the closure.
.generated(
"let mut evcxr_variable_store = evcxr_internal_runtime::VariableStore::new();",
).add_all(user_code)
)
.add_all(user_code)
.add_all(self.store_variable_statements(&VariableMoveState::MovedIntoCatchUnwind))
.add_all(self.store_variable_statements(&VariableMoveState::CopiedIntoCatchUnwind))
// Return our local variable store from the closure to be merged back into the
Expand Down
13 changes: 7 additions & 6 deletions evcxr/src/item.rs
Expand Up @@ -37,12 +37,13 @@ pub(crate) fn is_item_public(item: &syn::Item) -> bool {
syn::Item::Union(i) => is_public(&i.vis),
syn::Item::Trait(i) => is_public(&i.vis),
syn::Item::Impl(i) => {
i.trait_.is_some() || i.items.iter().all(|i2| match i2 {
syn::ImplItem::Const(i) => is_public(&i.vis),
syn::ImplItem::Method(i) => is_public(&i.vis),
syn::ImplItem::Type(i) => is_public(&i.vis),
_ => true,
})
i.trait_.is_some()
|| i.items.iter().all(|i2| match i2 {
syn::ImplItem::Const(i) => is_public(&i.vis),
syn::ImplItem::Method(i) => is_public(&i.vis),
syn::ImplItem::Type(i) => is_public(&i.vis),
_ => true,
})
}
_ => true,
}
Expand Down
6 changes: 4 additions & 2 deletions evcxr/src/module.rs
Expand Up @@ -131,7 +131,8 @@ impl Module {
}
None
})
}).collect();
})
.collect();
if errors.is_empty() {
if let Some(error) = non_json_error {
bail!(Error::JustMessage(error.to_owned()));
Expand All @@ -158,7 +159,8 @@ impl Module {
&mut loaded_module_deps,
"{} = {{ path = \"../{}\" }}",
m.crate_name, m.crate_name
).unwrap();
)
.unwrap();
}
let crate_imports = eval_context.format_cargo_deps();
format!(
Expand Down
22 changes: 11 additions & 11 deletions evcxr/tests/integration_tests.rs
Expand Up @@ -162,17 +162,17 @@ fn function_panics() {
fn tls_implementing_drop() {
let mut e = new_context();
eval!(e, pub struct Foo {}
impl Drop for Foo {
fn drop(&mut self) {
println!("Dropping Foo");
}
}
pub fn init_foo() {
thread_local! {
pub static FOO: Foo = Foo {};
}
FOO.with(|f| ())
});
impl Drop for Foo {
fn drop(&mut self) {
println!("Dropping Foo");
}
}
pub fn init_foo() {
thread_local! {
pub static FOO: Foo = Foo {};
}
FOO.with(|f| ())
});
eval!(e, init_foo(););
}

Expand Down
47 changes: 27 additions & 20 deletions evcxr_jupyter/src/core.rs
Expand Up @@ -157,10 +157,11 @@ impl Server {
execution_count += 1;
message
.new_message("execute_input")
.with_content(object!{
.with_content(object! {
"execution_count" => execution_count,
"code" => code
}).send(&mut *self.iopub.lock().unwrap())?;
})
.send(&mut *self.iopub.lock().unwrap())?;
let reply = match context.execute(code) {
Ok(output) => {
if !output.is_empty() {
Expand All @@ -183,11 +184,12 @@ impl Server {
}
message
.new_message("execute_result")
.with_content(object!{
.with_content(object! {
"execution_count" => execution_count,
"data" => data,
"metadata" => HashMap::new(),
}).send(&mut *self.iopub.lock().unwrap())?;
})
.send(&mut *self.iopub.lock().unwrap())?;
if let Some(duration) = output.timing {
// TODO replace by duration.as_millis() when stable
let ms =
Expand All @@ -202,21 +204,22 @@ impl Server {
);
message
.new_message("execute_result")
.with_content(object!{
.with_content(object! {
"execution_count" => execution_count,
"data" => data,
"metadata" => HashMap::new(),
}).send(&mut *self.iopub.lock().unwrap())?;
})
.send(&mut *self.iopub.lock().unwrap())?;
}
}
message.new_reply().with_content(object!{
message.new_reply().with_content(object! {
"status" => "ok",
"execution_count" => execution_count
})
}
Err(errors) => {
self.emit_errors(&errors, &message)?;
message.new_reply().with_content(object!{
message.new_reply().with_content(object! {
"status" => "error",
"execution_count" => execution_count,
})
Expand All @@ -239,11 +242,11 @@ impl Server {
// Jupiter Lab doesn't use the kernel until it received "idle" for kernel_info_request
message
.new_message("status")
.with_content(object!{"execution_state" => "busy"})
.with_content(object! {"execution_state" => "busy"})
.send(&mut *self.iopub.lock().unwrap())?;
let idle = message
.new_message("status")
.with_content(object!{"execution_state" => "idle"});
.with_content(object! {"execution_state" => "idle"});
if message.message_type() == "kernel_info_request" {
message
.new_reply()
Expand All @@ -252,7 +255,7 @@ impl Server {
} else if message.message_type() == "is_complete_request" {
message
.new_reply()
.with_content(object!{"status" => "complete"})
.with_content(object! {"status" => "complete"})
.send(&mut connection)?;
} else if message.message_type() == "execute_request" {
execution_channel.send(message)?;
Expand Down Expand Up @@ -306,10 +309,11 @@ impl Server {
}
if let Some(message) = message {
if let Err(error) = message
.with_content(object!{
.with_content(object! {
"name" => output_name,
"text" => format!("{}\n", line),
}).send(&mut *self.iopub.lock().unwrap())
})
.send(&mut *self.iopub.lock().unwrap())
{
eprintln!("{}", error);
}
Expand Down Expand Up @@ -353,33 +357,36 @@ impl Server {
traceback.push(error.message());
parent_message
.new_message("error")
.with_content(object!{
.with_content(object! {
"ename" => "Error",
"evalue" => error.message(),
"traceback" => traceback,
}).send(&mut *self.iopub.lock().unwrap())?;
})
.send(&mut *self.iopub.lock().unwrap())?;
} else {
parent_message
.new_message("error")
.with_content(object!{
.with_content(object! {
"ename" => "Error",
"evalue" => error.message(),
"traceback" => array![
message
],
}).send(&mut *self.iopub.lock().unwrap())?;
})
.send(&mut *self.iopub.lock().unwrap())?;
}
}
}
error => {
let displayed_error = format!("{}", error);
parent_message
.new_message("error")
.with_content(object!{
.with_content(object! {
"ename" => "Error",
"evalue" => displayed_error.clone(),
"traceback" => array![displayed_error],
}).send(&mut *self.iopub.lock().unwrap())?;
})
.send(&mut *self.iopub.lock().unwrap())?;
}
}
Ok(())
Expand All @@ -398,7 +405,7 @@ fn bind_socket(

/// See [Kernel info documentation](https://jupyter-client.readthedocs.io/en/stable/messaging.html#kernel-info)
fn kernel_info() -> JsonValue {
object!{
object! {
"protocol_version" => "5.3",
"implementation" => env!("CARGO_PKG_NAME"),
"implementation_version" => env!("CARGO_PKG_VERSION"),
Expand Down
2 changes: 1 addition & 1 deletion evcxr_jupyter/src/install.rs
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn install() -> Result<(), Error> {
let current_exe = current_exe_path
.to_str()
.ok_or_else(|| format_err!("current exe path isn't valid UTF-8"))?;
let kernel_json = object!{
let kernel_json = object! {
"argv" => array![current_exe, "--control_file", "{connection_file}"],
"display_name" => "Rust",
"language" => "rust",
Expand Down
3 changes: 2 additions & 1 deletion evcxr_jupyter/tests/integration_tests.rs
Expand Up @@ -29,7 +29,8 @@ fn test_binary_execution() {
.parent()
.unwrap()
.join("evcxr_jupyter"),
).arg("--help")
)
.arg("--help")
.env_remove("LD_LIBRARY_PATH")
.output()
.unwrap();
Expand Down
3 changes: 2 additions & 1 deletion evcxr_repl/tests/integration_tests.rs
Expand Up @@ -29,7 +29,8 @@ fn test_binary_execution() {
.parent()
.unwrap()
.join("evcxr"),
).arg("--help")
)
.arg("--help")
.env_remove("LD_LIBRARY_PATH")
.output()
.unwrap();
Expand Down

0 comments on commit ea2af3f

Please sign in to comment.