Skip to content

Commit

Permalink
Fix some clippy warning from Rust 1.78.0 (emilk#4444)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored May 2, 2024
1 parent c9b24d5 commit ded8dbd
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 72 deletions.
6 changes: 3 additions & 3 deletions crates/eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub enum HardwareAcceleration {

/// 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,
}

Expand Down Expand Up @@ -518,10 +518,10 @@ pub enum WebGlContextOption {
/// Force use WebGL2.
WebGl2,

/// Use WebGl2 first.
/// Use WebGL2 first.
BestFirst,

/// Use WebGl1 first
/// Use WebGL1 first
CompatibilityFirst,
}

Expand Down
15 changes: 0 additions & 15 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,6 @@ impl WinitApp for GlowWinitApp {
.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>> {
let running = self.running.as_ref()?;
let glutin = running.glutin.borrow();
Expand Down
14 changes: 0 additions & 14 deletions crates/eframe/src/native/wgpu_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,6 @@ impl WinitApp for WgpuWinitApp {
.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>> {
self.running
.as_ref()
Expand Down
6 changes: 0 additions & 6 deletions crates/eframe/src/native/winit_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use egui::ViewportId;
#[cfg(feature = "accesskit")]
use egui_winit::accesskit_winit;

use super::epi_integration::EpiIntegration;

/// Create an egui context, restoring it from storage if possible.
pub fn create_egui_context(storage: Option<&dyn crate::Storage>) -> egui::Context {
crate::profile_function!();
Expand Down Expand Up @@ -64,10 +62,6 @@ pub trait WinitApp {
/// The current frame number, as reported by egui.
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_id_from_viewport_id(&self, id: ViewportId) -> Option<WindowId>;
Expand Down
2 changes: 1 addition & 1 deletion crates/egui-wgpu/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub struct Renderer {
texture_bind_group_layout: wgpu::BindGroupLayout,

/// 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.
textures: HashMap<epaint::TextureId, (Option<wgpu::Texture>, wgpu::BindGroup)>,
next_user_texture_id: u64,
Expand Down
4 changes: 2 additions & 2 deletions crates/egui-wgpu/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl Painter {

if let Some(window) = window {
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)?;
self.add_surface(surface, viewport_id, size).await?;
}
Expand All @@ -235,7 +235,7 @@ impl Painter {

if let Some(window) = window {
let size = window.inner_size();
if self.surfaces.get(&viewport_id).is_none() {
if !self.surfaces.contains_key(&viewport_id) {
let surface = unsafe {
self.instance
.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&window)?)?
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/frame_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ pub(crate) struct FrameState {
/// All [`Id`]s that were used this frame.
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.
/// This is the area available to Window's.
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.
pub(crate) unused_rect: Rect,

Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/input_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct InputState {
/// State of the mouse or simple touch gestures which can be mapped to mouse operations.
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.)
touch_states: BTreeMap<TouchDeviceId, TouchState>,

Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/input_state/touch_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(crate) struct TouchState {

/// 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.
///
/// Refer to [`ActiveTouch`].
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) struct Region {
/// Always finite.
///
/// 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,

/// The maximum size of this [`Ui`](crate::Ui). This is a *soft max*
Expand All @@ -38,7 +38,7 @@ pub(crate) struct 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.
/// 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,
}

Expand Down
10 changes: 5 additions & 5 deletions crates/egui/src/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ pub enum OperatingSystem {
/// Unknown OS - could be wasm
Unknown,

/// Android OS.
/// Android OS
Android,

/// Apple iPhone OS.
/// Apple iPhone OS
IOS,

/// Linux or Unix other than Android.
/// Linux or Unix other than Android
Nix,

/// MacOS.
/// macOS
Mac,

/// Windows.
/// Windows
Windows,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub struct Style {
///
/// 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();
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/util/undoer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ pub struct Undoer<State> {

/// Stores redos immediately after a sequence of undos.
/// Gets cleared every time the state changes.
/// 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.
/// 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`.
redos: Vec<State>,

#[cfg_attr(feature = "serde", serde(skip))]
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ pub enum ViewportCommand {
/// This is equivalent to the system keyboard shortcut for copy (e.g. CTRL + C).
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).
RequestPaste,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/text_edit/text_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl TextBuffer for String {
}

fn replace_with(&mut self, text: &str) {
*self = text.to_owned();
text.clone_into(self);
}

fn take(&mut self) -> String {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_app/src/wrap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl WrapApp {
// Collect dropped files:
ctx.input(|i| {
if !i.raw.dropped_files.is_empty() {
self.dropped_files = i.raw.dropped_files.clone();
self.dropped_files.clone_from(&i.raw.dropped_files);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl MemoizedEasymarkHighlighter {
pub fn highlight(&mut self, egui_style: &egui::Style, code: &str) -> egui::text::LayoutJob {
if (&self.style, self.code.as_str()) != (egui_style, code) {
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.clone()
Expand Down
14 changes: 7 additions & 7 deletions crates/egui_plot/src/items/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ impl LineStyle {
}
}

impl ToString for LineStyle {
fn to_string(&self) -> String {
impl std::fmt::Display for LineStyle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Solid => "Solid".into(),
Self::Dotted { spacing } => format!("Dotted{spacing}Px"),
Self::Dashed { length } => format!("Dashed{length}Px"),
Self::Solid => write!(f, "Solid"),
Self::Dotted { spacing } => write!(f, "Dotted({spacing} px)"),
Self::Dashed { length } => write!(f, "Dashed({length} px)"),
}
}
}
Expand Down Expand Up @@ -426,9 +426,9 @@ impl ExplicitGenerator {

/// Result of [`super::PlotItem::find_closest()`] search, identifies an element inside the item for immediate use
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,

/// 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,
}
4 changes: 2 additions & 2 deletions crates/emath/src/rot2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use super::Vec2;
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
pub struct Rot2 {
/// angle.sin()
/// `angle.sin()`
s: f32,

/// angle.cos()
/// `angle.cos()`
c: f32,
}

Expand Down
6 changes: 3 additions & 3 deletions crates/epaint/src/text/text_layout_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ pub struct Galley {
/// `rect.top()` is always 0.0.
///
/// With [`LayoutJob::halign`]:
/// * [`Align::LEFT`]: rect.left() == 0.0
/// * [`Align::Center`]: rect.center() == 0.0
/// * [`Align::RIGHT`]: rect.right() == 0.0
/// * [`Align::LEFT`]: `rect.left() == 0.0`
/// * [`Align::Center`]: `rect.center() == 0.0`
/// * [`Align::RIGHT`]: `rect.right() == 0.0`
pub rect: Rect,

/// Tight bounding box around all the meshes in all the rows.
Expand Down
2 changes: 1 addition & 1 deletion examples/file_dialog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl eframe::App for MyApp {
// Collect dropped files:
ctx.input(|i| {
if !i.raw.dropped_files.is_empty() {
self.dropped_files = i.raw.dropped_files.clone();
self.dropped_files.clone_from(&i.raw.dropped_files);
}
});
}
Expand Down

0 comments on commit ded8dbd

Please sign in to comment.