Fix most rustc & clippy warnings

This commit is contained in:
Jonas Platte 2020-09-15 00:49:10 +02:00 committed by Victor Berger
parent c4f64489e8
commit bcc8f13b2b
9 changed files with 15 additions and 33 deletions

View File

@ -784,8 +784,6 @@ fn surface_commit(
.with_role_data(surface, |&mut role: &mut SubsurfaceRole| role)
.ok();
let mut next_state = CommitedState::default();
let (refresh, apply_children) = token.with_surface_data(surface, |attributes| {
attributes
.user_data
@ -796,13 +794,12 @@ fn surface_commit(
.unwrap()
.borrow_mut();
if let Some(ref cached_state) = data.cached_state {
let mut next_state = match data.cached_state {
// There is a pending state, accumulate into it
next_state = cached_state.clone();
} else {
// start from the current state
next_state = data.current_state.clone();
}
Some(ref cached_state) => cached_state.clone(),
// Start from the current state
None => data.current_state.clone(),
};
if let Some(ref data) = sub_data {
next_state.sub_location = data.location;

View File

@ -28,8 +28,8 @@ use std::{
sync::Mutex,
};
fn get_property_by_name<'a, D: ControlDevice, T: ResourceHandle>(
dev: &'a D,
fn get_property_by_name<D: ControlDevice, T: ResourceHandle>(
dev: &D,
handle: T,
name: &'static str,
) -> Option<(property::ValueType, property::RawValue)> {
@ -84,11 +84,7 @@ fn main() {
.unwrap();
let encoder_info = device.get_encoder_info(encoder).unwrap();
*res_handles
.filter_crtcs(encoder_info.possible_crtcs())
.iter()
.next()
.unwrap()
res_handles.filter_crtcs(encoder_info.possible_crtcs())[0]
}
_ => unreachable!("CRTC_ID does not return another property type"),
};

View File

@ -67,13 +67,7 @@ fn main() {
let crtc = encoder_info
.crtc()
// or use the first one that is compatible with the encoder
.unwrap_or_else(|| {
*res_handles
.filter_crtcs(encoder_info.possible_crtcs())
.iter()
.next()
.unwrap()
});
.unwrap_or_else(|| res_handles.filter_crtcs(encoder_info.possible_crtcs())[0]);
// Assuming we found a good connector and loaded the info into `connector_info`
let mode = connector_info.modes()[0]; // Use first mode (usually highest resoltion, but in reality you should filter and sort and check and match with other connectors, if you use more then one.)

View File

@ -97,13 +97,7 @@ fn main() {
let crtc = encoder_info
.crtc()
// or use the first one that is compatible with the encoder
.unwrap_or_else(|| {
*res_handles
.filter_crtcs(encoder_info.possible_crtcs())
.iter()
.next()
.unwrap()
});
.unwrap_or_else(|| res_handles.filter_crtcs(encoder_info.possible_crtcs())[0]);
println!("Crtc {:?}", crtc);
// Assuming we found a good connector and loaded the info into `connector_info`

View File

@ -42,7 +42,7 @@ pub fn make_sure_egl_is_loaded() {
});
}
#[allow(clippy::all, rust_2018_idioms)]
#[allow(clippy::all)]
pub mod egl {
use super::*;
use libloading::Library;

View File

@ -4,7 +4,7 @@ use nix::libc::c_void;
use super::{PixelFormat, SwapBuffersError};
#[allow(clippy::all, rust_2018_idioms, missing_docs)]
#[allow(clippy::all, missing_docs)]
pub(crate) mod ffi {
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
}

View File

@ -49,7 +49,7 @@ impl EventSource for DBusConnection {
fn process_events<F>(&mut self, _: Readiness, _: Token, mut callback: F) -> io::Result<()>
where
F: FnMut(Message, &mut DBusConnection) -> (),
F: FnMut(Message, &mut DBusConnection),
{
self.cx
.channel()

View File

@ -245,7 +245,7 @@ macro_rules! define_roles(
Ok(data)
} else {
// put it back in place
::std::mem::replace(self, temp);
*self = temp;
Err($crate::wayland::compositor::roles::WrongRole)
}
}

View File

@ -103,6 +103,7 @@ mod tests {
}
#[test]
#[allow(clippy::eq_op)]
fn serial_equals_self() {
let counter = create_serial_counter(0);
let serial = counter.next_serial();