diff --git a/dpi/src/libm.rs b/dpi/src/libm.rs index 1785b67f21..654c4bef47 100644 --- a/dpi/src/libm.rs +++ b/dpi/src/libm.rs @@ -23,7 +23,7 @@ pub(crate) fn round(x: f64) -> f64 { } // Adapted from: https://github.com/rust-lang/libm/blob/libm-v0.2.11/src/math/trunc.rs#L8-L12 -#[allow(clippy::needless_late_init /*, reason = "The original libm code uses this style" */)] +#[expect(clippy::needless_late_init, reason = "The original libm code uses this style")] fn trunc(x: f64) -> f64 { let x1p120 = f64::from_bits(0x4770000000000000); // 0x1p120f === 2 ^ 120 diff --git a/winit-android/src/event_loop.rs b/winit-android/src/event_loop.rs index 62895a34d2..6e9b7b9a03 100644 --- a/winit-android/src/event_loop.rs +++ b/winit-android/src/event_loop.rs @@ -789,7 +789,7 @@ impl Window { } // Allow the usage of HasRawWindowHandle inside this function - #[allow(deprecated)] + #[expect(deprecated)] fn raw_window_handle_rwh_06(&self) -> Result { use rwh_06::HasRawWindowHandle; diff --git a/winit-appkit/src/app.rs b/winit-appkit/src/app.rs index 25cd38392a..7d268f9c17 100644 --- a/winit-appkit/src/app.rs +++ b/winit-appkit/src/app.rs @@ -99,7 +99,6 @@ pub(crate) fn override_send_event(global_app: &NSApplication) { fn maybe_dispatch_device_event(app_state: &Rc, event: &NSEvent) { let event_type = event.r#type(); - #[allow(non_upper_case_globals)] match event_type { NSEventType::MouseMoved | NSEventType::LeftMouseDragged diff --git a/winit-appkit/src/app_state.rs b/winit-appkit/src/app_state.rs index bea2472eb4..cdf70602ac 100644 --- a/winit-appkit/src/app_state.rs +++ b/winit-appkit/src/app_state.rs @@ -123,7 +123,7 @@ impl AppState { } } - #[allow(deprecated)] + #[expect(deprecated, reason = "winit feature")] app.activateIgnoringOtherApps(self.activate_ignoring_other_apps); if self.default_menu { diff --git a/winit-appkit/src/cursor.rs b/winit-appkit/src/cursor.rs index 9c86c55db7..731dc48c45 100644 --- a/winit-appkit/src/cursor.rs +++ b/winit-appkit/src/cursor.rs @@ -138,7 +138,7 @@ unsafe fn load_webkit_cursor(name: &NSString) -> Retained { // TODO: Handle PLists better let info_path = cursor_path.stringByAppendingPathComponent(ns_string!("info.plist")); - #[allow(deprecated)] + #[expect(deprecated)] let info: Retained> = unsafe { NSDictionary::dictionaryWithContentsOfFile(&info_path) }.unwrap(); let mut x = 0.0; @@ -190,7 +190,7 @@ pub(crate) fn invisible_cursor() -> Retained { CURSOR.get_or_init(|| CustomCursor(new_invisible())).0.clone() } -#[allow(deprecated)] +#[expect(deprecated)] pub(crate) fn cursor_from_icon(icon: CursorIcon) -> Retained { match icon { CursorIcon::Default => default_cursor(), diff --git a/winit-appkit/src/ffi.rs b/winit-appkit/src/ffi.rs index 7f7cec0bfb..4322dc235d 100644 --- a/winit-appkit/src/ffi.rs +++ b/winit-appkit/src/ffi.rs @@ -54,16 +54,15 @@ pub type UniCharCount = std::os::raw::c_ulong; pub type UniChar = std::os::raw::c_ushort; pub type OSStatus = i32; -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] pub const kUCKeyActionDisplay: u16 = 3; -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] pub const kUCKeyTranslateNoDeadKeysMask: OptionBits = 1; #[link(name = "Carbon", kind = "framework")] unsafe extern "C" { pub static kTISPropertyUnicodeKeyLayoutData: &'static CFString; - #[allow(non_snake_case)] pub fn TISGetInputSourceProperty( inputSource: &TISInputSource, propertyKey: &CFString, @@ -73,7 +72,6 @@ unsafe extern "C" { pub fn LMGetKbdType() -> u8; - #[allow(non_snake_case)] pub fn UCKeyTranslate( keyLayoutPtr: *const UCKeyboardLayout, virtualKeyCode: u16, diff --git a/winit-appkit/src/monitor.rs b/winit-appkit/src/monitor.rs index d40b854e76..d9cbce9ff2 100644 --- a/winit-appkit/src/monitor.rs +++ b/winit-appkit/src/monitor.rs @@ -66,7 +66,7 @@ impl VideoModeHandle { refresh_rate_millihertz: Option, ) -> Self { // The bit-depth is basically always 32 since macOS 10.12. - #[allow(deprecated)] + #[expect(deprecated)] let pixel_encoding = CGDisplayMode::pixel_encoding(Some(&native_mode.0)).unwrap().to_string(); let bit_depth = if pixel_encoding.eq_ignore_ascii_case(ffi::IO32BitDirectPixels) { @@ -325,14 +325,14 @@ fn refresh_rate_millihertz(id: CGDirectDisplayID, mode: &NativeDisplayMode) -> O } let mut display_link = std::ptr::null_mut(); - #[allow(deprecated)] + #[expect(deprecated)] if unsafe { CVDisplayLink::create_with_cg_display(id, NonNull::from(&mut display_link)) } != kCVReturnSuccess { return None; } let display_link = unsafe { CFRetained::from_raw(NonNull::new(display_link).unwrap()) }; - #[allow(deprecated)] + #[expect(deprecated)] let time = display_link.nominal_output_video_refresh_period(); // This value is indefinite if an invalid display link was specified diff --git a/winit-appkit/src/view.rs b/winit-appkit/src/view.rs index 056ec93a2d..d950f79c22 100644 --- a/winit-appkit/src/view.rs +++ b/winit-appkit/src/view.rs @@ -1,4 +1,4 @@ -#![allow(clippy::unnecessary_cast)] +#![expect(clippy::unnecessary_cast)] use std::cell::{Cell, RefCell}; use std::collections::{HashMap, VecDeque}; use std::ptr; @@ -694,7 +694,6 @@ define_class!( // be mutually exclusive anyhow, which is why the API is rather incoherent). If no // momentum phase is recorded (or rather, the started/ended cases of the // momentum phase) then we report the touch phase. - #[allow(non_upper_case_globals)] let phase = match event.momentumPhase() { NSEventPhase::MayBegin | NSEventPhase::Began => TouchPhase::Started, NSEventPhase::Ended | NSEventPhase::Cancelled => TouchPhase::Ended, @@ -719,7 +718,6 @@ define_class!( self.mouse_motion(event); - #[allow(non_upper_case_globals)] let phase = match event.phase() { NSEventPhase::Began => TouchPhase::Started, NSEventPhase::Changed => TouchPhase::Moved, @@ -750,7 +748,6 @@ define_class!( self.mouse_motion(event); - #[allow(non_upper_case_globals)] let phase = match event.phase() { NSEventPhase::Began => TouchPhase::Started, NSEventPhase::Changed => TouchPhase::Moved, diff --git a/winit-appkit/src/window_delegate.rs b/winit-appkit/src/window_delegate.rs index cdf198d17c..133c5b4446 100644 --- a/winit-appkit/src/window_delegate.rs +++ b/winit-appkit/src/window_delegate.rs @@ -25,7 +25,7 @@ use objc2_app_kit::{ NSWindowSharingType, NSWindowStyleMask, NSWindowTabbingMode, NSWindowTitleVisibility, NSWindowToolbarStyle, }; -#[allow(deprecated)] +#[expect(deprecated)] use objc2_app_kit::{NSFilenamesPboardType, NSWindowFullScreenButton}; use objc2_core_foundation::{CGFloat, CGPoint}; use objc2_core_graphics::{ @@ -368,7 +368,7 @@ define_class!( let pb = sender.draggingPasteboard(); - #[allow(deprecated)] + #[expect(deprecated)] let property_list = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) { Some(property_list) => property_list, None => return false.into(), @@ -429,7 +429,7 @@ define_class!( let pb = sender.draggingPasteboard(); - #[allow(deprecated)] + #[expect(deprecated)] let property_list = match pb.propertyListForType(unsafe { NSFilenamesPboardType }) { Some(property_list) => property_list, None => return false.into(), @@ -673,7 +673,7 @@ fn new_window( } if macos_attrs.titlebar_buttons_hidden { for titlebar_button in &[ - #[allow(deprecated)] + #[expect(deprecated)] NSWindowFullScreenButton, NSWindowButton::MiniaturizeButton, NSWindowButton::CloseButton, @@ -717,7 +717,7 @@ fn new_window( // The default value of `setWantsBestResolutionOpenGLSurface:` was `false` until // macos 10.14 and `true` after 10.15, we should set it to `YES` or `NO` to avoid // always the default system value in favour of the user's code - #[allow(deprecated)] + #[expect(deprecated)] view.setWantsBestResolutionOpenGLSurface(!macos_attrs.disallow_hidpi); // On Mojave, views automatically become layer-backed shortly after being added to @@ -757,7 +757,7 @@ fn new_window( } // register for drag and drop operations. - #[allow(deprecated)] + #[expect(deprecated)] window.registerForDraggedTypes(&NSArray::from_slice(&[unsafe { NSFilenamesPboardType }])); Some(window) @@ -1729,7 +1729,7 @@ impl WindowDelegate { let is_visible = self.window().isVisible(); if !is_minimized && is_visible { - #[allow(deprecated)] + #[expect(deprecated)] NSApplication::sharedApplication(mtm).activateIgnoringOtherApps(true); self.window().makeKeyAndOrderFront(None); } diff --git a/winit-common/src/xkb/keymap.rs b/winit-common/src/xkb/keymap.rs index 81922e7464..16d3668b5e 100644 --- a/winit-common/src/xkb/keymap.rs +++ b/winit-common/src/xkb/keymap.rs @@ -660,9 +660,9 @@ pub fn keysym_to_key(keysym: u32) -> Key { // keysyms::Shift_Lock => NamedKey::ShiftLock, keysyms::Alt_L => NamedKey::Alt, keysyms::Alt_R => NamedKey::Alt, - #[allow(deprecated)] + #[expect(deprecated)] keysyms::Hyper_L => NamedKey::Hyper, - #[allow(deprecated)] + #[expect(deprecated)] keysyms::Hyper_R => NamedKey::Hyper, // Browsers map X11's Super keys to Meta, so we do that as well. diff --git a/winit-core/src/as_any.rs b/winit-core/src/as_any.rs index 5274bbe7bd..74ba142014 100644 --- a/winit-core/src/as_any.rs +++ b/winit-core/src/as_any.rs @@ -79,6 +79,7 @@ mod tests { impl_dyn_casting!(FooTrait); #[test] + #[expect(clippy::needless_borrow, reason = "test case")] fn dyn_casting() { let foo_owned: Box = Box::new(Foo); assert!(foo_owned.cast::().is_ok()); diff --git a/winit-core/src/window.rs b/winit-core/src/window.rs index 6f564ba900..41c8825701 100644 --- a/winit-core/src/window.rs +++ b/winit-core/src/window.rs @@ -2167,7 +2167,7 @@ mod tests { .is_some() ); - let text: &[u8] = ['a' as u8; 8000].as_slice(); + let text: &[u8] = [b'a'; 8000].as_slice(); let text = std::str::from_utf8(text).unwrap(); assert_eq!( ImeSurroundingText::new(text.into(), 0, 0), diff --git a/winit-uikit/src/app_state.rs b/winit-uikit/src/app_state.rs index 7876e34fe1..3c7aa955d4 100644 --- a/winit-uikit/src/app_state.rs +++ b/winit-uikit/src/app_state.rs @@ -361,7 +361,7 @@ pub(crate) fn send_occluded_event_for_all_windows(application: &UIApplication, o let mtm = MainThreadMarker::from(application); let mut events = Vec::new(); - #[allow(deprecated)] + #[expect(deprecated)] for window in application.windows().iter() { if let Ok(window) = window.downcast::() { events.push(EventWrapper::Window { @@ -420,7 +420,7 @@ pub(crate) fn terminated(application: &UIApplication) { let mtm = MainThreadMarker::from(application); let mut events = Vec::new(); - #[allow(deprecated)] + #[expect(deprecated)] for window in application.windows().iter() { if let Ok(window) = window.downcast::() { events.push(EventWrapper::Window { diff --git a/winit-uikit/src/event_loop.rs b/winit-uikit/src/event_loop.rs index d9e864b08a..dae53018f5 100644 --- a/winit-uikit/src/event_loop.rs +++ b/winit-uikit/src/event_loop.rs @@ -62,7 +62,7 @@ impl RootActiveEventLoop for ActiveEventLoop { } fn primary_monitor(&self) -> Option { - #[allow(deprecated)] + #[expect(deprecated)] let monitor = MonitorHandle::new(UIScreen::mainScreen(self.mtm)); Some(CoreMonitorHandle(Arc::new(monitor))) } diff --git a/winit-uikit/src/monitor.rs b/winit-uikit/src/monitor.rs index c2d7935372..4dea95839d 100644 --- a/winit-uikit/src/monitor.rs +++ b/winit-uikit/src/monitor.rs @@ -88,14 +88,14 @@ impl MonitorHandleProvider for MonitorHandle { fn name(&self) -> Option> { run_on_main(|mtm| { - #[allow(deprecated)] + #[expect(deprecated)] let main = UIScreen::mainScreen(mtm); if *self.ui_screen(mtm) == main { Some("Primary".into()) } else if Some(self.ui_screen(mtm)) == main.mirroredScreen().as_ref() { Some("Mirrored".into()) } else { - #[allow(deprecated)] + #[expect(deprecated)] UIScreen::screens(mtm) .iter() .position(|rhs| rhs == *self.ui_screen(mtm)) @@ -249,7 +249,7 @@ fn refresh_rate_millihertz(uiscreen: &UIScreen) -> Option { } pub fn uiscreens(mtm: MainThreadMarker) -> VecDeque { - #[allow(deprecated)] + #[expect(deprecated)] UIScreen::screens(mtm).into_iter().map(MonitorHandle::new).collect() } @@ -261,7 +261,7 @@ mod tests { // Test that UIScreen pointer comparisons are correct. #[test] - #[allow(deprecated)] + #[expect(deprecated)] fn screen_comparisons() { // Test code, doesn't matter that it's not thread safe let mtm = unsafe { MainThreadMarker::new_unchecked() }; diff --git a/winit-uikit/src/view_controller.rs b/winit-uikit/src/view_controller.rs index bc8607c2d3..fa91bff10d 100644 --- a/winit-uikit/src/view_controller.rs +++ b/winit-uikit/src/view_controller.rs @@ -122,7 +122,7 @@ impl WinitViewController { }, }; self.ivars().supported_orientations.set(mask); - #[allow(deprecated)] + #[expect(deprecated)] UIViewController::attemptRotationToDeviceOrientation(mtm); } diff --git a/winit-uikit/src/window.rs b/winit-uikit/src/window.rs index 788babcb71..5a1481ecfb 100644 --- a/winit-uikit/src/window.rs +++ b/winit-uikit/src/window.rs @@ -207,7 +207,7 @@ impl Inner { } else { // Assume the status bar frame is the only thing that obscures the view let app = UIApplication::sharedApplication(MainThreadMarker::new().unwrap()); - #[allow(deprecated)] + #[expect(deprecated)] let status_bar_frame = app.statusBarFrame(); UIEdgeInsets { top: status_bar_frame.size.height, left: 0.0, bottom: 0.0, right: 0.0 } }; @@ -434,7 +434,7 @@ impl Inner { } pub fn primary_monitor(&self) -> Option { - #[allow(deprecated)] + #[expect(deprecated)] Some(MonitorHandle::new(UIScreen::mainScreen(MainThreadMarker::new().unwrap()))) } @@ -505,7 +505,7 @@ impl Window { // TODO: transparency, visible - #[allow(deprecated)] + #[expect(deprecated)] let main_screen = UIScreen::mainScreen(mtm); let fullscreen = window_attributes.fullscreen.clone(); let screen = match fullscreen { diff --git a/winit-web/src/main_thread.rs b/winit-web/src/main_thread.rs index 59a2ac59f8..1692ade828 100644 --- a/winit-web/src/main_thread.rs +++ b/winit-web/src/main_thread.rs @@ -87,7 +87,7 @@ unsafe impl Sync for MainThreadSafe {} static DROP_HANDLER: OnceLock> = OnceLock::new(); -struct DropBox(#[allow(dead_code)] Box); +struct DropBox(#[expect(dead_code, reason = "field is dropped")] Box); unsafe impl Send for DropBox {} unsafe impl Sync for DropBox {} diff --git a/winit-win32/src/event_loop.rs b/winit-win32/src/event_loop.rs index 8f1008f98d..43342484e2 100644 --- a/winit-win32/src/event_loop.rs +++ b/winit-win32/src/event_loop.rs @@ -522,7 +522,6 @@ fn main_thread_id() -> u32 { // Mark as used so this is not removable. #[used] - #[allow(non_upper_case_globals)] // Place the function pointer inside of CRT initialization section so it is loaded before // main entrypoint. // diff --git a/winit-win32/src/keyboard_layout.rs b/winit-win32/src/keyboard_layout.rs index 7b6a370fdb..433ac363c6 100644 --- a/winit-win32/src/keyboard_layout.rs +++ b/winit-win32/src/keyboard_layout.rs @@ -670,9 +670,9 @@ fn keycode_to_vkey(keycode: KeyCode, hkl: u64) -> VIRTUAL_KEY { KeyCode::AudioVolumeMute => VK_VOLUME_MUTE, KeyCode::AudioVolumeUp => VK_VOLUME_UP, KeyCode::WakeUp => 0, - #[allow(deprecated)] + #[expect(deprecated)] KeyCode::Hyper => 0, - #[allow(deprecated)] + #[expect(deprecated)] KeyCode::Turbo => 0, KeyCode::Abort => 0, KeyCode::Resume => 0, diff --git a/winit/src/event_loop.rs b/winit/src/event_loop.rs index 6882ebf163..9bb8660633 100644 --- a/winit/src/event_loop.rs +++ b/winit/src/event_loop.rs @@ -340,7 +340,6 @@ impl winit_core::event_loop::pump_events::EventLoopExtPumpEvents for EventLoop { } } -#[allow(unused_imports)] #[cfg(any( windows_platform, macos_platform, @@ -518,5 +517,5 @@ impl winit_x11::EventLoopBuilderExtX11 for EventLoopBuilder { /// event_loop.run_app_on_demand(|_, _| {}); /// }); /// ``` -#[allow(dead_code)] +#[expect(dead_code, reason = "function for a compile_error doctest")] fn test_run_on_demand_cannot_access_event_loop() {} diff --git a/winit/tests/send_objects.rs b/winit/tests/send_objects.rs index da8c90b1e8..eb27177f72 100644 --- a/winit/tests/send_objects.rs +++ b/winit/tests/send_objects.rs @@ -1,4 +1,3 @@ -#[allow(dead_code)] fn needs_send() {} #[test] diff --git a/winit/tests/serde_objects.rs b/winit/tests/serde_objects.rs index 18e796cd31..961260b83b 100644 --- a/winit/tests/serde_objects.rs +++ b/winit/tests/serde_objects.rs @@ -6,7 +6,6 @@ use winit::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize}; use winit::event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase}; use winit::keyboard::{Key, KeyCode, KeyLocation, ModifiersState, NamedKey, PhysicalKey}; -#[allow(dead_code)] fn needs_serde>() {} #[test] diff --git a/winit/tests/sync_object.rs b/winit/tests/sync_object.rs index 0cea3cb00d..28bc0e68be 100644 --- a/winit/tests/sync_object.rs +++ b/winit/tests/sync_object.rs @@ -1,4 +1,3 @@ -#[allow(dead_code)] fn needs_sync() {} #[test]