Another batch of lint fixes (#36521)

- **Enable a bunch of extra lints**
- **First batch of fixes**
- **More fixes**

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 22:33:44 +02:00 committed by GitHub
parent 69b1c6d6f5
commit 6825715503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 788 additions and 1042 deletions

View file

@ -1707,8 +1707,8 @@ impl App {
.unwrap_or_else(|| {
is_first = true;
let future = A::load(source.clone(), self);
let task = self.background_executor().spawn(future).shared();
task
self.background_executor().spawn(future).shared()
});
self.loading_assets.insert(asset_id, Box::new(task.clone()));

View file

@ -326,7 +326,7 @@ impl TextLayout {
vec![text_style.to_run(text.len())]
};
let layout_id = window.request_measured_layout(Default::default(), {
window.request_measured_layout(Default::default(), {
let element_state = self.clone();
move |known_dimensions, available_space, window, cx| {
@ -416,9 +416,7 @@ impl TextLayout {
size
}
});
layout_id
})
}
fn prepaint(&self, bounds: Bounds<Pixels>, text: &str) {

View file

@ -949,11 +949,8 @@ impl Dispatch<WlCallback, ObjectId> for WaylandClientStatePtr {
};
drop(state);
match event {
wl_callback::Event::Done { .. } => {
window.frame();
}
_ => {}
if let wl_callback::Event::Done { .. } = event {
window.frame();
}
}
}
@ -2014,25 +2011,22 @@ impl Dispatch<wl_data_offer::WlDataOffer, ()> for WaylandClientStatePtr {
let client = this.get_client();
let mut state = client.borrow_mut();
match event {
wl_data_offer::Event::Offer { mime_type } => {
// Drag and drop
if mime_type == FILE_LIST_MIME_TYPE {
let serial = state.serial_tracker.get(SerialKind::DataDevice);
let mime_type = mime_type.clone();
data_offer.accept(serial, Some(mime_type));
}
// Clipboard
if let Some(offer) = state
.data_offers
.iter_mut()
.find(|wrapper| wrapper.inner.id() == data_offer.id())
{
offer.add_mime_type(mime_type);
}
if let wl_data_offer::Event::Offer { mime_type } = event {
// Drag and drop
if mime_type == FILE_LIST_MIME_TYPE {
let serial = state.serial_tracker.get(SerialKind::DataDevice);
let mime_type = mime_type.clone();
data_offer.accept(serial, Some(mime_type));
}
// Clipboard
if let Some(offer) = state
.data_offers
.iter_mut()
.find(|wrapper| wrapper.inner.id() == data_offer.id())
{
offer.add_mime_type(mime_type);
}
_ => {}
}
}
}
@ -2113,13 +2107,10 @@ impl Dispatch<zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1, ()>
let client = this.get_client();
let mut state = client.borrow_mut();
match event {
zwp_primary_selection_offer_v1::Event::Offer { mime_type } => {
if let Some(offer) = state.primary_data_offer.as_mut() {
offer.add_mime_type(mime_type);
}
}
_ => {}
if let zwp_primary_selection_offer_v1::Event::Offer { mime_type } = event
&& let Some(offer) = state.primary_data_offer.as_mut()
{
offer.add_mime_type(mime_type);
}
}
}

View file

@ -355,85 +355,82 @@ impl WaylandWindowStatePtr {
}
pub fn handle_xdg_surface_event(&self, event: xdg_surface::Event) {
match event {
xdg_surface::Event::Configure { serial } => {
{
let mut state = self.state.borrow_mut();
if let Some(window_controls) = state.in_progress_window_controls.take() {
state.window_controls = window_controls;
drop(state);
let mut callbacks = self.callbacks.borrow_mut();
if let Some(appearance_changed) = callbacks.appearance_changed.as_mut() {
appearance_changed();
}
}
}
{
let mut state = self.state.borrow_mut();
if let Some(mut configure) = state.in_progress_configure.take() {
let got_unmaximized = state.maximized && !configure.maximized;
state.fullscreen = configure.fullscreen;
state.maximized = configure.maximized;
state.tiling = configure.tiling;
// Limit interactive resizes to once per vblank
if configure.resizing && state.resize_throttle {
return;
} else if configure.resizing {
state.resize_throttle = true;
}
if !configure.fullscreen && !configure.maximized {
configure.size = if got_unmaximized {
Some(state.window_bounds.size)
} else {
compute_outer_size(state.inset(), configure.size, state.tiling)
};
if let Some(size) = configure.size {
state.window_bounds = Bounds {
origin: Point::default(),
size,
};
}
}
drop(state);
if let Some(size) = configure.size {
self.resize(size);
}
}
}
if let xdg_surface::Event::Configure { serial } = event {
{
let mut state = self.state.borrow_mut();
state.xdg_surface.ack_configure(serial);
if let Some(window_controls) = state.in_progress_window_controls.take() {
state.window_controls = window_controls;
let window_geometry = inset_by_tiling(
state.bounds.map_origin(|_| px(0.0)),
state.inset(),
state.tiling,
)
.map(|v| v.0 as i32)
.map_size(|v| if v <= 0 { 1 } else { v });
state.xdg_surface.set_window_geometry(
window_geometry.origin.x,
window_geometry.origin.y,
window_geometry.size.width,
window_geometry.size.height,
);
let request_frame_callback = !state.acknowledged_first_configure;
if request_frame_callback {
state.acknowledged_first_configure = true;
drop(state);
self.frame();
let mut callbacks = self.callbacks.borrow_mut();
if let Some(appearance_changed) = callbacks.appearance_changed.as_mut() {
appearance_changed();
}
}
}
_ => {}
{
let mut state = self.state.borrow_mut();
if let Some(mut configure) = state.in_progress_configure.take() {
let got_unmaximized = state.maximized && !configure.maximized;
state.fullscreen = configure.fullscreen;
state.maximized = configure.maximized;
state.tiling = configure.tiling;
// Limit interactive resizes to once per vblank
if configure.resizing && state.resize_throttle {
return;
} else if configure.resizing {
state.resize_throttle = true;
}
if !configure.fullscreen && !configure.maximized {
configure.size = if got_unmaximized {
Some(state.window_bounds.size)
} else {
compute_outer_size(state.inset(), configure.size, state.tiling)
};
if let Some(size) = configure.size {
state.window_bounds = Bounds {
origin: Point::default(),
size,
};
}
}
drop(state);
if let Some(size) = configure.size {
self.resize(size);
}
}
}
let mut state = self.state.borrow_mut();
state.xdg_surface.ack_configure(serial);
let window_geometry = inset_by_tiling(
state.bounds.map_origin(|_| px(0.0)),
state.inset(),
state.tiling,
)
.map(|v| v.0 as i32)
.map_size(|v| if v <= 0 { 1 } else { v });
state.xdg_surface.set_window_geometry(
window_geometry.origin.x,
window_geometry.origin.y,
window_geometry.size.width,
window_geometry.size.height,
);
let request_frame_callback = !state.acknowledged_first_configure;
if request_frame_callback {
state.acknowledged_first_configure = true;
drop(state);
self.frame();
}
}
}
pub fn handle_toplevel_decoration_event(&self, event: zxdg_toplevel_decoration_v1::Event) {
match event {
zxdg_toplevel_decoration_v1::Event::Configure { mode } => match mode {
if let zxdg_toplevel_decoration_v1::Event::Configure { mode } = event {
match mode {
WEnum::Value(zxdg_toplevel_decoration_v1::Mode::ServerSide) => {
self.state.borrow_mut().decorations = WindowDecorations::Server;
if let Some(mut appearance_changed) =
@ -457,17 +454,13 @@ impl WaylandWindowStatePtr {
WEnum::Unknown(v) => {
log::warn!("Unknown decoration mode: {}", v);
}
},
_ => {}
}
}
}
pub fn handle_fractional_scale_event(&self, event: wp_fractional_scale_v1::Event) {
match event {
wp_fractional_scale_v1::Event::PreferredScale { scale } => {
self.rescale(scale as f32 / 120.0);
}
_ => {}
if let wp_fractional_scale_v1::Event::PreferredScale { scale } = event {
self.rescale(scale as f32 / 120.0);
}
}

View file

@ -232,15 +232,12 @@ impl X11ClientStatePtr {
};
let mut state = client.0.borrow_mut();
if let Some(window_ref) = state.windows.remove(&x_window) {
match window_ref.refresh_state {
Some(RefreshState::PeriodicRefresh {
event_loop_token, ..
}) => {
state.loop_handle.remove(event_loop_token);
}
_ => {}
}
if let Some(window_ref) = state.windows.remove(&x_window)
&& let Some(RefreshState::PeriodicRefresh {
event_loop_token, ..
}) = window_ref.refresh_state
{
state.loop_handle.remove(event_loop_token);
}
if state.mouse_focused_window == Some(x_window) {
state.mouse_focused_window = None;
@ -876,22 +873,19 @@ impl X11Client {
let Some(reply) = reply else {
return Some(());
};
match str::from_utf8(&reply.value) {
Ok(file_list) => {
let paths: SmallVec<[_; 2]> = file_list
.lines()
.filter_map(|path| Url::parse(path).log_err())
.filter_map(|url| url.to_file_path().log_err())
.collect();
let input = PlatformInput::FileDrop(FileDropEvent::Entered {
position: state.xdnd_state.position,
paths: crate::ExternalPaths(paths),
});
drop(state);
window.handle_input(input);
self.0.borrow_mut().xdnd_state.retrieved = true;
}
Err(_) => {}
if let Ok(file_list) = str::from_utf8(&reply.value) {
let paths: SmallVec<[_; 2]> = file_list
.lines()
.filter_map(|path| Url::parse(path).log_err())
.filter_map(|url| url.to_file_path().log_err())
.collect();
let input = PlatformInput::FileDrop(FileDropEvent::Entered {
position: state.xdnd_state.position,
paths: crate::ExternalPaths(paths),
});
drop(state);
window.handle_input(input);
self.0.borrow_mut().xdnd_state.retrieved = true;
}
}
Event::ConfigureNotify(event) => {

View file

@ -426,7 +426,7 @@ unsafe fn parse_keystroke(native_event: id) -> Keystroke {
key_char = Some(chars_for_modified_key(native_event.keyCode(), mods));
}
let mut key = if shift
if shift
&& chars_ignoring_modifiers
.chars()
.all(|c| c.is_ascii_lowercase())
@ -437,9 +437,7 @@ unsafe fn parse_keystroke(native_event: id) -> Keystroke {
chars_with_shift
} else {
chars_ignoring_modifiers
};
key
}
}
};

View file

@ -2063,8 +2063,8 @@ fn screen_point_to_gpui_point(this: &Object, position: NSPoint) -> Point<Pixels>
let frame = get_frame(this);
let window_x = position.x - frame.origin.x;
let window_y = frame.size.height - (position.y - frame.origin.y);
let position = point(px(window_x as f32), px(window_y as f32));
position
point(px(window_x as f32), px(window_y as f32))
}
extern "C" fn dragging_entered(this: &Object, _: Sel, dragging_info: id) -> NSDragOperation {

View file

@ -228,7 +228,7 @@ fn run_capture(
display,
size,
}));
if let Err(_) = stream_send_result {
if stream_send_result.is_err() {
return;
}
while !cancel_stream.load(std::sync::atomic::Ordering::SeqCst) {

View file

@ -1128,22 +1128,19 @@ impl WindowsWindowInner {
&& let Some(parameter_string) = unsafe { parameter.to_string() }.log_err()
{
log::info!("System settings changed: {}", parameter_string);
match parameter_string.as_str() {
"ImmersiveColorSet" => {
let new_appearance = system_appearance()
.context("unable to get system appearance when handling ImmersiveColorSet")
.log_err()?;
let mut lock = self.state.borrow_mut();
if new_appearance != lock.appearance {
lock.appearance = new_appearance;
let mut callback = lock.callbacks.appearance_changed.take()?;
drop(lock);
callback();
self.state.borrow_mut().callbacks.appearance_changed = Some(callback);
configure_dwm_dark_mode(handle, new_appearance);
}
if parameter_string.as_str() == "ImmersiveColorSet" {
let new_appearance = system_appearance()
.context("unable to get system appearance when handling ImmersiveColorSet")
.log_err()?;
let mut lock = self.state.borrow_mut();
if new_appearance != lock.appearance {
lock.appearance = new_appearance;
let mut callback = lock.callbacks.appearance_changed.take()?;
drop(lock);
callback();
self.state.borrow_mut().callbacks.appearance_changed = Some(callback);
configure_dwm_dark_mode(handle, new_appearance);
}
_ => {}
}
}
Some(0)
@ -1469,7 +1466,7 @@ pub(crate) fn current_modifiers() -> Modifiers {
#[inline]
pub(crate) fn current_capslock() -> Capslock {
let on = unsafe { GetKeyState(VK_CAPITAL.0 as i32) & 1 } > 0;
Capslock { on: on }
Capslock { on }
}
fn get_client_area_insets(

View file

@ -58,23 +58,21 @@ impl TaffyLayoutEngine {
children: &[LayoutId],
) -> LayoutId {
let taffy_style = style.to_taffy(rem_size);
let layout_id = if children.is_empty() {
if children.is_empty() {
self.taffy
.new_leaf(taffy_style)
.expect(EXPECT_MESSAGE)
.into()
} else {
let parent_id = self
.taffy
self.taffy
// This is safe because LayoutId is repr(transparent) to taffy::tree::NodeId.
.new_with_children(taffy_style, unsafe {
std::mem::transmute::<&[LayoutId], &[taffy::NodeId]>(children)
})
.expect(EXPECT_MESSAGE)
.into();
parent_id
};
layout_id
.into()
}
}
pub fn request_measured_layout(
@ -91,8 +89,7 @@ impl TaffyLayoutEngine {
) -> LayoutId {
let taffy_style = style.to_taffy(rem_size);
let layout_id = self
.taffy
self.taffy
.new_leaf_with_context(
taffy_style,
NodeContext {
@ -100,8 +97,7 @@ impl TaffyLayoutEngine {
},
)
.expect(EXPECT_MESSAGE)
.into();
layout_id
.into()
}
// Used to understand performance

View file

@ -44,7 +44,7 @@ impl LineWrapper {
let mut prev_c = '\0';
let mut index = 0;
let mut candidates = fragments
.into_iter()
.iter()
.flat_map(move |fragment| fragment.wrap_boundary_candidates())
.peekable();
iter::from_fn(move || {

View file

@ -58,13 +58,7 @@ pub trait FluentBuilder {
where
Self: Sized,
{
self.map(|this| {
if let Some(_) = option {
this
} else {
then(this)
}
})
self.map(|this| if option.is_some() { this } else { then(this) })
}
}