From b101dc33d329b70e7330a8c029f9bab4463cb0ee Mon Sep 17 00:00:00 2001 From: Vadim Chugunov Date: Tue, 5 May 2020 22:54:39 -0700 Subject: [PATCH] cargo fmt --- .vscode/tasks.json | 2 +- adapter2/deps/debug-protocol/src/lib.rs | 2 +- adapter2/deps/lldb/src/sbattachinfo.rs | 14 ++++++++++---- adapter2/deps/lldb/src/sbbreakpoint.rs | 4 +++- adapter2/deps/lldb/src/sbcommandinterpreter.rs | 16 +++++++++++++--- adapter2/deps/lldb/src/sblistener.rs | 14 ++++++++++++-- adapter2/deps/lldb/src/sbtarget.rs | 8 ++++++-- adapter2/src/debug_session.rs | 3 ++- adapter2/src/disassembly.rs | 5 ++++- adapter2/src/wire_protocol.rs | 6 ++---- rustfmt.toml | 1 - 11 files changed, 54 insertions(+), 21 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 600e38a7..ecb99880 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -172,7 +172,7 @@ }, { "type": "process", - "label": "rustfmt", + "label": "Format current file", "command": "rustfmt", "args": [ "${file}" diff --git a/adapter2/deps/debug-protocol/src/lib.rs b/adapter2/deps/debug-protocol/src/lib.rs index 060195c3..35fb2ad6 100644 --- a/adapter2/deps/debug-protocol/src/lib.rs +++ b/adapter2/deps/debug-protocol/src/lib.rs @@ -1,7 +1,7 @@ #![allow(non_camel_case_types)] #![cfg(not(feature = "test"))] -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; schemafy::schemafy!("adapter2/deps/debug-protocol/src/debugAdapterProtocol.json"); diff --git a/adapter2/deps/lldb/src/sbattachinfo.rs b/adapter2/deps/lldb/src/sbattachinfo.rs index 6d16719e..c87c49d0 100644 --- a/adapter2/deps/lldb/src/sbattachinfo.rs +++ b/adapter2/deps/lldb/src/sbattachinfo.rs @@ -26,11 +26,11 @@ impl SBAttachInfo { }) } pub fn set_executable(&self, path: &str) { - with_cstr(path, |path| + with_cstr(path, |path| { cpp!(unsafe [self as "SBAttachInfo*", path as "const char*"] { self->SetExecutable(path); }) - ); + }); } /// Set attach by process name settings. /// @@ -87,7 +87,13 @@ impl SBAttachInfo { impl fmt::Debug for SBAttachInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Attach info: pid = {}, wait_for = {}, ignore_existing = {}, resume_count = {}", //. - self.process_id(), self.wait_for_launch(), self.ignore_existing(), self.resume_count()) + write!( + f, + "Attach info: pid = {}, wait_for = {}, ignore_existing = {}, resume_count = {}", + self.process_id(), + self.wait_for_launch(), + self.ignore_existing(), + self.resume_count() + ) } } diff --git a/adapter2/deps/lldb/src/sbbreakpoint.rs b/adapter2/deps/lldb/src/sbbreakpoint.rs index 6a2fa596..a6106502 100644 --- a/adapter2/deps/lldb/src/sbbreakpoint.rs +++ b/adapter2/deps/lldb/src/sbbreakpoint.rs @@ -68,7 +68,9 @@ impl SBBreakpoint { F: FnMut(&SBProcess, &SBThread, &SBBreakpointLocation) -> bool + Send + 'static, { unsafe extern "C" fn callback_thunk( - _baton: *mut c_void, process: *const SBProcess, thread: *const SBThread, + _baton: *mut c_void, + process: *const SBProcess, + thread: *const SBThread, location: *const SBBreakpointLocation, ) -> bool { let bp_id = (*location).breakpoint().id(); diff --git a/adapter2/deps/lldb/src/sbcommandinterpreter.rs b/adapter2/deps/lldb/src/sbcommandinterpreter.rs index 35358b23..067f68ba 100644 --- a/adapter2/deps/lldb/src/sbcommandinterpreter.rs +++ b/adapter2/deps/lldb/src/sbcommandinterpreter.rs @@ -6,7 +6,10 @@ unsafe impl Send for SBCommandInterpreter {} impl SBCommandInterpreter { pub fn handle_command( - &self, command: &str, result: &mut SBCommandReturnObject, add_to_history: bool, + &self, + command: &str, + result: &mut SBCommandReturnObject, + add_to_history: bool, ) -> ReturnStatus { with_cstr(command, |command| { cpp!(unsafe [self as "SBCommandInterpreter*", command as "const char*", @@ -16,7 +19,11 @@ impl SBCommandInterpreter { }) } pub fn handle_command_with_context( - &self, command: &str, context: &SBExecutionContext, result: &mut SBCommandReturnObject, add_to_history: bool, + &self, + command: &str, + context: &SBExecutionContext, + result: &mut SBCommandReturnObject, + add_to_history: bool, ) -> ReturnStatus { with_cstr(command, |command| { cpp!(unsafe [self as "SBCommandInterpreter*", command as "const char*", context as "SBExecutionContext*", @@ -26,7 +33,10 @@ impl SBCommandInterpreter { }) } pub fn handle_completions( - &self, current_line: &str, cursor_pos: u32, range: Option<(u32, u32)>, + &self, + current_line: &str, + cursor_pos: u32, + range: Option<(u32, u32)>, ) -> Option<(String, Vec)> { unsafe { let line_start = if current_line.is_empty() { diff --git a/adapter2/deps/lldb/src/sblistener.rs b/adapter2/deps/lldb/src/sblistener.rs index 2880f150..bfe06012 100644 --- a/adapter2/deps/lldb/src/sblistener.rs +++ b/adapter2/deps/lldb/src/sblistener.rs @@ -28,7 +28,12 @@ impl SBListener { }) } // returns effective event mask - pub fn start_listening_for_event_class(&self, debugger: &SBDebugger, broadcaster_class: &str, event_mask: u32) -> u32 { + pub fn start_listening_for_event_class( + &self, + debugger: &SBDebugger, + broadcaster_class: &str, + event_mask: u32, + ) -> u32 { with_cstr(broadcaster_class, |broadcaster_class| { cpp!(unsafe [self as "SBListener*", debugger as "SBDebugger*", broadcaster_class as "const char*", event_mask as "uint32_t"] -> u32 as "uint32_t" { @@ -36,7 +41,12 @@ impl SBListener { }) }) } - pub fn stop_listening_for_event_class(&self, debugger: &SBDebugger, broadcaster_class: &str, event_mask: u32) -> bool { + pub fn stop_listening_for_event_class( + &self, + debugger: &SBDebugger, + broadcaster_class: &str, + event_mask: u32, + ) -> bool { with_cstr(broadcaster_class, |broadcaster_class| { cpp!(unsafe [self as "SBListener*", debugger as "SBDebugger*", broadcaster_class as "const char*", event_mask as "uint32_t"] -> bool as "bool" { diff --git a/adapter2/deps/lldb/src/sbtarget.rs b/adapter2/deps/lldb/src/sbtarget.rs index 5aeb2964..ad295155 100644 --- a/adapter2/deps/lldb/src/sbtarget.rs +++ b/adapter2/deps/lldb/src/sbtarget.rs @@ -100,7 +100,8 @@ impl SBTarget { pub fn find_breakpoint_by_id(&self, id: BreakpointID) -> Option { cpp!(unsafe [self as "SBTarget*", id as "break_id_t"] -> SBBreakpoint as "SBBreakpoint" { return self->FindBreakpointByID(id); - }).check() + }) + .check() } pub fn breakpoint_create_by_location(&self, file: &str, line: u32) -> SBBreakpoint { with_cstr(file, |file| { @@ -124,7 +125,10 @@ impl SBTarget { }) } pub fn breakpoint_create_for_exception( - &self, language: LanguageType, catch_bp: bool, throw_bp: bool, + &self, + language: LanguageType, + catch_bp: bool, + throw_bp: bool, ) -> SBBreakpoint { cpp!(unsafe [self as "SBTarget*", language as "lldb::LanguageType", catch_bp as "bool", throw_bp as "bool"] -> SBBreakpoint as "SBBreakpoint" { return self->BreakpointCreateForException(language, catch_bp, throw_bp); diff --git a/adapter2/src/debug_session.rs b/adapter2/src/debug_session.rs index 88fe6fa2..797d5aec 100644 --- a/adapter2/src/debug_session.rs +++ b/adapter2/src/debug_session.rs @@ -1275,7 +1275,8 @@ impl DebugSession { err )), }) - }.right_future() + } + .right_future() } fn configure_stdio(&mut self, args: &LaunchRequestArguments, launch_info: &mut SBLaunchInfo) -> Result<(), Error> { diff --git a/adapter2/src/disassembly.rs b/adapter2/src/disassembly.rs index 64721b28..268b7ef8 100644 --- a/adapter2/src/disassembly.rs +++ b/adapter2/src/disassembly.rs @@ -80,7 +80,10 @@ impl AddressSpace { } fn add( - &mut self, start_addr: SBAddress, end_addr: SBAddress, instructions: SBInstructionList, + &mut self, + start_addr: SBAddress, + end_addr: SBAddress, + instructions: SBInstructionList, ) -> Rc { let handle = Handle::new((self.by_handle.len() + 1000) as u32).unwrap(); let instruction_addrs = instructions.iter().map(|i| i.address().load_address(&self.target)).collect(); diff --git a/adapter2/src/wire_protocol.rs b/adapter2/src/wire_protocol.rs index 9ec99900..61ee222c 100644 --- a/adapter2/src/wire_protocol.rs +++ b/adapter2/src/wire_protocol.rs @@ -1,8 +1,8 @@ use bytes::BytesMut; use log::{debug, error, info}; use std::fmt::Write; -use std::str; use std::io; +use std::str; use tokio_util::codec; use crate::debug_protocol::ProtocolMessage; @@ -59,9 +59,7 @@ impl codec::Decoder for Codec { debug!("--> {}", str::from_utf8(&message_bytes).unwrap()); match serde_json::from_slice(&message_bytes) { - Ok(message) => { - return Ok(Some(message)) - } + Ok(message) => return Ok(Some(message)), Err(err) => { error!("Could not deserialize: {}", err); return Err(io::Error::new(io::ErrorKind::InvalidData, Box::new(err))); diff --git a/rustfmt.toml b/rustfmt.toml index e0b4a1e1..a547fa89 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,2 @@ max_width = 120 -fn_args_density = "Compressed" use_small_heuristics = "Off"