Fix a bunch of other low-hanging style lints (#36498)
- **Fix a bunch of low hanging style lints like unnecessary-return** - **Fix single worktree violation** - **And the rest** Release Notes: - N/A
This commit is contained in:
@@ -49,7 +49,7 @@ fn parse_pci_id(id: &str) -> anyhow::Result<u32> {
|
||||
"Expected a 4 digit PCI ID in hexadecimal format"
|
||||
);
|
||||
|
||||
return u32::from_str_radix(id, 16).context("parsing PCI ID as hex");
|
||||
u32::from_str_radix(id, 16).context("parsing PCI ID as hex")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -441,7 +441,7 @@ impl<P: LinuxClient + 'static> Platform for P {
|
||||
fn app_path(&self) -> Result<PathBuf> {
|
||||
// get the path of the executable of the current process
|
||||
let app_path = env::current_exe()?;
|
||||
return Ok(app_path);
|
||||
Ok(app_path)
|
||||
}
|
||||
|
||||
fn set_menus(&self, menus: Vec<Menu>, _keymap: &Keymap) {
|
||||
|
||||
@@ -710,9 +710,7 @@ impl LinuxClient for WaylandClient {
|
||||
fn set_cursor_style(&self, style: CursorStyle) {
|
||||
let mut state = self.0.borrow_mut();
|
||||
|
||||
let need_update = state
|
||||
.cursor_style
|
||||
.map_or(true, |current_style| current_style != style);
|
||||
let need_update = state.cursor_style != Some(style);
|
||||
|
||||
if need_update {
|
||||
let serial = state.serial_tracker.get(SerialKind::MouseEnter);
|
||||
@@ -1577,7 +1575,7 @@ impl Dispatch<wl_pointer::WlPointer, ()> for WaylandClientStatePtr {
|
||||
if state
|
||||
.keyboard_focused_window
|
||||
.as_ref()
|
||||
.map_or(false, |keyboard_window| window.ptr_eq(keyboard_window))
|
||||
.is_some_and(|keyboard_window| window.ptr_eq(keyboard_window))
|
||||
{
|
||||
state.enter_token = None;
|
||||
}
|
||||
|
||||
@@ -669,8 +669,8 @@ impl WaylandWindowStatePtr {
|
||||
pub fn set_size_and_scale(&self, size: Option<Size<Pixels>>, scale: Option<f32>) {
|
||||
let (size, scale) = {
|
||||
let mut state = self.state.borrow_mut();
|
||||
if size.map_or(true, |size| size == state.bounds.size)
|
||||
&& scale.map_or(true, |scale| scale == state.scale)
|
||||
if size.is_none_or(|size| size == state.bounds.size)
|
||||
&& scale.is_none_or(|scale| scale == state.scale)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1586,11 +1586,11 @@ impl LinuxClient for X11Client {
|
||||
|
||||
fn read_from_primary(&self) -> Option<crate::ClipboardItem> {
|
||||
let state = self.0.borrow_mut();
|
||||
return state
|
||||
state
|
||||
.clipboard
|
||||
.get_any(clipboard::ClipboardKind::Primary)
|
||||
.context("X11: Failed to read from clipboard (primary)")
|
||||
.log_with_level(log::Level::Debug);
|
||||
.log_with_level(log::Level::Debug)
|
||||
}
|
||||
|
||||
fn read_from_clipboard(&self) -> Option<crate::ClipboardItem> {
|
||||
@@ -1603,11 +1603,11 @@ impl LinuxClient for X11Client {
|
||||
{
|
||||
return state.clipboard_item.clone();
|
||||
}
|
||||
return state
|
||||
state
|
||||
.clipboard
|
||||
.get_any(clipboard::ClipboardKind::Clipboard)
|
||||
.context("X11: Failed to read from clipboard (clipboard)")
|
||||
.log_with_level(log::Level::Debug);
|
||||
.log_with_level(log::Level::Debug)
|
||||
}
|
||||
|
||||
fn run(&self) {
|
||||
@@ -2010,12 +2010,12 @@ fn check_gtk_frame_extents_supported(
|
||||
}
|
||||
|
||||
fn xdnd_is_atom_supported(atom: u32, atoms: &XcbAtoms) -> bool {
|
||||
return atom == atoms.TEXT
|
||||
atom == atoms.TEXT
|
||||
|| atom == atoms.STRING
|
||||
|| atom == atoms.UTF8_STRING
|
||||
|| atom == atoms.TEXT_PLAIN
|
||||
|| atom == atoms.TEXT_PLAIN_UTF8
|
||||
|| atom == atoms.TextUriList;
|
||||
|| atom == atoms.TextUriList
|
||||
}
|
||||
|
||||
fn xdnd_get_supported_atom(
|
||||
@@ -2043,7 +2043,7 @@ fn xdnd_get_supported_atom(
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
0
|
||||
}
|
||||
|
||||
fn xdnd_send_finished(
|
||||
@@ -2144,7 +2144,7 @@ fn current_pointer_device_states(
|
||||
if pointer_device_states.is_empty() {
|
||||
log::error!("Found no xinput mouse pointers.");
|
||||
}
|
||||
return Some(pointer_device_states);
|
||||
Some(pointer_device_states)
|
||||
}
|
||||
|
||||
/// Returns true if the device is a pointer device. Does not include pointer device groups.
|
||||
|
||||
@@ -1078,11 +1078,11 @@ impl Clipboard {
|
||||
} else {
|
||||
String::from_utf8(result.bytes).map_err(|_| Error::ConversionFailure)?
|
||||
};
|
||||
return Ok(ClipboardItem::new_string(text));
|
||||
Ok(ClipboardItem::new_string(text))
|
||||
}
|
||||
|
||||
pub fn is_owner(&self, selection: ClipboardKind) -> bool {
|
||||
return self.inner.is_owner(selection).unwrap_or(false);
|
||||
self.inner.is_owner(selection).unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ fn bit_is_set_in_vec(bit_vec: &Vec<u32>, bit_index: u16) -> bool {
|
||||
let array_index = bit_index as usize / 32;
|
||||
bit_vec
|
||||
.get(array_index)
|
||||
.map_or(false, |bits| bit_is_set(*bits, bit_index % 32))
|
||||
.is_some_and(|bits| bit_is_set(*bits, bit_index % 32))
|
||||
}
|
||||
|
||||
fn bit_is_set(bits: u32, bit_index: u16) -> bool {
|
||||
|
||||
@@ -311,9 +311,8 @@ unsafe fn parse_keystroke(native_event: id) -> Keystroke {
|
||||
let mut shift = modifiers.contains(NSEventModifierFlags::NSShiftKeyMask);
|
||||
let command = modifiers.contains(NSEventModifierFlags::NSCommandKeyMask);
|
||||
let function = modifiers.contains(NSEventModifierFlags::NSFunctionKeyMask)
|
||||
&& first_char.map_or(true, |ch| {
|
||||
!(NSUpArrowFunctionKey..=NSModeSwitchFunctionKey).contains(&ch)
|
||||
});
|
||||
&& first_char
|
||||
.is_none_or(|ch| !(NSUpArrowFunctionKey..=NSModeSwitchFunctionKey).contains(&ch));
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
let key = match first_char {
|
||||
|
||||
@@ -797,7 +797,7 @@ impl Platform for MacPlatform {
|
||||
.to_owned();
|
||||
result.set_file_name(&new_filename);
|
||||
}
|
||||
return result;
|
||||
result
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ impl MacTextSystemState {
|
||||
fn is_emoji(&self, font_id: FontId) -> bool {
|
||||
self.postscript_names_by_font_id
|
||||
.get(&font_id)
|
||||
.map_or(false, |postscript_name| {
|
||||
.is_some_and(|postscript_name| {
|
||||
postscript_name == "AppleColorEmoji" || postscript_name == ".AppleColorEmojiUI"
|
||||
})
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ impl MacWindow {
|
||||
.and_then(|titlebar| titlebar.traffic_light_position),
|
||||
transparent_titlebar: titlebar
|
||||
.as_ref()
|
||||
.map_or(true, |titlebar| titlebar.appears_transparent),
|
||||
.is_none_or(|titlebar| titlebar.appears_transparent),
|
||||
previous_modifiers_changed_event: None,
|
||||
keystroke_for_do_command: None,
|
||||
do_command_handled: None,
|
||||
@@ -688,7 +688,7 @@ impl MacWindow {
|
||||
});
|
||||
}
|
||||
|
||||
if titlebar.map_or(true, |titlebar| titlebar.appears_transparent) {
|
||||
if titlebar.is_none_or(|titlebar| titlebar.appears_transparent) {
|
||||
native_window.setTitlebarAppearsTransparent_(YES);
|
||||
native_window.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden);
|
||||
}
|
||||
|
||||
@@ -270,9 +270,7 @@ impl PlatformDispatcher for TestDispatcher {
|
||||
fn dispatch(&self, runnable: Runnable, label: Option<TaskLabel>) {
|
||||
{
|
||||
let mut state = self.state.lock();
|
||||
if label.map_or(false, |label| {
|
||||
state.deprioritized_task_labels.contains(&label)
|
||||
}) {
|
||||
if label.is_some_and(|label| state.deprioritized_task_labels.contains(&label)) {
|
||||
state.deprioritized_background.push(runnable);
|
||||
} else {
|
||||
state.background.push(runnable);
|
||||
|
||||
Reference in New Issue
Block a user