diff --git a/glutin/src/api/egl/mod.rs b/glutin/src/api/egl/mod.rs index bd55e9076b..d567678e83 100644 --- a/glutin/src/api/egl/mod.rs +++ b/glutin/src/api/egl/mod.rs @@ -108,9 +108,11 @@ mod make_current_guard; pub use self::egl::Egl; use self::make_current_guard::MakeCurrentGuard; +#[cfg(not(target_os = "windows"))] +use crate::Rect; use crate::{ Api, ContextError, CreationError, GlAttributes, GlRequest, PixelFormat, - PixelFormatRequirements, Rect, ReleaseBehavior, Robustness, + PixelFormatRequirements, ReleaseBehavior, Robustness, }; use glutin_egl_sys as ffi; @@ -612,6 +614,7 @@ impl Context { } #[inline] + #[cfg(not(target_os = "windows"))] pub fn swap_buffers_with_damage(&self, rects: &[Rect]) -> Result<(), ContextError> { let egl = EGL.as_ref().unwrap(); @@ -655,6 +658,7 @@ impl Context { } #[inline] + #[cfg(not(target_os = "windows"))] pub fn swap_buffers_with_damage_supported(&self) -> bool { let egl = EGL.as_ref().unwrap(); egl.SwapBuffersWithDamageKHR.is_loaded() @@ -1217,7 +1221,7 @@ where } value }}; - }; + } let desc = PixelFormat { hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT) diff --git a/glutin/src/api/ios/mod.rs b/glutin/src/api/ios/mod.rs index e862e01d1d..b3c68207d2 100644 --- a/glutin/src/api/ios/mod.rs +++ b/glutin/src/api/ios/mod.rs @@ -306,7 +306,7 @@ impl Context { } #[inline] - pub fn swap_buffers_with_damage(&self, rects: &[Rect]) -> Result<(), ContextError> { + pub fn swap_buffers_with_damage(&self, _rects: &[Rect]) -> Result<(), ContextError> { Err(ContextError::OsError("buffer damage not suported".to_string())) } diff --git a/glutin/src/lib.rs b/glutin/src/lib.rs index a1ef8c3e8a..7ee1522016 100644 --- a/glutin/src/lib.rs +++ b/glutin/src/lib.rs @@ -84,15 +84,6 @@ extern crate lazy_static; #[cfg(any(target_os = "macos", target_os = "ios"))] #[macro_use] extern crate objc; -#[cfg(any( - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", -))] -#[macro_use] -extern crate log; pub mod platform; @@ -323,29 +314,29 @@ impl CreationError { } } - fn to_string(&self) -> &str { - match *self { - CreationError::OsError(ref text) | CreationError::NotSupported(ref text) => &text, - CreationError::NoBackendAvailable(_) => "No backend is available", + fn to_string(&self) -> String { + match self { + CreationError::OsError(text) | CreationError::NotSupported(text) => text.clone(), + CreationError::NoBackendAvailable(_) => "No backend is available".to_string(), CreationError::RobustnessNotSupported => { - "You requested robustness, but it is not supported." + "You requested robustness, but it is not supported.".to_string() } CreationError::OpenGlVersionNotSupported => { - "The requested OpenGL version is not supported." + "The requested OpenGL version is not supported.".to_string() } CreationError::NoAvailablePixelFormat => { - "Couldn't find any pixel format that matches the criteria." + "Couldn't find any pixel format that matches the criteria.".to_string() } - CreationError::PlatformSpecific(ref text) => &text, - CreationError::Window(ref err) => std::error::Error::description(err), - CreationError::CreationErrors(_) => "Received multiple errors.", + CreationError::PlatformSpecific(text) => text.clone(), + CreationError::Window(err) => err.to_string(), + CreationError::CreationErrors(_) => "Received multiple errors.".to_string(), } } } impl std::fmt::Display for CreationError { fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - formatter.write_str(self.to_string())?; + formatter.write_str(&self.to_string())?; if let CreationError::CreationErrors(ref es) = *self { use std::fmt::Debug; @@ -362,10 +353,6 @@ impl std::fmt::Display for CreationError { } impl std::error::Error for CreationError { - fn description(&self) -> &str { - self.to_string() - } - fn cause(&self) -> Option<&dyn std::error::Error> { match *self { CreationError::NoBackendAvailable(ref err) => Some(&**err), @@ -393,29 +380,18 @@ pub enum ContextError { FunctionUnavailable, } -impl ContextError { - fn to_string(&self) -> &str { - use std::error::Error; - match *self { - ContextError::OsError(ref string) => string, - ContextError::IoError(ref err) => err.description(), - ContextError::ContextLost => "Context lost", - ContextError::FunctionUnavailable => "Function unavailable", - } - } -} - impl std::fmt::Display for ContextError { fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - formatter.write_str(self.to_string()) + match self { + ContextError::OsError(string) => write!(formatter, "{}", string), + ContextError::IoError(err) => write!(formatter, "{}", err), + ContextError::ContextLost => write!(formatter, "Context lost"), + ContextError::FunctionUnavailable => write!(formatter, "Function unavailable"), + } } } -impl std::error::Error for ContextError { - fn description(&self) -> &str { - self.to_string() - } -} +impl std::error::Error for ContextError {} /// All APIs related to OpenGL that you can possibly get while using glutin. #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/glutin/src/platform_impl/unix/x11.rs b/glutin/src/platform_impl/unix/x11.rs index b48f1051de..063cbff330 100644 --- a/glutin/src/platform_impl/unix/x11.rs +++ b/glutin/src/platform_impl/unix/x11.rs @@ -27,15 +27,11 @@ pub mod utils; #[derive(Debug)] struct NoX11Connection; -impl std::error::Error for NoX11Connection { - fn description(&self) -> &str { - "failed to get x11 connection" - } -} +impl std::error::Error for NoX11Connection {} impl std::fmt::Display for NoX11Connection { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(std::error::Error::description(self)) + f.write_str("failed to get x11 connection") } } @@ -151,7 +147,7 @@ where match lacks_what { Some(Ok(())) => (), - Some(Err(Lacks::Transparency)) => warn!( + Some(Err(Lacks::Transparency)) => log::warn!( "Glutin could not a find fb config with an alpha mask. Transparency may be broken." ), Some(Err(Lacks::XID)) => panic!(), diff --git a/glutin/src/platform_impl/windows/mod.rs b/glutin/src/platform_impl/windows/mod.rs index 85895e8127..42e136e61f 100644 --- a/glutin/src/platform_impl/windows/mod.rs +++ b/glutin/src/platform_impl/windows/mod.rs @@ -233,7 +233,7 @@ impl Context { } #[inline] - pub fn swap_buffers_with_damage(&self, rects: &[Rect]) -> Result<(), ContextError> { + pub fn swap_buffers_with_damage(&self, _rects: &[Rect]) -> Result<(), ContextError> { Err(ContextError::OsError("buffer damage not suported".to_string())) }