Fix some clippy warning from Rust 1.78.0 (#4444)

This commit is contained in:
Emil Ernerfeldt 2024-05-02 17:04:25 +02:00 committed by GitHub
parent c9b24d5a5c
commit ded8dbd45b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 37 additions and 72 deletions

View File

@ -232,7 +232,7 @@ pub enum HardwareAcceleration {
/// Do NOT use graphics acceleration. /// Do NOT use graphics acceleration.
/// ///
/// On some platforms (MacOS) this is ignored and treated the same as [`Self::Preferred`]. /// On some platforms (macOS) this is ignored and treated the same as [`Self::Preferred`].
Off, Off,
} }
@ -518,10 +518,10 @@ pub enum WebGlContextOption {
/// Force use WebGL2. /// Force use WebGL2.
WebGl2, WebGl2,
/// Use WebGl2 first. /// Use WebGL2 first.
BestFirst, BestFirst,
/// Use WebGl1 first /// Use WebGL1 first
CompatibilityFirst, CompatibilityFirst,
} }

View File

@ -360,21 +360,6 @@ impl WinitApp for GlowWinitApp {
.map_or(0, |r| r.integration.egui_ctx.frame_nr_for(viewport_id)) .map_or(0, |r| r.integration.egui_ctx.frame_nr_for(viewport_id))
} }
fn is_focused(&self, window_id: WindowId) -> bool {
if let Some(running) = &self.running {
let glutin = running.glutin.borrow();
if let Some(window_id) = glutin.viewport_from_window.get(&window_id) {
return glutin.focused_viewport == Some(*window_id);
}
}
false
}
fn integration(&self) -> Option<&EpiIntegration> {
self.running.as_ref().map(|r| &r.integration)
}
fn window(&self, window_id: WindowId) -> Option<Arc<Window>> { fn window(&self, window_id: WindowId) -> Option<Arc<Window>> {
let running = self.running.as_ref()?; let running = self.running.as_ref()?;
let glutin = running.glutin.borrow(); let glutin = running.glutin.borrow();

View File

@ -341,20 +341,6 @@ impl WinitApp for WgpuWinitApp {
.map_or(0, |r| r.integration.egui_ctx.frame_nr_for(viewport_id)) .map_or(0, |r| r.integration.egui_ctx.frame_nr_for(viewport_id))
} }
fn is_focused(&self, window_id: WindowId) -> bool {
if let Some(running) = &self.running {
let shared = running.shared.borrow();
let viewport_id = shared.viewport_from_window.get(&window_id).copied();
shared.focused_viewport.is_some() && shared.focused_viewport == viewport_id
} else {
false
}
}
fn integration(&self) -> Option<&EpiIntegration> {
self.running.as_ref().map(|r| &r.integration)
}
fn window(&self, window_id: WindowId) -> Option<Arc<Window>> { fn window(&self, window_id: WindowId) -> Option<Arc<Window>> {
self.running self.running
.as_ref() .as_ref()

View File

@ -9,8 +9,6 @@ use egui::ViewportId;
#[cfg(feature = "accesskit")] #[cfg(feature = "accesskit")]
use egui_winit::accesskit_winit; use egui_winit::accesskit_winit;
use super::epi_integration::EpiIntegration;
/// Create an egui context, restoring it from storage if possible. /// Create an egui context, restoring it from storage if possible.
pub fn create_egui_context(storage: Option<&dyn crate::Storage>) -> egui::Context { pub fn create_egui_context(storage: Option<&dyn crate::Storage>) -> egui::Context {
crate::profile_function!(); crate::profile_function!();
@ -64,10 +62,6 @@ pub trait WinitApp {
/// The current frame number, as reported by egui. /// The current frame number, as reported by egui.
fn frame_nr(&self, viewport_id: ViewportId) -> u64; fn frame_nr(&self, viewport_id: ViewportId) -> u64;
fn is_focused(&self, window_id: WindowId) -> bool;
fn integration(&self) -> Option<&EpiIntegration>;
fn window(&self, window_id: WindowId) -> Option<Arc<Window>>; fn window(&self, window_id: WindowId) -> Option<Arc<Window>>;
fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<WindowId>; fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<WindowId>;

View File

@ -162,7 +162,7 @@ pub struct Renderer {
texture_bind_group_layout: wgpu::BindGroupLayout, texture_bind_group_layout: wgpu::BindGroupLayout,
/// Map of egui texture IDs to textures and their associated bindgroups (texture view + /// Map of egui texture IDs to textures and their associated bindgroups (texture view +
/// sampler). The texture may be None if the TextureId is just a handle to a user-provided /// sampler). The texture may be None if the `TextureId` is just a handle to a user-provided
/// sampler. /// sampler.
textures: HashMap<epaint::TextureId, (Option<wgpu::Texture>, wgpu::BindGroup)>, textures: HashMap<epaint::TextureId, (Option<wgpu::Texture>, wgpu::BindGroup)>,
next_user_texture_id: u64, next_user_texture_id: u64,

View File

@ -209,7 +209,7 @@ impl Painter {
if let Some(window) = window { if let Some(window) = window {
let size = window.inner_size(); let size = window.inner_size();
if self.surfaces.get(&viewport_id).is_none() { if !self.surfaces.contains_key(&viewport_id) {
let surface = self.instance.create_surface(window)?; let surface = self.instance.create_surface(window)?;
self.add_surface(surface, viewport_id, size).await?; self.add_surface(surface, viewport_id, size).await?;
} }
@ -235,7 +235,7 @@ impl Painter {
if let Some(window) = window { if let Some(window) = window {
let size = window.inner_size(); let size = window.inner_size();
if self.surfaces.get(&viewport_id).is_none() { if !self.surfaces.contains_key(&viewport_id) {
let surface = unsafe { let surface = unsafe {
self.instance self.instance
.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&window)?)? .create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&window)?)?

View File

@ -21,12 +21,12 @@ pub(crate) struct FrameState {
/// All [`Id`]s that were used this frame. /// All [`Id`]s that were used this frame.
pub(crate) used_ids: IdMap<Rect>, pub(crate) used_ids: IdMap<Rect>,
/// Starts off as the screen_rect, shrinks as panels are added. /// Starts off as the `screen_rect`, shrinks as panels are added.
/// The [`CentralPanel`] does not change this. /// The [`CentralPanel`] does not change this.
/// This is the area available to Window's. /// This is the area available to Window's.
pub(crate) available_rect: Rect, pub(crate) available_rect: Rect,
/// Starts off as the screen_rect, shrinks as panels are added. /// Starts off as the `screen_rect`, shrinks as panels are added.
/// The [`CentralPanel`] retracts from this. /// The [`CentralPanel`] retracts from this.
pub(crate) unused_rect: Rect, pub(crate) unused_rect: Rect,

View File

@ -35,7 +35,7 @@ pub struct InputState {
/// State of the mouse or simple touch gestures which can be mapped to mouse operations. /// State of the mouse or simple touch gestures which can be mapped to mouse operations.
pub pointer: PointerState, pub pointer: PointerState,
/// State of touches, except those covered by PointerState (like clicks and drags). /// State of touches, except those covered by `PointerState` (like clicks and drags).
/// (We keep a separate [`TouchState`] for each encountered touch device.) /// (We keep a separate [`TouchState`] for each encountered touch device.)
touch_states: BTreeMap<TouchDeviceId, TouchState>, touch_states: BTreeMap<TouchDeviceId, TouchState>,

View File

@ -72,7 +72,7 @@ pub(crate) struct TouchState {
/// Active touches, if any. /// Active touches, if any.
/// ///
/// TouchId is the unique identifier of the touch. It is valid as long as the finger/pen touches the surface. The /// `TouchId` is the unique identifier of the touch. It is valid as long as the finger/pen touches the surface. The
/// next touch will receive a new unique ID. /// next touch will receive a new unique ID.
/// ///
/// Refer to [`ActiveTouch`]. /// Refer to [`ActiveTouch`].

View File

@ -13,7 +13,7 @@ pub(crate) struct Region {
/// Always finite. /// Always finite.
/// ///
/// The bounding box of all child widgets, but not necessarily a tight bounding box /// The bounding box of all child widgets, but not necessarily a tight bounding box
/// since [`Ui`](crate::Ui) can start with a non-zero min_rect size. /// since [`Ui`](crate::Ui) can start with a non-zero `min_rect` size.
pub min_rect: Rect, pub min_rect: Rect,
/// The maximum size of this [`Ui`](crate::Ui). This is a *soft max* /// The maximum size of this [`Ui`](crate::Ui). This is a *soft max*
@ -38,7 +38,7 @@ pub(crate) struct Region {
/// So one can think of `cursor` as a constraint on the available region. /// So one can think of `cursor` as a constraint on the available region.
/// ///
/// If something has already been added, this will point to `style.spacing.item_spacing` beyond the latest child. /// If something has already been added, this will point to `style.spacing.item_spacing` beyond the latest child.
/// The cursor can thus be `style.spacing.item_spacing` pixels outside of the min_rect. /// The cursor can thus be `style.spacing.item_spacing` pixels outside of the `min_rect`.
pub(crate) cursor: Rect, pub(crate) cursor: Rect,
} }

View File

@ -5,19 +5,19 @@ pub enum OperatingSystem {
/// Unknown OS - could be wasm /// Unknown OS - could be wasm
Unknown, Unknown,
/// Android OS. /// Android OS
Android, Android,
/// Apple iPhone OS. /// Apple iPhone OS
IOS, IOS,
/// Linux or Unix other than Android. /// Linux or Unix other than Android
Nix, Nix,
/// MacOS. /// macOS
Mac, Mac,
/// Windows. /// Windows
Windows, Windows,
} }

View File

@ -152,7 +152,7 @@ pub struct Style {
/// ///
/// The most convenient way to look something up in this is to use [`TextStyle::resolve`]. /// The most convenient way to look something up in this is to use [`TextStyle::resolve`].
/// ///
/// If you would like to overwrite app text_styles /// If you would like to overwrite app `text_styles`
/// ///
/// ``` /// ```
/// # let mut ctx = egui::Context::default(); /// # let mut ctx = egui::Context::default();

View File

@ -59,8 +59,8 @@ pub struct Undoer<State> {
/// Stores redos immediately after a sequence of undos. /// Stores redos immediately after a sequence of undos.
/// Gets cleared every time the state changes. /// Gets cleared every time the state changes.
/// Does not need to be a deque, because there can only be up to undos.len() redos, /// Does not need to be a deque, because there can only be up to `undos.len()` redos,
/// which is already limited to settings.max_undos. /// which is already limited to `settings.max_undos`.
redos: Vec<State>, redos: Vec<State>,
#[cfg_attr(feature = "serde", serde(skip))] #[cfg_attr(feature = "serde", serde(skip))]

View File

@ -1071,7 +1071,7 @@ pub enum ViewportCommand {
/// This is equivalent to the system keyboard shortcut for copy (e.g. CTRL + C). /// This is equivalent to the system keyboard shortcut for copy (e.g. CTRL + C).
RequestCopy, RequestCopy,
/// Request a paste from the clipboard to the current focused TextEdit if any. /// Request a paste from the clipboard to the current focused `TextEdit` if any.
/// ///
/// This is equivalent to the system keyboard shortcut for paste (e.g. CTRL + V). /// This is equivalent to the system keyboard shortcut for paste (e.g. CTRL + V).
RequestPaste, RequestPaste,

View File

@ -220,7 +220,7 @@ impl TextBuffer for String {
} }
fn replace_with(&mut self, text: &str) { fn replace_with(&mut self, text: &str) {
*self = text.to_owned(); text.clone_into(self);
} }
fn take(&mut self) -> String { fn take(&mut self) -> String {

View File

@ -464,7 +464,7 @@ impl WrapApp {
// Collect dropped files: // Collect dropped files:
ctx.input(|i| { ctx.input(|i| {
if !i.raw.dropped_files.is_empty() { if !i.raw.dropped_files.is_empty() {
self.dropped_files = i.raw.dropped_files.clone(); self.dropped_files.clone_from(&i.raw.dropped_files);
} }
}); });

View File

@ -14,7 +14,7 @@ impl MemoizedEasymarkHighlighter {
pub fn highlight(&mut self, egui_style: &egui::Style, code: &str) -> egui::text::LayoutJob { pub fn highlight(&mut self, egui_style: &egui::Style, code: &str) -> egui::text::LayoutJob {
if (&self.style, self.code.as_str()) != (egui_style, code) { if (&self.style, self.code.as_str()) != (egui_style, code) {
self.style = egui_style.clone(); self.style = egui_style.clone();
self.code = code.to_owned(); code.clone_into(&mut self.code);
self.output = highlight_easymark(egui_style, code); self.output = highlight_easymark(egui_style, code);
} }
self.output.clone() self.output.clone()

View File

@ -123,12 +123,12 @@ impl LineStyle {
} }
} }
impl ToString for LineStyle { impl std::fmt::Display for LineStyle {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::Solid => "Solid".into(), Self::Solid => write!(f, "Solid"),
Self::Dotted { spacing } => format!("Dotted{spacing}Px"), Self::Dotted { spacing } => write!(f, "Dotted({spacing} px)"),
Self::Dashed { length } => format!("Dashed{length}Px"), Self::Dashed { length } => write!(f, "Dashed({length} px)"),
} }
} }
} }
@ -426,9 +426,9 @@ impl ExplicitGenerator {
/// Result of [`super::PlotItem::find_closest()`] search, identifies an element inside the item for immediate use /// Result of [`super::PlotItem::find_closest()`] search, identifies an element inside the item for immediate use
pub struct ClosestElem { pub struct ClosestElem {
/// Position of hovered-over value (or bar/box-plot/...) in PlotItem /// Position of hovered-over value (or bar/box-plot/...) in `PlotItem`
pub index: usize, pub index: usize,
/// Squared distance from the mouse cursor (needed to compare against other PlotItems, which might be nearer) /// Squared distance from the mouse cursor (needed to compare against other `PlotItems`, which might be nearer)
pub dist_sq: f32, pub dist_sq: f32,
} }

View File

@ -18,10 +18,10 @@ use super::Vec2;
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))] #[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
pub struct Rot2 { pub struct Rot2 {
/// angle.sin() /// `angle.sin()`
s: f32, s: f32,
/// angle.cos() /// `angle.cos()`
c: f32, c: f32,
} }

View File

@ -453,9 +453,9 @@ pub struct Galley {
/// `rect.top()` is always 0.0. /// `rect.top()` is always 0.0.
/// ///
/// With [`LayoutJob::halign`]: /// With [`LayoutJob::halign`]:
/// * [`Align::LEFT`]: rect.left() == 0.0 /// * [`Align::LEFT`]: `rect.left() == 0.0`
/// * [`Align::Center`]: rect.center() == 0.0 /// * [`Align::Center`]: `rect.center() == 0.0`
/// * [`Align::RIGHT`]: rect.right() == 0.0 /// * [`Align::RIGHT`]: `rect.right() == 0.0`
pub rect: Rect, pub rect: Rect,
/// Tight bounding box around all the meshes in all the rows. /// Tight bounding box around all the meshes in all the rows.

View File

@ -78,7 +78,7 @@ impl eframe::App for MyApp {
// Collect dropped files: // Collect dropped files:
ctx.input(|i| { ctx.input(|i| {
if !i.raw.dropped_files.is_empty() { if !i.raw.dropped_files.is_empty() {
self.dropped_files = i.raw.dropped_files.clone(); self.dropped_files.clone_from(&i.raw.dropped_files);
} }
}); });
} }