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

Replace cargo-cranky with workspace lints (#4413)

Replace `cargo-cranky` (which has served us well) with workspace lints
This commit is contained in:
Emil Ernerfeldt
2024-04-25 17:24:50 +02:00
committed by GitHub
parent cee790681d
commit 2f508d6a61
82 changed files with 348 additions and 289 deletions

View File

@@ -16,6 +16,9 @@ categories = ["mathematics", "encoding"]
keywords = ["gui", "color", "conversion", "gamedev", "images"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -24,6 +24,9 @@ all-features = true
rustc-args = ["--cfg=web_sys_unstable_apis"]
targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
[lints]
workspace = true
[lib]

View File

@@ -224,6 +224,7 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS
static NSApp: Option<&'static NSApplication>;
}
// SAFETY: we don't do anything dangerous here
unsafe {
let Some(app) = NSApp else {
log::debug!("NSApp is null");

View File

@@ -5,7 +5,11 @@
//! There is a bunch of improvements we could do,
//! like removing a bunch of `unwraps`.
#![allow(clippy::arc_with_non_send_sync)] // glow::Context was accidentally non-Sync in glow 0.13, but that will be fixed in future releases of glow: https://github.com/grovesNL/glow/commit/c4a5f7151b9b4bbb380faa06ec27415235d1bf7e
// `clippy::arc_with_non_send_sync`: `glow::Context` was accidentally non-Sync in glow 0.13,
// but that will be fixed in future releases of glow.
// https://github.com/grovesNL/glow/commit/c4a5f7151b9b4bbb380faa06ec27415235d1bf7e
#![allow(clippy::arc_with_non_send_sync)]
#![allow(clippy::undocumented_unsafe_blocks)]
use std::{cell::RefCell, num::NonZeroU32, rc::Rc, sync::Arc, time::Instant};

View File

@@ -119,7 +119,7 @@ pub fn install_text_agent(runner_ref: &WebRunner) -> Result<(), JsValue> {
}
/// Focus or blur text agent to toggle mobile keyboard.
pub fn update_text_agent(runner: &mut AppRunner) -> Option<()> {
pub fn update_text_agent(runner: &AppRunner) -> Option<()> {
use web_sys::HtmlInputElement;
let window = web_sys::window()?;
let document = window.document()?;

View File

@@ -23,6 +23,9 @@ include = [
"Cargo.toml",
]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -1,3 +1,6 @@
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::undocumented_unsafe_blocks)]
use std::{num::NonZeroU32, sync::Arc};
use egui::{ViewportId, ViewportIdMap, ViewportIdSet};

View File

@@ -13,6 +13,9 @@ categories = ["gui", "game-development"]
keywords = ["winit", "egui", "gui", "gamedev"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -137,6 +137,8 @@ fn init_arboard() -> Option<arboard::Clipboard> {
fn init_smithay_clipboard(
raw_display_handle: Option<RawDisplayHandle>,
) -> Option<smithay_clipboard::Clipboard> {
#![allow(clippy::undocumented_unsafe_blocks)]
crate::profile_function!();
if let Some(RawDisplayHandle::Wayland(display)) = raw_display_handle {

View File

@@ -56,7 +56,7 @@ pub struct EventResponse {
/// (e.g. a mouse click on an egui window, or entering text into a text field).
///
/// For instance, if you use egui for a game, you should only
/// pass on the events to your game when [`Self::consumed`] is `false.
/// pass on the events to your game when [`Self::consumed`] is `false`.
///
/// Note that egui uses `tab` to move focus between elements, so this will always be `true` for tabs.
pub consumed: bool,
@@ -1521,6 +1521,9 @@ fn process_viewport_command(
/// Build and intitlaize a window.
///
/// Wrapper around `create_winit_window_builder` and `apply_viewport_builder_to_window`.
///
/// # Errors
/// Possible causes of error include denied permission, incompatible system, and lack of memory.
pub fn create_window<T>(
egui_ctx: &egui::Context,
event_loop: &EventLoopWindowTarget<T>,

View File

@@ -13,6 +13,9 @@ categories = ["gui", "game-development"]
keywords = ["gui", "imgui", "immediate", "portable", "gamedev"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -1838,7 +1838,7 @@ impl Context {
let paint_widget_id = |id: Id, text: &str, color: Color32| {
if let Some(widget) =
self.write(|ctx| ctx.viewport().widgets_this_frame.get(id).cloned())
self.write(|ctx| ctx.viewport().widgets_this_frame.get(id).copied())
{
paint_widget(&widget, text, color);
}
@@ -2398,7 +2398,7 @@ impl Context {
/// See also [`Response::contains_pointer`].
pub fn rect_contains_pointer(&self, layer_id: LayerId, rect: Rect) -> bool {
let rect =
if let Some(transform) = self.memory(|m| m.layer_transforms.get(&layer_id).cloned()) {
if let Some(transform) = self.memory(|m| m.layer_transforms.get(&layer_id).copied()) {
transform * rect
} else {
rect

View File

@@ -35,25 +35,25 @@ pub enum Key {
/// `,`
Comma,
/// '\\'
/// `\`
Backslash,
/// '/'
/// `/`
Slash,
/// '|', a vertical bar
/// `|`, a vertical bar
Pipe,
/// `?`
Questionmark,
// '['
// `[`
OpenBracket,
// ']'
// `]`
CloseBracket,
/// '`', also known as "backquote" or "grave"
/// \`, also known as "backquote" or "grave"
Backtick,
/// `-`

View File

@@ -53,7 +53,7 @@ impl BytesLoader for DefaultBytesLoader {
#[cfg(feature = "log")]
log::trace!("forget {uri:?}");
let _ = self.cache.lock().remove(uri);
self.cache.lock().remove(uri);
}
fn forget_all(&self) {

View File

@@ -465,7 +465,7 @@ impl Response {
let mut pos = self.ctx.input(|i| i.pointer.hover_pos())?;
if let Some(transform) = self
.ctx
.memory(|m| m.layer_transforms.get(&self.layer_id).cloned())
.memory(|m| m.layer_transforms.get(&self.layer_id).copied())
{
pos = transform * pos;
}

View File

@@ -78,7 +78,7 @@ pub fn paint_cursor_end(painter: &Painter, visuals: &Visuals, cursor_rect: Rect)
/// Paint one end of the selection, e.g. the primary cursor, with blinking (if enabled).
pub fn paint_text_cursor(
ui: &mut Ui,
ui: &Ui,
painter: &Painter,
primary_cursor_rect: Rect,
time_since_last_edit: f64,

View File

@@ -702,7 +702,7 @@ impl<'t> TextEdit<'t> {
// Set IME output (in screen coords) when text is editable and visible
let transform = ui
.memory(|m| m.layer_transforms.get(&ui.layer_id()).cloned())
.memory(|m| m.layer_transforms.get(&ui.layer_id()).copied())
.unwrap_or_default();
ui.ctx().output_mut(|o| {
@@ -948,7 +948,7 @@ fn events(
key,
pressed: true,
..
} => check_for_mutating_key_press(os, &mut cursor_range, text, galley, modifiers, *key),
} => check_for_mutating_key_press(os, &cursor_range, text, galley, modifiers, *key),
Event::Ime(ime_event) => match ime_event {
ImeEvent::Enabled => {
@@ -1028,7 +1028,7 @@ fn events(
/// Returns `Some(new_cursor)` if we did mutate `text`.
fn check_for_mutating_key_press(
os: OperatingSystem,
cursor_range: &mut CursorRange,
cursor_range: &CursorRange,
text: &mut dyn TextBuffer,
galley: &Galley,
modifiers: &Modifiers,

View File

@@ -8,6 +8,9 @@ rust-version.workspace = true
publish = false
default-run = "egui_demo_app"
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -1,3 +1,5 @@
#![allow(clippy::undocumented_unsafe_blocks)]
use std::sync::Arc;
use eframe::egui_glow;

View File

@@ -116,7 +116,7 @@ impl eframe::App for HttpApp {
}
}
fn ui_url(ui: &mut egui::Ui, frame: &mut eframe::Frame, url: &mut String) -> bool {
fn ui_url(ui: &mut egui::Ui, frame: &eframe::Frame, url: &mut String) -> bool {
let mut trigger_fetch = false;
ui.horizontal(|ui| {

View File

@@ -1,6 +1,7 @@
//! Demo app for egui
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example
#![allow(clippy::never_loop)] // False positive
// When compiling natively:

View File

@@ -19,6 +19,9 @@ include = [
"data/icon.png",
]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -45,7 +45,7 @@ impl EasyMarkEditor {
pub fn ui(&mut self, ui: &mut egui::Ui) {
egui::Grid::new("controls").show(ui, |ui| {
let _ = ui.button("Hotkeys").on_hover_ui(nested_hotkeys_ui);
let _response = ui.button("Hotkeys").on_hover_ui(nested_hotkeys_ui);
ui.checkbox(&mut self.show_rendered, "Show rendered");
ui.checkbox(&mut self.highlight_editor, "Highlight editor");
egui::reset_button(ui, self, "Reset");

View File

@@ -17,6 +17,9 @@ categories = ["gui", "game-development"]
keywords = ["gui", "imgui", "immediate", "portable", "gamedev"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -19,6 +19,9 @@ include = [
"src/shader/*.glsl",
]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -1,8 +1,11 @@
//! Example how to use pure `egui_glow`.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example
#![allow(clippy::undocumented_unsafe_blocks)]
#![allow(clippy::arc_with_non_send_sync)]
// `clippy::arc_with_non_send_sync`: `glow::Context` was accidentally non-Sync in glow 0.13, but that will be fixed in future releases of glow: https://github.com/grovesNL/glow/commit/c4a5f7151b9b4bbb380faa06ec27415235d1bf7e
#![allow(unsafe_code)]
#![allow(clippy::arc_with_non_send_sync)] // glow::Context was accidentally non-Sync in glow 0.13, but that will be fixed in future releases of glow: https://github.com/grovesNL/glow/commit/c4a5f7151b9b4bbb380faa06ec27415235d1bf7e
use std::num::NonZeroU32;

View File

@@ -10,6 +10,7 @@
#![allow(clippy::float_cmp)]
#![allow(clippy::manual_range_contains)]
#![allow(clippy::undocumented_unsafe_blocks)]
pub mod painter;
pub use glow;

View File

@@ -1,4 +1,5 @@
#![allow(unsafe_code)]
#![allow(clippy::undocumented_unsafe_blocks)]
use std::convert::TryInto;

View File

@@ -17,6 +17,9 @@ categories = ["visualization", "gui"]
keywords = ["egui", "plot", "plotting"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -13,6 +13,9 @@ categories = ["mathematics", "gui"]
keywords = ["math", "gui"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true

View File

@@ -22,6 +22,9 @@ include = [
"fonts/UFL.txt",
]
[lints]
workspace = true
[package.metadata.docs.rs]
all-features = true