address more clippy warnings

Not sure how much of an improvement these are.
This commit is contained in:
Colin Benner 2018-06-29 12:30:42 +02:00
parent 4598ba0b48
commit 6d31e9e5ff
5 changed files with 12 additions and 11 deletions

View File

@ -171,11 +171,11 @@ impl<A: Device + 'static> DrmBackend<A> {
if !encoders if !encoders
.iter() .iter()
.map(|encoder| encoder.possible_crtcs()) .map(|encoder| encoder.possible_crtcs())
.all(|crtc_list| { .all(|crtc_list|
resource_handles resource_handles
.filter_crtcs(crtc_list) .filter_crtcs(crtc_list)
.contains(&self.backend.crtc) .contains(&self.backend.crtc)
}) { ) {
bail!(ErrorKind::NoSuitableEncoder(info, self.backend.crtc)); bail!(ErrorKind::NoSuitableEncoder(info, self.backend.crtc));
} }
@ -473,12 +473,13 @@ impl<A: Device + 'static> GraphicsBackend for DrmBackend<A> {
impl<A: Device + 'static> EGLGraphicsBackend for DrmBackend<A> { impl<A: Device + 'static> EGLGraphicsBackend for DrmBackend<A> {
fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> { fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {
if { let res = {
let nb = self.backend.next_buffer.take(); let nb = self.backend.next_buffer.take();
let res = nb.is_some(); let res = nb.is_some();
self.backend.next_buffer.set(nb); self.backend.next_buffer.set(nb);
res res
} { };
if res {
// We cannot call lock_front_buffer anymore without releasing the previous buffer, which will happen when the page flip is done // We cannot call lock_front_buffer anymore without releasing the previous buffer, which will happen when the page flip is done
warn!( warn!(
self.backend.logger, self.backend.logger,

View File

@ -179,7 +179,7 @@ unsafe impl NativeDisplay<X11> for WinitWindow {
fn create_surface(&self, _args: ()) -> Result<XlibWindow> { fn create_surface(&self, _args: ()) -> Result<XlibWindow> {
self.get_xlib_window() self.get_xlib_window()
.map(|ptr| XlibWindow(ptr)) .map(XlibWindow)
.ok_or(ErrorKind::NonMatchingBackend("X11").into()) .ok_or(ErrorKind::NonMatchingBackend("X11").into())
} }
} }

View File

@ -177,7 +177,7 @@ impl DirectSession {
fcntl::OFlag::O_RDWR | fcntl::OFlag::O_CLOEXEC, fcntl::OFlag::O_RDWR | fcntl::OFlag::O_CLOEXEC,
Mode::empty(), Mode::empty(),
).chain_err(|| ErrorKind::FailedToOpenTTY(String::from(path.to_string_lossy()))) ).chain_err(|| ErrorKind::FailedToOpenTTY(String::from(path.to_string_lossy())))
}).unwrap_or(dup(0 /*stdin*/).chain_err(|| ErrorKind::FailedToOpenTTY(String::from("<stdin>"))))?; }).unwrap_or_else(|| dup(0 /*stdin*/).chain_err(|| ErrorKind::FailedToOpenTTY(String::from("<stdin>"))))?;
let active = Arc::new(AtomicBool::new(true)); let active = Arc::new(AtomicBool::new(true));

View File

@ -138,7 +138,7 @@ impl PointerHandle {
/// ///
/// A single frame will group multiple scroll events as if they happended in the same instance. /// A single frame will group multiple scroll events as if they happended in the same instance.
/// Dropping the returned `PointerAxisHandle` will group the events together. /// Dropping the returned `PointerAxisHandle` will group the events together.
pub fn axis<'a>(&'a self) -> PointerAxisHandle<'a> { pub fn axis(& self) -> PointerAxisHandle {
PointerAxisHandle { PointerAxisHandle {
inner: self.inner.lock().unwrap(), inner: self.inner.lock().unwrap(),
} }

View File

@ -19,7 +19,7 @@ pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [Unix
} }
// If we reach here, all values from 0 to 32 failed // If we reach here, all values from 0 to 32 failed
// we need to stop trying at some point // we need to stop trying at some point
return Err(()); Err(())
} }
pub(crate) struct X11Lock { pub(crate) struct X11Lock {
@ -44,11 +44,11 @@ impl X11Lock {
// write to the file failed ? we abandon // write to the file failed ? we abandon
::std::mem::drop(file); ::std::mem::drop(file);
let _ = ::std::fs::remove_file(&filename); let _ = ::std::fs::remove_file(&filename);
return Err(()); Err(())
} else { } else {
debug!(log, "X11 lock aquired"; "D" => display); debug!(log, "X11 lock aquired"; "D" => display);
// we got the lockfile and wrote our pid to it, all is good // we got the lockfile and wrote our pid to it, all is good
return Ok(X11Lock { display, log }); Ok(X11Lock { display, log })
} }
} }
Err(_) => { Err(_) => {
@ -79,7 +79,7 @@ impl X11Lock {
} }
} }
// if we reach here, this lockfile exists and is probably in use, give up // if we reach here, this lockfile exists and is probably in use, give up
return Err(()); Err(())
} }
} }
} }