From 18a61f1058345d1c347580d2d5fce2abb7abe23e Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 11 Dec 2021 03:02:48 +0100 Subject: [PATCH] Fix warnings (#2076) * examples: Fix unused `Result` that must be used when initializing console_log * examples: Fix unused imports * Fix unread name field warning in linux x11 ime InputMethod struct * Fix unread name field warning in linux x11 Device struct * Ignore unread field warning in macos/ios MonitorHandle struct * ci: Add `--deny warnings` to `RUSTFLAGS` --- .github/workflows/ci.yml | 2 +- examples/request_redraw_threaded.rs | 18 +++++++++--------- examples/web.rs | 2 +- src/platform_impl/ios/monitor.rs | 2 ++ .../linux/x11/ime/input_method.rs | 4 ++-- src/platform_impl/linux/x11/mod.rs | 4 ++-- src/platform_impl/macos/monitor.rs | 1 + 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27bdf19b50..1457eaa5b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: env: RUST_BACKTRACE: 1 CARGO_INCREMENTAL: 0 - RUSTFLAGS: "-C debuginfo=0" + RUSTFLAGS: "-C debuginfo=0 --deny warnings" OPTIONS: ${{ matrix.platform.options }} FEATURES: ${{ format(',{0}', matrix.platform.features ) }} CMD: ${{ matrix.platform.cmd }} diff --git a/examples/request_redraw_threaded.rs b/examples/request_redraw_threaded.rs index d725cc8d93..7a28c23b55 100644 --- a/examples/request_redraw_threaded.rs +++ b/examples/request_redraw_threaded.rs @@ -1,14 +1,14 @@ -use std::{thread, time}; - -use simple_logger::SimpleLogger; -use winit::{ - event::{Event, WindowEvent}, - event_loop::{ControlFlow, EventLoop}, - window::WindowBuilder, -}; - #[cfg(not(target_arch = "wasm32"))] fn main() { + use std::{thread, time}; + + use simple_logger::SimpleLogger; + use winit::{ + event::{Event, WindowEvent}, + event_loop::{ControlFlow, EventLoop}, + window::WindowBuilder, + }; + SimpleLogger::new().init().unwrap(); let event_loop = EventLoop::new(); diff --git a/examples/web.rs b/examples/web.rs index 1936bc2b90..83ccc45ee2 100644 --- a/examples/web.rs +++ b/examples/web.rs @@ -51,7 +51,7 @@ mod wasm { #[wasm_bindgen(start)] pub fn run() { - console_log::init_with_level(log::Level::Debug); + console_log::init_with_level(log::Level::Debug).expect("error initializing logger"); super::main(); } diff --git a/src/platform_impl/ios/monitor.rs b/src/platform_impl/ios/monitor.rs index 42c71ffc7a..4ba3a3dbb3 100644 --- a/src/platform_impl/ios/monitor.rs +++ b/src/platform_impl/ios/monitor.rs @@ -168,7 +168,9 @@ impl Drop for MonitorHandle { impl fmt::Debug for MonitorHandle { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // TODO: Do this using the proper fmt API #[derive(Debug)] + #[allow(dead_code)] struct MonitorHandle { name: Option, size: PhysicalSize, diff --git a/src/platform_impl/linux/x11/ime/input_method.rs b/src/platform_impl/linux/x11/ime/input_method.rs index 142c150199..808dfcb7d3 100644 --- a/src/platform_impl/linux/x11/ime/input_method.rs +++ b/src/platform_impl/linux/x11/ime/input_method.rs @@ -42,12 +42,12 @@ unsafe fn open_im(xconn: &Arc, locale_modifiers: &CStr) -> Option Self { - InputMethod { im, name } + InputMethod { im, _name: name } } } diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 3ea03b1eb8..7adf80e902 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -592,7 +592,7 @@ fn mkdid(w: c_int) -> crate::event::DeviceId { #[derive(Debug)] struct Device { - name: String, + _name: String, scroll_axes: Vec<(i32, ScrollAxis)>, // For master devices, this is the paired device (pointer <-> keyboard). // For slave devices, this is the master. @@ -658,7 +658,7 @@ impl Device { } let mut device = Device { - name: name.into_owned(), + _name: name.into_owned(), scroll_axes, attachment: info.attachment, }; diff --git a/src/platform_impl/macos/monitor.rs b/src/platform_impl/macos/monitor.rs index 817d38ee57..cf16f97dbc 100644 --- a/src/platform_impl/macos/monitor.rs +++ b/src/platform_impl/macos/monitor.rs @@ -162,6 +162,7 @@ impl fmt::Debug for MonitorHandle { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // TODO: Do this using the proper fmt API #[derive(Debug)] + #[allow(dead_code)] struct MonitorHandle { name: Option, native_identifier: u32,