summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/binding.rs6
-rw-r--r--src/handlers.rs6
-rw-r--r--src/main.rs16
-rwxr-xr-xtools/format.py8
-rw-r--r--tools/rustfmt.toml1
5 files changed, 28 insertions, 9 deletions
diff --git a/src/binding.rs b/src/binding.rs
index 62d727627..fc57200c3 100644
--- a/src/binding.rs
+++ b/src/binding.rs
@@ -37,7 +37,11 @@ extern "C" {
js_source: *const c_char,
) -> c_int;
pub fn deno_handle_msg_from_js(d: *const DenoC, buf: deno_buf);
- pub fn deno_reply_error(d: *const DenoC, cmd_id: uint32_t, msg: *const c_char);
+ pub fn deno_reply_error(
+ d: *const DenoC,
+ cmd_id: uint32_t,
+ msg: *const c_char,
+ );
pub fn deno_reply_null(d: *const DenoC, cmd_id: uint32_t);
pub fn deno_reply_code_fetch(
d: *const DenoC,
diff --git a/src/handlers.rs b/src/handlers.rs
index 0649e5a9b..e8cf62a5b 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -164,7 +164,8 @@ fn test_resolve_module() {
for &test in test_cases.iter() {
let module_specifier = String::from(test.0);
let containing_file = String::from(test.1);
- let (module_name, filename) = resolve_module(&module_specifier, &containing_file).unwrap();
+ let (module_name, filename) =
+ resolve_module(&module_specifier, &containing_file).unwrap();
assert_eq!(module_name, test.2);
assert_eq!(filename, test.3);
}
@@ -184,7 +185,8 @@ pub extern "C" fn handle_code_fetch(
let result = resolve_module(&module_specifier, &containing_file);
if result.is_err() {
let err = result.unwrap_err();
- let errmsg = format!("{} {} {}", err, module_specifier, containing_file);
+ let errmsg =
+ format!("{} {} {}", err, module_specifier, containing_file);
let errmsg_c = as_cstring(&errmsg);
unsafe { deno_reply_error(d, cmd_id, errmsg_c.as_ptr()) };
return;
diff --git a/src/main.rs b/src/main.rs
index e1284d303..efe7d86c0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,8 +8,10 @@ use std::ffi::CString;
use std::ptr;
mod binding;
-use binding::{deno_delete, deno_execute, deno_handle_msg_from_js, deno_init, deno_last_exception,
- deno_new, deno_set_flags, DenoC};
+use binding::{
+ deno_delete, deno_execute, deno_handle_msg_from_js, deno_init,
+ deno_last_exception, deno_new, deno_set_flags, DenoC,
+};
// Pass the command line arguments to v8.
// Returns a vector of command line arguments that v8 did not understand.
@@ -58,10 +60,16 @@ impl Deno {
Deno { ptr: ptr }
}
- fn execute(&mut self, js_filename: &str, js_source: &str) -> Result<(), DenoException> {
+ fn execute(
+ &mut self,
+ js_filename: &str,
+ js_source: &str,
+ ) -> Result<(), DenoException> {
let filename = CString::new(js_filename).unwrap();
let source = CString::new(js_source).unwrap();
- let r = unsafe { deno_execute(self.ptr, filename.as_ptr(), source.as_ptr()) };
+ let r = unsafe {
+ deno_execute(self.ptr, filename.as_ptr(), source.as_ptr())
+ };
if r == 0 {
let ptr = unsafe { deno_last_exception(self.ptr) };
let cstr = unsafe { CStr::from_ptr(ptr) };
diff --git a/tools/format.py b/tools/format.py
index fc11ced4d..cb3b15a7e 100755
--- a/tools/format.py
+++ b/tools/format.py
@@ -8,6 +8,8 @@ root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
third_party_path = os.path.join(root_path, "third_party")
prettier = os.path.join(third_party_path, "node_modules", "prettier",
"bin-prettier.js")
+tools_path = os.path.join(root_path, "tools")
+rustfmt_config = os.path.join(tools_path, "rustfmt.toml")
os.chdir(root_path)
# TODO(ry) Install clang-format in third_party.
@@ -24,5 +26,7 @@ run(["node", prettier, "--write"] + glob("js/*.js") + glob("js/*.ts") +
rustfmt_extra_args = []
if 'RUSTFMT_FLAGS' in os.environ:
rustfmt_extra_args += os.environ['RUSTFMT_FLAGS'].split()
-run(["rustfmt", "--write-mode", "overwrite"] + rustfmt_extra_args +
- glob("src/*.rs"))
+run([
+ "rustfmt", "--config-path", rustfmt_config, "--error-on-unformatted",
+ "--write-mode", "overwrite"
+] + rustfmt_extra_args + glob("src/*.rs"))
diff --git a/tools/rustfmt.toml b/tools/rustfmt.toml
new file mode 100644
index 000000000..df99c6919
--- /dev/null
+++ b/tools/rustfmt.toml
@@ -0,0 +1 @@
+max_width = 80