Skip to content

Commit

Permalink
Update MSRV to Rust 1.72 (#3595)
Browse files Browse the repository at this point in the history
Required to update to puffin 0.18
  • Loading branch information
emilk authored Nov 21, 2023
1 parent 7abf8af commit bfadb90
Show file tree
Hide file tree
Showing 48 changed files with 208 additions and 192 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_web_demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
15 changes: 10 additions & 5 deletions Cranky.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
]
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -----------------------------------------------------------------------------
# Section identical to scripts/clippy_wasm/clippy.toml:

msrv = "1.70"
msrv = "1.72"

allow-unwrap-in-tests = true

Expand Down
2 changes: 1 addition & 1 deletion crates/ecolor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/eframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.23.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
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"
Expand Down
10 changes: 6 additions & 4 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion crates/egui-wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
"Emil Ernerfeldt <[email protected]>",
]
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"
Expand Down
7 changes: 0 additions & 7 deletions crates/egui-wgpu/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn CallbackTrait>);

Expand Down Expand Up @@ -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<T: Send + Sync>() {}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui-winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.23.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.23.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ impl Style {
fn text_styles_ui(ui: &mut Ui, text_styles: &mut BTreeMap<TextStyle, FontId>) -> 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();
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.23.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.70"
rust-version = "1.72"
publish = false
default-run = "egui_demo_app"

Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.23.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_glow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.23.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
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"
Expand Down
36 changes: 20 additions & 16 deletions crates/egui_glow/src/misc_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,38 @@ pub(crate) unsafe fn compile_shader(
shader_type: u32,
source: &str,
) -> Result<glow::Shader, String> {
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))
}
}
}

pub(crate) unsafe fn link_program<'a, T: IntoIterator<Item = &'a glow::Shader>>(
gl: &glow::Context,
shaders: T,
) -> Result<glow::Program, String> {
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))
}
}
}
Loading

0 comments on commit bfadb90

Please sign in to comment.