Skip to content

Commit

Permalink
Increase MSRV to 1.67 (emilk#3234)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
emilk authored Aug 11, 2023
1 parent bdeae9e commit 08fb447
Show file tree
Hide file tree
Showing 84 changed files with 166 additions and 193 deletions.
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.65.0
toolchain: 1.67.0

- name: Install packages (Linux)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Cranky.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -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 = [
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.65"
rust-version = "1.67"
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.22.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
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"
Expand Down
2 changes: 1 addition & 1 deletion crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion crates/eframe/src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn canvas_element(canvas_id: &str) -> Option<web_sys::HtmlCanvasElement> {

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 {
Expand Down
7 changes: 3 additions & 4 deletions crates/eframe/src/web/text_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -221,8 +220,8 @@ pub fn move_text_cursor(cursor: Option<egui::Pos2>, 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()?;
Expand Down
2 changes: 1 addition & 1 deletion crates/eframe/src/web/web_painter_glow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions crates/eframe/src/web/web_painter_wgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
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.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"
Expand Down
5 changes: 2 additions & 3 deletions crates/egui-wgpu/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
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.22.0"
authors = ["Emil Ernerfeldt <[email protected]>"]
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"
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.22.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.65"
rust-version = "1.67"
homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0"
readme = "../../README.md"
Expand Down
19 changes: 9 additions & 10 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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}"));
}
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand All @@ -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| {
Expand Down
14 changes: 7 additions & 7 deletions crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}
Expand Down
20 changes: 10 additions & 10 deletions crates/egui/src/data/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:?})"),
}
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -630,7 +630,7 @@ impl WidgetInfo {
} else {
text = "blank".into();
}
description = format!("{}: {}", text, description);
description = format!("{text}: {description}");
}

if let Some(value) = value {
Expand Down
Loading

0 comments on commit 08fb447

Please sign in to comment.