1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40: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

@@ -1,8 +1,9 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![expect(rustdoc::missing_crate_level_docs, clippy::unwrap_used)] // it's an example
use core::cell::Cell;
use eframe::{UserEvent, egui};
use std::{cell::Cell, rc::Rc};
use std::rc::Rc;
use winit::event_loop::{ControlFlow, EventLoop};
fn main() -> eframe::Result {

View File

@@ -1,6 +1,7 @@
#![expect(clippy::unwrap_used)] // It's an example
use std::{cell::Cell, io, os::fd::AsRawFd as _, rc::Rc, time::Duration};
use core::{cell::Cell, time::Duration};
use std::{io, os::fd::AsRawFd as _, rc::Rc};
use tokio::task::LocalSet;
use winit::event_loop::{ControlFlow, EventLoop};

View File

@@ -83,8 +83,8 @@ impl eframe::App for MyApp {
/// Preview hovering files:
fn preview_files_being_dropped(ctx: &egui::Context) {
use core::fmt::Write as _;
use egui::{Align2, Color32, Id, LayerId, Order, TextStyle};
use std::fmt::Write as _;
if !ctx.input(|i| i.raw.hovered_files.is_empty()) {
let text = ctx.input(|i| {

View File

@@ -106,10 +106,10 @@ impl MyApp {
}
}
impl std::ops::Drop for MyApp {
impl core::ops::Drop for MyApp {
fn drop(&mut self) {
for (handle, show_tx) in self.threads.drain(..) {
std::mem::drop(show_tx);
core::mem::drop(show_tx);
handle.join().unwrap();
}
}

View File

@@ -1,10 +1,8 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![expect(rustdoc::missing_crate_level_docs)] // it's an example
use std::sync::{
Arc,
atomic::{AtomicBool, Ordering},
};
use core::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use eframe::egui;

View File

@@ -1,10 +1,8 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![expect(rustdoc::missing_crate_level_docs)] // it's an example
use std::sync::{
Arc,
atomic::{AtomicBool, Ordering},
};
use core::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use eframe::egui;
@@ -88,7 +86,7 @@ impl eframe::App for MyApp {
.clicked()
{
puffin::profile_scope!("long_sleep");
std::thread::sleep(std::time::Duration::from_millis(50));
std::thread::sleep(core::time::Duration::from_millis(50));
}
ui.checkbox(
@@ -172,7 +170,7 @@ fn start_puffin_server() {
// We can store the server if we want, but in this case we just want
// it to keep running. Dropping it closes the server, so let's not drop it!
#[expect(clippy::mem_forget)]
std::mem::forget(puffin_server);
core::mem::forget(puffin_server);
}
Err(err) => {
log::error!("Failed to start puffin server: {err}");

View File

@@ -19,7 +19,7 @@ fn main() -> eframe::Result {
Box::new(|_cc| Ok(Box::new(MyApp { has_next: true }))),
)?;
std::thread::sleep(std::time::Duration::from_secs(2));
std::thread::sleep(core::time::Duration::from_secs(2));
log::info!("Starting second window…");
eframe::run_native(
@@ -28,7 +28,7 @@ fn main() -> eframe::Result {
Box::new(|_cc| Ok(Box::new(MyApp { has_next: true }))),
)?;
std::thread::sleep(std::time::Duration::from_secs(2));
std::thread::sleep(core::time::Duration::from_secs(2));
log::info!("Starting third window…");
eframe::run_native(

View File

@@ -4,7 +4,8 @@
use eframe::{CreationContext, NativeOptions, egui};
use egui::{Button, CentralPanel, UserAttentionType};
use std::time::{Duration, SystemTime};
use core::time::Duration;
use std::time::SystemTime;
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).