From 08fb447fb55293b2d49343cf5ade2c59d436bc58 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 11 Aug 2023 13:54:02 +0200 Subject: [PATCH] Increase MSRV to 1.67 (#3234) * Bump MSRV to 1.67 * clippy fixes * cargo clippy: inline format args * Add `clippy::uninlined_format_args` to cranky lints * Fix clippy on wasm * More clippy fixes --- .github/workflows/rust.yml | 10 ++--- Cranky.toml | 1 + clippy.toml | 2 +- crates/ecolor/Cargo.toml | 2 +- crates/eframe/Cargo.toml | 2 +- crates/eframe/src/native/run.rs | 2 +- crates/eframe/src/web/mod.rs | 2 +- crates/eframe/src/web/text_agent.rs | 7 ++- crates/eframe/src/web/web_painter_glow.rs | 2 +- crates/eframe/src/web/web_painter_wgpu.rs | 3 +- crates/egui-wgpu/Cargo.toml | 2 +- crates/egui-wgpu/src/renderer.rs | 5 +-- crates/egui-winit/Cargo.toml | 2 +- crates/egui/Cargo.toml | 2 +- crates/egui/src/context.rs | 19 ++++---- crates/egui/src/data/input.rs | 14 +++--- crates/egui/src/data/output.rs | 20 ++++----- crates/egui/src/input_state.rs | 43 +++++++++---------- crates/egui/src/input_state/touch_state.rs | 4 +- crates/egui/src/introspection.rs | 7 +-- crates/egui/src/painter.rs | 2 +- crates/egui/src/widgets/color_picker.rs | 8 ++-- crates/egui/src/widgets/drag_value.rs | 2 +- crates/egui/src/widgets/plot/items/mod.rs | 2 +- crates/egui/src/widgets/plot/items/values.rs | 4 +- crates/egui/src/widgets/plot/mod.rs | 4 +- crates/egui_demo_app/Cargo.toml | 2 +- crates/egui_demo_app/src/apps/http_app.rs | 2 +- crates/egui_demo_app/src/backend_panel.rs | 5 +-- crates/egui_demo_app/src/wrap_app.rs | 2 +- crates/egui_demo_lib/Cargo.toml | 2 +- crates/egui_demo_lib/src/demo/about.rs | 4 +- crates/egui_demo_lib/src/demo/code_example.rs | 2 +- .../src/demo/demo_app_windows.rs | 4 +- crates/egui_demo_lib/src/demo/layout_test.rs | 4 +- .../src/demo/misc_demo_window.rs | 2 +- crates/egui_demo_lib/src/demo/multi_touch.rs | 2 +- crates/egui_demo_lib/src/demo/plot_demo.rs | 13 +++--- crates/egui_demo_lib/src/demo/scrolling.rs | 7 ++- crates/egui_demo_lib/src/demo/tests.rs | 10 ++--- .../egui_demo_lib/src/demo/widget_gallery.rs | 8 ++-- .../src/easy_mark/easy_mark_viewer.rs | 2 +- crates/egui_extras/Cargo.toml | 2 +- crates/egui_extras/src/datepicker/popup.rs | 2 +- crates/egui_extras/src/image.rs | 2 +- crates/egui_glium/Cargo.toml | 2 +- crates/egui_glow/Cargo.toml | 2 +- crates/emath/Cargo.toml | 2 +- crates/emath/src/lib.rs | 8 ++-- crates/emath/src/pos2.rs | 4 +- crates/emath/src/rot2.rs | 5 +-- crates/emath/src/vec2.rs | 4 +- crates/epaint/Cargo.toml | 2 +- crates/epaint/src/mesh.rs | 3 +- crates/epaint/src/mutex.rs | 2 +- crates/epaint/src/stats.rs | 2 +- crates/epaint/src/text/font.rs | 3 +- crates/epaint/src/text/fonts.rs | 17 +++----- examples/confirm_exit/Cargo.toml | 2 +- examples/custom_3d_glow/Cargo.toml | 2 +- examples/custom_3d_glow/src/main.rs | 2 +- examples/custom_font/Cargo.toml | 2 +- examples/custom_font_style/Cargo.toml | 2 +- examples/custom_window_frame/Cargo.toml | 2 +- examples/download_image/Cargo.toml | 2 +- examples/download_image/src/main.rs | 3 +- examples/file_dialog/Cargo.toml | 2 +- examples/hello_world/Cargo.toml | 2 +- examples/hello_world_par/Cargo.toml | 2 +- examples/hello_world_par/src/main.rs | 2 +- examples/hello_world_simple/Cargo.toml | 2 +- examples/keyboard_events/Cargo.toml | 2 +- examples/puffin_profiler/Cargo.toml | 2 +- examples/puffin_profiler/src/main.rs | 2 +- examples/retained_image/Cargo.toml | 2 +- examples/save_plot/Cargo.toml | 2 +- examples/save_plot/src/main.rs | 2 +- examples/screenshot/Cargo.toml | 2 +- examples/serial_windows/Cargo.toml | 2 +- examples/svg/Cargo.toml | 2 +- examples/user_attention/Cargo.toml | 2 +- examples/user_attention/src/main.rs | 2 +- rust-toolchain | 2 +- scripts/clippy_wasm/clippy.toml | 2 +- 84 files changed, 166 insertions(+), 193 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 61fb36f7..cd73fd9d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,7 +19,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.65.0 + toolchain: 1.67.0 - name: Install packages (Linux) if: runner.os == 'Linux' @@ -87,7 +87,7 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.65.0 + toolchain: 1.67.0 targets: wasm32-unknown-unknown - run: sudo apt-get update && sudo apt-get install libgtk-3-dev @@ -145,7 +145,7 @@ jobs: - uses: actions/checkout@v3 - uses: EmbarkStudios/cargo-deny-action@v1 with: - rust-version: "1.65.0" + rust-version: "1.67.0" log-level: error command: check arguments: --target ${{ matrix.target }} @@ -160,7 +160,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.65.0 + toolchain: 1.67.0 targets: aarch64-linux-android - name: Set up cargo cache @@ -178,7 +178,7 @@ jobs: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.65.0 + toolchain: 1.67.0 - name: Set up cargo cache uses: Swatinem/rust-cache@v2 diff --git a/Cranky.toml b/Cranky.toml index 6fa6ca09..aaa2d8d6 100644 --- a/Cranky.toml +++ b/Cranky.toml @@ -91,6 +91,7 @@ warn = [ "clippy::trailing_empty_array", "clippy::trait_duplication_in_bounds", "clippy::unimplemented", + "clippy::uninlined_format_args", "clippy::unnecessary_wraps", "clippy::unnested_or_patterns", "clippy::unused_peekable", diff --git a/clippy.toml b/clippy.toml index 31bbadb8..38feddcf 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,6 +1,6 @@ # There is also a scripts/clippy_wasm/clippy.toml which forbids some mthods that are not available in wasm. -msrv = "1.65" +msrv = "1.67" # Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown doc-valid-idents = [ diff --git a/crates/ecolor/Cargo.toml b/crates/ecolor/Cargo.toml index 6a2feb2e..ea2f895f 100644 --- a/crates/ecolor/Cargo.toml +++ b/crates/ecolor/Cargo.toml @@ -7,7 +7,7 @@ authors = [ ] description = "Color structs and color conversion utilities" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index 81b36d82..8046394e 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "egui framework - write GUI apps that compiles to web and/or natively" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/eframe" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 3672c9bf..af8d3aed 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -708,7 +708,7 @@ mod glow_integration { let painter = egui_glow::Painter::new(gl.clone(), "", self.native_options.shader_version) - .unwrap_or_else(|error| panic!("some OpenGL error occurred {}\n", error)); + .unwrap_or_else(|err| panic!("An OpenGL error occurred: {err}\n")); let system_theme = system_theme(gl_window.window(), &self.native_options); let mut integration = epi_integration::EpiIntegration::new( diff --git a/crates/eframe/src/web/mod.rs b/crates/eframe/src/web/mod.rs index 5cea5d61..9c3920a5 100644 --- a/crates/eframe/src/web/mod.rs +++ b/crates/eframe/src/web/mod.rs @@ -104,7 +104,7 @@ pub fn canvas_element(canvas_id: &str) -> Option { pub fn canvas_element_or_die(canvas_id: &str) -> web_sys::HtmlCanvasElement { canvas_element(canvas_id) - .unwrap_or_else(|| panic!("Failed to find canvas with id {:?}", canvas_id)) + .unwrap_or_else(|| panic!("Failed to find canvas with id {canvas_id:?}")) } fn canvas_origin(canvas_id: &str) -> egui::Pos2 { diff --git a/crates/eframe/src/web/text_agent.rs b/crates/eframe/src/web/text_agent.rs index 579f98c7..1688163b 100644 --- a/crates/eframe/src/web/text_agent.rs +++ b/crates/eframe/src/web/text_agent.rs @@ -104,8 +104,7 @@ pub fn install_text_agent(runner_ref: &WebRunner) -> Result<(), JsValue> { runner_ref.add_event_listener(&input, "focusout", move |_event: web_sys::MouseEvent, _| { // Delay 10 ms, and focus again. let func = js_sys::Function::new_no_args(&format!( - "document.getElementById('{}').focus()", - AGENT_ID + "document.getElementById('{AGENT_ID}').focus()" )); window .set_timeout_with_callback_and_timeout_and_arguments_0(&func, 10) @@ -221,8 +220,8 @@ pub fn move_text_cursor(cursor: Option, canvas_id: &str) -> Option<( let x = (x - canvas.offset_width() as f32 / 2.0) .min(canvas.client_width() as f32 - bounding_rect.width() as f32); style.set_property("position", "absolute").ok()?; - style.set_property("top", &format!("{}px", y)).ok()?; - style.set_property("left", &format!("{}px", x)).ok() + style.set_property("top", &format!("{y}px")).ok()?; + style.set_property("left", &format!("{x}px")).ok() }) } else { style.set_property("position", "absolute").ok()?; diff --git a/crates/eframe/src/web/web_painter_glow.rs b/crates/eframe/src/web/web_painter_glow.rs index 939ac8a0..b12ac1ce 100644 --- a/crates/eframe/src/web/web_painter_glow.rs +++ b/crates/eframe/src/web/web_painter_glow.rs @@ -27,7 +27,7 @@ impl WebPainterGlow { let gl = std::sync::Arc::new(gl); let painter = egui_glow::Painter::new(gl, shader_prefix, None) - .map_err(|error| format!("Error starting glow painter: {}", error))?; + .map_err(|err| format!("Error starting glow painter: {err}"))?; Ok(Self { canvas, diff --git a/crates/eframe/src/web/web_painter_wgpu.rs b/crates/eframe/src/web/web_painter_wgpu.rs index 80abb5bf..83510dc4 100644 --- a/crates/eframe/src/web/web_painter_wgpu.rs +++ b/crates/eframe/src/web/web_painter_wgpu.rs @@ -87,8 +87,7 @@ impl WebPainterWgpu { } else { // Workaround for https://github.com/gfx-rs/wgpu/issues/3710: // Don't use `create_surface_from_canvas`, but `create_surface` instead! - let raw_window = - EguiWebWindow(egui::util::hash(&format!("egui on wgpu {canvas_id}")) as u32); + let raw_window = EguiWebWindow(egui::util::hash(("egui on wgpu", canvas_id)) as u32); canvas.set_attribute("data-raw-handle", &raw_window.0.to_string()); #[allow(unsafe_code)] diff --git a/crates/egui-wgpu/Cargo.toml b/crates/egui-wgpu/Cargo.toml index d1812dcb..7df86b6a 100644 --- a/crates/egui-wgpu/Cargo.toml +++ b/crates/egui-wgpu/Cargo.toml @@ -8,7 +8,7 @@ authors = [ "Emil Ernerfeldt ", ] edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/egui-wgpu" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui-wgpu/src/renderer.rs b/crates/egui-wgpu/src/renderer.rs index fe925857..c3def5fc 100644 --- a/crates/egui-wgpu/src/renderer.rs +++ b/crates/egui-wgpu/src/renderer.rs @@ -560,7 +560,7 @@ impl Renderer { } else { // allocate a new texture // Use same label for all resources associated with this texture id (no point in retyping the type) - let label_str = format!("egui_texid_{:?}", id); + let label_str = format!("egui_texid_{id:?}"); let label = Some(label_str.as_str()); let texture = device.create_texture(&wgpu::TextureDescriptor { label, @@ -904,8 +904,7 @@ fn create_sampler( }; device.create_sampler(&wgpu::SamplerDescriptor { label: Some(&format!( - "egui sampler (mag: {:?}, min {:?})", - mag_filter, min_filter + "egui sampler (mag: {mag_filter:?}, min {min_filter:?})" )), mag_filter, min_filter, diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index 27a456da..2d6833d9 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "Bindings for using egui with winit" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/egui-winit" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui/Cargo.toml b/crates/egui/Cargo.toml index 913a17cd..61519583 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "An easy-to-use immediate mode GUI that runs on both web and native" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui" license = "MIT OR Apache-2.0" readme = "../../README.md" diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index bcb61d2c..d8d5a0f5 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -566,7 +566,7 @@ impl Context { } let show_error = |widget_rect: Rect, text: String| { - let text = format!("🔥 {}", text); + let text = format!("🔥 {text}"); let color = self.style().visuals.error_fg_color; let painter = self.debug_painter(); painter.rect_stroke(widget_rect, 0.0, (1.0, color)); @@ -612,10 +612,10 @@ impl Context { let id_str = id.short_debug_format(); if prev_rect.min.distance(new_rect.min) < 4.0 { - show_error(new_rect, format!("Double use of {} ID {}", what, id_str)); + show_error(new_rect, format!("Double use of {what} ID {id_str}")); } else { - show_error(prev_rect, format!("First use of {} ID {}", what, id_str)); - show_error(new_rect, format!("Second use of {} ID {}", what, id_str)); + show_error(prev_rect, format!("First use of {what} ID {id_str}")); + show_error(new_rect, format!("Second use of {what} ID {id_str}")); } } @@ -1574,14 +1574,14 @@ impl Context { let pointer_pos = self .pointer_hover_pos() - .map_or_else(String::new, |pos| format!("{:?}", pos)); - ui.label(format!("Pointer pos: {}", pointer_pos)); + .map_or_else(String::new, |pos| format!("{pos:?}")); + ui.label(format!("Pointer pos: {pointer_pos}")); let top_layer = self .pointer_hover_pos() .and_then(|pos| self.layer_id_at(pos)) .map_or_else(String::new, |layer| layer.short_debug_format()); - ui.label(format!("Top layer under mouse: {}", top_layer)); + ui.label(format!("Top layer under mouse: {top_layer}")); ui.add_space(16.0); @@ -1667,7 +1667,7 @@ impl Context { ui.image(texture_id, size); }); - ui.label(format!("{} x {}", w, h)); + ui.label(format!("{w} x {h}")); ui.label(format!("{:.3} MB", meta.bytes_used() as f64 * 1e-6)); ui.label(format!("{:?}", meta.name)); ui.end_row(); @@ -1688,8 +1688,7 @@ impl Context { let (num_state, num_serialized) = self.data(|d| (d.len(), d.count_serialized())); ui.label(format!( - "{} widget states stored (of which {} are serialized).", - num_state, num_serialized + "{num_state} widget states stored (of which {num_serialized} are serialized)." )); ui.horizontal(|ui| { diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index 4bb9fdc0..bb1b9f6a 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -937,25 +937,25 @@ impl RawInput { focused, } = self; - ui.label(format!("screen_rect: {:?} points", screen_rect)); - ui.label(format!("pixels_per_point: {:?}", pixels_per_point)) + ui.label(format!("screen_rect: {screen_rect:?} points")); + ui.label(format!("pixels_per_point: {pixels_per_point:?}")) .on_hover_text( "Also called HDPI factor.\nNumber of physical pixels per each logical pixel.", ); - ui.label(format!("max_texture_side: {:?}", max_texture_side)); + ui.label(format!("max_texture_side: {max_texture_side:?}")); if let Some(time) = time { - ui.label(format!("time: {:.3} s", time)); + ui.label(format!("time: {time:.3} s")); } else { ui.label("time: None"); } ui.label(format!("predicted_dt: {:.1} ms", 1e3 * predicted_dt)); - ui.label(format!("modifiers: {:#?}", modifiers)); + ui.label(format!("modifiers: {modifiers:#?}")); ui.label(format!("hovered_files: {}", hovered_files.len())); ui.label(format!("dropped_files: {}", dropped_files.len())); - ui.label(format!("focused: {}", focused)); + ui.label(format!("focused: {focused}")); ui.scope(|ui| { ui.set_min_height(150.0); - ui.label(format!("events: {:#?}", events)) + ui.label(format!("events: {events:#?}")) .on_hover_text("key presses etc"); }); } diff --git a/crates/egui/src/data/output.rs b/crates/egui/src/data/output.rs index cea031ed..156a3492 100644 --- a/crates/egui/src/data/output.rs +++ b/crates/egui/src/data/output.rs @@ -100,7 +100,7 @@ impl PlatformOutput { /// This can be used by a text-to-speech system to describe the events (if any). pub fn events_description(&self) -> String { // only describe last event: - if let Some(event) = self.events.iter().rev().next() { + if let Some(event) = self.events.iter().next_back() { match event { OutputEvent::Clicked(widget_info) | OutputEvent::DoubleClicked(widget_info) @@ -417,12 +417,12 @@ impl OutputEvent { impl std::fmt::Debug for OutputEvent { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::Clicked(wi) => write!(f, "Clicked({:?})", wi), - Self::DoubleClicked(wi) => write!(f, "DoubleClicked({:?})", wi), - Self::TripleClicked(wi) => write!(f, "TripleClicked({:?})", wi), - Self::FocusGained(wi) => write!(f, "FocusGained({:?})", wi), - Self::TextSelectionChanged(wi) => write!(f, "TextSelectionChanged({:?})", wi), - Self::ValueChanged(wi) => write!(f, "ValueChanged({:?})", wi), + Self::Clicked(wi) => write!(f, "Clicked({wi:?})"), + Self::DoubleClicked(wi) => write!(f, "DoubleClicked({wi:?})"), + Self::TripleClicked(wi) => write!(f, "TripleClicked({wi:?})"), + Self::FocusGained(wi) => write!(f, "FocusGained({wi:?})"), + Self::TextSelectionChanged(wi) => write!(f, "TextSelectionChanged({wi:?})"), + Self::ValueChanged(wi) => write!(f, "ValueChanged({wi:?})"), } } } @@ -609,14 +609,14 @@ impl WidgetInfo { if let Some(selected) = selected { if *typ == WidgetType::Checkbox { let state = if *selected { "checked" } else { "unchecked" }; - description = format!("{} {}", state, description); + description = format!("{state} {description}"); } else { description += if *selected { "selected" } else { "" }; }; } if let Some(label) = label { - description = format!("{}: {}", label, description); + description = format!("{label}: {description}"); } if typ == &WidgetType::TextEdit { @@ -630,7 +630,7 @@ impl WidgetInfo { } else { text = "blank".into(); } - description = format!("{}: {}", text, description); + description = format!("{text}: {description}"); } if let Some(value) = value { diff --git a/crates/egui/src/input_state.rs b/crates/egui/src/input_state.rs index 1b49757b..1c0fe22f 100644 --- a/crates/egui/src/input_state.rs +++ b/crates/egui/src/input_state.rs @@ -990,30 +990,28 @@ impl InputState { }); } - ui.label(format!("scroll_delta: {:?} points", scroll_delta)); - ui.label(format!("zoom_factor_delta: {:4.2}x", zoom_factor_delta)); - ui.label(format!("screen_rect: {:?} points", screen_rect)); + ui.label(format!("scroll_delta: {scroll_delta:?} points")); + ui.label(format!("zoom_factor_delta: {zoom_factor_delta:4.2}x")); + ui.label(format!("screen_rect: {screen_rect:?} points")); ui.label(format!( - "{} physical pixels for each logical point", - pixels_per_point + "{pixels_per_point} physical pixels for each logical point" )); ui.label(format!( - "max texture size (on each side): {}", - max_texture_side + "max texture size (on each side): {max_texture_side}" )); - ui.label(format!("time: {:.3} s", time)); + ui.label(format!("time: {time:.3} s")); ui.label(format!( "time since previous frame: {:.1} ms", 1e3 * unstable_dt )); ui.label(format!("predicted_dt: {:.1} ms", 1e3 * predicted_dt)); ui.label(format!("stable_dt: {:.1} ms", 1e3 * stable_dt)); - ui.label(format!("focused: {}", focused)); - ui.label(format!("modifiers: {:#?}", modifiers)); - ui.label(format!("keys_down: {:?}", keys_down)); + ui.label(format!("focused: {focused}")); + ui.label(format!("modifiers: {modifiers:#?}")); + ui.label(format!("keys_down: {keys_down:?}")); ui.scope(|ui| { ui.set_min_height(150.0); - ui.label(format!("events: {:#?}", events)) + ui.label(format!("events: {events:#?}")) .on_hover_text("key presses etc"); }); } @@ -1037,22 +1035,21 @@ impl PointerState { pointer_events, } = self; - ui.label(format!("latest_pos: {:?}", latest_pos)); - ui.label(format!("interact_pos: {:?}", interact_pos)); - ui.label(format!("delta: {:?}", delta)); + ui.label(format!("latest_pos: {latest_pos:?}")); + ui.label(format!("interact_pos: {interact_pos:?}")); + ui.label(format!("delta: {delta:?}")); ui.label(format!( "velocity: [{:3.0} {:3.0}] points/sec", velocity.x, velocity.y )); - ui.label(format!("down: {:#?}", down)); - ui.label(format!("press_origin: {:?}", press_origin)); - ui.label(format!("press_start_time: {:?} s", press_start_time)); + ui.label(format!("down: {down:#?}")); + ui.label(format!("press_origin: {press_origin:?}")); + ui.label(format!("press_start_time: {press_start_time:?} s")); ui.label(format!( - "has_moved_too_much_for_a_click: {}", - has_moved_too_much_for_a_click + "has_moved_too_much_for_a_click: {has_moved_too_much_for_a_click}" )); - ui.label(format!("last_click_time: {:#?}", last_click_time)); - ui.label(format!("last_last_click_time: {:#?}", last_last_click_time)); - ui.label(format!("pointer_events: {:?}", pointer_events)); + ui.label(format!("last_click_time: {last_click_time:#?}")); + ui.label(format!("last_last_click_time: {last_last_click_time:#?}")); + ui.label(format!("pointer_events: {pointer_events:?}")); } } diff --git a/crates/egui/src/input_state/touch_state.rs b/crates/egui/src/input_state/touch_state.rs index becd0d52..37d418a5 100644 --- a/crates/egui/src/input_state/touch_state.rs +++ b/crates/egui/src/input_state/touch_state.rs @@ -286,7 +286,7 @@ impl TouchState { impl TouchState { pub fn ui(&self, ui: &mut crate::Ui) { - ui.label(format!("{:?}", self)); + ui.label(format!("{self:?}")); } } @@ -294,7 +294,7 @@ impl Debug for TouchState { // This outputs less clutter than `#[derive(Debug)]`: fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for (id, touch) in &self.active_touches { - f.write_fmt(format_args!("#{:?}: {:#?}\n", id, touch))?; + f.write_fmt(format_args!("#{id:?}: {touch:#?}\n"))?; } f.write_fmt(format_args!("gesture: {:#?}\n", self.gesture_state))?; Ok(()) diff --git a/crates/egui/src/introspection.rs b/crates/egui/src/introspection.rs index ae66cddb..6f0cada7 100644 --- a/crates/egui/src/introspection.rs +++ b/crates/egui/src/introspection.rs @@ -31,10 +31,7 @@ pub(crate) fn font_texture_ui(ui: &mut Ui, [width, height]: [usize; 2]) -> Respo Color32::BLACK }; - ui.label(format!( - "Texture size: {} x {} (hover to zoom)", - width, height - )); + ui.label(format!("Texture size: {width} x {height} (hover to zoom)")); if width <= 1 || height <= 1 { return; } @@ -108,7 +105,7 @@ impl Widget for &epaint::stats::PaintStats { label(ui, shape_path, "paths"); label(ui, shape_mesh, "nested meshes"); label(ui, shape_vec, "nested shapes"); - ui.label(format!("{:6} callbacks", num_callbacks)); + ui.label(format!("{num_callbacks:6} callbacks")); ui.add_space(10.0); ui.label("Text shapes:"); diff --git a/crates/egui/src/painter.rs b/crates/egui/src/painter.rs index baf3b921..17028e6c 100644 --- a/crates/egui/src/painter.rs +++ b/crates/egui/src/painter.rs @@ -226,7 +226,7 @@ impl Painter { pub fn error(&self, pos: Pos2, text: impl std::fmt::Display) -> Rect { let color = self.ctx.style().visuals.error_fg_color; - self.debug_text(pos, Align2::LEFT_TOP, color, format!("🔥 {}", text)) + self.debug_text(pos, Align2::LEFT_TOP, color, format!("🔥 {text}")) } /// text with a background diff --git a/crates/egui/src/widgets/color_picker.rs b/crates/egui/src/widgets/color_picker.rs index da5f2867..fcb701f4 100644 --- a/crates/egui/src/widgets/color_picker.rs +++ b/crates/egui/src/widgets/color_picker.rs @@ -234,17 +234,17 @@ fn color_text_ui(ui: &mut Ui, color: impl Into, alpha: Alpha) { if ui.button("📋").on_hover_text("Click to copy").clicked() { if alpha == Alpha::Opaque { - ui.output_mut(|o| o.copied_text = format!("{}, {}, {}", r, g, b)); + ui.output_mut(|o| o.copied_text = format!("{r}, {g}, {b}")); } else { - ui.output_mut(|o| o.copied_text = format!("{}, {}, {}, {}", r, g, b, a)); + ui.output_mut(|o| o.copied_text = format!("{r}, {g}, {b}, {a}")); } } if alpha == Alpha::Opaque { - ui.label(format!("rgb({}, {}, {})", r, g, b)) + ui.label(format!("rgb({r}, {g}, {b})")) .on_hover_text("Red Green Blue"); } else { - ui.label(format!("rgba({}, {}, {}, {})", r, g, b, a)) + ui.label(format!("rgba({r}, {g}, {b}, {a})")) .on_hover_text("Red Green Blue with premultiplied Alpha"); } }); diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index 2b62c8d8..0e1b5460 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -627,7 +627,7 @@ impl<'a> Widget for DragValue<'a> { // The value is exposed as a string by the text edit widget // when in edit mode. if !is_kb_editing { - let value_text = format!("{}{}{}", prefix, value_text, suffix); + let value_text = format!("{prefix}{value_text}{suffix}"); builder.set_value(value_text); } }); diff --git a/crates/egui/src/widgets/plot/items/mod.rs b/crates/egui/src/widgets/plot/items/mod.rs index f18f34af..2cbcb26d 100644 --- a/crates/egui/src/widgets/plot/items/mod.rs +++ b/crates/egui/src/widgets/plot/items/mod.rs @@ -1732,7 +1732,7 @@ pub(super) fn rulers_at_value( let mut prefix = String::new(); if !name.is_empty() { - prefix = format!("{}\n", name); + prefix = format!("{name}\n"); } let text = { diff --git a/crates/egui/src/widgets/plot/items/values.rs b/crates/egui/src/widgets/plot/items/values.rs index 739490dc..52fceba7 100644 --- a/crates/egui/src/widgets/plot/items/values.rs +++ b/crates/egui/src/widgets/plot/items/values.rs @@ -125,8 +125,8 @@ impl ToString for LineStyle { fn to_string(&self) -> String { match self { LineStyle::Solid => "Solid".into(), - LineStyle::Dotted { spacing } => format!("Dotted{}Px", spacing), - LineStyle::Dashed { length } => format!("Dashed{}Px", length), + LineStyle::Dotted { spacing } => format!("Dotted{spacing}Px"), + LineStyle::Dashed { length } => format!("Dashed{length}Px"), } } } diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index 9eca796d..ebc73d72 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -1453,7 +1453,7 @@ impl PreparedPlot { let axis_range = match axis { 0 => bounds.range_x(), 1 => bounds.range_y(), - _ => panic!("Axis {} does not exist.", axis), + _ => panic!("Axis {axis} does not exist."), }; let font_id = TextStyle::Body.resolve(ui.style()); @@ -1676,7 +1676,7 @@ pub fn format_number(number: f64, num_decimals: usize) -> String { let is_integral = number as i64 as f64 == number; if is_integral { // perfect integer - show it as such: - format!("{:.0}", number) + format!("{number:.0}") } else { // make sure we tell the user it is not an integer by always showing a decimal or two: format!("{:.*}", num_decimals.at_least(1), number) diff --git a/crates/egui_demo_app/Cargo.toml b/crates/egui_demo_app/Cargo.toml index af3eef61..79ae4874 100644 --- a/crates/egui_demo_app/Cargo.toml +++ b/crates/egui_demo_app/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" publish = false default-run = "egui_demo_app" diff --git a/crates/egui_demo_app/src/apps/http_app.rs b/crates/egui_demo_app/src/apps/http_app.rs index 4d87a3e2..e550c1db 100644 --- a/crates/egui_demo_app/src/apps/http_app.rs +++ b/crates/egui_demo_app/src/apps/http_app.rs @@ -133,7 +133,7 @@ fn ui_url(ui: &mut egui::Ui, frame: &mut eframe::Frame, url: &mut String) -> boo if ui.button("Random image").clicked() { let seed = ui.input(|i| i.time); let side = 640; - *url = format!("https://picsum.photos/seed/{}/{}", seed, side); + *url = format!("https://picsum.photos/seed/{seed}/{side}"); trigger_fetch = true; } }); diff --git a/crates/egui_demo_app/src/backend_panel.rs b/crates/egui_demo_app/src/backend_panel.rs index 33d1cc63..6480756f 100644 --- a/crates/egui_demo_app/src/backend_panel.rs +++ b/crates/egui_demo_app/src/backend_panel.rs @@ -232,8 +232,7 @@ impl BackendPanel { if ui .add_enabled(enabled, egui::Button::new("Reset")) .on_hover_text(format!( - "Reset scale to native value ({:.1})", - native_pixels_per_point + "Reset scale to native value ({native_pixels_per_point:.1})" )) .clicked() { @@ -441,7 +440,7 @@ impl EguiWindows { .stick_to_bottom(true) .show(ui, |ui| { for event in output_event_history { - ui.label(format!("{:?}", event)); + ui.label(format!("{event:?}")); } }); }); diff --git a/crates/egui_demo_app/src/wrap_app.rs b/crates/egui_demo_app/src/wrap_app.rs index 3b2c09a7..69a23e7a 100644 --- a/crates/egui_demo_app/src/wrap_app.rs +++ b/crates/egui_demo_app/src/wrap_app.rs @@ -354,7 +354,7 @@ impl WrapApp { { selected_anchor = anchor; if frame.is_web() { - ui.output_mut(|o| o.open_url(format!("#{}", anchor))); + ui.output_mut(|o| o.open_url(format!("#{anchor}"))); } } } diff --git a/crates/egui_demo_lib/Cargo.toml b/crates/egui_demo_lib/Cargo.toml index d8f7c688..e86baca2 100644 --- a/crates/egui_demo_lib/Cargo.toml +++ b/crates/egui_demo_lib/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "Example library for egui" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/egui_demo_lib" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui_demo_lib/src/demo/about.rs b/crates/egui_demo_lib/src/demo/about.rs index 0fbb9764..4972b224 100644 --- a/crates/egui_demo_lib/src/demo/about.rs +++ b/crates/egui_demo_lib/src/demo/about.rs @@ -83,11 +83,11 @@ fn about_immediate_mode(ui: &mut egui::Ui) { fn links(ui: &mut egui::Ui) { use egui::special_emojis::{GITHUB, TWITTER}; ui.hyperlink_to( - format!("{} egui on GitHub", GITHUB), + format!("{GITHUB} egui on GitHub"), "https://github.com/emilk/egui", ); ui.hyperlink_to( - format!("{} @ernerfeldt", TWITTER), + format!("{TWITTER} @ernerfeldt"), "https://twitter.com/ernerfeldt", ); ui.hyperlink_to("egui documentation", "https://docs.rs/egui/"); diff --git a/crates/egui_demo_lib/src/demo/code_example.rs b/crates/egui_demo_lib/src/demo/code_example.rs index c72fde22..7b135147 100644 --- a/crates/egui_demo_lib/src/demo/code_example.rs +++ b/crates/egui_demo_lib/src/demo/code_example.rs @@ -121,7 +121,7 @@ impl CodeExample { ui.separator(); - code_view_ui(ui, &format!("{:#?}", self)); + code_view_ui(ui, &format!("{self:#?}")); ui.separator(); diff --git a/crates/egui_demo_lib/src/demo/demo_app_windows.rs b/crates/egui_demo_lib/src/demo/demo_app_windows.rs index 4ad6c2d9..354bb44e 100644 --- a/crates/egui_demo_lib/src/demo/demo_app_windows.rs +++ b/crates/egui_demo_lib/src/demo/demo_app_windows.rs @@ -251,11 +251,11 @@ impl DemoWindows { use egui::special_emojis::{GITHUB, TWITTER}; ui.hyperlink_to( - format!("{} egui on GitHub", GITHUB), + format!("{GITHUB} egui on GitHub"), "https://github.com/emilk/egui", ); ui.hyperlink_to( - format!("{} @ernerfeldt", TWITTER), + format!("{TWITTER} @ernerfeldt"), "https://twitter.com/ernerfeldt", ); diff --git a/crates/egui_demo_lib/src/demo/layout_test.rs b/crates/egui_demo_lib/src/demo/layout_test.rs index 2d4fa8a8..8adf1bb6 100644 --- a/crates/egui_demo_lib/src/demo/layout_test.rs +++ b/crates/egui_demo_lib/src/demo/layout_test.rs @@ -140,7 +140,7 @@ impl LayoutTest { Direction::TopDown, Direction::BottomUp, ] { - ui.radio_value(&mut self.layout.main_dir, dir, format!("{:?}", dir)); + ui.radio_value(&mut self.layout.main_dir, dir, format!("{dir:?}")); } }); @@ -162,7 +162,7 @@ impl LayoutTest { ui.horizontal(|ui| { ui.label("Cross Align:"); for &align in &[Align::Min, Align::Center, Align::Max] { - ui.radio_value(&mut self.layout.cross_align, align, format!("{:?}", align)); + ui.radio_value(&mut self.layout.cross_align, align, format!("{align:?}")); } }); diff --git a/crates/egui_demo_lib/src/demo/misc_demo_window.rs b/crates/egui_demo_lib/src/demo/misc_demo_window.rs index 61a6091e..e4cf9264 100644 --- a/crates/egui_demo_lib/src/demo/misc_demo_window.rs +++ b/crates/egui_demo_lib/src/demo/misc_demo_window.rs @@ -455,7 +455,7 @@ impl Tree { .into_iter() .enumerate() .filter_map(|(i, mut tree)| { - if tree.ui_impl(ui, depth + 1, &format!("child #{}", i)) == Action::Keep { + if tree.ui_impl(ui, depth + 1, &format!("child #{i}")) == Action::Keep { Some(tree) } else { None diff --git a/crates/egui_demo_lib/src/demo/multi_touch.rs b/crates/egui_demo_lib/src/demo/multi_touch.rs index c358f6b2..1a3b29e8 100644 --- a/crates/egui_demo_lib/src/demo/multi_touch.rs +++ b/crates/egui_demo_lib/src/demo/multi_touch.rs @@ -50,7 +50,7 @@ impl super::View for MultiTouch { ui.label("Try touch gestures Pinch/Stretch, Rotation, and Pressure with 2+ fingers."); let num_touches = ui.input(|i| i.multi_touch().map_or(0, |mt| mt.num_touches)); - ui.label(format!("Current touches: {}", num_touches)); + ui.label(format!("Current touches: {num_touches}")); let color = if ui.visuals().dark_mode { Color32::WHITE diff --git a/crates/egui_demo_lib/src/demo/plot_demo.rs b/crates/egui_demo_lib/src/demo/plot_demo.rs index 2f6180ea..8daf3c37 100644 --- a/crates/egui_demo_lib/src/demo/plot_demo.rs +++ b/crates/egui_demo_lib/src/demo/plot_demo.rs @@ -326,7 +326,7 @@ impl MarkerDemo { [5.0, 0.0 + y_offset], [6.0, 0.5 + y_offset], ]) - .name(format!("{:?}", marker)) + .name(format!("{marker:?}")) .filled(self.fill_markers) .radius(self.marker_radius) .shape(marker); @@ -416,7 +416,7 @@ impl LegendDemo { ui.label("Position:"); ui.horizontal(|ui| { Corner::all().for_each(|position| { - ui.selectable_value(&mut config.position, position, format!("{:?}", position)); + ui.selectable_value(&mut config.position, position, format!("{position:?}")); }); }); ui.end_row(); @@ -774,21 +774,18 @@ impl InteractionDemo { "origin in screen coordinates: x: {:.02}, y: {:.02}", screen_pos.x, screen_pos.y )); - ui.label(format!("plot hovered: {}", hovered)); + ui.label(format!("plot hovered: {hovered}")); let coordinate_text = if let Some(coordinate) = pointer_coordinate { format!("x: {:.02}, y: {:.02}", coordinate.x, coordinate.y) } else { "None".to_owned() }; - ui.label(format!("pointer coordinate: {}", coordinate_text)); + ui.label(format!("pointer coordinate: {coordinate_text}")); let coordinate_text = format!( "x: {:.02}, y: {:.02}", pointer_coordinate_drag_delta.x, pointer_coordinate_drag_delta.y ); - ui.label(format!( - "pointer coordinate drag delta: {}", - coordinate_text - )); + ui.label(format!("pointer coordinate drag delta: {coordinate_text}")); response } diff --git a/crates/egui_demo_lib/src/demo/scrolling.rs b/crates/egui_demo_lib/src/demo/scrolling.rs index b970b326..f5833521 100644 --- a/crates/egui_demo_lib/src/demo/scrolling.rs +++ b/crates/egui_demo_lib/src/demo/scrolling.rs @@ -232,10 +232,10 @@ impl super::View for ScrollTo { for item in 1..=50 { if track_item && item == self.track_item { let response = - ui.colored_label(Color32::YELLOW, format!("This is item {}", item)); + ui.colored_label(Color32::YELLOW, format!("This is item {item}")); response.scroll_to_me(self.tack_item_align); } else { - ui.label(format!("This is item {}", item)); + ui.label(format!("This is item {item}")); } } }); @@ -254,8 +254,7 @@ impl super::View for ScrollTo { ui.separator(); ui.label(format!( - "Scroll offset: {:.0}/{:.0} px", - current_scroll, max_scroll + "Scroll offset: {current_scroll:.0}/{max_scroll:.0} px" )); ui.separator(); diff --git a/crates/egui_demo_lib/src/demo/tests.rs b/crates/egui_demo_lib/src/demo/tests.rs index 83e79876..784b9525 100644 --- a/crates/egui_demo_lib/src/demo/tests.rs +++ b/crates/egui_demo_lib/src/demo/tests.rs @@ -20,7 +20,7 @@ impl super::View for CursorTest { ui.heading("Hover to switch cursor icon:"); for &cursor_icon in &egui::CursorIcon::ALL { let _ = ui - .button(format!("{:?}", cursor_icon)) + .button(format!("{cursor_icon:?}")) .on_hover_cursor(cursor_icon); } ui.add(crate::egui_github_link_file!()); @@ -239,7 +239,7 @@ impl super::View for TableTest { for row in 0..self.num_rows { for col in 0..self.num_cols { if col == 0 { - ui.label(format!("row {}", row)); + ui.label(format!("row {row}")); } else { let word_idx = row * 3 + col * 5; let word_count = (row * 5 + col * 75) % 13; @@ -350,13 +350,13 @@ impl super::View for InputTest { use std::fmt::Write as _; if response.clicked_by(button) { - writeln!(new_info, "Clicked by {:?} button", button).ok(); + writeln!(new_info, "Clicked by {button:?} button").ok(); } if response.double_clicked_by(button) { - writeln!(new_info, "Double-clicked by {:?} button", button).ok(); + writeln!(new_info, "Double-clicked by {button:?} button").ok(); } if response.triple_clicked_by(button) { - writeln!(new_info, "Triple-clicked by {:?} button", button).ok(); + writeln!(new_info, "Triple-clicked by {button:?} button").ok(); } if response.dragged_by(button) { writeln!( diff --git a/crates/egui_demo_lib/src/demo/widget_gallery.rs b/crates/egui_demo_lib/src/demo/widget_gallery.rs index d91ae395..eb424e9e 100644 --- a/crates/egui_demo_lib/src/demo/widget_gallery.rs +++ b/crates/egui_demo_lib/src/demo/widget_gallery.rs @@ -126,7 +126,7 @@ impl WidgetGallery { ui.add(doc_link_label("Hyperlink", "Hyperlink")); use egui::special_emojis::GITHUB; ui.hyperlink_to( - format!("{} egui on GitHub", GITHUB), + format!("{GITHUB} egui on GitHub"), "https://github.com/emilk/egui", ); ui.end_row(); @@ -173,7 +173,7 @@ impl WidgetGallery { ui.add(doc_link_label("ComboBox", "ComboBox")); egui::ComboBox::from_label("Take your pick") - .selected_text(format!("{:?}", radio)) + .selected_text(format!("{radio:?}")) .show_ui(ui, |ui| { ui.style_mut().wrap = Some(false); ui.set_min_width(60.0); @@ -277,8 +277,8 @@ fn example_plot(ui: &mut egui::Ui) -> egui::Response { } fn doc_link_label<'a>(title: &'a str, search_term: &'a str) -> impl egui::Widget + 'a { - let label = format!("{}:", title); - let url = format!("https://docs.rs/egui?search={}", search_term); + let label = format!("{title}:"); + let url = format!("https://docs.rs/egui?search={search_term}"); move |ui: &mut egui::Ui| { ui.hyperlink_to(label, url).on_hover_ui(|ui| { ui.horizontal_wrapped(|ui| { diff --git a/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs b/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs index 44408ff2..29be2d2e 100644 --- a/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs +++ b/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs @@ -161,7 +161,7 @@ fn numbered_point(ui: &mut Ui, width: f32, number: &str) -> Response { let font_id = TextStyle::Body.resolve(ui.style()); let row_height = ui.fonts(|f| f.row_height(&font_id)); let (rect, response) = ui.allocate_exact_size(vec2(width, row_height), Sense::hover()); - let text = format!("{}.", number); + let text = format!("{number}."); let text_color = ui.visuals().strong_text_color(); ui.painter().text( rect.right_center(), diff --git a/crates/egui_extras/Cargo.toml b/crates/egui_extras/Cargo.toml index f5f4595a..fe3bf887 100644 --- a/crates/egui_extras/Cargo.toml +++ b/crates/egui_extras/Cargo.toml @@ -8,7 +8,7 @@ authors = [ ] description = "Extra functionality and widgets for the egui GUI library" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui_extras/src/datepicker/popup.rs b/crates/egui_extras/src/datepicker/popup.rs index 7da8cbc1..d8dd4672 100644 --- a/crates/egui_extras/src/datepicker/popup.rs +++ b/crates/egui_extras/src/datepicker/popup.rs @@ -428,6 +428,6 @@ fn month_name(i: u32) -> &'static str { 10 => "October", 11 => "November", 12 => "December", - _ => panic!("Unknown month: {}", i), + _ => panic!("Unknown month: {i}"), } } diff --git a/crates/egui_extras/src/image.rs b/crates/egui_extras/src/image.rs index ba8acaf4..bec11d1a 100644 --- a/crates/egui_extras/src/image.rs +++ b/crates/egui_extras/src/image.rs @@ -258,7 +258,7 @@ pub fn load_svg_bytes_with_size( }; let mut pixmap = tiny_skia::Pixmap::new(w, h) - .ok_or_else(|| format!("Failed to create SVG Pixmap of size {}x{}", w, h))?; + .ok_or_else(|| format!("Failed to create SVG Pixmap of size {w}x{h}"))?; resvg::render(&rtree, fit_to, Default::default(), pixmap.as_mut()) .ok_or_else(|| "Failed to render SVG".to_owned())?; diff --git a/crates/egui_glium/Cargo.toml b/crates/egui_glium/Cargo.toml index 9be5870d..a4be314d 100644 --- a/crates/egui_glium/Cargo.toml +++ b/crates/egui_glium/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "Bindings for using egui natively using the glium library" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glium" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui_glow/Cargo.toml b/crates/egui_glow/Cargo.toml index 1c1a797c..dfd6e0de 100644 --- a/crates/egui_glow/Cargo.toml +++ b/crates/egui_glow/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "Bindings for using egui natively using the glow library" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glow" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/emath/Cargo.toml b/crates/emath/Cargo.toml index d4eec7c7..8fea677e 100644 --- a/crates/emath/Cargo.toml +++ b/crates/emath/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "Minimal 2D math library for GUI work" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/emath" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/emath/src/lib.rs b/crates/emath/src/lib.rs index 25b3b9ea..8cfe16de 100644 --- a/crates/emath/src/lib.rs +++ b/crates/emath/src/lib.rs @@ -183,9 +183,7 @@ where /// Round a value to the given number of decimal places. pub fn round_to_decimals(value: f64, decimal_places: usize) -> f64 { // This is a stupid way of doing this, but stupid works. - format!("{:.*}", decimal_places, value) - .parse() - .unwrap_or(value) + format!("{value:.decimal_places$}").parse().unwrap_or(value) } pub fn format_with_minimum_decimals(value: f64, decimals: usize) -> String { @@ -203,7 +201,7 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive().unwrap(), value as f32, epsilon) { // Enough precision to show the value accurately - good! @@ -214,7 +212,7 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive for Pos2 { match index { 0 => &self.x, 1 => &self.y, - _ => panic!("Pos2 index out of bounds: {}", index), + _ => panic!("Pos2 index out of bounds: {index}"), } } } @@ -217,7 +217,7 @@ impl std::ops::IndexMut for Pos2 { match index { 0 => &mut self.x, 1 => &mut self.y, - _ => panic!("Pos2 index out of bounds: {}", index), + _ => panic!("Pos2 index out of bounds: {index}"), } } } diff --git a/crates/emath/src/rot2.rs b/crates/emath/src/rot2.rs index e29f18f4..b281ca58 100644 --- a/crates/emath/src/rot2.rs +++ b/crates/emath/src/rot2.rs @@ -184,10 +184,7 @@ mod test { let expected = vec2(0.0, 3.0); assert!( (rotated - expected).length() < 1e-5, - "Expected {:?} to equal {:?}. rot: {:?}", - rotated, - expected, - rot, + "Expected {rotated:?} to equal {expected:?}. rot: {rot:?}", ); let undone = rot.inverse() * rot; diff --git a/crates/emath/src/vec2.rs b/crates/emath/src/vec2.rs index ac70f9b4..133c3fd3 100644 --- a/crates/emath/src/vec2.rs +++ b/crates/emath/src/vec2.rs @@ -292,7 +292,7 @@ impl std::ops::Index for Vec2 { match index { 0 => &self.x, 1 => &self.y, - _ => panic!("Vec2 index out of bounds: {}", index), + _ => panic!("Vec2 index out of bounds: {index}"), } } } @@ -303,7 +303,7 @@ impl std::ops::IndexMut for Vec2 { match index { 0 => &mut self.x, 1 => &mut self.y, - _ => panic!("Vec2 index out of bounds: {}", index), + _ => panic!("Vec2 index out of bounds: {index}"), } } } diff --git a/crates/epaint/Cargo.toml b/crates/epaint/Cargo.toml index 094b6c45..5a4c7424 100644 --- a/crates/epaint/Cargo.toml +++ b/crates/epaint/Cargo.toml @@ -4,7 +4,7 @@ version = "0.22.0" authors = ["Emil Ernerfeldt "] description = "Minimal 2D graphics library for GUI work" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" homepage = "https://github.com/emilk/egui/tree/master/crates/epaint" license = "(MIT OR Apache-2.0) AND OFL-1.1 AND LicenseRef-UFL-1.0" # OFL and UFL used by default_fonts. See https://github.com/emilk/egui/issues/2321 readme = "README.md" diff --git a/crates/epaint/src/mesh.rs b/crates/epaint/src/mesh.rs index 09025268..62f0de21 100644 --- a/crates/epaint/src/mesh.rs +++ b/crates/epaint/src/mesh.rs @@ -251,8 +251,7 @@ impl Mesh { assert!( index_cursor > span_start, - "One triangle spanned more than {} vertices", - MAX_SIZE + "One triangle spanned more than {MAX_SIZE} vertices" ); let mesh = Mesh16 { diff --git a/crates/epaint/src/mutex.rs b/crates/epaint/src/mutex.rs index cca86466..ce2bf7c9 100644 --- a/crates/epaint/src/mutex.rs +++ b/crates/epaint/src/mutex.rs @@ -333,7 +333,7 @@ mod rw_lock_impl { fn format_backtrace(backtrace: &mut backtrace::Backtrace) -> String { backtrace.resolve(); - let stacktrace = format!("{:?}", backtrace); + let stacktrace = format!("{backtrace:?}"); // Remove irrelevant parts of the stacktrace: let end_offset = stacktrace diff --git a/crates/epaint/src/stats.rs b/crates/epaint/src/stats.rs index 24293aa7..6723b61f 100644 --- a/crates/epaint/src/stats.rs +++ b/crates/epaint/src/stats.rs @@ -106,7 +106,7 @@ impl AllocInfo { element_size: ElementSize::Homogeneous(element_size), num_allocs: 1, num_elements: slice.len(), - num_bytes: slice.len() * element_size, + num_bytes: std::mem::size_of_val(slice), } } diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index 4cf26014..dfcb52a1 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -367,8 +367,7 @@ impl Font { .or_else(|| slf.glyph_info_no_cache_or_fallback(FALLBACK_REPLACEMENT_CHAR)) .unwrap_or_else(|| { panic!( - "Failed to find replacement characters {:?} or {:?}", - PRIMARY_REPLACEMENT_CHAR, FALLBACK_REPLACEMENT_CHAR + "Failed to find replacement characters {PRIMARY_REPLACEMENT_CHAR:?} or {FALLBACK_REPLACEMENT_CHAR:?}" ) }); slf.replacement_glyph = replacement_glyph; diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 829a593f..474d6e70 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -200,7 +200,7 @@ fn ab_glyph_font_from_font_data(name: &str, data: &FontData) -> ab_glyph::FontAr .map(ab_glyph::FontArc::from) } } - .unwrap_or_else(|err| panic!("Error parsing {:?} TTF/OTF font file: {}", name, err)) + .unwrap_or_else(|err| panic!("Error parsing {name:?} TTF/OTF font file: {err}")) } /// Describes the font data and the sizes to use. @@ -586,8 +586,7 @@ impl FontsImpl { ) -> Self { assert!( 0.0 < pixels_per_point && pixels_per_point < 100.0, - "pixels_per_point out of range: {}", - pixels_per_point + "pixels_per_point out of range: {pixels_per_point}" ); let texture_width = max_texture_side.at_most(8 * 1024); @@ -627,9 +626,8 @@ impl FontsImpl { .entry((HashableF32(*size), family.clone())) .or_insert_with(|| { let fonts = &self.definitions.families.get(family); - let fonts = fonts.unwrap_or_else(|| { - panic!("FontFamily::{:?} is not bound to any fonts", family) - }); + let fonts = fonts + .unwrap_or_else(|| panic!("FontFamily::{family:?} is not bound to any fonts")); let fonts: Vec> = fonts .iter() @@ -752,17 +750,14 @@ impl FontImplCache { let (tweak, ab_glyph_font) = self .ab_glyph_fonts .get(font_name) - .unwrap_or_else(|| panic!("No font data found for {:?}", font_name)) + .unwrap_or_else(|| panic!("No font data found for {font_name:?}")) .clone(); let scale_in_pixels = self.pixels_per_point * scale_in_points; // Scale the font properly (see https://github.com/emilk/egui/issues/2068). let units_per_em = ab_glyph_font.units_per_em().unwrap_or_else(|| { - panic!( - "The font unit size of {:?} exceeds the expected range (16..=16384)", - font_name - ) + panic!("The font unit size of {font_name:?} exceeds the expected range (16..=16384)") }); let font_scaling = ab_glyph_font.height_unscaled() / units_per_em; let scale_in_pixels = scale_in_pixels * font_scaling; diff --git a/examples/confirm_exit/Cargo.toml b/examples/confirm_exit/Cargo.toml index e4b193e3..08144e7f 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.65" +rust-version = "1.67" publish = false diff --git a/examples/custom_3d_glow/Cargo.toml b/examples/custom_3d_glow/Cargo.toml index 9dfa403c..c75ee3c4 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.65" +rust-version = "1.67" publish = false diff --git a/examples/custom_3d_glow/src/main.rs b/examples/custom_3d_glow/src/main.rs index f72859d2..7cd954c3 100644 --- a/examples/custom_3d_glow/src/main.rs +++ b/examples/custom_3d_glow/src/main.rs @@ -144,7 +144,7 @@ impl RotatingTriangle { let shader = gl .create_shader(*shader_type) .expect("Cannot create shader"); - gl.shader_source(shader, &format!("{}\n{}", shader_version, shader_source)); + gl.shader_source(shader, &format!("{shader_version}\n{shader_source}")); gl.compile_shader(shader); assert!( gl.get_shader_compile_status(shader), diff --git a/examples/custom_font/Cargo.toml b/examples/custom_font/Cargo.toml index 78d0491d..c7b212b5 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.65" +rust-version = "1.67" publish = false diff --git a/examples/custom_font_style/Cargo.toml b/examples/custom_font_style/Cargo.toml index 3eda5ee3..3c5e9600 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.65" +rust-version = "1.67" publish = false diff --git a/examples/custom_window_frame/Cargo.toml b/examples/custom_window_frame/Cargo.toml index 1cad5da2..448d8c2b 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.65" +rust-version = "1.67" publish = false diff --git a/examples/download_image/Cargo.toml b/examples/download_image/Cargo.toml index 0097d9e3..5e4f28e1 100644 --- a/examples/download_image/Cargo.toml +++ b/examples/download_image/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" publish = false diff --git a/examples/download_image/src/main.rs b/examples/download_image/src/main.rs index 2a2c3540..9a48c895 100644 --- a/examples/download_image/src/main.rs +++ b/examples/download_image/src/main.rs @@ -58,8 +58,7 @@ fn parse_response(response: ehttp::Response) -> Result { RetainedImage::from_image_bytes(&response.url, &response.bytes) } else { Err(format!( - "Expected image, found content-type {:?}", - content_type + "Expected image, found content-type {content_type:?}" )) } } diff --git a/examples/file_dialog/Cargo.toml b/examples/file_dialog/Cargo.toml index 5447e681..02045d62 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.65" +rust-version = "1.67" publish = false diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 9dc377ce..580fe04e 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.65" +rust-version = "1.67" publish = false diff --git a/examples/hello_world_par/Cargo.toml b/examples/hello_world_par/Cargo.toml index 9b02345f..76c1ac88 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.65" +rust-version = "1.67" publish = false diff --git a/examples/hello_world_par/src/main.rs b/examples/hello_world_par/src/main.rs index b9d03ba6..8a568cb1 100644 --- a/examples/hello_world_par/src/main.rs +++ b/examples/hello_world_par/src/main.rs @@ -63,7 +63,7 @@ fn new_worker( ) -> (JoinHandle<()>, mpsc::SyncSender) { let (show_tx, show_rc) = mpsc::sync_channel(0); let handle = std::thread::Builder::new() - .name(format!("EguiPanelWorker {}", thread_nr)) + .name(format!("EguiPanelWorker {thread_nr}")) .spawn(move || { let mut state = ThreadState::new(thread_nr); while let Ok(ctx) = show_rc.recv() { diff --git a/examples/hello_world_simple/Cargo.toml b/examples/hello_world_simple/Cargo.toml index 1c6bcfa4..be399552 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.65" +rust-version = "1.67" publish = false diff --git a/examples/keyboard_events/Cargo.toml b/examples/keyboard_events/Cargo.toml index 7e544a2e..39a389f3 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.65" +rust-version = "1.67" publish = false diff --git a/examples/puffin_profiler/Cargo.toml b/examples/puffin_profiler/Cargo.toml index dbb048fe..90baa1ac 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.65" +rust-version = "1.67" publish = false diff --git a/examples/puffin_profiler/src/main.rs b/examples/puffin_profiler/src/main.rs index 2cfc5e61..f8d52e91 100644 --- a/examples/puffin_profiler/src/main.rs +++ b/examples/puffin_profiler/src/main.rs @@ -62,7 +62,7 @@ fn start_puffin_server() { std::mem::forget(puffin_server); } Err(err) => { - eprintln!("Failed to start puffin server: {}", err); + eprintln!("Failed to start puffin server: {err}"); } }; } diff --git a/examples/retained_image/Cargo.toml b/examples/retained_image/Cargo.toml index abbe01fd..a1df1039 100644 --- a/examples/retained_image/Cargo.toml +++ b/examples/retained_image/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" publish = false diff --git a/examples/save_plot/Cargo.toml b/examples/save_plot/Cargo.toml index 83f919d7..2a12692f 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.65" +rust-version = "1.67" publish = false [dependencies] diff --git a/examples/save_plot/src/main.rs b/examples/save_plot/src/main.rs index 68c48182..0d9de35c 100644 --- a/examples/save_plot/src/main.rs +++ b/examples/save_plot/src/main.rs @@ -14,7 +14,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "My egui App with a plot", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/screenshot/Cargo.toml b/examples/screenshot/Cargo.toml index 692fc367..3cc5887f 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.65" +rust-version = "1.67" publish = false diff --git a/examples/serial_windows/Cargo.toml b/examples/serial_windows/Cargo.toml index 089858dd..39f5a022 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.65" +rust-version = "1.67" publish = false diff --git a/examples/svg/Cargo.toml b/examples/svg/Cargo.toml index fcf56e49..219efd58 100644 --- a/examples/svg/Cargo.toml +++ b/examples/svg/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.65" +rust-version = "1.67" publish = false diff --git a/examples/user_attention/Cargo.toml b/examples/user_attention/Cargo.toml index 8b438793..3a7e49a1 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.65" +rust-version = "1.67" publish = false [dependencies] diff --git a/examples/user_attention/src/main.rs b/examples/user_attention/src/main.rs index 4f7e521d..8134062f 100644 --- a/examples/user_attention/src/main.rs +++ b/examples/user_attention/src/main.rs @@ -19,7 +19,7 @@ fn main() -> eframe::Result<()> { } fn repr(attention: UserAttentionType) -> String { - format!("{:?}", attention) + format!("{attention:?}") } struct Application { diff --git a/rust-toolchain b/rust-toolchain index 0e334035..5698c9e2 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.65.0" +channel = "1.67.0" components = [ "rustfmt", "clippy" ] targets = [ "wasm32-unknown-unknown" ] diff --git a/scripts/clippy_wasm/clippy.toml b/scripts/clippy_wasm/clippy.toml index e2ec8be9..436e1fb8 100644 --- a/scripts/clippy_wasm/clippy.toml +++ b/scripts/clippy_wasm/clippy.toml @@ -3,7 +3,7 @@ # We cannot forbid all these methods in the main `clippy.toml` because of # https://github.com/rust-lang/rust-clippy/issues/10406 -msrv = "1.65" +msrv = "1.67" # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods disallowed-methods = [