1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Enable more clippy lints (#6853)

* Follows https://github.com/emilk/egui/pull/6848
This commit is contained in:
Emil Ernerfeldt
2025-04-24 17:32:50 +02:00
committed by GitHub
parent fdb9aa282a
commit f9245954eb
124 changed files with 243 additions and 244 deletions

View File

@@ -9,7 +9,7 @@ use std::num::NonZeroU32;
use std::sync::Arc;
use egui_winit::winit;
use winit::raw_window_handle::HasWindowHandle;
use winit::raw_window_handle::HasWindowHandle as _;
/// The majority of `GlutinWindowContext` is taken from `eframe`
struct GlutinWindowContext {
@@ -22,12 +22,12 @@ struct GlutinWindowContext {
impl GlutinWindowContext {
// refactor this function to use `glutin-winit` crate eventually.
// preferably add android support at the same time.
#[allow(unsafe_code)]
#[expect(unsafe_code)]
unsafe fn new(event_loop: &winit::event_loop::ActiveEventLoop) -> Self {
use glutin::context::NotCurrentGlContext;
use glutin::display::GetGlDisplay;
use glutin::display::GlDisplay;
use glutin::prelude::GlSurface;
use glutin::context::NotCurrentGlContext as _;
use glutin::display::GetGlDisplay as _;
use glutin::display::GlDisplay as _;
use glutin::prelude::GlSurface as _;
let winit_window_builder = winit::window::WindowAttributes::default()
.with_resizable(true)
.with_inner_size(winit::dpi::LogicalSize {
@@ -138,7 +138,7 @@ impl GlutinWindowContext {
}
fn resize(&self, physical_size: winit::dpi::PhysicalSize<u32>) {
use glutin::surface::GlSurface;
use glutin::surface::GlSurface as _;
self.gl_surface.resize(
&self.gl_context,
physical_size.width.try_into().unwrap(),
@@ -147,12 +147,12 @@ impl GlutinWindowContext {
}
fn swap_buffers(&self) -> glutin::error::Result<()> {
use glutin::surface::GlSurface;
use glutin::surface::GlSurface as _;
self.gl_surface.swap_buffers(&self.gl_context)
}
fn get_proc_address(&self, addr: &std::ffi::CStr) -> *const std::ffi::c_void {
use glutin::display::GlDisplay;
use glutin::display::GlDisplay as _;
self.gl_display.get_proc_address(addr)
}
}

View File

@@ -73,7 +73,7 @@ macro_rules! check_for_gl_error_even_in_release {
#[doc(hidden)]
pub fn check_for_gl_error_impl(gl: &glow::Context, file: &str, line: u32, context: &str) {
use glow::HasContext as _;
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let error_code = unsafe { gl.get_error() };
if error_code != glow::NO_ERROR {
let error_str = match error_code {

View File

@@ -296,7 +296,7 @@ impl Painter {
/// So if in a [`egui::Shape::Callback`] you need to use an offscreen FBO, you should
/// then restore to this afterwards with
/// `gl.bind_framebuffer(glow::FRAMEBUFFER, painter.intermediate_fbo());`
#[allow(clippy::unused_self)]
#[expect(clippy::unused_self)]
pub fn intermediate_fbo(&self) -> Option<glow::Framebuffer> {
// We don't currently ever render to an offscreen buffer,
// but we may want to start to in order to do anti-aliasing on web, for instance.
@@ -663,7 +663,6 @@ impl Painter {
self.textures.get(&texture_id).copied()
}
#[allow(clippy::needless_pass_by_value)] // False positive
pub fn register_native_texture(&mut self, native: glow::Texture) -> egui::TextureId {
self.assert_not_destroyed();
let id = egui::TextureId::User(self.next_native_tex_id);
@@ -672,7 +671,6 @@ impl Painter {
id
}
#[allow(clippy::needless_pass_by_value)] // False positive
pub fn replace_native_texture(&mut self, id: egui::TextureId, replacing: glow::Texture) {
if let Some(old_tex) = self.textures.insert(id, replacing) {
self.textures_to_destroy.push(old_tex);

View File

@@ -1,11 +1,10 @@
#![allow(unsafe_code)]
#![allow(clippy::undocumented_unsafe_blocks)]
use std::convert::TryInto;
use std::convert::TryInto as _;
/// Helper for parsing and interpreting the OpenGL shader version.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[allow(dead_code)]
pub enum ShaderVersion {
Gl120,

View File

@@ -27,7 +27,6 @@ pub(crate) struct VertexArrayObject {
}
impl VertexArrayObject {
#[allow(clippy::needless_pass_by_value)] // false positive
pub(crate) unsafe fn new(
gl: &glow::Context,
vbo: glow::Buffer,