Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeicor committed Aug 19, 2024
1 parent 24be343 commit fac77b6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ thread_local! {
/// Sadly we can't just create a [`scene::Context`] in [`MyApp::new`] and pass it
/// to the [`egui::PaintCallback`] because [`scene::Context`] isn't `Send+Sync`, which
/// [`egui::PaintCallback`] is.
pub static SCENE: RefCell<Option<SDFViewerAppScene>> = RefCell::new(None);
pub static SCENE: RefCell<Option<SDFViewerAppScene>> = const { RefCell::new(None) };
}

/// Renders the main 3D scene, containing the SDF object
Expand Down
2 changes: 0 additions & 2 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ pub fn native_main(sync: bool, event_loop_builder: EventLoopBuilderHook) -> Pin<
event_loop_builder,
..eframe::NativeOptions::default()
};
println!("Starting native app");
eframe::run_native("SDF Viewer", native_options, app_creator.unwrap()).unwrap();
println!("Native app exited");
}
};
if sync {
Expand Down
4 changes: 2 additions & 2 deletions src/sdf/wasm/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn handle_sdf_data_response(data: ehttp::Result<ehttp::Response>, watch_url_clos
tracing::error!("Failed to load SDF from URL: {:?}", err);
sender_single_update.try_send(unsafe {
// FIXME: Extremely unsafe code (forcing SDFDemo Send+Sync), but only used for this error path
std::mem::transmute(Box::new(SDFDemo::default()) as Box<dyn SDFSurface>)
std::mem::transmute::<Box<dyn SDFSurface>, Box<dyn SDFSurface + Send + Sync>>(Box::new(SDFDemo::default()) as Box<dyn SDFSurface>)
}).map_err(|_| anyhow!("can't send SDF update"))
}
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -132,7 +132,7 @@ fn handle_sdf_data_response(data: ehttp::Result<ehttp::Response>, watch_url_clos
tracing::error!("Failed to load SDF from URL ({:?}) or file ({:?})", err, err2);
sender_single_update.try_send(unsafe {
// FIXME: Extremely unsafe code (forcing SDFDemo Send+Sync), but only used for this error path
std::mem::transmute(Box::<SDFDemo>::default() as Box<dyn SDFSurface>)
std::mem::transmute::<Box<dyn SDFSurface>, Box<dyn SDFSurface + Send + Sync>>(Box::<SDFDemo>::default() as Box<dyn SDFSurface>)
}).map_err(|_| anyhow!("can't send SDF update"))
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/sdf/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
//! # WebAssembly API specification
//!
//! The WebAssembly module:
//!
//! - MUST NOT use any import from the host (it may have unused imports).
//! - MUST export (at least) the required methods from the [`SDF`](crate::sdf::SDFSurface) trait
//! (check the documentation of the trait).
//! (check the documentation of the trait).
//!
//! As an SDF can provide access to the whole hierarchy it contains, each function must have an extra
//! initial parameter indicating the ID (u32) of the SDF it refers to, with 0 being the root SDF.
Expand Down
2 changes: 1 addition & 1 deletion src/sdf/wasm/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ compile_error!("On wasm32 targets, you need to enable the web feature (and disab

/// Loads the given bytes as a WebAssembly module that is then queried to satisfy the SDF trait.
pub async fn load_sdf_wasm(wasm_bytes: &[u8]) -> anyhow::Result<Box<dyn SDFSurface>> {
unsafe { std::mem::transmute(load_sdf_wasm_send_sync(wasm_bytes).await?) }
unsafe { std::mem::transmute::<anyhow::Result<Box<dyn SDFSurface + Send + Sync>>, anyhow::Result<Box<dyn SDFSurface>>>(load_sdf_wasm_send_sync(wasm_bytes).await) }
}

/// Loads the given bytes as a WebAssembly module that is then queried to satisfy the SDF trait.
Expand Down

0 comments on commit fac77b6

Please sign in to comment.