Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI warnings #1356

Merged
merged 7 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions glutin/src/api/egl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -1217,7 +1221,7 @@ where
}
value
}};
};
}

let desc = PixelFormat {
hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT)
Expand Down
2 changes: 1 addition & 1 deletion glutin/src/api/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

Expand Down
60 changes: 18 additions & 42 deletions glutin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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),
Expand Down Expand Up @@ -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)]
Expand Down
10 changes: 3 additions & 7 deletions glutin/src/platform_impl/unix/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -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!(),
Expand Down
2 changes: 1 addition & 1 deletion glutin/src/platform_impl/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

Expand Down