diff --git a/.github/workflows/deploy_web_demo.yml b/.github/workflows/deploy_web_demo.yml index d6f01e3ac99..ea2956db313 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.70.0 + toolchain: 1.72.0 override: true - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e3809226552..94d06c70f8a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,7 +19,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.70.0 + toolchain: 1.72.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.70.0 + toolchain: 1.72.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.70.0" + rust-version: "1.72.0" log-level: error command: check arguments: --target ${{ matrix.target }} @@ -166,7 +166,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.70.0 + toolchain: 1.72.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.70.0 + toolchain: 1.72.0 - name: Set up cargo cache uses: Swatinem/rust-cache@v2 diff --git a/Cargo.toml b/Cargo.toml index 14aa7453ee3..4a10a585998 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,8 @@ puffin = "0.17" raw-window-handle = "0.5.0" thiserror = "1.0.37" -wgpu = "0.18.0" +# Make the renderer `Sync` even on wasm32, because it makes the code simpler: +wgpu = { version = "0.18.0", features = ["fragile-send-sync-non-atomic-wasm"] } + # Use this to build wgpu with WebGL support on the Web *instead* of using WebGPU. #wgpu = { version = "0.18.0", features = ["webgl"] } diff --git a/Cranky.toml b/Cranky.toml index 4099a187c4f..4659f6b97b6 100644 --- a/Cranky.toml +++ b/Cranky.toml @@ -55,6 +55,7 @@ warn = [ "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", @@ -90,7 +91,9 @@ warn = [ "clippy::option_option", "clippy::path_buf_push_overwrite", "clippy::ptr_as_ptr", + "clippy::ptr_cast_constness", "clippy::rc_mutex", + "clippy::redundant_type_annotations", "clippy::ref_option_ref", "clippy::rest_pat_in_fully_bound_structs", "clippy::same_functions_in_if_condition", @@ -106,6 +109,7 @@ warn = [ "clippy::todo", "clippy::trailing_empty_array", "clippy::trait_duplication_in_bounds", + "clippy::tuple_array_conversions", "clippy::unchecked_duration_subtraction", "clippy::unimplemented", "clippy::uninlined_format_args", @@ -129,23 +133,24 @@ warn = [ "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", ] allow = [ - "clippy::manual_range_contains", # this one is just worse imho - - "clippy::significant_drop_tightening", # False positives + "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::undocumented_unsafe_blocks", "clippy::unwrap_used", - "clippy::wildcard_imports", + "clippy::wildcard_imports", # we do this a lot "trivial_casts", - "unsafe_op_in_unsafe_fn", # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668 "unused_qualifications", ] diff --git a/clippy.toml b/clippy.toml index 76f804a381c..48a487e4bbc 100644 --- a/clippy.toml +++ b/clippy.toml @@ -3,7 +3,7 @@ # ----------------------------------------------------------------------------- # Section identical to scripts/clippy_wasm/clippy.toml: -msrv = "1.70" +msrv = "1.72" allow-unwrap-in-tests = true diff --git a/crates/ecolor/Cargo.toml b/crates/ecolor/Cargo.toml index 8acafe7bda0..245fbe43363 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.70" +rust-version = "1.72" 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 c4586a8bf53..defcbd17687 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "egui framework - write GUI apps that compiles to web and/or natively" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" 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/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index 21ea63fa19f..f4b0d54752d 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -853,7 +853,7 @@ impl GlutinWindowContext { .with_context_api(glutin::context::ContextApi::Gles(None)) .build(raw_window_handle); - let gl_context_result = { + let gl_context_result = unsafe { crate::profile_scope!("create_context"); gl_config .display() @@ -867,9 +867,11 @@ impl GlutinWindowContext { log::debug!( "Retrying with fallback context attributes: {fallback_context_attributes:?}" ); - gl_config - .display() - .create_context(&gl_config, &fallback_context_attributes)? + unsafe { + gl_config + .display() + .create_context(&gl_config, &fallback_context_attributes)? + } } }; let not_current_gl_context = Some(gl_context); diff --git a/crates/egui-wgpu/Cargo.toml b/crates/egui-wgpu/Cargo.toml index ce6c2aa7c5b..e7fd6f8797a 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.70" +rust-version = "1.72" 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 b4bc91fd715..f6817ee97b9 100644 --- a/crates/egui-wgpu/src/renderer.rs +++ b/crates/egui-wgpu/src/renderer.rs @@ -7,11 +7,7 @@ use epaint::{ahash::HashMap, emath::NumExt, PaintCallbackInfo, Primitive, Vertex use wgpu; use wgpu::util::DeviceExt as _; -// Only implements Send + Sync on wasm32 in order to allow storing wgpu resources on the type map. -#[cfg(not(target_arch = "wasm32"))] pub type CallbackResources = type_map::concurrent::TypeMap; -#[cfg(target_arch = "wasm32")] -pub type CallbackResources = type_map::TypeMap; pub struct Callback(Box); @@ -987,9 +983,6 @@ impl ScissorRect { } } -// Wgpu objects contain references to the JS heap on the web, therefore they are not Send/Sync. -// It follows that egui_wgpu::Renderer can not be Send/Sync either when building with wasm. -#[cfg(not(target_arch = "wasm32"))] #[test] fn renderer_impl_send_sync() { fn assert_send_sync() {} diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index fb341d1341b..396b8ffd38c 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "Bindings for using egui with winit" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" 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 b96c5f8453f..cb87b5b99ab 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "An easy-to-use immediate mode GUI that runs on both web and native" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" homepage = "https://github.com/emilk/egui" license = "MIT OR Apache-2.0" readme = "../../README.md" diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index b6a7d23052c..fb03bcfd805 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -1399,7 +1399,7 @@ impl Style { fn text_styles_ui(ui: &mut Ui, text_styles: &mut BTreeMap) -> Response { ui.vertical(|ui| { crate::Grid::new("text_styles").show(ui, |ui| { - for (text_style, font_id) in text_styles.iter_mut() { + for (text_style, font_id) in &mut *text_styles { ui.label(RichText::new(text_style.to_string()).font(font_id.clone())); crate::introspection::font_id_ui(ui, font_id); ui.end_row(); diff --git a/crates/egui_demo_app/Cargo.toml b/crates/egui_demo_app/Cargo.toml index c416bcd97d9..df0296f2762 100644 --- a/crates/egui_demo_app/Cargo.toml +++ b/crates/egui_demo_app/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" publish = false default-run = "egui_demo_app" diff --git a/crates/egui_demo_lib/Cargo.toml b/crates/egui_demo_lib/Cargo.toml index 1aa59fd88b0..abab970ae61 100644 --- a/crates/egui_demo_lib/Cargo.toml +++ b/crates/egui_demo_lib/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "Example library for egui" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" 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_extras/Cargo.toml b/crates/egui_extras/Cargo.toml index c30d0b18769..3fdf9285765 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.70" +rust-version = "1.72" homepage = "https://github.com/emilk/egui" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui_glow/Cargo.toml b/crates/egui_glow/Cargo.toml index d61eb88b736..cfb04492014 100644 --- a/crates/egui_glow/Cargo.toml +++ b/crates/egui_glow/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "Bindings for using egui natively using the glow library" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glow" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui_glow/src/misc_util.rs b/crates/egui_glow/src/misc_util.rs index ee22f58bd8d..c0c440d78b9 100644 --- a/crates/egui_glow/src/misc_util.rs +++ b/crates/egui_glow/src/misc_util.rs @@ -7,16 +7,18 @@ pub(crate) unsafe fn compile_shader( shader_type: u32, source: &str, ) -> Result { - let shader = gl.create_shader(shader_type)?; + unsafe { + let shader = gl.create_shader(shader_type)?; - gl.shader_source(shader, source); + gl.shader_source(shader, source); - gl.compile_shader(shader); + gl.compile_shader(shader); - if gl.get_shader_compile_status(shader) { - Ok(shader) - } else { - Err(gl.get_shader_info_log(shader)) + if gl.get_shader_compile_status(shader) { + Ok(shader) + } else { + Err(gl.get_shader_info_log(shader)) + } } } @@ -24,17 +26,19 @@ pub(crate) unsafe fn link_program<'a, T: IntoIterator>( gl: &glow::Context, shaders: T, ) -> Result { - let program = gl.create_program()?; + unsafe { + let program = gl.create_program()?; - for shader in shaders { - gl.attach_shader(program, *shader); - } + for shader in shaders { + gl.attach_shader(program, *shader); + } - gl.link_program(program); + gl.link_program(program); - if gl.get_program_link_status(program) { - Ok(program) - } else { - Err(gl.get_program_info_log(program)) + if gl.get_program_link_status(program) { + Ok(program) + } else { + Err(gl.get_program_info_log(program)) + } } } diff --git a/crates/egui_glow/src/painter.rs b/crates/egui_glow/src/painter.rs index 65575b63790..a6d38713bd3 100644 --- a/crates/egui_glow/src/painter.rs +++ b/crates/egui_glow/src/painter.rs @@ -276,51 +276,51 @@ impl Painter { &mut self, [width_in_pixels, height_in_pixels]: [u32; 2], pixels_per_point: f32, - ) -> (u32, u32) { - self.gl.enable(glow::SCISSOR_TEST); - // egui outputs mesh in both winding orders - self.gl.disable(glow::CULL_FACE); - self.gl.disable(glow::DEPTH_TEST); - - self.gl.color_mask(true, true, true, true); - - self.gl.enable(glow::BLEND); - self.gl - .blend_equation_separate(glow::FUNC_ADD, glow::FUNC_ADD); - self.gl.blend_func_separate( - // egui outputs colors with premultiplied alpha: - glow::ONE, - glow::ONE_MINUS_SRC_ALPHA, - // Less important, but this is technically the correct alpha blend function - // when you want to make use of the framebuffer alpha (for screenshots, compositing, etc). - glow::ONE_MINUS_DST_ALPHA, - glow::ONE, - ); + ) { + unsafe { + self.gl.enable(glow::SCISSOR_TEST); + // egui outputs mesh in both winding orders + self.gl.disable(glow::CULL_FACE); + self.gl.disable(glow::DEPTH_TEST); + + self.gl.color_mask(true, true, true, true); + + self.gl.enable(glow::BLEND); + self.gl + .blend_equation_separate(glow::FUNC_ADD, glow::FUNC_ADD); + self.gl.blend_func_separate( + // egui outputs colors with premultiplied alpha: + glow::ONE, + glow::ONE_MINUS_SRC_ALPHA, + // Less important, but this is technically the correct alpha blend function + // when you want to make use of the framebuffer alpha (for screenshots, compositing, etc). + glow::ONE_MINUS_DST_ALPHA, + glow::ONE, + ); - if !cfg!(target_arch = "wasm32") { - self.gl.disable(glow::FRAMEBUFFER_SRGB); - check_for_gl_error!(&self.gl, "FRAMEBUFFER_SRGB"); - } + if !cfg!(target_arch = "wasm32") { + self.gl.disable(glow::FRAMEBUFFER_SRGB); + check_for_gl_error!(&self.gl, "FRAMEBUFFER_SRGB"); + } - let width_in_points = width_in_pixels as f32 / pixels_per_point; - let height_in_points = height_in_pixels as f32 / pixels_per_point; + let width_in_points = width_in_pixels as f32 / pixels_per_point; + let height_in_points = height_in_pixels as f32 / pixels_per_point; - self.gl - .viewport(0, 0, width_in_pixels as i32, height_in_pixels as i32); - self.gl.use_program(Some(self.program)); + self.gl + .viewport(0, 0, width_in_pixels as i32, height_in_pixels as i32); + self.gl.use_program(Some(self.program)); - self.gl - .uniform_2_f32(Some(&self.u_screen_size), width_in_points, height_in_points); - self.gl.uniform_1_i32(Some(&self.u_sampler), 0); - self.gl.active_texture(glow::TEXTURE0); + self.gl + .uniform_2_f32(Some(&self.u_screen_size), width_in_points, height_in_points); + self.gl.uniform_1_i32(Some(&self.u_sampler), 0); + self.gl.active_texture(glow::TEXTURE0); - self.vao.bind(&self.gl); - self.gl - .bind_buffer(glow::ELEMENT_ARRAY_BUFFER, Some(self.element_array_buffer)); + self.vao.bind(&self.gl); + self.gl + .bind_buffer(glow::ELEMENT_ARRAY_BUFFER, Some(self.element_array_buffer)); + } check_for_gl_error!(&self.gl, "prepare_painting"); - - (width_in_pixels, height_in_pixels) } pub fn clear(&self, screen_size_in_pixels: [u32; 2], clear_color: [f32; 4]) { @@ -377,14 +377,14 @@ impl Painter { crate::profile_function!(); self.assert_not_destroyed(); - let size_in_pixels = unsafe { self.prepare_painting(screen_size_px, pixels_per_point) }; + unsafe { self.prepare_painting(screen_size_px, pixels_per_point) }; for egui::ClippedPrimitive { clip_rect, primitive, } in clipped_primitives { - set_clip_rect(&self.gl, size_in_pixels, pixels_per_point, *clip_rect); + set_clip_rect(&self.gl, screen_size_px, pixels_per_point, *clip_rect); match primitive { Primitive::Mesh(mesh) => { @@ -687,14 +687,16 @@ impl Painter { } unsafe fn destroy_gl(&self) { - self.gl.delete_program(self.program); - for tex in self.textures.values() { - self.gl.delete_texture(*tex); - } - self.gl.delete_buffer(self.vbo); - self.gl.delete_buffer(self.element_array_buffer); - for t in &self.textures_to_destroy { - self.gl.delete_texture(*t); + unsafe { + self.gl.delete_program(self.program); + for tex in self.textures.values() { + self.gl.delete_texture(*tex); + } + self.gl.delete_buffer(self.vbo); + self.gl.delete_buffer(self.element_array_buffer); + for t in &self.textures_to_destroy { + self.gl.delete_texture(*t); + } } } @@ -747,7 +749,7 @@ impl Drop for Painter { fn set_clip_rect( gl: &glow::Context, - size_in_pixels: (u32, u32), + [width_px, height_px]: [u32; 2], pixels_per_point: f32, clip_rect: Rect, ) { @@ -764,15 +766,15 @@ fn set_clip_rect( let clip_max_y = clip_max_y.round() as i32; // Clamp: - let clip_min_x = clip_min_x.clamp(0, size_in_pixels.0 as i32); - let clip_min_y = clip_min_y.clamp(0, size_in_pixels.1 as i32); - let clip_max_x = clip_max_x.clamp(clip_min_x, size_in_pixels.0 as i32); - let clip_max_y = clip_max_y.clamp(clip_min_y, size_in_pixels.1 as i32); + let clip_min_x = clip_min_x.clamp(0, width_px as i32); + let clip_min_y = clip_min_y.clamp(0, height_px as i32); + let clip_max_x = clip_max_x.clamp(clip_min_x, width_px as i32); + let clip_max_y = clip_max_y.clamp(clip_min_y, height_px as i32); unsafe { gl.scissor( clip_min_x, - size_in_pixels.1 as i32 - clip_max_y, + height_px as i32 - clip_max_y, clip_max_x - clip_min_x, clip_max_y - clip_min_y, ); diff --git a/crates/egui_glow/src/vao.rs b/crates/egui_glow/src/vao.rs index c94bbbb76a7..6759a829d7a 100644 --- a/crates/egui_glow/src/vao.rs +++ b/crates/egui_glow/src/vao.rs @@ -34,30 +34,32 @@ impl VertexArrayObject { buffer_infos: Vec, ) -> Self { let vao = if supports_vao(gl) { - let vao = gl.create_vertex_array().unwrap(); - check_for_gl_error!(gl, "create_vertex_array"); - - // Store state in the VAO: - gl.bind_vertex_array(Some(vao)); - gl.bind_buffer(glow::ARRAY_BUFFER, Some(vbo)); - - for attribute in &buffer_infos { - gl.vertex_attrib_pointer_f32( - attribute.location, - attribute.vector_size, - attribute.data_type, - attribute.normalized, - attribute.stride, - attribute.offset, - ); - check_for_gl_error!(gl, "vertex_attrib_pointer_f32"); - gl.enable_vertex_attrib_array(attribute.location); - check_for_gl_error!(gl, "enable_vertex_attrib_array"); + unsafe { + let vao = gl.create_vertex_array().unwrap(); + check_for_gl_error!(gl, "create_vertex_array"); + + // Store state in the VAO: + gl.bind_vertex_array(Some(vao)); + gl.bind_buffer(glow::ARRAY_BUFFER, Some(vbo)); + + for attribute in &buffer_infos { + gl.vertex_attrib_pointer_f32( + attribute.location, + attribute.vector_size, + attribute.data_type, + attribute.normalized, + attribute.stride, + attribute.offset, + ); + check_for_gl_error!(gl, "vertex_attrib_pointer_f32"); + gl.enable_vertex_attrib_array(attribute.location); + check_for_gl_error!(gl, "enable_vertex_attrib_array"); + } + + gl.bind_vertex_array(None); + + Some(vao) } - - gl.bind_vertex_array(None); - - Some(vao) } else { log::debug!("VAO not supported"); None @@ -71,36 +73,40 @@ impl VertexArrayObject { } pub(crate) unsafe fn bind(&self, gl: &glow::Context) { - if let Some(vao) = self.vao { - gl.bind_vertex_array(Some(vao)); - check_for_gl_error!(gl, "bind_vertex_array"); - } else { - gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vbo)); - check_for_gl_error!(gl, "bind_buffer"); - - for attribute in &self.buffer_infos { - gl.vertex_attrib_pointer_f32( - attribute.location, - attribute.vector_size, - attribute.data_type, - attribute.normalized, - attribute.stride, - attribute.offset, - ); - check_for_gl_error!(gl, "vertex_attrib_pointer_f32"); - gl.enable_vertex_attrib_array(attribute.location); - check_for_gl_error!(gl, "enable_vertex_attrib_array"); + unsafe { + if let Some(vao) = self.vao { + gl.bind_vertex_array(Some(vao)); + check_for_gl_error!(gl, "bind_vertex_array"); + } else { + gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vbo)); + check_for_gl_error!(gl, "bind_buffer"); + + for attribute in &self.buffer_infos { + gl.vertex_attrib_pointer_f32( + attribute.location, + attribute.vector_size, + attribute.data_type, + attribute.normalized, + attribute.stride, + attribute.offset, + ); + check_for_gl_error!(gl, "vertex_attrib_pointer_f32"); + gl.enable_vertex_attrib_array(attribute.location); + check_for_gl_error!(gl, "enable_vertex_attrib_array"); + } } } } pub(crate) unsafe fn unbind(&self, gl: &glow::Context) { - if self.vao.is_some() { - gl.bind_vertex_array(None); - } else { - gl.bind_buffer(glow::ARRAY_BUFFER, None); - for attribute in &self.buffer_infos { - gl.disable_vertex_attrib_array(attribute.location); + unsafe { + if self.vao.is_some() { + gl.bind_vertex_array(None); + } else { + gl.bind_buffer(glow::ARRAY_BUFFER, None); + for attribute in &self.buffer_infos { + gl.disable_vertex_attrib_array(attribute.location); + } } } } diff --git a/crates/egui_plot/Cargo.toml b/crates/egui_plot/Cargo.toml index d61a2c63d18..40c7e0d0744 100644 --- a/crates/egui_plot/Cargo.toml +++ b/crates/egui_plot/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "Immediate mode plotting for the egui GUI library" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" homepage = "https://github.com/emilk/egui" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/egui_plot/src/items/mod.rs b/crates/egui_plot/src/items/mod.rs index 025cf1921ac..b49f6773cba 100644 --- a/crates/egui_plot/src/items/mod.rs +++ b/crates/egui_plot/src/items/mod.rs @@ -1855,7 +1855,7 @@ where .into_iter() .enumerate() .map(|(index, bar)| { - let bar_rect: Rect = transform.rect_from_values(&bar.bounds_min(), &bar.bounds_max()); + let bar_rect = transform.rect_from_values(&bar.bounds_min(), &bar.bounds_max()); let dist_sq = bar_rect.distance_sq_to_pos(point); ClosestElem { index, dist_sq } diff --git a/crates/egui_plot/src/items/values.rs b/crates/egui_plot/src/items/values.rs index 0527fb26e75..f1563452362 100644 --- a/crates/egui_plot/src/items/values.rs +++ b/crates/egui_plot/src/items/values.rs @@ -245,8 +245,7 @@ impl PlotPoints { (0..points) .map(|i| { let t = start + i as f64 * increment; - let (x, y) = function(t); - [x, y] + function(t).into() }) .collect() } diff --git a/crates/egui_plot/src/lib.rs b/crates/egui_plot/src/lib.rs index f7eef12b0fd..61b902834e4 100644 --- a/crates/egui_plot/src/lib.rs +++ b/crates/egui_plot/src/lib.rs @@ -1845,7 +1845,7 @@ impl PreparedPlot { return Vec::new(); } - let interact_radius_sq: f32 = (16.0f32).powi(2); + let interact_radius_sq = (16.0_f32).powi(2); let candidates = items.iter().filter_map(|item| { let item = &**item; diff --git a/crates/emath/Cargo.toml b/crates/emath/Cargo.toml index 0e40ea274f9..4b45815ab18 100644 --- a/crates/emath/Cargo.toml +++ b/crates/emath/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "Minimal 2D math library for GUI work" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" homepage = "https://github.com/emilk/egui/tree/master/crates/emath" license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/crates/epaint/Cargo.toml b/crates/epaint/Cargo.toml index 16eda3dfa2d..cfbe3290828 100644 --- a/crates/epaint/Cargo.toml +++ b/crates/epaint/Cargo.toml @@ -4,7 +4,7 @@ version = "0.23.0" authors = ["Emil Ernerfeldt "] description = "Minimal 2D graphics library for GUI work" edition = "2021" -rust-version = "1.70" +rust-version = "1.72" 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/tessellator.rs b/crates/epaint/src/tessellator.rs index 9771362ba37..fa50f0df435 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -702,7 +702,7 @@ fn fill_closed_path(feathering: f32, path: &mut [PathPoint], color: Color32, out if cw_signed_area(path) < 0.0 { // Wrong winding order - fix: path.reverse(); - for point in path.iter_mut() { + for point in &mut *path { point.normal = -point.normal; } } @@ -772,7 +772,7 @@ fn fill_closed_path_with_uv( if cw_signed_area(path) < 0.0 { // Wrong winding order - fix: path.reverse(); - for point in path.iter_mut() { + for point in &mut *path { point.normal = -point.normal; } } diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index f33ff1cee1c..045f42aa702 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -273,15 +273,18 @@ impl FontImpl { if glyph_width == 0 || glyph_height == 0 { UvRect::default() } else { - let atlas = &mut self.atlas.lock(); - let (glyph_pos, image) = atlas.allocate((glyph_width, glyph_height)); - glyph.draw(|x, y, v| { - if v > 0.0 { - let px = glyph_pos.0 + x as usize; - let py = glyph_pos.1 + y as usize; - image[(px, py)] = v; - } - }); + let glyph_pos = { + let atlas = &mut self.atlas.lock(); + let (glyph_pos, image) = atlas.allocate((glyph_width, glyph_height)); + glyph.draw(|x, y, v| { + if 0.0 < v { + let px = glyph_pos.0 + x as usize; + let py = glyph_pos.1 + y as usize; + image[(px, py)] = v; + } + }); + glyph_pos + }; let offset_in_pixels = vec2(bb.min.x, bb.min.y); let offset = diff --git a/examples/confirm_exit/Cargo.toml b/examples/confirm_exit/Cargo.toml index 78b4f5bbfcd..1a7504775d3 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.70" +rust-version = "1.72" publish = false diff --git a/examples/custom_3d_glow/Cargo.toml b/examples/custom_3d_glow/Cargo.toml index 7e249fed740..42e1d73d4f1 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.70" +rust-version = "1.72" publish = false diff --git a/examples/custom_font/Cargo.toml b/examples/custom_font/Cargo.toml index b81691e2955..c87ad9dadab 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.70" +rust-version = "1.72" publish = false diff --git a/examples/custom_font_style/Cargo.toml b/examples/custom_font_style/Cargo.toml index ad5efe3f2f8..45ee60c352b 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.70" +rust-version = "1.72" publish = false diff --git a/examples/custom_window_frame/Cargo.toml b/examples/custom_window_frame/Cargo.toml index 3a9a743f47d..d518f615fd2 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.70" +rust-version = "1.72" publish = false diff --git a/examples/file_dialog/Cargo.toml b/examples/file_dialog/Cargo.toml index 7eac874e7a7..3d5cc6d8af9 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.70" +rust-version = "1.72" publish = false diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index a3ae0ea7d7e..9e846a2362e 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.70" +rust-version = "1.72" publish = false diff --git a/examples/hello_world_par/Cargo.toml b/examples/hello_world_par/Cargo.toml index 74d019ee515..65fb00646da 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.70" +rust-version = "1.72" publish = false diff --git a/examples/hello_world_simple/Cargo.toml b/examples/hello_world_simple/Cargo.toml index c4b26699fa6..b08fc3857c6 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.70" +rust-version = "1.72" publish = false diff --git a/examples/images/Cargo.toml b/examples/images/Cargo.toml index 851fa8f79ff..d400e1087a6 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.70" +rust-version = "1.72" publish = false diff --git a/examples/keyboard_events/Cargo.toml b/examples/keyboard_events/Cargo.toml index ae6276ab157..e38260ec38c 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.70" +rust-version = "1.72" publish = false diff --git a/examples/multiple_viewports/Cargo.toml b/examples/multiple_viewports/Cargo.toml index fb0fa3371b9..81e7c7b2d28 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.70" +rust-version = "1.72" publish = false diff --git a/examples/puffin_profiler/Cargo.toml b/examples/puffin_profiler/Cargo.toml index 0df75c539e4..c26b084adbd 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.70" +rust-version = "1.72" publish = false diff --git a/examples/save_plot/Cargo.toml b/examples/save_plot/Cargo.toml index a8161d7ff51..04e337020c7 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.70" +rust-version = "1.72" publish = false [dependencies] diff --git a/examples/screenshot/Cargo.toml b/examples/screenshot/Cargo.toml index fdec95537b2..b2a521cac06 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.70" +rust-version = "1.72" publish = false diff --git a/examples/serial_windows/Cargo.toml b/examples/serial_windows/Cargo.toml index 65e4efb3cd7..f8b0388a666 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.70" +rust-version = "1.72" publish = false diff --git a/examples/test_viewports/Cargo.toml b/examples/test_viewports/Cargo.toml index a7c7606990f..132f98cc7d7 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.70" +rust-version = "1.72" publish = false [features] diff --git a/examples/user_attention/Cargo.toml b/examples/user_attention/Cargo.toml index 31b0afaef1a..01ebe116f43 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.70" +rust-version = "1.72" publish = false [dependencies] diff --git a/rust-toolchain b/rust-toolchain index 024d9db9ec1..694e5af99e5 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.70.0" -components = [ "rustfmt", "clippy" ] -targets = [ "wasm32-unknown-unknown" ] +channel = "1.72.0" +components = ["rustfmt", "clippy"] +targets = ["wasm32-unknown-unknown"] diff --git a/scripts/clippy_wasm/clippy.toml b/scripts/clippy_wasm/clippy.toml index 309e1c424ea..586209a775f 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.70" +msrv = "1.72" allow-unwrap-in-tests = true