Skip to content

Commit

Permalink
Enable and fix some more clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 5, 2022
1 parent e1f348e commit 5093b67
Show file tree
Hide file tree
Showing 28 changed files with 44 additions and 44 deletions.
6 changes: 3 additions & 3 deletions Cranky.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ warn = [
"clippy::bool_to_int_with_if",
"clippy::char_lit_as_u8",
"clippy::checked_conversions",
"clippy::cloned_instead_of_copied",
"clippy::dbg_macro",
"clippy::debug_assert_with_mut_call",
"clippy::derive_partial_eq_without_eq",
"clippy::disallowed_methods",
"clippy::disallowed_script_idents",
"clippy::doc_link_with_quotes",
Expand Down Expand Up @@ -112,11 +114,9 @@ warn = [

allow = [
# TODO(emilk): enable more lints
"clippy::cloned_instead_of_copied",
"clippy::derive_partial_eq_without_eq",
"clippy::type_complexity",
"clippy::undocumented_unsafe_blocks",
"trivial_casts",
"unsafe_op_in_unsafe_fn", # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668
"unsafe_op_in_unsafe_fn", # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668
"unused_qualifications",
]
2 changes: 1 addition & 1 deletion crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Area {

let layer_id = LayerId::new(order, id);

let state = ctx.memory().areas.get(id).cloned();
let state = ctx.memory().areas.get(id).copied();
let is_new = state.is_none();
if is_new {
ctx.request_repaint(); // if we don't know the previous size we are likely drawing the area in the wrong place
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/containers/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl PanelState {
// ----------------------------------------------------------------------------

/// [`Left`](Side::Left) or [`Right`](Side::Right)
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Side {
Left,
Right,
Expand Down Expand Up @@ -468,7 +468,7 @@ impl SidePanel {
// ----------------------------------------------------------------------------

/// [`Top`](TopBottomSide::Top) or [`Bottom`](TopBottomSide::Bottom)
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TopBottomSide {
Top,
Bottom,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/containers/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl TooltipState {

fn individual_tooltip_size(&self, common_id: Id, index: usize) -> Option<Vec2> {
if self.last_common_id == Some(common_id) {
Some(self.individual_ids_and_sizes.get(&index).cloned()?.1)
Some(self.individual_ids_and_sizes.get(&index)?.1)
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ impl Context {
ui.label("Hover to highlight");
let layers_ids: Vec<LayerId> = self.memory().areas.order().to_vec();
for layer_id in layers_ids {
let area = self.memory().areas.get(layer_id.id).cloned();
let area = self.memory().areas.get(layer_id.id).copied();
if let Some(area) = area {
let is_visible = self.memory().areas.is_visible(&layer_id);
if !is_visible {
Expand Down
8 changes: 4 additions & 4 deletions crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl RawInput {
}

/// A file about to be dropped into egui.
#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct HoveredFile {
/// Set by the `egui-winit` backend.
Expand All @@ -144,7 +144,7 @@ pub struct HoveredFile {
}

/// A file dropped into egui.
#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct DroppedFile {
/// Set by the `egui-winit` backend.
Expand Down Expand Up @@ -305,7 +305,7 @@ pub const NUM_POINTER_BUTTONS: usize = 5;
/// NOTE: For cross-platform uses, ALT+SHIFT is a bad combination of modifiers
/// as on mac that is how you type special characters,
/// so those key presses are usually not reported to egui.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Modifiers {
/// Either of the alt keys are down (option ⌥ on Mac).
Expand Down Expand Up @@ -768,7 +768,7 @@ impl Key {
///
/// Can be used with [`crate::InputState::consume_shortcut`]
/// and [`crate::Context::format_shortcut`].
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct KeyboardShortcut {
pub modifiers: Modifiers,
pub key: Key,
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/data/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl PlatformOutput {
}

/// What URL to open, and how.
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct OpenUrl {
pub url: String,
Expand Down Expand Up @@ -190,7 +190,7 @@ impl OpenUrl {
/// egui emits a [`CursorIcon`] in [`PlatformOutput`] each frame as a request to the integration.
///
/// Loosely based on <https://developer.mozilla.org/en-US/docs/Web/CSS/cursor>.
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum CursorIcon {
/// Normal cursor icon, whatever that is.
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl LayerId {
}

/// A unique identifier of a specific [`Shape`] in a [`PaintList`].
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct ShapeIdx(usize);

/// A list of [`Shape`]s paired with a clip rectangle.
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 @@ -75,7 +75,7 @@ impl Region {
// ----------------------------------------------------------------------------

/// Layout direction, one of [`LeftToRight`](Direction::LeftToRight), [`RightToLeft`](Direction::RightToLeft), [`TopDown`](Direction::TopDown), [`BottomUp`](Direction::BottomUp).
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum Direction {
LeftToRight,
Expand Down Expand Up @@ -114,7 +114,7 @@ impl Direction {
/// });
/// # });
/// ```
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
// #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Layout {
/// Main axis direction
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ pub mod special_emojis {
}

/// The different types of built-in widgets in egui
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum WidgetType {
Label, // TODO(emilk): emit Label events
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ impl Areas {
pub fn visible_layer_ids(&self) -> ahash::HashSet<LayerId> {
self.visible_last_frame
.iter()
.cloned()
.chain(self.visible_current_frame.iter().cloned())
.copied()
.chain(self.visible_current_frame.iter().copied())
.collect()
}

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 @@ -592,7 +592,7 @@ impl WidgetVisuals {
}

/// Options for help debug egui by adding extra visualization
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct DebugOptions {
/// However over widgets to see their rectangles
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/widgets/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn color_slider_2d(
}

/// What options to show for alpha
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum Alpha {
// Set alpha to 1.0, and show no option for it.
Opaque,
Expand Down Expand Up @@ -425,7 +425,7 @@ pub fn color_edit_button_rgb(ui: &mut Ui, rgb: &mut [f32; 3]) -> Response {
// To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
fn color_cache_get(ctx: &Context, rgba: impl Into<Rgba>) -> Hsva {
let rgba = rgba.into();
use_color_cache(ctx, |cc| cc.get(&rgba).cloned()).unwrap_or_else(|| Hsva::from(rgba))
use_color_cache(ctx, |cc| cc.get(&rgba).copied()).unwrap_or_else(|| Hsva::from(rgba))
}

// To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/plot/legend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::*;
use super::items::PlotItem;

/// Where to place the plot legend.
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Corner {
LeftTop,
RightTop,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/drag_and_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn drop_target<R>(
InnerResponse::new(ret, response)
}

#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct DragAndDropDemo {
/// columns with items
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/layout_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Default for LayoutTest {
}
}

#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct LayoutSettings {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/text_edit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Showcase [`TextEdit`].
#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct TextEdit {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/window_with_panels.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Clone, PartialEq, Default)]
#[derive(Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct WindowWithPanels {}

Expand Down
2 changes: 1 addition & 1 deletion crates/emath/src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl Rect {
/// Rotate the bounds (will expand the [`Rect`])
#[must_use]
#[inline]
pub fn rotate_bb(self, rot: crate::Rot2) -> Self {
pub fn rotate_bb(self, rot: Rot2) -> Self {
let a = rot * self.left_top().to_vec2();
let b = rot * self.right_top().to_vec2();
let c = rot * self.left_bottom().to_vec2();
Expand Down
4 changes: 2 additions & 2 deletions crates/emath/src/rect_transform.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::*;
use crate::{pos2, remap, remap_clamp, Pos2, Rect, Vec2};

/// Linearly transforms positions from one [`Rect`] to another.
///
/// [`RectTransform`] stores the rectangles, and therefore supports clamping and culling.
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
pub struct RectTransform {
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl ImageData {
// ----------------------------------------------------------------------------

/// A 2D RGBA color image in RAM.
#[derive(Clone, Default, PartialEq)]
#[derive(Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct ColorImage {
/// width, height.
Expand Down
4 changes: 2 additions & 2 deletions crates/epaint/src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use emath::*;
///
/// Should be friendly to send to GPU as is.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
pub struct Vertex {
Expand All @@ -23,7 +23,7 @@ pub struct Vertex {
}

/// Textured triangles in two dimensions.
#[derive(Clone, Debug, Default, PartialEq)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Mesh {
/// Draw as triangles (i.e. the length is always multiple of three).
Expand Down
6 changes: 3 additions & 3 deletions crates/epaint/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ impl Shadow {
}
}

/// Used for widnows in dark mode.
/// Used for egui windows in dark mode.
pub fn big_dark() -> Self {
Self {
extrusion: 32.0,
color: Color32::from_black_alpha(96),
}
}

/// Used for widnows in light mode.
/// Used for egui windows in light mode.
pub fn big_light() -> Self {
Self {
extrusion: 32.0,
color: Color32::from_black_alpha(16),
}
}

pub fn tessellate(&self, rect: emath::Rect, rounding: impl Into<Rounding>) -> Mesh {
pub fn tessellate(&self, rect: Rect, rounding: impl Into<Rounding>) -> Mesh {
// tessellator.clip_rect = clip_rect; // TODO(emilk): culling

let Self { extrusion, color } = *self;
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/tessellator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ pub mod path {

// ----------------------------------------------------------------------------

#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum PathType {
Open,
Closed,
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/text/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl std::ops::SubAssign<usize> for CCursor {
}

/// Row Cursor
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct RCursor {
/// 0 is first row, and so on.
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/text/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;

// ----------------------------------------------------------------------------

#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct UvRect {
/// X/Y offset for nice rendering (unit: points).
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 @@ -351,7 +351,7 @@ pub struct Galley {
pub pixels_per_point: f32,
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Row {
/// One for each `char`.
Expand All @@ -374,7 +374,7 @@ pub struct Row {
}

/// The tessellated output of a row.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct RowVisuals {
/// The tessellated text, using non-normalized (texel) UV coordinates.
Expand All @@ -400,7 +400,7 @@ impl Default for RowVisuals {
}
}

#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Glyph {
/// The character this glyph represents.
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/textures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl TextureManager {
}

/// Meta-data about an allocated texture.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TextureMeta {
/// A human-readable name useful for debugging.
pub name: String,
Expand Down

0 comments on commit 5093b67

Please sign in to comment.