1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Enable the clippy::std_instead_of_core lint (#8394)

Prefer `core::` over `std::` where either work

* Part of https://github.com/emilk/egui/issues/5735
This commit is contained in:
Emil Ernerfeldt
2026-08-06 04:19:13 -07:00
committed by GitHub
parent 2a5f3d99b5
commit 6aea7eff94
176 changed files with 633 additions and 615 deletions

View File

@@ -2,8 +2,8 @@ use crate::app_kind::AppKind;
#[cfg(feature = "eframe")]
use crate::app_kind::AppKindEframe;
use crate::{Harness, LazyRenderer, TestRenderer};
use core::marker::PhantomData;
use egui::{Pos2, Rect, Vec2};
use std::marker::PhantomData;
/// Builder for [`Harness`].
#[must_use]

View File

@@ -26,7 +26,7 @@ pub use {
kittest,
};
use std::{
use core::{
fmt::{Debug, Display, Formatter},
time::Duration,
};
@@ -47,7 +47,7 @@ pub struct ExceededMaxStepsError {
}
impl Display for ExceededMaxStepsError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(
f,
"Harness::run exceeded max_steps ({}). If your expect your ui to keep repainting \
@@ -90,7 +90,7 @@ pub struct Harness<'a, State = ()> {
}
impl<State> Debug for Harness<'_, State> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
self.kittest.fmt(f)
}
}
@@ -245,7 +245,7 @@ impl<'a, State> Harness<'a, State> {
/// This will call the app closure with each queued event and
/// update the Harness.
pub fn step(&mut self) {
let events = std::mem::take(&mut *self.queued_events.lock());
let events = core::mem::take(&mut *self.queued_events.lock());
if events.is_empty() {
self._step(false);
}
@@ -802,7 +802,7 @@ impl<'a, State> Harness<'a, State> {
// SAFETY: `pthread_main_np` is a thread-safe libc query with no arguments.
let is_main_thread = unsafe {
unsafe extern "C" {
fn pthread_main_np() -> std::ffi::c_int;
fn pthread_main_np() -> core::ffi::c_int;
}
pthread_main_np() != 0
};

View File

@@ -1,8 +1,8 @@
use core::fmt::{Debug, Formatter};
use egui::accesskit::ActionRequest;
use egui::mutex::Mutex;
use egui::{Modifiers, PointerButton, Pos2, accesskit};
use kittest::{AccessKitNode, NodeT, debug_fmt_node};
use std::fmt::{Debug, Formatter};
pub type EventQueue = Mutex<Vec<egui::Event>>;
@@ -14,7 +14,7 @@ pub struct Node<'tree> {
}
impl Debug for Node<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
debug_fmt_node(self, f)
}
}

View File

@@ -1,5 +1,5 @@
use core::mem;
use egui::TexturesDelta;
use std::mem;
pub trait TestRenderer {
/// We use this to pass the glow / wgpu render state to [`eframe::Frame`].

View File

@@ -1,4 +1,4 @@
use std::fmt::Display;
use core::fmt::Display;
use std::io::ErrorKind;
use std::path::PathBuf;
@@ -305,7 +305,7 @@ const HOW_TO_UPDATE_SCREENSHOTS: &str =
"Run `UPDATE_SNAPSHOTS=1 cargo test --all-features` to update the snapshots.";
impl Display for SnapshotError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Diff {
name,
@@ -840,7 +840,7 @@ impl<State> Harness<'_, State> {
/// This removes the snapshot results from the harness. Useful if you e.g. want to merge it
/// with the results from another harness (using [`SnapshotResults::add`]).
pub fn take_snapshot_results(&mut self) -> SnapshotResults {
std::mem::take(&mut self.snapshot_results)
core::mem::take(&mut self.snapshot_results)
}
}
@@ -872,7 +872,7 @@ impl<State> Harness<'_, State> {
pub struct SnapshotResults {
errors: Vec<SnapshotError>,
handled: bool,
location: std::panic::Location<'static>,
location: core::panic::Location<'static>,
}
impl Default for SnapshotResults {
@@ -881,13 +881,13 @@ impl Default for SnapshotResults {
Self {
errors: Vec::new(),
handled: true, // If no snapshots were added, we should consider this handled.
location: *std::panic::Location::caller(),
location: *core::panic::Location::caller(),
}
}
}
impl Display for SnapshotResults {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
if self.errors.is_empty() {
write!(f, "All snapshots passed")
} else {
@@ -939,7 +939,7 @@ impl SnapshotResults {
/// Consume this and return the list of errors.
pub fn into_inner(mut self) -> Vec<SnapshotError> {
self.handled = true;
std::mem::take(&mut self.errors)
core::mem::take(&mut self.errors)
}
/// Panics if there are any errors, displaying each.
@@ -968,7 +968,7 @@ impl Drop for SnapshotResults {
}
thread_local! {
static UNHANDLED_SNAPSHOT_RESULTS_COUNTER: std::cell::RefCell<usize> = const { std::cell::RefCell::new(0) };
static UNHANDLED_SNAPSHOT_RESULTS_COUNTER: core::cell::RefCell<usize> = const { core::cell::RefCell::new(0) };
}
if !self.handled {

View File

@@ -1,8 +1,8 @@
use core::iter;
use core::mem::size_of;
use egui_wgpu::wgpu;
use egui_wgpu::wgpu::{Device, Extent3d, Queue, Texture};
use image::RgbaImage;
use std::iter;
use std::mem::size_of;
use std::sync::mpsc::channel;
use crate::wgpu::WAIT_TIMEOUT;

View File

@@ -1,5 +1,5 @@
use core::{iter::once, time::Duration};
use std::sync::Arc;
use std::{iter::once, time::Duration};
use egui::TexturesDelta;
use egui_wgpu::{RenderState, ScreenDescriptor, WgpuSetup, wgpu};
@@ -230,7 +230,7 @@ impl crate::TestRenderer for WgpuTestRenderer {
self.render_state
.queue
.submit(std::iter::chain(user_buffers, once(encoder.finish())));
.submit(core::iter::chain(user_buffers, once(encoder.finish())));
self.render_state
.device