From 14194f5d3a5d3c10a09822d3234d2e03e737a0db Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 23 Apr 2024 17:35:12 +0200 Subject: [PATCH 1/8] eframe: Use `objc2` and its framework crates (#4395) These are a replacement to the `objc` and `cocoa` crates. This PR prevents: - An extra copy when creating `NSData` - A memory leak when creating `NSImage` - A memory leak when creating `NSString` And is generally a readability improvement. Note that we define `NSApp` manually for now, the implementation in `objc2-app-kit` is currently suboptimal and wouldn't allow you to check whether the NSApplication has been created or not. Related: https://github.com/emilk/egui/issues/4219, this should nicely coincide with the Winit `0.30` release. --------- Co-authored-by: Emil Ernerfeldt --- Cargo.lock | 101 +++++++++++++++++---------- crates/eframe/Cargo.toml | 15 +++- crates/eframe/src/native/app_icon.rs | 43 +++++------- deny.toml | 3 +- 4 files changed, 99 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9214151c0a..1afbd85fbd0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,7 +548,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dd7cf50912cddc06dc5ea7c08c5e81c1b2c842a70d19def1848d54c586fed92" dependencies = [ - "objc-sys 0.3.1", + "objc-sys 0.3.3", ] [[package]] @@ -571,6 +571,15 @@ dependencies = [ "objc2 0.4.1", ] +[[package]] +name = "block2" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43ff7d91d3c1d568065b06c899777d1e48dcf76103a672a0adbc238a7f247f1e" +dependencies = [ + "objc2 0.5.1", +] + [[package]] name = "blocking" version = "1.4.0" @@ -795,36 +804,6 @@ dependencies = [ "error-code", ] -[[package]] -name = "cocoa" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" -dependencies = [ - "bitflags 1.3.2", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics", - "foreign-types", - "libc", - "objc", -] - -[[package]] -name = "cocoa-foundation" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" -dependencies = [ - "bitflags 1.3.2", - "block", - "core-foundation", - "core-graphics-types", - "libc", - "objc", -] - [[package]] name = "codespan-reporting" version = "0.11.1" @@ -1201,7 +1180,6 @@ name = "eframe" version = "0.27.2" dependencies = [ "bytemuck", - "cocoa", "directories-next", "document-features", "egui", @@ -1214,7 +1192,9 @@ dependencies = [ "image", "js-sys", "log", - "objc", + "objc2 0.5.1", + "objc2-app-kit", + "objc2-foundation", "parking_lot", "percent-encoding", "pollster", @@ -2599,9 +2579,9 @@ checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" [[package]] name = "objc-sys" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e1d07c6eab1ce8b6382b8e3c7246fe117ff3f8b34be065f5ebace6749fe845" +checksum = "da284c198fb9b7b0603f8635185e85fbd5b64ee154b1ed406d489077de2d6d60" [[package]] name = "objc2" @@ -2620,10 +2600,43 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" dependencies = [ - "objc-sys 0.3.1", + "objc-sys 0.3.3", "objc2-encode 3.0.0", ] +[[package]] +name = "objc2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b25e1034d0e636cd84707ccdaa9f81243d399196b8a773946dcffec0401659" +dependencies = [ + "objc-sys 0.3.3", + "objc2-encode 4.0.1", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb79768a710a9a1798848179edb186d1af7e8a8679f369e4b8d201dd2a034047" +dependencies = [ + "block2 0.5.0", + "objc2 0.5.1", + "objc2-core-data", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e092bc42eaf30a08844e6a076938c60751225ec81431ab89f5d1ccd9f958d6c" +dependencies = [ + "block2 0.5.0", + "objc2 0.5.1", + "objc2-foundation", +] + [[package]] name = "objc2-encode" version = "2.0.0-pre.2" @@ -2639,6 +2652,22 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" +[[package]] +name = "objc2-encode" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88658da63e4cc2c8adb1262902cd6af51094df0488b760d6fd27194269c0950a" + +[[package]] +name = "objc2-foundation" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfaefe14254871ea16c7d88968c0ff14ba554712a20d76421eec52f0a7fb8904" +dependencies = [ + "block2 0.5.0", + "objc2 0.5.1", +] + [[package]] name = "objc_exception" version = "0.1.2" diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index da1aea6badf..5b2651c9ad4 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -178,8 +178,19 @@ wgpu = { workspace = true, optional = true, features = [ # mac: [target.'cfg(any(target_os = "macos"))'.dependencies] -cocoa = "0.25.0" -objc = "0.2.7" +objc2 = "0.5.1" +objc2-foundation = { version = "0.2.0", features = [ + "block2", + "NSData", + "NSString", +] } +objc2-app-kit = { version = "0.2.0", features = [ + "NSApplication", + "NSImage", + "NSMenu", + "NSMenuItem", + "NSResponder", +] } # windows: [target.'cfg(any(target_os = "windows"))'.dependencies] diff --git a/crates/eframe/src/native/app_icon.rs b/crates/eframe/src/native/app_icon.rs index f169420863c..4986549cc1b 100644 --- a/crates/eframe/src/native/app_icon.rs +++ b/crates/eframe/src/native/app_icon.rs @@ -203,12 +203,9 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS use crate::icon_data::IconDataExt as _; crate::profile_function!(); - use cocoa::{ - appkit::{NSApp, NSApplication, NSImage, NSMenu, NSWindow}, - base::{id, nil}, - foundation::{NSData, NSString}, - }; - use objc::{msg_send, sel, sel_impl}; + use objc2::ClassType; + use objc2_app_kit::{NSApplication, NSImage}; + use objc2_foundation::{NSData, NSString}; let png_bytes = if let Some(icon_data) = icon_data { match icon_data.to_png_bytes() { @@ -222,38 +219,36 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS None }; - // SAFETY: Accessing raw data from icon in a read-only manner. Icon data is static! + // TODO(madsmtm): Move this into `objc2-app-kit` + extern "C" { + static NSApp: Option<&'static NSApplication>; + } + unsafe { - let app = NSApp(); - if app.is_null() { + let app = if let Some(app) = NSApp { + app + } else { log::debug!("NSApp is null"); return AppIconStatus::NotSetIgnored; - } + }; if let Some(png_bytes) = png_bytes { - let data = NSData::dataWithBytes_length_( - nil, - png_bytes.as_ptr().cast::(), - png_bytes.len() as u64, - ); + let data = NSData::from_vec(png_bytes); log::trace!("NSImage::initWithData…"); - let app_icon = NSImage::initWithData_(NSImage::alloc(nil), data); + let app_icon = NSImage::initWithData(NSImage::alloc(), &data); crate::profile_scope!("setApplicationIconImage_"); log::trace!("setApplicationIconImage…"); - app.setApplicationIconImage_(app_icon); + app.setApplicationIconImage(app_icon.as_deref()); } // Change the title in the top bar - for python processes this would be again "python" otherwise. - let main_menu = app.mainMenu(); - if !main_menu.is_null() { - let item = main_menu.itemAtIndex_(0); - if !item.is_null() { - let app_menu: id = msg_send![item, submenu]; - if !app_menu.is_null() { + if let Some(main_menu) = app.mainMenu() { + if let Some(item) = main_menu.itemAtIndex(0) { + if let Some(app_menu) = item.submenu() { crate::profile_scope!("setTitle_"); - app_menu.setTitle_(NSString::alloc(nil).init_str(title)); + app_menu.setTitle(&NSString::from_str(title)); } } } diff --git a/deny.toml b/deny.toml index ebe372744dd..02a9cdb04a3 100644 --- a/deny.toml +++ b/deny.toml @@ -47,6 +47,7 @@ deny = [ skip = [ { name = "bitflags" }, # old 1.0 version via glutin, png, spirv, … + { name = "block2" }, # old version via glutin->icrate { name = "event-listener" }, # TODO(emilk): rustls pulls in two versions of this 😭 { name = "libloading" }, # wgpu-hal itself depends on 0.8 while some of its dependencies, like ash and d3d12, depend on 0.7 { name = "memoffset" }, # tiny dependency @@ -61,7 +62,7 @@ skip = [ skip-tree = [ { name = "criterion" }, # dev-dependency { name = "fastrand" }, # old version via accesskit_unix - { name = "foreign-types" }, # small crate. Old version via cocoa and core-graphics (winit). + { name = "foreign-types" }, # small crate. Old version via core-graphics (winit). { name = "objc2" }, # old version via accesskit_macos { name = "polling" }, # old version via accesskit_unix { name = "rfd" }, # example dependency From bfe1858e0bdd3ee50a9d594fe9351476ede44241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Sch=C3=B6n?= Date: Thu, 25 Apr 2024 15:43:24 +0200 Subject: [PATCH 2/8] eframe: update ViewportBuilder.with_icon() documentation (#4408) `None` is no longer correct. To disable the egui icon one has to pass `IconData::default()` now. --- crates/egui/src/viewport.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/viewport.rs b/crates/egui/src/viewport.rs index 090e93b3fe5..e1e3ebf0e82 100644 --- a/crates/egui/src/viewport.rs +++ b/crates/egui/src/viewport.rs @@ -389,7 +389,7 @@ impl ViewportBuilder { /// The application icon, e.g. in the Windows task bar or the alt-tab menu. /// /// The default icon is a white `e` on a black background (for "egui" or "eframe"). - /// If you prefer the OS default, set this to `None`. + /// If you prefer the OS default, set this to `IconData::default()`. #[inline] pub fn with_icon(mut self, icon: impl Into>) -> Self { self.icon = Some(icon.into()); From cee790681d10971afdbb94aa734db71fd9ce28e6 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 25 Apr 2024 15:51:01 +0200 Subject: [PATCH 3/8] Update to Rust 1.76 (#4411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Motivation: I want to replace `cargo-cranky` with workspace lints, first available in Rust 1.74. However, `cargo doc` would hange on `wgpu` and `wgpu-core` on 1.74 and 1.75… so now we're on 1.76. I think this is fine - when 1.78 is released next week we're still two versions behind the bleeding edge. …and the branch name is just wrong 🤦 --- .github/workflows/deploy_web_demo.yml | 2 +- .github/workflows/rust.yml | 10 +++++----- Cargo.toml | 2 +- clippy.toml | 2 +- crates/eframe/src/native/app_icon.rs | 4 +--- crates/eframe/src/native/run.rs | 4 ++++ crates/eframe/src/web/storage.rs | 2 +- crates/egui/src/containers/collapsing_header.rs | 2 +- crates/egui/src/lib.rs | 4 ++-- crates/egui/src/memory.rs | 2 +- crates/egui/src/style.rs | 2 +- crates/egui_extras/src/table.rs | 2 +- crates/epaint/src/shape.rs | 7 +------ examples/confirm_exit/Cargo.toml | 2 +- examples/custom_3d_glow/Cargo.toml | 2 +- examples/custom_font/Cargo.toml | 2 +- examples/custom_font_style/Cargo.toml | 2 +- examples/custom_keypad/Cargo.toml | 2 +- examples/custom_plot_manipulation/Cargo.toml | 2 +- examples/custom_window_frame/Cargo.toml | 2 +- examples/file_dialog/Cargo.toml | 2 +- examples/hello_world/Cargo.toml | 2 +- examples/hello_world_par/Cargo.toml | 2 +- examples/hello_world_simple/Cargo.toml | 2 +- examples/images/Cargo.toml | 2 +- examples/images/src/ferris.svg | 2 +- examples/keyboard_events/Cargo.toml | 2 +- examples/multiple_viewports/Cargo.toml | 2 +- examples/puffin_profiler/Cargo.toml | 2 +- examples/save_plot/Cargo.toml | 2 +- examples/screenshot/Cargo.toml | 2 +- examples/serial_windows/Cargo.toml | 2 +- examples/test_inline_glow_paint/Cargo.toml | 2 +- examples/test_viewports/Cargo.toml | 2 +- examples/user_attention/Cargo.toml | 2 +- rust-toolchain | 2 +- scripts/clippy_wasm/clippy.toml | 2 +- 37 files changed, 45 insertions(+), 48 deletions(-) diff --git a/.github/workflows/deploy_web_demo.yml b/.github/workflows/deploy_web_demo.yml index ea2956db313..41203da390b 100644 --- a/.github/workflows/deploy_web_demo.yml +++ b/.github/workflows/deploy_web_demo.yml @@ -43,7 +43,7 @@ jobs: with: profile: minimal target: wasm32-unknown-unknown - toolchain: 1.72.0 + toolchain: 1.76.0 override: true - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d641b17b284..89983a2c48b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,7 +19,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.72.0 + toolchain: 1.76.0 - name: Install packages (Linux) if: runner.os == 'Linux' @@ -93,7 +93,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.72.0 + toolchain: 1.76.0 targets: wasm32-unknown-unknown - run: sudo apt-get update && sudo apt-get install libgtk-3-dev libatk1.0-dev @@ -151,7 +151,7 @@ jobs: - uses: actions/checkout@v4 - uses: EmbarkStudios/cargo-deny-action@v1 with: - rust-version: "1.72.0" + rust-version: "1.76.0" log-level: error command: check arguments: --target ${{ matrix.target }} @@ -166,7 +166,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.72.0 + toolchain: 1.76.0 targets: aarch64-linux-android - name: Set up cargo cache @@ -184,7 +184,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.72.0 + toolchain: 1.76.0 - name: Set up cargo cache uses: Swatinem/rust-cache@v2 diff --git a/Cargo.toml b/Cargo.toml index 425eb8de208..47ef422cb5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ members = [ [workspace.package] edition = "2021" license = "MIT OR Apache-2.0" -rust-version = "1.72" +rust-version = "1.76" version = "0.27.2" diff --git a/clippy.toml b/clippy.toml index 93d7874068e..d91f9666c47 100644 --- a/clippy.toml +++ b/clippy.toml @@ -3,7 +3,7 @@ # ----------------------------------------------------------------------------- # Section identical to scripts/clippy_wasm/clippy.toml: -msrv = "1.72" +msrv = "1.76" allow-unwrap-in-tests = true diff --git a/crates/eframe/src/native/app_icon.rs b/crates/eframe/src/native/app_icon.rs index 4986549cc1b..39c32dfdb3e 100644 --- a/crates/eframe/src/native/app_icon.rs +++ b/crates/eframe/src/native/app_icon.rs @@ -225,9 +225,7 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS } unsafe { - let app = if let Some(app) = NSApp { - app - } else { + let Some(app) = NSApp else { log::debug!("NSApp is null"); return AppIconStatus::NotSetIgnored; }; diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 896d640de36..3ee249edf76 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -391,6 +391,8 @@ pub fn run_glow( mut native_options: epi::NativeOptions, app_creator: epi::AppCreator, ) -> Result<()> { + #![allow(clippy::needless_return_with_question_mark)] // False positive + use super::glow_integration::GlowWinitApp; #[cfg(not(target_os = "ios"))] @@ -414,6 +416,8 @@ pub fn run_wgpu( mut native_options: epi::NativeOptions, app_creator: epi::AppCreator, ) -> Result<()> { + #![allow(clippy::needless_return_with_question_mark)] // False positive + use super::wgpu_integration::WgpuWinitApp; #[cfg(not(target_os = "ios"))] diff --git a/crates/eframe/src/web/storage.rs b/crates/eframe/src/web/storage.rs index 4a2a53326a1..170798dc662 100644 --- a/crates/eframe/src/web/storage.rs +++ b/crates/eframe/src/web/storage.rs @@ -31,7 +31,7 @@ pub(crate) fn load_memory(_: &egui::Context) {} #[cfg(feature = "persistence")] pub(crate) fn save_memory(ctx: &egui::Context) { - match ctx.memory(|mem| ron::to_string(mem)) { + match ctx.memory(ron::to_string) { Ok(ron) => { local_storage_set("egui_memory_ron", &ron); } diff --git a/crates/egui/src/containers/collapsing_header.rs b/crates/egui/src/containers/collapsing_header.rs index 6fb7662af22..7c541a1a2f7 100644 --- a/crates/egui/src/containers/collapsing_header.rs +++ b/crates/egui/src/containers/collapsing_header.rs @@ -230,7 +230,7 @@ impl CollapsingState { } } - /// Paint this [CollapsingState](CollapsingState)'s toggle button. Takes an [IconPainter](IconPainter) as the icon. + /// Paint this [`CollapsingState`]'s toggle button. Takes an [`IconPainter`] as the icon. /// ``` /// # egui::__run_test_ui(|ui| { /// fn circle_icon(ui: &mut egui::Ui, openness: f32, response: &egui::Response) { diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index b8f0c8fa3d2..30e3b804f11 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -517,7 +517,7 @@ macro_rules! include_image { }; } -/// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] (and line) on Github +/// Create a [`Hyperlink`] to the current [`file!()`] (and line) on Github /// /// ``` /// # egui::__run_test_ui(|ui| { @@ -532,7 +532,7 @@ macro_rules! github_link_file_line { }}; } -/// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] on github. +/// Create a [`Hyperlink`] to the current [`file!()`] on github. /// /// ``` /// # egui::__run_test_ui(|ui| { diff --git a/crates/egui/src/memory.rs b/crates/egui/src/memory.rs index 7d61acd965f..2ef8bbf58ba 100644 --- a/crates/egui/src/memory.rs +++ b/crates/egui/src/memory.rs @@ -868,7 +868,7 @@ impl Memory { // ---------------------------------------------------------------------------- /// Keeps track of [`Area`](crate::containers::area::Area)s, which are free-floating [`Ui`](crate::Ui)s. -/// These [`Area`](crate::containers::area::Area)s can be in any [`Order`](crate::Order). +/// These [`Area`](crate::containers::area::Area)s can be in any [`Order`]. #[derive(Clone, Debug, Default)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", serde(default))] diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 9f9aac0534a..aad8e3eea2d 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -288,7 +288,7 @@ pub struct Spacing { /// Default rail height of a [`Slider`]. pub slider_rail_height: f32, - /// Default (minimum) width of a [`ComboBox`](crate::ComboBox). + /// Default (minimum) width of a [`ComboBox`]. pub combo_width: f32, /// Default width of a [`TextEdit`]. diff --git a/crates/egui_extras/src/table.rs b/crates/egui_extras/src/table.rs index 5e9cf80fdcd..0cbf5e13b5f 100644 --- a/crates/egui_extras/src/table.rs +++ b/crates/egui_extras/src/table.rs @@ -131,7 +131,7 @@ impl Column { self } - /// Allowed range of movement (in points), if in a resizable [`Table`](crate::table::Table). + /// Allowed range of movement (in points), if in a resizable [`Table`]. #[inline] pub fn range(mut self, range: impl Into) -> Self { self.width_range = range.into(); diff --git a/crates/epaint/src/shape.rs b/crates/epaint/src/shape.rs index 336c9087316..593cc78b0f3 100644 --- a/crates/epaint/src/shape.rs +++ b/crates/epaint/src/shape.rs @@ -1293,12 +1293,7 @@ impl std::fmt::Debug for PaintCallback { impl std::cmp::PartialEq for PaintCallback { fn eq(&self, other: &Self) -> bool { - // As I understand it, the problem this clippy is trying to protect against - // can only happen if we do dynamic casts back and forth on the pointers, and we don't do that. - #[allow(clippy::vtable_address_comparisons)] - { - self.rect.eq(&other.rect) && Arc::ptr_eq(&self.callback, &other.callback) - } + self.rect.eq(&other.rect) && Arc::ptr_eq(&self.callback, &other.callback) } } diff --git a/examples/confirm_exit/Cargo.toml b/examples/confirm_exit/Cargo.toml index 09ad2c4f606..8e9d3af2872 100644 --- a/examples/confirm_exit/Cargo.toml +++ b/examples/confirm_exit/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/custom_3d_glow/Cargo.toml b/examples/custom_3d_glow/Cargo.toml index d7e70401a47..ef3d1cbc828 100644 --- a/examples/custom_3d_glow/Cargo.toml +++ b/examples/custom_3d_glow/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/custom_font/Cargo.toml b/examples/custom_font/Cargo.toml index db633431531..89840c4526d 100644 --- a/examples/custom_font/Cargo.toml +++ b/examples/custom_font/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/custom_font_style/Cargo.toml b/examples/custom_font_style/Cargo.toml index 51990ee919d..60e3e37b9c2 100644 --- a/examples/custom_font_style/Cargo.toml +++ b/examples/custom_font_style/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["tami5 "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/custom_keypad/Cargo.toml b/examples/custom_keypad/Cargo.toml index 1557b35c86c..f008884c5c7 100644 --- a/examples/custom_keypad/Cargo.toml +++ b/examples/custom_keypad/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Varphone Wong "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/custom_plot_manipulation/Cargo.toml b/examples/custom_plot_manipulation/Cargo.toml index 3df5de96f3d..3db38a45b92 100644 --- a/examples/custom_plot_manipulation/Cargo.toml +++ b/examples/custom_plot_manipulation/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Ygor Souza "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/custom_window_frame/Cargo.toml b/examples/custom_window_frame/Cargo.toml index e163bda492a..c334c6a662b 100644 --- a/examples/custom_window_frame/Cargo.toml +++ b/examples/custom_window_frame/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/file_dialog/Cargo.toml b/examples/file_dialog/Cargo.toml index ceafd1be28a..ef30dfce8e1 100644 --- a/examples/file_dialog/Cargo.toml +++ b/examples/file_dialog/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index e9e113c6722..acf7e2b8ab8 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/hello_world_par/Cargo.toml b/examples/hello_world_par/Cargo.toml index 442f671e330..3d0e92eaec4 100644 --- a/examples/hello_world_par/Cargo.toml +++ b/examples/hello_world_par/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Maxim Osipenko "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/hello_world_simple/Cargo.toml b/examples/hello_world_simple/Cargo.toml index 5b93eb686c7..bec4670b790 100644 --- a/examples/hello_world_simple/Cargo.toml +++ b/examples/hello_world_simple/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/images/Cargo.toml b/examples/images/Cargo.toml index b6cb142f723..cd9157f5715 100644 --- a/examples/images/Cargo.toml +++ b/examples/images/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Jan Procházka "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/images/src/ferris.svg b/examples/images/src/ferris.svg index c7f240dd97a..fe1589d912c 100644 --- a/examples/images/src/ferris.svg +++ b/examples/images/src/ferris.svg @@ -3,7 +3,7 @@ - + diff --git a/examples/keyboard_events/Cargo.toml b/examples/keyboard_events/Cargo.toml index 5428bc6a3ae..08f7ba3a81e 100644 --- a/examples/keyboard_events/Cargo.toml +++ b/examples/keyboard_events/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Jose Palazon "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/multiple_viewports/Cargo.toml b/examples/multiple_viewports/Cargo.toml index 37b27cb5f96..b5bd8e80411 100644 --- a/examples/multiple_viewports/Cargo.toml +++ b/examples/multiple_viewports/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false [features] diff --git a/examples/puffin_profiler/Cargo.toml b/examples/puffin_profiler/Cargo.toml index 021c05651a6..6b6acad726d 100644 --- a/examples/puffin_profiler/Cargo.toml +++ b/examples/puffin_profiler/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/save_plot/Cargo.toml b/examples/save_plot/Cargo.toml index cb31594343c..7c9eb245285 100644 --- a/examples/save_plot/Cargo.toml +++ b/examples/save_plot/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["hacknus "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false [dependencies] diff --git a/examples/screenshot/Cargo.toml b/examples/screenshot/Cargo.toml index 5c7bbbeec42..0fb5da7fd2a 100644 --- a/examples/screenshot/Cargo.toml +++ b/examples/screenshot/Cargo.toml @@ -7,7 +7,7 @@ authors = [ ] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/serial_windows/Cargo.toml b/examples/serial_windows/Cargo.toml index ee0f7b78d25..58d5cdecced 100644 --- a/examples/serial_windows/Cargo.toml +++ b/examples/serial_windows/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false diff --git a/examples/test_inline_glow_paint/Cargo.toml b/examples/test_inline_glow_paint/Cargo.toml index f1ff645ac27..893b0d07de1 100644 --- a/examples/test_inline_glow_paint/Cargo.toml +++ b/examples/test_inline_glow_paint/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/examples/test_viewports/Cargo.toml b/examples/test_viewports/Cargo.toml index cd5b2be0e18..4e106e37ec8 100644 --- a/examples/test_viewports/Cargo.toml +++ b/examples/test_viewports/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["konkitoman"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false [features] diff --git a/examples/user_attention/Cargo.toml b/examples/user_attention/Cargo.toml index 02a776477dd..10f0ce711c0 100644 --- a/examples/user_attention/Cargo.toml +++ b/examples/user_attention/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["TicClick "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.72" +rust-version = "1.76" publish = false [dependencies] diff --git a/rust-toolchain b/rust-toolchain index 694e5af99e5..871f562485d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -5,6 +5,6 @@ # to the user in the error, instead of "error: invalid channel name '[toolchain]'". [toolchain] -channel = "1.72.0" +channel = "1.76.0" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/scripts/clippy_wasm/clippy.toml b/scripts/clippy_wasm/clippy.toml index 0e8b9474ea7..943444cfc50 100644 --- a/scripts/clippy_wasm/clippy.toml +++ b/scripts/clippy_wasm/clippy.toml @@ -6,7 +6,7 @@ # ----------------------------------------------------------------------------- # Section identical to the root clippy.toml: -msrv = "1.72" +msrv = "1.76" allow-unwrap-in-tests = true From 2f508d6a6163c8b40ddded83eb2a7390d1e4c1e7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 25 Apr 2024 17:24:50 +0200 Subject: [PATCH 4/8] Replace cargo-cranky with workspace lints (#4413) Replace `cargo-cranky` (which has served us well) with workspace lints --- .github/pull_request_template.md | 2 +- .github/workflows/rust.yml | 20 +- Cargo.toml | 166 +++++++++++++++++ Cranky.toml | 176 ------------------ bacon.toml | 74 -------- crates/ecolor/Cargo.toml | 3 + crates/eframe/Cargo.toml | 3 + crates/eframe/src/native/app_icon.rs | 1 + crates/eframe/src/native/glow_integration.rs | 6 +- crates/eframe/src/web/text_agent.rs | 2 +- crates/egui-wgpu/Cargo.toml | 3 + crates/egui-wgpu/src/winit.rs | 3 + crates/egui-winit/Cargo.toml | 3 + crates/egui-winit/src/clipboard.rs | 2 + crates/egui-winit/src/lib.rs | 5 +- crates/egui/Cargo.toml | 3 + crates/egui/src/context.rs | 4 +- crates/egui/src/data/key.rs | 12 +- crates/egui/src/load/bytes_loader.rs | 2 +- crates/egui/src/response.rs | 2 +- crates/egui/src/text_selection/visuals.rs | 2 +- crates/egui/src/widgets/text_edit/builder.rs | 6 +- crates/egui_demo_app/Cargo.toml | 3 + .../egui_demo_app/src/apps/custom3d_glow.rs | 2 + crates/egui_demo_app/src/apps/http_app.rs | 2 +- crates/egui_demo_app/src/main.rs | 1 + crates/egui_demo_lib/Cargo.toml | 3 + .../src/easy_mark/easy_mark_editor.rs | 2 +- crates/egui_extras/Cargo.toml | 3 + crates/egui_glow/Cargo.toml | 3 + crates/egui_glow/examples/pure_glow.rs | 5 +- crates/egui_glow/src/lib.rs | 1 + crates/egui_glow/src/shader_version.rs | 1 + crates/egui_plot/Cargo.toml | 3 + crates/emath/Cargo.toml | 3 + crates/epaint/Cargo.toml | 3 + examples/confirm_exit/Cargo.toml | 3 + examples/confirm_exit/src/main.rs | 1 + examples/custom_3d_glow/Cargo.toml | 3 + examples/custom_3d_glow/src/main.rs | 2 + examples/custom_font/Cargo.toml | 3 + examples/custom_font/src/main.rs | 1 + examples/custom_font_style/Cargo.toml | 3 + examples/custom_font_style/src/main.rs | 1 + examples/custom_keypad/Cargo.toml | 3 + examples/custom_keypad/src/main.rs | 1 + examples/custom_plot_manipulation/Cargo.toml | 3 + examples/custom_plot_manipulation/src/main.rs | 1 + examples/custom_window_frame/Cargo.toml | 3 + examples/custom_window_frame/src/main.rs | 1 + examples/file_dialog/Cargo.toml | 3 + examples/file_dialog/src/main.rs | 1 + examples/hello_world/Cargo.toml | 3 + examples/hello_world/src/main.rs | 1 + examples/hello_world_par/Cargo.toml | 3 + examples/hello_world_par/src/main.rs | 1 + examples/hello_world_simple/Cargo.toml | 3 + examples/hello_world_simple/src/main.rs | 1 + examples/images/Cargo.toml | 3 + examples/images/src/main.rs | 1 + examples/keyboard_events/Cargo.toml | 3 + examples/keyboard_events/src/main.rs | 1 + examples/multiple_viewports/Cargo.toml | 3 + examples/multiple_viewports/src/main.rs | 1 + examples/puffin_profiler/Cargo.toml | 3 + examples/puffin_profiler/src/main.rs | 1 + examples/save_plot/Cargo.toml | 3 + examples/save_plot/src/main.rs | 1 + examples/screenshot/Cargo.toml | 3 + examples/screenshot/src/main.rs | 1 + examples/serial_windows/Cargo.toml | 3 + examples/serial_windows/src/main.rs | 1 + examples/test_inline_glow_paint/Cargo.toml | 3 + examples/test_inline_glow_paint/src/main.rs | 4 + examples/test_viewports/Cargo.toml | 3 + examples/test_viewports/src/main.rs | 3 + examples/user_attention/Cargo.toml | 3 + examples/user_attention/src/main.rs | 3 + scripts/check.sh | 3 +- scripts/clippy_wasm.sh | 2 +- xtask/Cargo.toml | 3 + xtask/src/main.rs | 2 + 82 files changed, 348 insertions(+), 289 deletions(-) delete mode 100644 Cranky.toml delete mode 100644 bacon.toml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c3bc239276b..98a3b496a21 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,7 +6,7 @@ Please read the "Making a PR" section of [`CONTRIBUTING.md`](https://github.com/ * If applicable, add a screenshot or gif. * If it is a non-trivial addition, consider adding a demo for it to `egui_demo_lib`, or a new example. * Do NOT open PR:s from your `master` branch, as that makes it hard for maintainers to add commits to your PR. -* Remember to run `cargo fmt` and `cargo cranky`. +* Remember to run `cargo fmt` and `cargo clippy`. * Open the PR as a draft until you have self-reviewed it and run `./scripts/check.sh`. * When you have addressed a PR comment, mark it as resolved. diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 89983a2c48b..26404d294a3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -40,11 +40,6 @@ jobs: - name: Lint vertical spacing run: ./scripts/lint.py - - name: Install cargo-cranky - uses: baptiste0928/cargo-install@v1 - with: - crate: cargo-cranky - - name: check --all-features run: cargo check --locked --all-features --all-targets @@ -78,11 +73,11 @@ jobs: - name: Test run: cargo test --all-features - - name: Cranky - run: cargo cranky --all-targets --all-features -- -D warnings + - name: clippy + run: cargo clippy --all-targets --all-features -- -D warnings - - name: Cranky release - run: cargo cranky --all-targets --all-features --release -- -D warnings + - name: clippy release + run: cargo clippy --all-targets --all-features --release -- -D warnings # --------------------------------------------------------------------------- @@ -101,11 +96,6 @@ jobs: - name: Set up cargo cache uses: Swatinem/rust-cache@v2 - - name: Install cargo-cranky - uses: baptiste0928/cargo-install@v1 - with: - crate: cargo-cranky - - name: Check wasm32 egui_demo_app run: cargo check -p egui_demo_app --lib --target wasm32-unknown-unknown @@ -122,7 +112,7 @@ jobs: - run: ./scripts/wasm_bindgen_check.sh --skip-setup - - name: Cranky wasm32 + - name: clippy wasm32 run: ./scripts/clippy_wasm.sh # --------------------------------------------------------------------------- diff --git a/Cargo.toml b/Cargo.toml index 47ef422cb5a..c94baab2843 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,3 +84,169 @@ wgpu = { version = "0.19.1", default-features = false, features = [ "fragile-send-sync-non-atomic-wasm", ] } winit = { version = "0.29.4", default-features = false } + + +[workspace.lints.rust] +unsafe_code = "deny" + +elided_lifetimes_in_paths = "warn" +future_incompatible = "warn" +nonstandard_style = "warn" +rust_2018_idioms = "warn" +rust_2021_prelude_collisions = "warn" +semicolon_in_expressions_from_macros = "warn" +trivial_numeric_casts = "warn" +unsafe_op_in_unsafe_fn = "warn" # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668 +unused_extern_crates = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" + +trivial_casts = "allow" +unused_qualifications = "allow" + +[workspace.lints.rustdoc] +all = "warn" +missing_crate_level_docs = "warn" + +# See also clippy.toml +[workspace.lints.clippy] +as_ptr_cast_mut = "warn" +await_holding_lock = "warn" +bool_to_int_with_if = "warn" +char_lit_as_u8 = "warn" +checked_conversions = "warn" +clear_with_drain = "warn" +cloned_instead_of_copied = "warn" +dbg_macro = "warn" +debug_assert_with_mut_call = "warn" +derive_partial_eq_without_eq = "warn" +disallowed_macros = "warn" # See clippy.toml +disallowed_methods = "warn" # See clippy.toml +disallowed_names = "warn" # See clippy.toml +disallowed_script_idents = "warn" # See clippy.toml +disallowed_types = "warn" # See clippy.toml +doc_link_with_quotes = "warn" +doc_markdown = "warn" +empty_enum = "warn" +enum_glob_use = "warn" +equatable_if_let = "warn" +exit = "warn" +expl_impl_clone_on_copy = "warn" +explicit_deref_methods = "warn" +explicit_into_iter_loop = "warn" +explicit_iter_loop = "warn" +fallible_impl_from = "warn" +filter_map_next = "warn" +flat_map_option = "warn" +float_cmp_const = "warn" +fn_params_excessive_bools = "warn" +fn_to_numeric_cast_any = "warn" +from_iter_instead_of_collect = "warn" +get_unwrap = "warn" +if_let_mutex = "warn" +implicit_clone = "warn" +implied_bounds_in_impls = "warn" +imprecise_flops = "warn" +index_refutable_slice = "warn" +inefficient_to_string = "warn" +infinite_loop = "warn" +into_iter_without_iter = "warn" +invalid_upcast_comparisons = "warn" +iter_not_returning_iterator = "warn" +iter_on_empty_collections = "warn" +iter_on_single_items = "warn" +iter_without_into_iter = "warn" +large_digit_groups = "warn" +large_include_file = "warn" +large_stack_arrays = "warn" +large_stack_frames = "warn" +large_types_passed_by_value = "warn" +let_unit_value = "warn" +linkedlist = "warn" +lossy_float_literal = "warn" +macro_use_imports = "warn" +manual_assert = "warn" +manual_clamp = "warn" +manual_instant_elapsed = "warn" +manual_let_else = "warn" +manual_ok_or = "warn" +manual_string_new = "warn" +map_err_ignore = "warn" +map_flatten = "warn" +map_unwrap_or = "warn" +match_on_vec_items = "warn" +match_same_arms = "warn" +match_wild_err_arm = "warn" +match_wildcard_for_single_variants = "warn" +mem_forget = "warn" +mismatched_target_os = "warn" +mismatching_type_param_order = "warn" +missing_enforced_import_renames = "warn" +missing_errors_doc = "warn" +missing_safety_doc = "warn" +mut_mut = "warn" +mutex_integer = "warn" +needless_borrow = "warn" +needless_continue = "warn" +needless_for_each = "warn" +needless_pass_by_ref_mut = "warn" +needless_pass_by_value = "warn" +negative_feature_names = "warn" +nonstandard_macro_braces = "warn" +option_option = "warn" +path_buf_push_overwrite = "warn" +ptr_as_ptr = "warn" +ptr_cast_constness = "warn" +pub_without_shorthand = "warn" +rc_mutex = "warn" +readonly_write_lock = "warn" +redundant_type_annotations = "warn" +ref_option_ref = "warn" +ref_patterns = "warn" +rest_pat_in_fully_bound_structs = "warn" +same_functions_in_if_condition = "warn" +semicolon_if_nothing_returned = "warn" +single_match_else = "warn" +str_to_string = "warn" +string_add = "warn" +string_add_assign = "warn" +string_lit_as_bytes = "warn" +string_lit_chars_any = "warn" +string_to_string = "warn" +suspicious_command_arg_space = "warn" +suspicious_xor_used_as_pow = "warn" +todo = "warn" +trailing_empty_array = "warn" +trait_duplication_in_bounds = "warn" +tuple_array_conversions = "warn" +unchecked_duration_subtraction = "warn" +undocumented_unsafe_blocks = "warn" +unimplemented = "warn" +uninhabited_references = "warn" +uninlined_format_args = "warn" +unnecessary_box_returns = "warn" +unnecessary_safety_doc = "warn" +unnecessary_struct_initialization = "warn" +unnecessary_wraps = "warn" +unnested_or_patterns = "warn" +unused_peekable = "warn" +unused_rounding = "warn" +unused_self = "warn" +useless_transmute = "warn" +verbose_file_reads = "warn" +wildcard_dependencies = "warn" +zero_sized_map_values = "warn" + +# TODO(emilk): enable more of these linits: +iter_over_hash_type = "allow" +let_underscore_untyped = "allow" +missing_assert_message = "allow" +print_stderr = "allow" # TODO(emilk): use `log` crate insteaditer_over_hash_type = "allow" +should_panic_without_expect = "allow" +too_many_lines = "allow" +unwrap_used = "allow" # TODO(emilk): We really wanna warn on this one + +manual_range_contains = "allow" # this one is just worse imho +self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602 +significant_drop_tightening = "allow" # Too many false positives +wildcard_imports = "allow" # we do this a lot in egui diff --git a/Cranky.toml b/Cranky.toml deleted file mode 100644 index db236bff421..00000000000 --- a/Cranky.toml +++ /dev/null @@ -1,176 +0,0 @@ -# https://github.com/ericseppanen/cargo-cranky -# cargo install cargo-cranky && cargo cranky -# See also clippy.toml - -deny = ["unsafe_code"] - -warn = [ - "clippy::all", - "clippy::as_ptr_cast_mut", - "clippy::await_holding_lock", - "clippy::bool_to_int_with_if", - "clippy::branches_sharing_code", - "clippy::char_lit_as_u8", - "clippy::checked_conversions", - "clippy::clear_with_drain", - "clippy::cloned_instead_of_copied", - "clippy::dbg_macro", - "clippy::debug_assert_with_mut_call", - "clippy::default_union_representation", - "clippy::derive_partial_eq_without_eq", - "clippy::disallowed_macros", # See clippy.toml - "clippy::disallowed_methods", # See clippy.toml - "clippy::disallowed_names", # See clippy.toml - "clippy::disallowed_script_idents", # See clippy.toml - "clippy::disallowed_types", # See clippy.toml - "clippy::doc_link_with_quotes", - "clippy::doc_markdown", - "clippy::empty_enum", - "clippy::empty_line_after_outer_attr", - "clippy::enum_glob_use", - "clippy::equatable_if_let", - "clippy::exit", - "clippy::expl_impl_clone_on_copy", - "clippy::explicit_deref_methods", - "clippy::explicit_into_iter_loop", - "clippy::explicit_iter_loop", - "clippy::fallible_impl_from", - "clippy::filter_map_next", - "clippy::flat_map_option", - "clippy::float_cmp_const", - "clippy::fn_params_excessive_bools", - "clippy::fn_to_numeric_cast_any", - "clippy::from_iter_instead_of_collect", - "clippy::get_unwrap", - "clippy::if_let_mutex", - "clippy::implicit_clone", - "clippy::imprecise_flops", - "clippy::index_refutable_slice", - "clippy::inefficient_to_string", - "clippy::invalid_upcast_comparisons", - "clippy::iter_not_returning_iterator", - "clippy::iter_on_empty_collections", - "clippy::iter_on_single_items", - "clippy::large_digit_groups", - "clippy::large_include_file", - "clippy::large_stack_arrays", - "clippy::large_stack_frames", - "clippy::large_types_passed_by_value", - "clippy::let_unit_value", - "clippy::linkedlist", - "clippy::lossy_float_literal", - "clippy::macro_use_imports", - "clippy::manual_assert", - "clippy::manual_clamp", - "clippy::manual_instant_elapsed", - "clippy::manual_let_else", - "clippy::manual_ok_or", - "clippy::manual_string_new", - "clippy::map_err_ignore", - "clippy::map_flatten", - "clippy::map_unwrap_or", - "clippy::match_on_vec_items", - "clippy::match_same_arms", - "clippy::match_wild_err_arm", - "clippy::match_wildcard_for_single_variants", - "clippy::mem_forget", - "clippy::mismatched_target_os", - "clippy::mismatching_type_param_order", - "clippy::missing_enforced_import_renames", - "clippy::missing_errors_doc", - "clippy::missing_safety_doc", - "clippy::mut_mut", - "clippy::mutex_integer", - "clippy::needless_borrow", - "clippy::needless_continue", - "clippy::needless_for_each", - "clippy::needless_pass_by_value", - "clippy::negative_feature_names", - "clippy::nonstandard_macro_braces", - "clippy::option_option", - "clippy::path_buf_push_overwrite", - "clippy::print_stdout", - "clippy::ptr_as_ptr", - "clippy::ptr_cast_constness", - "clippy::pub_without_shorthand", - "clippy::rc_mutex", - "clippy::redundant_type_annotations", - "clippy::ref_option_ref", - "clippy::rest_pat_in_fully_bound_structs", - "clippy::same_functions_in_if_condition", - "clippy::semicolon_if_nothing_returned", - "clippy::significant_drop_tightening", - "clippy::single_match_else", - "clippy::str_to_string", - "clippy::string_add_assign", - "clippy::string_add", - "clippy::string_lit_as_bytes", - "clippy::string_to_string", - "clippy::suspicious_command_arg_space", - "clippy::suspicious_xor_used_as_pow", - "clippy::todo", - "clippy::trailing_empty_array", - "clippy::trait_duplication_in_bounds", - "clippy::transmute_ptr_to_ptr", - "clippy::tuple_array_conversions", - "clippy::unchecked_duration_subtraction", - "clippy::undocumented_unsafe_blocks", - "clippy::unimplemented", - "clippy::uninlined_format_args", - "clippy::unnecessary_box_returns", - "clippy::unnecessary_safety_comment", - "clippy::unnecessary_safety_doc", - "clippy::unnecessary_self_imports", - "clippy::unnecessary_struct_initialization", - "clippy::unnecessary_wraps", - "clippy::unnested_or_patterns", - "clippy::unused_peekable", - "clippy::unused_rounding", - "clippy::unused_self", - "clippy::use_self", - "clippy::useless_transmute", - "clippy::verbose_file_reads", - "clippy::wildcard_dependencies", - "clippy::wildcard_imports", - "clippy::zero_sized_map_values", - "elided_lifetimes_in_paths", - "future_incompatible", - "nonstandard_style", - "rust_2018_idioms", - "rust_2021_prelude_collisions", - "rustdoc::missing_crate_level_docs", - "semicolon_in_expressions_from_macros", - "trivial_numeric_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 - "unused_extern_crates", - "unused_import_braces", - "unused_lifetimes", - - - # Enable when we update MSRV: - # "clippy::implied_bounds_in_impls", - # "clippy::needless_pass_by_ref_mut", - # "clippy::readonly_write_lock", - # "clippy::should_panic_without_expect", - # "clippy::string_lit_chars_any", -] - -allow = [ - "clippy::manual_range_contains", # this one is just worse imho - "clippy::significant_drop_tightening", # A lot of false positives - - # TODO(emilk): enable more of these lints: - "clippy::cloned_instead_of_copied", - "clippy::let_underscore_untyped", - "clippy::missing_assert_message", - "clippy::missing_errors_doc", - "clippy::print_stderr", # TODO(emilk): use `log` crate instead - "clippy::self_named_module_files", # False positives - "clippy::too_many_lines", - "clippy::undocumented_unsafe_blocks", - "clippy::unwrap_used", - "clippy::useless_let_if_seq", # False positives - "clippy::wildcard_imports", # We do this a lot - "trivial_casts", - "unused_qualifications", -] diff --git a/bacon.toml b/bacon.toml deleted file mode 100644 index 63d72eeb055..00000000000 --- a/bacon.toml +++ /dev/null @@ -1,74 +0,0 @@ -# This is a configuration file for the bacon tool -# More info at https://github.com/Canop/bacon - -default_job = "cranky" - -[jobs] - -[jobs.cranky] -command = [ - "cargo", - "cranky", - "--all-targets", - "--all-features", - "--color=always", -] -need_stdout = false -watch = ["tests", "benches", "examples"] - -[jobs.wasm] -command = [ - "cargo", - "cranky", - "-p=egui_demo_app", - "--lib", - "--target=wasm32-unknown-unknown", - "--target-dir=target_wasm", - "--all-features", - "--color=always", -] -need_stdout = false -watch = ["tests", "benches", "examples"] - -[jobs.test] -command = ["cargo", "test", "--color=always"] -need_stdout = true -watch = ["tests"] - -[jobs.doc] -command = ["cargo", "doc", "--color=always", "--all-features", "--no-deps"] -need_stdout = false - -# if the doc compiles, then it opens in your browser and bacon switches -# to the previous job -[jobs.doc-open] -command = [ - "cargo", - "doc", - "--color=always", - "--all-features", - "--no-deps", - "--open", -] -need_stdout = false -on_success = "back" # so that we don't open the browser at each change - -# You can run your application and have the result displayed in bacon, -# *if* it makes sense for this crate. You can run an example the same -# way. Don't forget the `--color always` part or the errors won't be -# properly parsed. -[jobs.run] -command = ["cargo", "run", "--color=always"] -need_stdout = true - -# You may define here keybindings that would be specific to -# a project, for example a shortcut to launch a specific job. -# Shortcuts to internal functions (scrolling, toggling, etc.) -# should go in your personal prefs.toml file instead. -[keybindings] -i = "job:initial" -c = "job:cranky" -a = "job:wasm" -d = "job:doc-open" -t = "job:test" -r = "job:run" diff --git a/crates/ecolor/Cargo.toml b/crates/ecolor/Cargo.toml index 611b9a4dec9..ad5d6f96369 100644 --- a/crates/ecolor/Cargo.toml +++ b/crates/ecolor/Cargo.toml @@ -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 diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index 5b2651c9ad4..c5cfae87733 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -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] diff --git a/crates/eframe/src/native/app_icon.rs b/crates/eframe/src/native/app_icon.rs index 39c32dfdb3e..90100298680 100644 --- a/crates/eframe/src/native/app_icon.rs +++ b/crates/eframe/src/native/app_icon.rs @@ -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"); diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index 880b906c2b8..f08ed14d623 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -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}; diff --git a/crates/eframe/src/web/text_agent.rs b/crates/eframe/src/web/text_agent.rs index c61b7093596..5cfec81bf30 100644 --- a/crates/eframe/src/web/text_agent.rs +++ b/crates/eframe/src/web/text_agent.rs @@ -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()?; diff --git a/crates/egui-wgpu/Cargo.toml b/crates/egui-wgpu/Cargo.toml index 09e48e07643..817233b88ba 100644 --- a/crates/egui-wgpu/Cargo.toml +++ b/crates/egui-wgpu/Cargo.toml @@ -23,6 +23,9 @@ include = [ "Cargo.toml", ] +[lints] +workspace = true + [package.metadata.docs.rs] all-features = true diff --git a/crates/egui-wgpu/src/winit.rs b/crates/egui-wgpu/src/winit.rs index 07c917155aa..84dd0b41235 100644 --- a/crates/egui-wgpu/src/winit.rs +++ b/crates/egui-wgpu/src/winit.rs @@ -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}; diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index a09829699fc..fc2b8a53620 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -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 diff --git a/crates/egui-winit/src/clipboard.rs b/crates/egui-winit/src/clipboard.rs index c86a9e19d5b..44e3840b64f 100644 --- a/crates/egui-winit/src/clipboard.rs +++ b/crates/egui-winit/src/clipboard.rs @@ -137,6 +137,8 @@ fn init_arboard() -> Option { fn init_smithay_clipboard( raw_display_handle: Option, ) -> Option { + #![allow(clippy::undocumented_unsafe_blocks)] + crate::profile_function!(); if let Some(RawDisplayHandle::Wayland(display)) = raw_display_handle { diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 313cc58906b..abadd9ee5c2 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -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( egui_ctx: &egui::Context, event_loop: &EventLoopWindowTarget, diff --git a/crates/egui/Cargo.toml b/crates/egui/Cargo.toml index 87b25a7ea4b..a1929f060ad 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -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 diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index aa8a0b13e32..192b0cc49d4 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -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 diff --git a/crates/egui/src/data/key.rs b/crates/egui/src/data/key.rs index 92e6b69dba2..66fe6b9336f 100644 --- a/crates/egui/src/data/key.rs +++ b/crates/egui/src/data/key.rs @@ -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, /// `-` diff --git a/crates/egui/src/load/bytes_loader.rs b/crates/egui/src/load/bytes_loader.rs index 3ab46794912..d03b2ad418a 100644 --- a/crates/egui/src/load/bytes_loader.rs +++ b/crates/egui/src/load/bytes_loader.rs @@ -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) { diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index 1bee1b29860..44eb4f74bd6 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -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; } diff --git a/crates/egui/src/text_selection/visuals.rs b/crates/egui/src/text_selection/visuals.rs index 4fc8af0abd4..d31f1756edd 100644 --- a/crates/egui/src/text_selection/visuals.rs +++ b/crates/egui/src/text_selection/visuals.rs @@ -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, diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index c0b8532d6d9..440916f31b2 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -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, diff --git a/crates/egui_demo_app/Cargo.toml b/crates/egui_demo_app/Cargo.toml index b928702e08b..4ae9572bd0a 100644 --- a/crates/egui_demo_app/Cargo.toml +++ b/crates/egui_demo_app/Cargo.toml @@ -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 diff --git a/crates/egui_demo_app/src/apps/custom3d_glow.rs b/crates/egui_demo_app/src/apps/custom3d_glow.rs index 7f488e7671e..ad6bfc3bc60 100644 --- a/crates/egui_demo_app/src/apps/custom3d_glow.rs +++ b/crates/egui_demo_app/src/apps/custom3d_glow.rs @@ -1,3 +1,5 @@ +#![allow(clippy::undocumented_unsafe_blocks)] + use std::sync::Arc; use eframe::egui_glow; diff --git a/crates/egui_demo_app/src/apps/http_app.rs b/crates/egui_demo_app/src/apps/http_app.rs index d0da5c0a395..d6b57284267 100644 --- a/crates/egui_demo_app/src/apps/http_app.rs +++ b/crates/egui_demo_app/src/apps/http_app.rs @@ -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| { diff --git a/crates/egui_demo_app/src/main.rs b/crates/egui_demo_app/src/main.rs index 45b0ee067a4..9d660ed046c 100644 --- a/crates/egui_demo_app/src/main.rs +++ b/crates/egui_demo_app/src/main.rs @@ -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: diff --git a/crates/egui_demo_lib/Cargo.toml b/crates/egui_demo_lib/Cargo.toml index 8c5a703b5d6..d1daa5b8cfb 100644 --- a/crates/egui_demo_lib/Cargo.toml +++ b/crates/egui_demo_lib/Cargo.toml @@ -19,6 +19,9 @@ include = [ "data/icon.png", ] +[lints] +workspace = true + [package.metadata.docs.rs] all-features = true diff --git a/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs b/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs index 0b0bb9608a3..be2650cb03e 100644 --- a/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs +++ b/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs @@ -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"); diff --git a/crates/egui_extras/Cargo.toml b/crates/egui_extras/Cargo.toml index a0829180924..372f754cc52 100644 --- a/crates/egui_extras/Cargo.toml +++ b/crates/egui_extras/Cargo.toml @@ -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 diff --git a/crates/egui_glow/Cargo.toml b/crates/egui_glow/Cargo.toml index 1ee1f6cd90b..6bb081980d3 100644 --- a/crates/egui_glow/Cargo.toml +++ b/crates/egui_glow/Cargo.toml @@ -19,6 +19,9 @@ include = [ "src/shader/*.glsl", ] +[lints] +workspace = true + [package.metadata.docs.rs] all-features = true diff --git a/crates/egui_glow/examples/pure_glow.rs b/crates/egui_glow/examples/pure_glow.rs index 3da382af6ec..70f07421475 100644 --- a/crates/egui_glow/examples/pure_glow.rs +++ b/crates/egui_glow/examples/pure_glow.rs @@ -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; diff --git a/crates/egui_glow/src/lib.rs b/crates/egui_glow/src/lib.rs index b12d2ff5f61..8621dbd74e7 100644 --- a/crates/egui_glow/src/lib.rs +++ b/crates/egui_glow/src/lib.rs @@ -10,6 +10,7 @@ #![allow(clippy::float_cmp)] #![allow(clippy::manual_range_contains)] +#![allow(clippy::undocumented_unsafe_blocks)] pub mod painter; pub use glow; diff --git a/crates/egui_glow/src/shader_version.rs b/crates/egui_glow/src/shader_version.rs index c59792a0aba..77c1e63cea9 100644 --- a/crates/egui_glow/src/shader_version.rs +++ b/crates/egui_glow/src/shader_version.rs @@ -1,4 +1,5 @@ #![allow(unsafe_code)] +#![allow(clippy::undocumented_unsafe_blocks)] use std::convert::TryInto; diff --git a/crates/egui_plot/Cargo.toml b/crates/egui_plot/Cargo.toml index 61faf7432c0..91c4b3a50fc 100644 --- a/crates/egui_plot/Cargo.toml +++ b/crates/egui_plot/Cargo.toml @@ -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 diff --git a/crates/emath/Cargo.toml b/crates/emath/Cargo.toml index a48a9cbdbaf..ae0153cc9f2 100644 --- a/crates/emath/Cargo.toml +++ b/crates/emath/Cargo.toml @@ -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 diff --git a/crates/epaint/Cargo.toml b/crates/epaint/Cargo.toml index a24a299b8ed..861afb1a14b 100644 --- a/crates/epaint/Cargo.toml +++ b/crates/epaint/Cargo.toml @@ -22,6 +22,9 @@ include = [ "fonts/UFL.txt", ] +[lints] +workspace = true + [package.metadata.docs.rs] all-features = true diff --git a/examples/confirm_exit/Cargo.toml b/examples/confirm_exit/Cargo.toml index 8e9d3af2872..b1cab21a1bb 100644 --- a/examples/confirm_exit/Cargo.toml +++ b/examples/confirm_exit/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/confirm_exit/src/main.rs b/examples/confirm_exit/src/main.rs index 3a09da59d91..14816e1bdea 100644 --- a/examples/confirm_exit/src/main.rs +++ b/examples/confirm_exit/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; diff --git a/examples/custom_3d_glow/Cargo.toml b/examples/custom_3d_glow/Cargo.toml index ef3d1cbc828..3b8c9a45383 100644 --- a/examples/custom_3d_glow/Cargo.toml +++ b/examples/custom_3d_glow/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/custom_3d_glow/src/main.rs b/examples/custom_3d_glow/src/main.rs index a1f6fa26946..241124b7c17 100644 --- a/examples/custom_3d_glow/src/main.rs +++ b/examples/custom_3d_glow/src/main.rs @@ -1,5 +1,7 @@ #![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(unsafe_code)] +#![allow(clippy::undocumented_unsafe_blocks)] use eframe::{egui, egui_glow, glow}; diff --git a/examples/custom_font/Cargo.toml b/examples/custom_font/Cargo.toml index 89840c4526d..d6021c12425 100644 --- a/examples/custom_font/Cargo.toml +++ b/examples/custom_font/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/custom_font/src/main.rs b/examples/custom_font/src/main.rs index 8a852319dd1..f42c5763150 100644 --- a/examples/custom_font/src/main.rs +++ b/examples/custom_font/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; diff --git a/examples/custom_font_style/Cargo.toml b/examples/custom_font_style/Cargo.toml index 60e3e37b9c2..65b5045238c 100644 --- a/examples/custom_font_style/Cargo.toml +++ b/examples/custom_font_style/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/custom_font_style/src/main.rs b/examples/custom_font_style/src/main.rs index 89117b4f01a..c1a61e3e69c 100644 --- a/examples/custom_font_style/src/main.rs +++ b/examples/custom_font_style/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; use egui::{FontFamily, FontId, RichText, TextStyle}; diff --git a/examples/custom_keypad/Cargo.toml b/examples/custom_keypad/Cargo.toml index f008884c5c7..7d000fd0d46 100644 --- a/examples/custom_keypad/Cargo.toml +++ b/examples/custom_keypad/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/custom_keypad/src/main.rs b/examples/custom_keypad/src/main.rs index 5cb26240cbd..654de25fa44 100644 --- a/examples/custom_keypad/src/main.rs +++ b/examples/custom_keypad/src/main.rs @@ -1,4 +1,5 @@ // #![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 use eframe::egui; mod keypad; diff --git a/examples/custom_plot_manipulation/Cargo.toml b/examples/custom_plot_manipulation/Cargo.toml index 3db38a45b92..fc7b66c5ccc 100644 --- a/examples/custom_plot_manipulation/Cargo.toml +++ b/examples/custom_plot_manipulation/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/custom_plot_manipulation/src/main.rs b/examples/custom_plot_manipulation/src/main.rs index 4dffaf18ed1..e423d890fcb 100644 --- a/examples/custom_plot_manipulation/src/main.rs +++ b/examples/custom_plot_manipulation/src/main.rs @@ -1,5 +1,6 @@ //! This example shows how to implement custom gestures to pan and zoom in the plot #![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 use eframe::egui::{self, DragValue, Event, Vec2}; use egui_plot::{Legend, Line, PlotPoints}; diff --git a/examples/custom_window_frame/Cargo.toml b/examples/custom_window_frame/Cargo.toml index c334c6a662b..6b800d0a0af 100644 --- a/examples/custom_window_frame/Cargo.toml +++ b/examples/custom_window_frame/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/custom_window_frame/src/main.rs b/examples/custom_window_frame/src/main.rs index 87daf82e06a..bb098652cbf 100644 --- a/examples/custom_window_frame/src/main.rs +++ b/examples/custom_window_frame/src/main.rs @@ -1,6 +1,7 @@ //! Show a custom window frame instead of the default OS window chrome decorations. #![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 use eframe::egui::{self, ViewportCommand}; diff --git a/examples/file_dialog/Cargo.toml b/examples/file_dialog/Cargo.toml index ef30dfce8e1..9684a423256 100644 --- a/examples/file_dialog/Cargo.toml +++ b/examples/file_dialog/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/file_dialog/src/main.rs b/examples/file_dialog/src/main.rs index 4077c6de4a2..d0623a73a28 100644 --- a/examples/file_dialog/src/main.rs +++ b/examples/file_dialog/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index acf7e2b8ab8..bdd728a61e1 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/hello_world/src/main.rs b/examples/hello_world/src/main.rs index b3fda5a5810..1c74f4c4992 100644 --- a/examples/hello_world/src/main.rs +++ b/examples/hello_world/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; diff --git a/examples/hello_world_par/Cargo.toml b/examples/hello_world_par/Cargo.toml index 3d0e92eaec4..e64cdd36108 100644 --- a/examples/hello_world_par/Cargo.toml +++ b/examples/hello_world_par/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, default-features = false, features = [ diff --git a/examples/hello_world_par/src/main.rs b/examples/hello_world_par/src/main.rs index 617e840dc4c..2896f24843f 100644 --- a/examples/hello_world_par/src/main.rs +++ b/examples/hello_world_par/src/main.rs @@ -1,6 +1,7 @@ //! This example shows that you can use egui in parallel from multiple threads. #![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 use std::sync::mpsc; use std::thread::JoinHandle; diff --git a/examples/hello_world_simple/Cargo.toml b/examples/hello_world_simple/Cargo.toml index bec4670b790..c88382b9f6d 100644 --- a/examples/hello_world_simple/Cargo.toml +++ b/examples/hello_world_simple/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/hello_world_simple/src/main.rs b/examples/hello_world_simple/src/main.rs index 5f0ed31a49f..4e48feeff90 100644 --- a/examples/hello_world_simple/src/main.rs +++ b/examples/hello_world_simple/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; diff --git a/examples/images/Cargo.toml b/examples/images/Cargo.toml index cd9157f5715..092535c9125 100644 --- a/examples/images/Cargo.toml +++ b/examples/images/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/images/src/main.rs b/examples/images/src/main.rs index efb088b6727..8a124e051a5 100644 --- a/examples/images/src/main.rs +++ b/examples/images/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; diff --git a/examples/keyboard_events/Cargo.toml b/examples/keyboard_events/Cargo.toml index 08f7ba3a81e..f7b12047062 100644 --- a/examples/keyboard_events/Cargo.toml +++ b/examples/keyboard_events/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/keyboard_events/src/main.rs b/examples/keyboard_events/src/main.rs index 581ae11eb74..bf0b3389981 100644 --- a/examples/keyboard_events/src/main.rs +++ b/examples/keyboard_events/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; use egui::*; diff --git a/examples/multiple_viewports/Cargo.toml b/examples/multiple_viewports/Cargo.toml index b5bd8e80411..7aad28550fc 100644 --- a/examples/multiple_viewports/Cargo.toml +++ b/examples/multiple_viewports/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [features] wgpu = ["eframe/wgpu"] diff --git a/examples/multiple_viewports/src/main.rs b/examples/multiple_viewports/src/main.rs index 0ef06e7815f..262002e2c5b 100644 --- a/examples/multiple_viewports/src/main.rs +++ b/examples/multiple_viewports/src/main.rs @@ -1,4 +1,5 @@ #![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 use std::sync::{ atomic::{AtomicBool, Ordering}, diff --git a/examples/puffin_profiler/Cargo.toml b/examples/puffin_profiler/Cargo.toml index 6b6acad726d..d787eeb9168 100644 --- a/examples/puffin_profiler/Cargo.toml +++ b/examples/puffin_profiler/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [features] wgpu = ["eframe/wgpu"] diff --git a/examples/puffin_profiler/src/main.rs b/examples/puffin_profiler/src/main.rs index 521184f506b..8fe30d679ff 100644 --- a/examples/puffin_profiler/src/main.rs +++ b/examples/puffin_profiler/src/main.rs @@ -1,4 +1,5 @@ #![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 use std::sync::{ atomic::{AtomicBool, Ordering}, diff --git a/examples/save_plot/Cargo.toml b/examples/save_plot/Cargo.toml index 7c9eb245285..c4c287c001d 100644 --- a/examples/save_plot/Cargo.toml +++ b/examples/save_plot/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ "default", diff --git a/examples/save_plot/src/main.rs b/examples/save_plot/src/main.rs index 3f13d3f28b6..61657faae86 100644 --- a/examples/save_plot/src/main.rs +++ b/examples/save_plot/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; use egui_plot::{Legend, Line, Plot, PlotPoints}; diff --git a/examples/screenshot/Cargo.toml b/examples/screenshot/Cargo.toml index 0fb5da7fd2a..aba066669c9 100644 --- a/examples/screenshot/Cargo.toml +++ b/examples/screenshot/Cargo.toml @@ -10,6 +10,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/screenshot/src/main.rs b/examples/screenshot/src/main.rs index 91f2f92cfc0..c0c627e86a7 100644 --- a/examples/screenshot/src/main.rs +++ b/examples/screenshot/src/main.rs @@ -1,4 +1,5 @@ #![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 use std::sync::Arc; diff --git a/examples/serial_windows/Cargo.toml b/examples/serial_windows/Cargo.toml index 58d5cdecced..eebd08957af 100644 --- a/examples/serial_windows/Cargo.toml +++ b/examples/serial_windows/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ diff --git a/examples/serial_windows/src/main.rs b/examples/serial_windows/src/main.rs index 57dccaa8b0e..04bed8006ae 100644 --- a/examples/serial_windows/src/main.rs +++ b/examples/serial_windows/src/main.rs @@ -1,4 +1,5 @@ #![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 use eframe::egui; diff --git a/examples/test_inline_glow_paint/Cargo.toml b/examples/test_inline_glow_paint/Cargo.toml index 893b0d07de1..ae66b6abdd3 100644 --- a/examples/test_inline_glow_paint/Cargo.toml +++ b/examples/test_inline_glow_paint/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/examples/test_inline_glow_paint/src/main.rs b/examples/test_inline_glow_paint/src/main.rs index 1710ee154a6..7851ad63b8b 100644 --- a/examples/test_inline_glow_paint/src/main.rs +++ b/examples/test_inline_glow_paint/src/main.rs @@ -1,3 +1,7 @@ +#![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)] + // Test that we can paint to the screen using glow directly. use eframe::egui; diff --git a/examples/test_viewports/Cargo.toml b/examples/test_viewports/Cargo.toml index 4e106e37ec8..142bafe2293 100644 --- a/examples/test_viewports/Cargo.toml +++ b/examples/test_viewports/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [features] wgpu = ["eframe/wgpu"] diff --git a/examples/test_viewports/src/main.rs b/examples/test_viewports/src/main.rs index 05679668013..8bbb1b22a07 100644 --- a/examples/test_viewports/src/main.rs +++ b/examples/test_viewports/src/main.rs @@ -1,3 +1,6 @@ +#![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 + use std::sync::Arc; use eframe::egui; diff --git a/examples/user_attention/Cargo.toml b/examples/user_attention/Cargo.toml index 10f0ce711c0..6c3c91cdc25 100644 --- a/examples/user_attention/Cargo.toml +++ b/examples/user_attention/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" rust-version = "1.76" publish = false +[lints] +workspace = true + [dependencies] eframe = { workspace = true, features = [ "default", diff --git a/examples/user_attention/src/main.rs b/examples/user_attention/src/main.rs index 4625abefa93..cbe27b6d5bc 100644 --- a/examples/user_attention/src/main.rs +++ b/examples/user_attention/src/main.rs @@ -1,3 +1,6 @@ +#![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 + use eframe::{egui, CreationContext, NativeOptions}; use egui::{Button, CentralPanel, Context, UserAttentionType}; diff --git a/scripts/check.sh b/scripts/check.sh index c1852a2d81a..5b802f6c606 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -9,7 +9,6 @@ set -x # Checks all tests, lints etc. # Basically does what the CI does. -cargo install --quiet cargo-cranky # Uses lints defined in Cranky.toml. See https://github.com/ericseppanen/cargo-cranky cargo +1.75.0 install --quiet typos-cli # web_sys_unstable_apis is required to enable the web_sys clipboard API which eframe web uses, @@ -24,7 +23,7 @@ cargo fmt --all -- --check cargo doc --quiet --lib --no-deps --all-features cargo doc --quiet --document-private-items --no-deps --all-features -cargo cranky --quiet --all-targets --all-features -- -D warnings +cargo clippy --quiet --all-targets --all-features -- -D warnings ./scripts/clippy_wasm.sh cargo check --quiet --all-targets diff --git a/scripts/clippy_wasm.sh b/scripts/clippy_wasm.sh index 72f6cc0e53e..3d80bd0f703 100755 --- a/scripts/clippy_wasm.sh +++ b/scripts/clippy_wasm.sh @@ -10,4 +10,4 @@ set -x # Use scripts/clippy_wasm/clippy.toml export CLIPPY_CONF_DIR="scripts/clippy_wasm" -cargo cranky --quiet --all-features --target wasm32-unknown-unknown --target-dir target_wasm -p egui_demo_app --lib -- --deny warnings +cargo clippy --quiet --all-features --target wasm32-unknown-unknown --target-dir target_wasm -p egui_demo_app --lib -- --deny warnings diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index ba5b9382089..26bdbb47e59 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -6,4 +6,7 @@ rust-version.workspace = true version.workspace = true publish = false +[lints] +workspace = true + [dependencies] diff --git a/xtask/src/main.rs b/xtask/src/main.rs index b194629203a..0f16c545427 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1,3 +1,5 @@ +//! Helper crate for running scripts within the `egui` repo + #![allow(clippy::print_stdout)] #![allow(clippy::print_stderr)] #![allow(clippy::exit)] From 0bc59f578b907e357f118dba362d89d5e36f4c31 Mon Sep 17 00:00:00 2001 From: YgorSouza <43298013+YgorSouza@users.noreply.github.com> Date: Fri, 26 Apr 2024 07:46:25 +0200 Subject: [PATCH 5/8] Fix some typos from the cranky-clippy transition (#4417) --- .vscode/settings.json | 4 ++-- Cargo.toml | 4 ++-- clippy.toml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8ec1e4aa67f..681dc12fe15 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,7 +15,7 @@ // Tell Rust Analyzer to use its own target directory, so we don't need to wait for it to finish wen we want to `cargo run` "rust-analyzer.check.overrideCommand": [ "cargo", - "cranky", + "clippy", "--target-dir=target_ra", "--workspace", "--message-format=json", @@ -24,7 +24,7 @@ ], "rust-analyzer.cargo.buildScripts.overrideCommand": [ "cargo", - "cranky", + "clippy", "--quiet", "--target-dir=target_ra", "--workspace", diff --git a/Cargo.toml b/Cargo.toml index c94baab2843..0fd46f9ec0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -237,11 +237,11 @@ verbose_file_reads = "warn" wildcard_dependencies = "warn" zero_sized_map_values = "warn" -# TODO(emilk): enable more of these linits: +# TODO(emilk): enable more of these lints: iter_over_hash_type = "allow" let_underscore_untyped = "allow" missing_assert_message = "allow" -print_stderr = "allow" # TODO(emilk): use `log` crate insteaditer_over_hash_type = "allow" +print_stderr = "allow" # TODO(emilk): use `log` crate instead should_panic_without_expect = "allow" too_many_lines = "allow" unwrap_used = "allow" # TODO(emilk): We really wanna warn on this one diff --git a/clippy.toml b/clippy.toml index d91f9666c47..f480ca93d7e 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,4 +1,4 @@ -# There is also a scripts/clippy_wasm/clippy.toml which forbids some mthods that are not available in wasm. +# There is also a scripts/clippy_wasm/clippy.toml which forbids some methods that are not available in wasm. # ----------------------------------------------------------------------------- # Section identical to scripts/clippy_wasm/clippy.toml: @@ -67,7 +67,7 @@ disallowed-types = [ # ----------------------------------------------------------------------------- -# Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown +# Allow-list of words for markdown in docstrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown doc-valid-idents = [ # You must also update the same list in the root `clippy.toml`! "AccessKit", From c1fc9213c3fe9e1a034e42515b5db647cd2313b0 Mon Sep 17 00:00:00 2001 From: Simon Frankau Date: Mon, 29 Apr 2024 09:33:23 +0100 Subject: [PATCH 6/8] Enable egui_glow's winit feature on wasm (#4420) (#4421) Reverts change in #1303, enabling the egui_glow::winit module when using wasm. * Closes --- crates/egui_glow/Cargo.toml | 2 +- crates/egui_glow/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/egui_glow/Cargo.toml b/crates/egui_glow/Cargo.toml index 6bb081980d3..44939640cfb 100644 --- a/crates/egui_glow/Cargo.toml +++ b/crates/egui_glow/Cargo.toml @@ -54,6 +54,7 @@ x11 = ["winit?/x11"] [dependencies] egui = { workspace = true, default-features = false, features = ["bytemuck"] } +egui-winit = { workspace = true, optional = true, default-features = false } bytemuck = "1.7" glow.workspace = true @@ -66,7 +67,6 @@ document-features = { workspace = true, optional = true } # Native: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -egui-winit = { workspace = true, optional = true, default-features = false } puffin = { workspace = true, optional = true } winit = { workspace = true, optional = true, default-features = false, features = [ "rwh_06", # for compatibility with egui-winit diff --git a/crates/egui_glow/src/lib.rs b/crates/egui_glow/src/lib.rs index 8621dbd74e7..cfb95acd3d7 100644 --- a/crates/egui_glow/src/lib.rs +++ b/crates/egui_glow/src/lib.rs @@ -21,9 +21,9 @@ mod vao; pub use shader_version::ShaderVersion; -#[cfg(all(not(target_arch = "wasm32"), feature = "winit"))] +#[cfg(feature = "winit")] pub mod winit; -#[cfg(all(not(target_arch = "wasm32"), feature = "winit"))] +#[cfg(feature = "winit")] pub use winit::*; /// Check for OpenGL error and report it using `log::error`. From 3bb33980a93547c41898a2f0ba294843adaacea7 Mon Sep 17 00:00:00 2001 From: hardlydearly <167623323+hardlydearly@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:33:29 +0800 Subject: [PATCH 7/8] chore: remove repetitive words (#4400) remove repetitive words Signed-off-by: hardlydearly <799511800@qq.com> --- crates/egui/src/callstack.rs | 2 +- crates/egui/src/containers/frame.rs | 2 +- crates/egui/src/context.rs | 4 ++-- crates/egui/src/memory.rs | 4 ++-- crates/egui/src/text_selection/cursor_range.rs | 2 +- crates/egui/src/text_selection/text_cursor_state.rs | 2 +- crates/egui/src/ui.rs | 4 ++-- crates/egui/src/viewport.rs | 4 ++-- crates/egui/src/widgets/text_edit/state.rs | 2 +- crates/epaint/src/tessellator.rs | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/egui/src/callstack.rs b/crates/egui/src/callstack.rs index fac5ac5936e..aa6f44cb08d 100644 --- a/crates/egui/src/callstack.rs +++ b/crates/egui/src/callstack.rs @@ -77,7 +77,7 @@ pub fn capture() -> String { // Remove stuff that isn't user calls: let skip_prefixes = [ - // "backtrace::", // not needed, since we cut at at egui::callstack::capture + // "backtrace::", // not needed, since we cut at egui::callstack::capture "egui::", "", diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index 82ef47770a7..40bd17d3c4d 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -306,7 +306,7 @@ impl Prepared { self.content_ui.min_rect() + self.frame.inner_margin + self.frame.outer_margin } - /// Allocate the the space that was used by [`Self::content_ui`]. + /// Allocate the space that was used by [`Self::content_ui`]. /// /// This MUST be called, or the parent ui will not know how much space this widget used. /// diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 192b0cc49d4..f697fb4b8e5 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -257,7 +257,7 @@ pub struct RepaintCause { /// What file had the call that requested the repaint? pub file: &'static str, - /// What line number of the the call that requested the repaint? + /// What line number of the call that requested the repaint? pub line: u32, } @@ -924,7 +924,7 @@ impl Context { self.write(move |ctx| writer(&mut ctx.memory.options.tessellation_options)) } - /// If the given [`Id`] has been used previously the same frame at at different position, + /// If the given [`Id`] has been used previously the same frame at different position, /// then an error will be printed on screen. /// /// This function is already called for all widgets that do any interaction, diff --git a/crates/egui/src/memory.rs b/crates/egui/src/memory.rs index 2ef8bbf58ba..4bee395c530 100644 --- a/crates/egui/src/memory.rs +++ b/crates/egui/src/memory.rs @@ -132,7 +132,7 @@ enum FocusDirection { /// Select the widget below the current focused widget. Down, - /// Select the widget to the left of the the current focused widget. + /// Select the widget to the left of the current focused widget. Left, /// Select the previous widget that had focus. @@ -812,7 +812,7 @@ impl Memory { /// ## Popups /// Popups are things like combo-boxes, color pickers, menus etc. -/// Only one can be be open at a time. +/// Only one can be open at a time. impl Memory { /// Is the given popup open? pub fn is_popup_open(&self, popup_id: Id) -> bool { diff --git a/crates/egui/src/text_selection/cursor_range.rs b/crates/egui/src/text_selection/cursor_range.rs index cebcf3fb56d..cf17a2e9ba1 100644 --- a/crates/egui/src/text_selection/cursor_range.rs +++ b/crates/egui/src/text_selection/cursor_range.rs @@ -63,7 +63,7 @@ impl CursorRange { self.primary.ccursor == self.secondary.ccursor } - /// Is `self` a super-set of the the other range? + /// Is `self` a super-set of the other range? pub fn contains(&self, other: &Self) -> bool { let [self_min, self_max] = self.sorted_cursors(); let [other_min, other_max] = other.sorted_cursors(); diff --git a/crates/egui/src/text_selection/text_cursor_state.rs b/crates/egui/src/text_selection/text_cursor_state.rs index 7aca96f8b19..bd596e7e846 100644 --- a/crates/egui/src/text_selection/text_cursor_state.rs +++ b/crates/egui/src/text_selection/text_cursor_state.rs @@ -46,7 +46,7 @@ impl TextCursorState { self.cursor_range.is_none() && self.ccursor_range.is_none() } - /// The the currently selected range of characters. + /// The currently selected range of characters. pub fn char_range(&self) -> Option { self.ccursor_range.or_else(|| { self.cursor_range diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index d160f5d404d..1215d0eeb0f 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -1886,7 +1886,7 @@ impl Ui { /// adjusted up and down to lie in the center of the horizontal layout. /// The initial height is `style.spacing.interact_size.y`. /// Centering is almost always what you want if you are - /// planning to to mix widgets or use different types of text. + /// planning to mix widgets or use different types of text. /// /// If you don't want the contents to be centered, use [`Self::horizontal_top`] instead. /// @@ -1947,7 +1947,7 @@ impl Ui { /// adjusted up and down to lie in the center of the horizontal layout. /// The initial height is `style.spacing.interact_size.y`. /// Centering is almost always what you want if you are - /// planning to to mix widgets or use different types of text. + /// planning to mix widgets or use different types of text. /// /// The returned [`Response`] will only have checked for mouse hover /// but can be used for tooltips (`on_hover_text`). diff --git a/crates/egui/src/viewport.rs b/crates/egui/src/viewport.rs index e1e3ebf0e82..cce90487721 100644 --- a/crates/egui/src/viewport.rs +++ b/crates/egui/src/viewport.rs @@ -889,7 +889,7 @@ pub enum X11WindowType { /// This property is typically used on override-redirect windows. Combo, - /// This indicates the the window is being dragged. + /// This indicates the window is being dragged. /// This property is typically used on override-redirect windows. Dnd, } @@ -1015,7 +1015,7 @@ pub enum ViewportCommand { /// Set window to be always-on-top, always-on-bottom, or neither. WindowLevel(WindowLevel), - /// The the window icon. + /// The window icon. Icon(Option>), /// Set the IME cursor editing area. diff --git a/crates/egui/src/widgets/text_edit/state.rs b/crates/egui/src/widgets/text_edit/state.rs index ef4a8909a73..c95d676910a 100644 --- a/crates/egui/src/widgets/text_edit/state.rs +++ b/crates/egui/src/widgets/text_edit/state.rs @@ -67,7 +67,7 @@ impl TextEditState { ctx.data_mut(|d| d.insert_persisted(id, self)); } - /// The the currently selected range of characters. + /// The currently selected range of characters. #[deprecated = "Use `self.cursor.char_range` instead"] pub fn ccursor_range(&self) -> Option { self.cursor.char_range() diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index c7dc31b75ab..4135cc58d22 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -653,7 +653,7 @@ pub struct TessellationOptions { /// Default: `true`. pub feathering: bool, - /// The size of the the feathering, in physical pixels. + /// The size of the feathering, in physical pixels. /// /// The default, and suggested, value for this is `1.0`. /// If you use a larger value, edges will appear blurry. From af39bd22ab3c7f995b7341745ccb99570a094de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Mon, 29 Apr 2024 06:16:55 -0300 Subject: [PATCH 8/8] crates: egui_demo_lib: Fix table height (#4422) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Closes #4404 Signed-off-by: Patrick José Pereira --- crates/egui_demo_lib/src/demo/table_demo.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/egui_demo_lib/src/demo/table_demo.rs b/crates/egui_demo_lib/src/demo/table_demo.rs index 4cf0449fb6f..c7029d44e49 100644 --- a/crates/egui_demo_lib/src/demo/table_demo.rs +++ b/crates/egui_demo_lib/src/demo/table_demo.rs @@ -136,6 +136,7 @@ impl TableDemo { .size .max(ui.spacing().interact_size.y); + let available_height = ui.available_height(); let mut table = TableBuilder::new(ui) .striped(self.striped) .resizable(self.resizable) @@ -145,7 +146,8 @@ impl TableDemo { .column(Column::initial(100.0).range(40.0..=300.0)) .column(Column::initial(100.0).at_least(40.0).clip(true)) .column(Column::remainder()) - .min_scrolled_height(0.0); + .min_scrolled_height(0.0) + .max_scroll_height(available_height); if self.clickable { table = table.sense(egui::Sense::click());