CI: Run cargo clippy for wasm32-unknown-unknown (#2200)
* CI: Run cargo clippy for wasm32-unknown-unknown * wasm32 clippy fixes * Document when AppRunner::new can fail
This commit is contained in:
parent
53b800502a
commit
2b1341095d
|
@ -74,7 +74,7 @@ jobs:
|
|||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: cranky
|
||||
args: --all-targets --all-features -- -D warnings
|
||||
args: --all-targets --all-features -- -D warnings
|
||||
|
||||
check_wasm:
|
||||
name: Check wasm32 + wasm-bindgen
|
||||
|
@ -87,30 +87,48 @@ jobs:
|
|||
toolchain: 1.61.0
|
||||
target: wasm32-unknown-unknown
|
||||
override: true
|
||||
|
||||
- run: sudo apt-get update && sudo apt-get install libgtk-3-dev
|
||||
|
||||
- name: Set up cargo cache
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Install cargo-cranky
|
||||
uses: baptiste0928/cargo-install@v1
|
||||
with:
|
||||
crate: cargo-cranky
|
||||
|
||||
- name: Check wasm32 egui_demo_app
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: -p egui_demo_app --lib --target wasm32-unknown-unknown
|
||||
|
||||
- name: Check wasm32 egui_demo_app --all-features
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: -p egui_demo_app --lib --target wasm32-unknown-unknown --all-features
|
||||
|
||||
- name: Check wasm32 eframe
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: -p eframe --lib --no-default-features --features glow,persistence --target wasm32-unknown-unknown
|
||||
|
||||
- name: wasm-bindgen
|
||||
uses: jetli/wasm-bindgen-action@v0.1.0
|
||||
with:
|
||||
version: "0.2.83"
|
||||
|
||||
- run: ./sh/wasm_bindgen_check.sh --skip-setup
|
||||
|
||||
- name: Cranky wasm32
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: cranky
|
||||
args: --target wasm32-unknown-unknown --all-features -p egui_demo_app --lib -- -D warnings
|
||||
|
||||
cargo-deny:
|
||||
name: cargo deny
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -75,7 +75,7 @@ pub trait App {
|
|||
///
|
||||
/// You need to implement this if you want to be able to access the application from JS using [`AppRunner::app_mut`].
|
||||
///
|
||||
/// This is needed because downcasting Box<dyn App> -> Box<dyn Any> to get &ConcreteApp is not simple in current rust.
|
||||
/// This is needed because downcasting `Box<dyn App>` -> `Box<dyn Any>` to get &`ConcreteApp` is not simple in current rust.
|
||||
///
|
||||
/// Just copy-paste this as your implementation:
|
||||
/// ```ignore
|
||||
|
|
|
@ -108,6 +108,9 @@ pub use web_sys;
|
|||
/// eframe::start_web(canvas_id, web_options, Box::new(|cc| Box::new(MyEguiApp::new(cc)))).await
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// # Errors
|
||||
/// Failing to initialize WebGL graphics.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub async fn start_web(
|
||||
canvas_id: &str,
|
||||
|
|
|
@ -101,7 +101,7 @@ fn web_location() -> epi::Location {
|
|||
|
||||
let query_map = parse_query_map(&query)
|
||||
.iter()
|
||||
.map(|(k, v)| ((*k).to_string(), (*v).to_string()))
|
||||
.map(|(k, v)| ((*k).to_owned(), (*v).to_owned()))
|
||||
.collect();
|
||||
|
||||
epi::Location {
|
||||
|
@ -181,14 +181,14 @@ impl Drop for AppRunner {
|
|||
}
|
||||
|
||||
impl AppRunner {
|
||||
/// # Errors
|
||||
/// Failure to initialize WebGL renderer.
|
||||
pub async fn new(
|
||||
canvas_id: &str,
|
||||
web_options: crate::WebOptions,
|
||||
app_creator: epi::AppCreator,
|
||||
) -> Result<Self, JsValue> {
|
||||
let painter = ActiveWebPainter::new(canvas_id, &web_options)
|
||||
.await
|
||||
.map_err(JsValue::from)?;
|
||||
) -> Result<Self, String> {
|
||||
let painter = ActiveWebPainter::new(canvas_id, &web_options).await?;
|
||||
|
||||
let system_theme = if web_options.follow_system_theme {
|
||||
super::system_theme()
|
||||
|
@ -469,9 +469,6 @@ pub struct AppRunnerContainer {
|
|||
impl AppRunnerContainer {
|
||||
/// Convenience function to reduce boilerplate and ensure that all event handlers
|
||||
/// are dealt with in the same way
|
||||
///
|
||||
|
||||
#[must_use]
|
||||
pub fn add_event_listener<E: wasm_bindgen::JsCast>(
|
||||
&mut self,
|
||||
target: &EventTarget,
|
||||
|
@ -502,7 +499,7 @@ impl AppRunnerContainer {
|
|||
|
||||
let handle = TargetEvent {
|
||||
target: target.clone(),
|
||||
event_name: event_name.to_string(),
|
||||
event_name: event_name.to_owned(),
|
||||
closure,
|
||||
};
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ pub fn install_canvas_events(runner_container: &mut AppRunnerContainer) -> Resul
|
|||
|
||||
let closure =
|
||||
move |event: web_sys::MouseEvent,
|
||||
mut _runner_lock: egui::mutex::MutexGuard<AppRunner>| {
|
||||
mut _runner_lock: egui::mutex::MutexGuard<'_, AppRunner>| {
|
||||
event.prevent_default();
|
||||
};
|
||||
|
||||
|
@ -213,7 +213,7 @@ pub fn install_canvas_events(runner_container: &mut AppRunnerContainer) -> Resul
|
|||
runner_container.add_event_listener(
|
||||
&canvas,
|
||||
"mousedown",
|
||||
|event: web_sys::MouseEvent, mut runner_lock: egui::mutex::MutexGuard<AppRunner>| {
|
||||
|event: web_sys::MouseEvent, mut runner_lock: egui::mutex::MutexGuard<'_, AppRunner>| {
|
||||
if let Some(button) = button_from_mouse_event(&event) {
|
||||
let pos = pos_from_mouse_event(runner_lock.canvas_id(), &event);
|
||||
let modifiers = runner_lock.input.raw.modifiers;
|
||||
|
|
|
@ -54,8 +54,8 @@ pub fn pos_from_touch_event(
|
|||
|
||||
fn pos_from_touch(canvas_origin: egui::Pos2, touch: &web_sys::Touch) -> egui::Pos2 {
|
||||
egui::Pos2 {
|
||||
x: touch.page_x() as f32 - canvas_origin.x as f32,
|
||||
y: touch.page_y() as f32 - canvas_origin.y as f32,
|
||||
x: touch.page_x() as f32 - canvas_origin.x,
|
||||
y: touch.page_y() as f32 - canvas_origin.y,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ impl WebPainter for WebPainterGlow {
|
|||
}
|
||||
|
||||
fn destroy(&mut self) {
|
||||
self.painter.destroy()
|
||||
self.painter.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ impl WebPainter for WebPainterWgpu {
|
|||
alpha_mode: wgpu::CompositeAlphaMode::Auto,
|
||||
},
|
||||
);
|
||||
self.surface_size = canvas_size.clone();
|
||||
self.surface_size = canvas_size;
|
||||
}
|
||||
|
||||
let frame = self.surface.get_current_texture().map_err(|err| {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//! Demo app for egui
|
||||
#![allow(clippy::missing_errors_doc)]
|
||||
|
||||
mod apps;
|
||||
mod backend_panel;
|
||||
|
@ -34,13 +35,7 @@ impl WebHandle {
|
|||
#[wasm_bindgen]
|
||||
pub fn stop_web(&self) -> Result<(), wasm_bindgen::JsValue> {
|
||||
let mut app = self.handle.lock();
|
||||
let res = app.destroy();
|
||||
|
||||
// let numw = Arc::weak_count(&app);
|
||||
// let nums = Arc::strong_count(&app);
|
||||
// tracing::debug!("runner ref {:?}, {:?}", numw, nums);
|
||||
|
||||
res
|
||||
app.destroy()
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
|
|
|
@ -55,6 +55,8 @@ cargo doc --document-private-items --no-deps --all-features
|
|||
|
||||
./sh/wasm_bindgen_check.sh
|
||||
|
||||
cargo cranky --target wasm32-unknown-unknown --all-features -p egui_demo_app --lib -- -D warnings
|
||||
|
||||
# cargo install cargo-deny
|
||||
cargo deny check
|
||||
|
||||
|
|
Loading…
Reference in New Issue