fix unnecessary cast lint (#2596)

* fix clippy lints on Windows

* fix lints on other platforms

* a couple more

* again

* don't know what's goging on anymore

* fix examples

* comon

* how about now?

* this is getting annoying

* hmmm

* explicitly set a type

* 😢

* don't cast on x64 targets

* apply code review requests

* fix attributes on expressions

* fix ios
This commit is contained in:
Amr Bashir 2022-12-22 21:35:33 +02:00 committed by GitHub
parent da7422c6e1
commit 402cbd55f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 63 additions and 64 deletions

View file

@ -65,7 +65,7 @@ pub fn get_monitor_dpi(hmonitor: HMONITOR) -> Option<u32> {
// MSDN says that "the values of *dpiX and *dpiY are identical. You only need to
// record one of the values to determine the DPI and respond appropriately".
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn280510(v=vs.85).aspx
return Some(dpi_x as u32);
return Some(dpi_x);
}
}
}
@ -86,7 +86,7 @@ pub unsafe fn hwnd_dpi(hwnd: HWND) -> u32 {
// We are on Windows 10 Anniversary Update (1607) or later.
match GetDpiForWindow(hwnd) {
0 => BASE_DPI, // 0 is returned if hwnd is invalid
dpi => dpi as u32,
dpi => dpi,
}
} else if let Some(GetDpiForMonitor) = *GET_DPI_FOR_MONITOR {
// We are on Windows 8.1 or later.
@ -98,7 +98,7 @@ pub unsafe fn hwnd_dpi(hwnd: HWND) -> u32 {
let mut dpi_x = 0;
let mut dpi_y = 0;
if GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &mut dpi_x, &mut dpi_y) == S_OK {
dpi_x as u32
dpi_x
} else {
BASE_DPI
}

View file

@ -169,7 +169,7 @@ impl FileDropHandler {
let drop_format = FORMATETC {
cfFormat: CF_HDROP as u16,
ptd: ptr::null_mut(),
dwAspect: DVASPECT_CONTENT as u32,
dwAspect: DVASPECT_CONTENT,
lindex: -1,
tymed: TYMED_HGLOBAL as u32,
};

View file

@ -1151,8 +1151,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
let windowpos = lparam as *const WINDOWPOS;
if (*windowpos).flags & SWP_NOMOVE != SWP_NOMOVE {
let physical_position =
PhysicalPosition::new((*windowpos).x as i32, (*windowpos).y as i32);
let physical_position = PhysicalPosition::new((*windowpos).x, (*windowpos).y);
userdata.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),
event: Moved(physical_position),
@ -2437,7 +2436,7 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
0
}
_ if msg == *EXEC_MSG_ID => {
let mut function: ThreadExecFn = Box::from_raw(wparam as usize as *mut _);
let mut function: ThreadExecFn = Box::from_raw(wparam as *mut _);
function();
0
}

View file

@ -90,8 +90,8 @@ impl WinIcon {
0,
wide_path.as_ptr(),
IMAGE_ICON,
width as i32,
height as i32,
width,
height,
LR_DEFAULTSIZE | LR_LOADFROMFILE,
)
};
@ -113,8 +113,8 @@ impl WinIcon {
util::get_instance_handle(),
resource_id as PCWSTR,
IMAGE_ICON,
width as i32,
height as i32,
width,
height,
LR_DEFAULTSIZE,
)
};

View file

@ -241,7 +241,7 @@ impl MonitorHandle {
i += 1;
const REQUIRED_FIELDS: u32 =
(DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY) as u32;
DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
assert!(has_flag(mode.dmFields, REQUIRED_FIELDS));
// Use Ord impl of RootVideoMode
@ -249,7 +249,7 @@ impl MonitorHandle {
video_mode: VideoMode {
size: (mode.dmPelsWidth, mode.dmPelsHeight),
bit_depth: mode.dmBitsPerPel as u16,
refresh_rate_millihertz: mode.dmDisplayFrequency as u32 * 1000,
refresh_rate_millihertz: mode.dmDisplayFrequency * 1000,
monitor: self.clone(),
native_video_mode: Box::new(mode),
},

View file

@ -140,7 +140,7 @@ impl Window {
#[inline]
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
util::WindowArea::Outer.get_rect(self.hwnd())
.map(|rect| Ok(PhysicalPosition::new(rect.left as i32, rect.top as i32)))
.map(|rect| Ok(PhysicalPosition::new(rect.left, rect.top)))
.expect("Unexpected GetWindowRect failure; please report this error to https://github.com/rust-windowing/winit")
}
@ -150,7 +150,7 @@ impl Window {
if unsafe { ClientToScreen(self.hwnd(), &mut position) } == false.into() {
panic!("Unexpected ClientToScreen failure: please report this error to https://github.com/rust-windowing/winit")
}
Ok(PhysicalPosition::new(position.x as i32, position.y as i32))
Ok(PhysicalPosition::new(position.x, position.y))
}
#[inline]