diff --git a/src/binding.rs b/src/binding.rs index 62d727627b30f9..fc57200c39f22c 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 0649e5a9be88a7..e8cf62a5b86efa 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 e1284d3039837f..efe7d86c0865b8 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 fc11ced4d4442a..cb3b15a7e4544c 100755 --- a/tools/format.py +++ b/tools/format.py @@ -8,6 +8,8 @@ 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 @@ 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 00000000000000..df99c69198f581 --- /dev/null +++ b/tools/rustfmt.toml @@ -0,0 +1 @@ +max_width = 80