Skip to content

Commit dafe378

Browse files
authored
Merge branch 'master' into wgpu-25
2 parents 9c09af1 + f924595 commit dafe378

File tree

124 files changed

+243
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+243
-244
lines changed

Cargo.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ broken_intra_doc_links = "warn"
134134

135135
# See also clippy.toml
136136
[workspace.lints.clippy]
137+
allow_attributes = "warn"
137138
as_ptr_cast_mut = "warn"
138139
await_holding_lock = "warn"
139140
bool_to_int_with_if = "warn"
@@ -195,13 +196,13 @@ macro_use_imports = "warn"
195196
manual_assert = "warn"
196197
manual_clamp = "warn"
197198
manual_instant_elapsed = "warn"
199+
manual_is_power_of_two = "warn"
198200
manual_is_variant_and = "warn"
199201
manual_let_else = "warn"
200202
manual_ok_or = "warn"
201203
manual_string_new = "warn"
202204
map_err_ignore = "warn"
203205
map_flatten = "warn"
204-
map_unwrap_or = "warn"
205206
match_bool = "warn"
206207
match_on_vec_items = "warn"
207208
match_same_arms = "warn"
@@ -222,11 +223,13 @@ needless_for_each = "warn"
222223
needless_pass_by_ref_mut = "warn"
223224
needless_pass_by_value = "warn"
224225
negative_feature_names = "warn"
226+
non_zero_suggestions = "warn"
225227
nonstandard_macro_braces = "warn"
226228
option_as_ref_cloned = "warn"
227229
option_option = "warn"
228230
path_buf_push_overwrite = "warn"
229231
print_stderr = "warn"
232+
pathbuf_init_then_push = "warn"
230233
ptr_as_ptr = "warn"
231234
ptr_cast_constness = "warn"
232235
pub_underscore_fields = "warn"
@@ -240,6 +243,7 @@ ref_patterns = "warn"
240243
rest_pat_in_fully_bound_structs = "warn"
241244
same_functions_in_if_condition = "warn"
242245
semicolon_if_nothing_returned = "warn"
246+
set_contains_or_insert = "warn"
243247
single_char_pattern = "warn"
244248
single_match_else = "warn"
245249
str_split_at_newline = "warn"
@@ -252,6 +256,7 @@ string_to_string = "warn"
252256
suspicious_command_arg_space = "warn"
253257
suspicious_xor_used_as_pow = "warn"
254258
todo = "warn"
259+
too_long_first_doc_paragraph = "warn"
255260
trailing_empty_array = "warn"
256261
trait_duplication_in_bounds = "warn"
257262
tuple_array_conversions = "warn"
@@ -261,13 +266,15 @@ unimplemented = "warn"
261266
uninhabited_references = "warn"
262267
uninlined_format_args = "warn"
263268
unnecessary_box_returns = "warn"
269+
unnecessary_literal_bound = "warn"
264270
unnecessary_safety_doc = "warn"
265271
unnecessary_struct_initialization = "warn"
266272
unnecessary_wraps = "warn"
267273
unnested_or_patterns = "warn"
268274
unused_peekable = "warn"
269275
unused_rounding = "warn"
270276
unused_self = "warn"
277+
unused_trait_names = "warn"
271278
use_self = "warn"
272279
useless_transmute = "warn"
273280
verbose_file_reads = "warn"
@@ -286,6 +293,7 @@ assigning_clones = "allow" # No please
286293
let_underscore_must_use = "allow"
287294
let_underscore_untyped = "allow"
288295
manual_range_contains = "allow" # this one is just worse imho
296+
map_unwrap_or = "allow" # so is this one
289297
self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602
290298
significant_drop_tightening = "allow" # Too many false positives
291299
wildcard_imports = "allow" # `use crate::*` is useful to avoid merge conflicts when adding/removing imports

crates/ecolor/src/rgba.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ pub(crate) fn f32_hash<H: std::hash::Hasher>(state: &mut H, f: f32) {
3333
} else if f.is_nan() {
3434
state.write_u8(1);
3535
} else {
36-
use std::hash::Hash;
36+
use std::hash::Hash as _;
3737
f.to_bits().hash(state);
3838
}
3939
}
4040

41-
#[allow(clippy::derived_hash_with_manual_eq)]
4241
impl std::hash::Hash for Rgba {
4342
#[inline]
4443
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {

crates/eframe/src/epi.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct CreationContext<'s> {
9191
pub(crate) raw_display_handle: Result<RawDisplayHandle, HandleError>,
9292
}
9393

94-
#[allow(unsafe_code)]
94+
#[expect(unsafe_code)]
9595
#[cfg(not(target_arch = "wasm32"))]
9696
impl HasWindowHandle for CreationContext<'_> {
9797
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError> {
@@ -100,7 +100,7 @@ impl HasWindowHandle for CreationContext<'_> {
100100
}
101101
}
102102

103-
#[allow(unsafe_code)]
103+
#[expect(unsafe_code)]
104104
#[cfg(not(target_arch = "wasm32"))]
105105
impl HasDisplayHandle for CreationContext<'_> {
106106
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
@@ -662,7 +662,7 @@ pub struct Frame {
662662
#[cfg(not(target_arch = "wasm32"))]
663663
assert_not_impl_any!(Frame: Clone);
664664

665-
#[allow(unsafe_code)]
665+
#[expect(unsafe_code)]
666666
#[cfg(not(target_arch = "wasm32"))]
667667
impl HasWindowHandle for Frame {
668668
fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError> {
@@ -671,7 +671,7 @@ impl HasWindowHandle for Frame {
671671
}
672672
}
673673

674-
#[allow(unsafe_code)]
674+
#[expect(unsafe_code)]
675675
#[cfg(not(target_arch = "wasm32"))]
676676
impl HasDisplayHandle for Frame {
677677
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
@@ -703,7 +703,7 @@ impl Frame {
703703
/// True if you are in a web environment.
704704
///
705705
/// Equivalent to `cfg!(target_arch = "wasm32")`
706-
#[allow(clippy::unused_self)]
706+
#[expect(clippy::unused_self)]
707707
pub fn is_web(&self) -> bool {
708708
cfg!(target_arch = "wasm32")
709709
}

crates/eframe/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
//! #[wasm_bindgen]
7070
//! impl WebHandle {
7171
//! /// Installs a panic hook, then returns.
72-
//! #[allow(clippy::new_without_default)]
72+
//! #[expect(clippy::new_without_default)]
7373
//! #[wasm_bindgen(constructor)]
7474
//! pub fn new() -> Self {
7575
//! // Redirect [`log`] message to `console.log` and friends:
@@ -236,7 +236,7 @@ pub mod icon_data;
236236
/// This function can fail if we fail to set up a graphics context.
237237
#[cfg(not(target_arch = "wasm32"))]
238238
#[cfg(any(feature = "glow", feature = "wgpu"))]
239-
#[allow(clippy::needless_pass_by_value)]
239+
#[allow(clippy::needless_pass_by_value, clippy::allow_attributes)]
240240
pub fn run_native(
241241
app_name: &str,
242242
mut native_options: NativeOptions,

crates/eframe/src/native/app_icon.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum AppIconStatus {
4747
NotSetTryAgain,
4848

4949
/// We successfully set the icon and it should be visible now.
50-
#[allow(dead_code)] // Not used on Linux
50+
#[allow(dead_code, clippy::allow_attributes)] // Not used on Linux
5151
Set,
5252
}
5353

@@ -71,13 +71,13 @@ fn set_title_and_icon(_title: &str, _icon_data: Option<&IconData>) -> AppIconSta
7171
#[cfg(target_os = "macos")]
7272
return set_title_and_icon_mac(_title, _icon_data);
7373

74-
#[allow(unreachable_code)]
74+
#[allow(unreachable_code, clippy::allow_attributes)]
7575
AppIconStatus::NotSetIgnored
7676
}
7777

7878
/// Set icon for Windows applications.
7979
#[cfg(target_os = "windows")]
80-
#[allow(unsafe_code)]
80+
#[expect(unsafe_code)]
8181
fn set_app_icon_windows(icon_data: &IconData) -> AppIconStatus {
8282
use crate::icon_data::IconDataExt as _;
8383
use winapi::um::winuser;
@@ -198,12 +198,12 @@ fn set_app_icon_windows(icon_data: &IconData) -> AppIconStatus {
198198

199199
/// Set icon & app title for `MacOS` applications.
200200
#[cfg(target_os = "macos")]
201-
#[allow(unsafe_code)]
201+
#[expect(unsafe_code)]
202202
fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconStatus {
203203
use crate::icon_data::IconDataExt as _;
204204
profiling::function_scope!();
205205

206-
use objc2::ClassType;
206+
use objc2::ClassType as _;
207207
use objc2_app_kit::{NSApplication, NSImage};
208208
use objc2_foundation::{NSData, NSString};
209209

crates/eframe/src/native/epi_integration.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub fn create_storage(_app_name: &str) -> Option<Box<dyn epi::Storage>> {
136136
None
137137
}
138138

139-
#[allow(clippy::unnecessary_wraps)]
139+
#[expect(clippy::unnecessary_wraps)]
140140
pub fn create_storage_with_file(_file: impl Into<PathBuf>) -> Option<Box<dyn epi::Storage>> {
141141
#[cfg(feature = "persistence")]
142142
return Some(Box::new(
@@ -169,7 +169,7 @@ pub struct EpiIntegration {
169169
}
170170

171171
impl EpiIntegration {
172-
#[allow(clippy::too_many_arguments)]
172+
#[expect(clippy::too_many_arguments)]
173173
pub fn new(
174174
egui_ctx: egui::Context,
175175
window: &winit::window::Window,
@@ -326,7 +326,7 @@ impl EpiIntegration {
326326
}
327327
}
328328

329-
#[allow(clippy::unused_self)]
329+
#[allow(clippy::unused_self, clippy::allow_attributes)]
330330
pub fn save(&mut self, _app: &mut dyn epi::App, _window: Option<&winit::window::Window>) {
331331
#[cfg(feature = "persistence")]
332332
if let Some(storage) = self.frame.storage_mut() {

crates/eframe/src/native/event_loop_context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Drop for EventLoopGuard {
2727
}
2828

2929
// Helper function to safely use the current event loop
30-
#[allow(unsafe_code)]
30+
#[expect(unsafe_code)]
3131
pub fn with_current_event_loop<F, R>(f: F) -> Option<R>
3232
where
3333
F: FnOnce(&ActiveEventLoop) -> R,

crates/eframe/src/native/file_storage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{
22
collections::HashMap,
3-
io::Write,
3+
io::Write as _,
44
path::{Path, PathBuf},
55
};
66

@@ -42,7 +42,7 @@ pub fn storage_dir(app_id: &str) -> Option<PathBuf> {
4242
// Adapted from
4343
// https://github.com/rust-lang/cargo/blob/6e11c77384989726bb4f412a0e23b59c27222c34/crates/home/src/windows.rs#L19-L37
4444
#[cfg(all(windows, not(target_vendor = "uwp")))]
45-
#[allow(unsafe_code)]
45+
#[expect(unsafe_code)]
4646
fn roaming_appdata() -> Option<PathBuf> {
4747
use std::ffi::OsString;
4848
use std::os::windows::ffi::OsStringExt;

crates/eframe/src/native/glow_integration.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ use std::{cell::RefCell, num::NonZeroU32, rc::Rc, sync::Arc, time::Instant};
1111

1212
use egui_winit::ActionRequested;
1313
use glutin::{
14-
config::GlConfig,
15-
context::NotCurrentGlContext,
16-
display::GetGlDisplay,
17-
prelude::{GlDisplay, PossiblyCurrentGlContext},
18-
surface::GlSurface,
14+
config::GlConfig as _,
15+
context::NotCurrentGlContext as _,
16+
display::GetGlDisplay as _,
17+
prelude::{GlDisplay as _, PossiblyCurrentGlContext as _},
18+
surface::GlSurface as _,
1919
};
20-
use raw_window_handle::HasWindowHandle;
20+
use raw_window_handle::HasWindowHandle as _;
2121
use winit::{
2222
event_loop::{ActiveEventLoop, EventLoop, EventLoopProxy},
2323
window::{Window, WindowId},
@@ -139,7 +139,7 @@ impl<'app> GlowWinitApp<'app> {
139139
}
140140
}
141141

142-
#[allow(unsafe_code)]
142+
#[expect(unsafe_code)]
143143
fn create_glutin_windowed_context(
144144
egui_ctx: &egui::Context,
145145
event_loop: &ActiveEventLoop,
@@ -901,7 +901,7 @@ fn change_gl_context(
901901
}
902902

903903
impl GlutinWindowContext {
904-
#[allow(unsafe_code)]
904+
#[expect(unsafe_code)]
905905
unsafe fn new(
906906
egui_ctx: &egui::Context,
907907
viewport_builder: ViewportBuilder,
@@ -1094,7 +1094,7 @@ impl GlutinWindowContext {
10941094
}
10951095

10961096
/// Create a surface, window, and winit integration for the viewport, if missing.
1097-
#[allow(unsafe_code)]
1097+
#[expect(unsafe_code)]
10981098
pub(crate) fn initialize_window(
10991099
&mut self,
11001100
viewport_id: ViewportId,
@@ -1566,6 +1566,6 @@ fn save_screenshot_and_exit(
15661566
});
15671567
log::info!("Screenshot saved to {path:?}.");
15681568

1569-
#[allow(clippy::exit)]
1569+
#[expect(clippy::exit)]
15701570
std::process::exit(0);
15711571
}

crates/eframe/src/native/run.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ impl<T: WinitApp> WinitAppWrapper<T> {
163163

164164
log::debug!("Exiting with return code 0");
165165

166-
#[allow(clippy::exit)]
167166
std::process::exit(0);
168167
}
169168
}
@@ -317,7 +316,7 @@ impl<T: WinitApp> ApplicationHandler<UserEvent> for WinitAppWrapper<T> {
317316

318317
#[cfg(not(target_os = "ios"))]
319318
fn run_and_return(event_loop: &mut EventLoop<UserEvent>, winit_app: impl WinitApp) -> Result {
320-
use winit::platform::run_on_demand::EventLoopExtRunOnDemand;
319+
use winit::platform::run_on_demand::EventLoopExtRunOnDemand as _;
321320

322321
log::trace!("Entering the winit event loop (run_app_on_demand)…");
323322

crates/eframe/src/native/wgpu_integration.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use winit::{
1515
window::{Window, WindowId},
1616
};
1717

18-
use ahash::{HashMap, HashSet, HashSetExt};
18+
use ahash::{HashMap, HashSet, HashSetExt as _};
1919
use egui::{
2020
DeferredViewportUiCallback, FullOutput, ImmediateViewport, ViewportBuilder, ViewportClass,
2121
ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportInfo, ViewportOutput,
@@ -182,7 +182,6 @@ impl<'app> WgpuWinitApp<'app> {
182182
builder: ViewportBuilder,
183183
) -> crate::Result<&mut WgpuWinitRunning<'app>> {
184184
profiling::function_scope!();
185-
#[allow(unsafe_code, unused_mut, unused_unsafe)]
186185
let mut painter = pollster::block_on(egui_wgpu::winit::Painter::new(
187186
egui_ctx.clone(),
188187
self.native_options.wgpu_options.clone(),
@@ -236,7 +235,7 @@ impl<'app> WgpuWinitApp<'app> {
236235
});
237236
}
238237

239-
#[allow(unused_mut)] // used for accesskit
238+
#[allow(unused_mut, clippy::allow_attributes)] // used for accesskit
240239
let mut egui_winit = egui_winit::State::new(
241240
egui_ctx.clone(),
242241
ViewportId::ROOT,

crates/eframe/src/web/app_runner.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use egui::{TexturesDelta, UserData, ViewportCommand};
22

33
use crate::{epi, App};
44

5-
use super::{now_sec, text_agent::TextAgent, web_painter::WebPainter, NeedRepaint};
5+
use super::{now_sec, text_agent::TextAgent, web_painter::WebPainter as _, NeedRepaint};
66

77
pub struct AppRunner {
8-
#[allow(dead_code)]
8+
#[allow(dead_code, clippy::allow_attributes)]
99
pub(crate) web_options: crate::WebOptions,
1010
pub(crate) frame: epi::Frame,
1111
egui_ctx: egui::Context,

crates/eframe/src/web/events.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::{
44
button_from_mouse_event, location_hash, modifiers_from_kb_event, modifiers_from_mouse_event,
55
modifiers_from_wheel_event, native_pixels_per_point, pos_from_mouse_event,
66
prefers_color_scheme_dark, primary_touch_pos, push_touches, text_from_keyboard_event,
7-
theme_from_dark_mode, translate_key, AppRunner, Closure, JsCast, JsValue, WebRunner,
7+
theme_from_dark_mode, translate_key, AppRunner, Closure, JsCast as _, JsValue, WebRunner,
88
DEBUG_RESIZE,
99
};
1010

@@ -163,7 +163,7 @@ fn install_keydown(runner_ref: &WebRunner, target: &EventTarget) -> Result<(), J
163163
)
164164
}
165165

166-
#[allow(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener`
166+
#[expect(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener`
167167
pub(crate) fn on_keydown(event: web_sys::KeyboardEvent, runner: &mut AppRunner) {
168168
let has_focus = runner.input.raw.focused;
169169
if !has_focus {
@@ -261,7 +261,7 @@ fn install_keyup(runner_ref: &WebRunner, target: &EventTarget) -> Result<(), JsV
261261
runner_ref.add_event_listener(target, "keyup", on_keyup)
262262
}
263263

264-
#[allow(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener`
264+
#[expect(clippy::needless_pass_by_value)] // So that we can pass it directly to `add_event_listener`
265265
pub(crate) fn on_keyup(event: web_sys::KeyboardEvent, runner: &mut AppRunner) {
266266
let modifiers = modifiers_from_kb_event(&event);
267267
runner.input.raw.modifiers = modifiers;

crates/eframe/src/web/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn create_clipboard_item(mime: &str, bytes: &[u8]) -> Result<web_sys::ClipboardI
281281
let items = js_sys::Object::new();
282282

283283
// SAFETY: I hope so
284-
#[allow(unsafe_code, unused_unsafe)] // Weird false positive
284+
#[expect(unsafe_code, unused_unsafe)] // Weird false positive
285285
unsafe {
286286
js_sys::Reflect::set(&items, &JsValue::from_str(mime), &blob)?
287287
};

0 commit comments

Comments
 (0)