diff --git a/gui/lib/code-builder/src/lib.rs b/gui/lib/code-builder/src/lib.rs index d06abbb1985..270b650aebb 100644 --- a/gui/lib/code-builder/src/lib.rs +++ b/gui/lib/code-builder/src/lib.rs @@ -4,7 +4,9 @@ #![feature(specialization)] #![allow(missing_docs)] - +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] use basegl_prelude::*; use std::fmt::Write; diff --git a/gui/lib/core/embedded-fonts/src/lib.rs b/gui/lib/core/embedded-fonts/src/lib.rs index 147cbf1b8a6..04011aed920 100644 --- a/gui/lib/core/embedded-fonts/src/lib.rs +++ b/gui/lib/core/embedded-fonts/src/lib.rs @@ -1,4 +1,7 @@ #![allow(missing_docs)] +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] use basegl_prelude::*; use basegl_prelude::fmt::{Formatter, Error}; diff --git a/gui/lib/core/msdf-sys/src/emscripten_data.rs b/gui/lib/core/msdf-sys/src/emscripten_data.rs index 99f14c460ea..9012dcacc4f 100644 --- a/gui/lib/core/msdf-sys/src/emscripten_data.rs +++ b/gui/lib/core/msdf-sys/src/emscripten_data.rs @@ -48,6 +48,7 @@ impl EmscriptenRepresentation for f64 { // ======================= /// View of array in `msdfgen` library memory +#[derive(Debug)] pub struct ArrayMemoryView { begin_address : usize, end_address : usize, @@ -58,6 +59,7 @@ pub struct ArrayMemoryView { /// /// It cannot outlives view from which was created, because one might expect, that data may be freed /// by library once view is destroyed +#[derive(Clone,Copy,Debug)] pub struct ArrayMemoryViewIterator<'a, F : EmscriptenRepresentation> { next_read_address : usize, end_address : usize, diff --git a/gui/lib/core/msdf-sys/src/internal.rs b/gui/lib/core/msdf-sys/src/internal.rs index a4ef8f25d06..38df84c7ebf 100644 --- a/gui/lib/core/msdf-sys/src/internal.rs +++ b/gui/lib/core/msdf-sys/src/internal.rs @@ -1,3 +1,5 @@ +#![allow(unsafe_code)] + use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::JsValue; diff --git a/gui/lib/core/msdf-sys/src/lib.rs b/gui/lib/core/msdf-sys/src/lib.rs index 8408f9d9d19..b309f9f49d8 100644 --- a/gui/lib/core/msdf-sys/src/lib.rs +++ b/gui/lib/core/msdf-sys/src/lib.rs @@ -1,4 +1,7 @@ #![allow(missing_docs)] +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] mod internal; pub mod emscripten_data; @@ -87,6 +90,7 @@ impl Drop for Font { /// /// The structure gathering MSDF generation parameters meant to be same for all /// rendered glyphs +#[derive(Clone,Copy,Debug)] pub struct MsdfParameters { pub width : usize, pub height : usize, @@ -97,6 +101,7 @@ pub struct MsdfParameters { pub overlap_support : bool } +#[derive(Debug)] pub struct MultichannelSignedDistanceField { handle : JsValue, pub advance : f64, diff --git a/gui/lib/core/msdf-sys/src/test_utils.rs b/gui/lib/core/msdf-sys/src/test_utils.rs index 4da7e3c4db9..63e05b836e9 100644 --- a/gui/lib/core/msdf-sys/src/test_utils.rs +++ b/gui/lib/core/msdf-sys/src/test_utils.rs @@ -4,6 +4,7 @@ use std::future::Future; use crate::{ is_emscripten_runtime_initialized, run_once_initialized }; /// The future for running test after initialization +#[derive(Debug)] pub struct TestAfterInit { test : F } diff --git a/gui/lib/core/src/animation/animator.rs b/gui/lib/core/src/animation/animator.rs index e22fc729474..dcec3586ed8 100644 --- a/gui/lib/core/src/animation/animator.rs +++ b/gui/lib/core/src/animation/animator.rs @@ -43,6 +43,7 @@ impl AnimatorData { /// This struct which runs a callback once per frame with a time difference from the last frame /// as its input. +#[derive(Debug)] pub struct Animator { _continuous_animator: ContinuousAnimator } diff --git a/gui/lib/core/src/animation/animator/continuous.rs b/gui/lib/core/src/animation/animator/continuous.rs index b7348ae5f8a..20d22eaf253 100644 --- a/gui/lib/core/src/animation/animator/continuous.rs +++ b/gui/lib/core/src/animation/animator/continuous.rs @@ -1,6 +1,8 @@ //! This module implements `ContinuousAnimator`, an object used to run a callback with a continuous //! time in milliseconds as its input. It can be used to implement a playback mechanism. +use crate::prelude::*; + use crate::control::EventLoop; use crate::control::callback::CallbackHandle; use super::AnimationCallback; @@ -13,7 +15,10 @@ use std::cell::RefCell; // === ContinuousTimeAnimatorProperties === // ======================================== +#[derive(Derivative)] +#[derivative(Debug)] struct ContinuousTimeAnimatorProperties { + #[derivative(Debug="ignore")] callback : Box, relative_start_ms : f64, absolute_start_ms : Option, @@ -26,6 +31,7 @@ struct ContinuousTimeAnimatorProperties { // === ContinuousTimeAnimatorData === // ================================== +#[derive(Debug)] struct ContinuousAnimatorData { properties : RefCell } @@ -96,6 +102,7 @@ impl ContinuousAnimatorData { /// `ContinuousAnimator` calls `AnimationCallback` with the playback time in millisecond as its /// input once per frame. +#[derive(Debug)] pub struct ContinuousAnimator { data : Rc, event_loop : EventLoop diff --git a/gui/lib/core/src/animation/animator/easing.rs b/gui/lib/core/src/animation/animator/easing.rs index abc9d635980..c9d977d29e5 100644 --- a/gui/lib/core/src/animation/animator/easing.rs +++ b/gui/lib/core/src/animation/animator/easing.rs @@ -25,10 +25,11 @@ pub trait EasingAnimationCallback = FnMut(T) + 'static; // === EasingAnimatorData === // ========================== +#[derive(Debug)] struct EasingAnimatorData> { initial_value : T, final_value : T, - duration_ms: f64, + duration_ms : f64, continuous_animator : Option } @@ -42,6 +43,7 @@ struct EasingAnimatorData> { pub trait InterpolableArgument = Interpolable + 'static; /// This struct animates from `origin_position` to `target_position` using easing functions. +#[derive(Debug)] pub struct EasingAnimator> { data : Rc>> } diff --git a/gui/lib/core/src/animation/animator/fixed_step.rs b/gui/lib/core/src/animation/animator/fixed_step.rs index 96778a73d36..94923989995 100644 --- a/gui/lib/core/src/animation/animator/fixed_step.rs +++ b/gui/lib/core/src/animation/animator/fixed_step.rs @@ -14,7 +14,7 @@ use nalgebra::zero; // ======================= /// This struct counts the intervals in a time period. -#[derive(Debug)] +#[derive(Clone,Copy,Debug)] pub struct IntervalCounter { /// Interval duration. pub interval_duration : f64, @@ -72,6 +72,7 @@ impl FixedStepAnimatorData { /// (AnimationCallback(delta_ms)) will be 1000ms. But keep in mind that if the actual frame /// takes longer, say 2000ms, AnimationCallback will be called twice in the same moment, but /// its delta_ms parameter will always be fixed to 1 second. +#[derive(Debug)] pub struct FixedStepAnimator { _animator: Animator } diff --git a/gui/lib/core/src/animation/physics/inertia.rs b/gui/lib/core/src/animation/physics/inertia.rs index 6fbd61a5cd0..74c416f7324 100644 --- a/gui/lib/core/src/animation/physics/inertia.rs +++ b/gui/lib/core/src/animation/physics/inertia.rs @@ -30,7 +30,7 @@ pub trait PhysicsForce { // ====================== /// This structure contains air dragging properties. -#[derive(Default, Clone, Copy)] +#[derive(Default,Clone,Copy,Debug)] pub struct DragProperties { /// Drag`s coefficient. pub coefficient: f32 @@ -175,6 +175,7 @@ impl KinematicsProperties { // === PhysicsPropertiesData === // ============================= +#[derive(Debug)] struct PhysicsPropertiesData { kinematics : KinematicsProperties, spring : SpringProperties, @@ -195,7 +196,7 @@ impl PhysicsPropertiesData { // ========================= /// A structure including kinematics, drag and spring properties. -#[derive(Clone)] +#[derive(Clone,Debug)] pub struct PhysicsProperties { data : Rc> } @@ -272,6 +273,7 @@ impl PhysicsProperties { pub trait PhysicsCallback = FnMut(Vector3) + 'static; /// A fixed step physics simulator used to simulate `PhysicsProperties`. +#[derive(Debug)] pub struct PhysicsSimulator { _animator : Animator } diff --git a/gui/lib/core/src/control/callback.rs b/gui/lib/core/src/control/callback.rs index 27c7a789418..dd670c8b93f 100644 --- a/gui/lib/core/src/control/callback.rs +++ b/gui/lib/core/src/control/callback.rs @@ -48,8 +48,7 @@ pub type XCallbackMut1 = Box>; // ====================== /// Handle to a callback. When the handle is dropped, the callback is removed. -#[derive(Derivative)] -#[derivative(Debug, Default)] +#[derive(Debug,Default)] pub struct CallbackHandle { rc: Rc<()> } @@ -75,6 +74,7 @@ impl CallbackHandle { } /// CallbackHandle's guard. Used to check if the handle is still valid. +#[derive(Debug)] pub struct Guard { weak: Weak<()> } diff --git a/gui/lib/core/src/control/event_loop.rs b/gui/lib/core/src/control/event_loop.rs index e6067cf1632..ec9e6a28ff1 100644 --- a/gui/lib/core/src/control/event_loop.rs +++ b/gui/lib/core/src/control/event_loop.rs @@ -34,8 +34,7 @@ pub trait EventLoopCallback = FnMut(f64) + 'static; /// removed as soon as the handle is dropped. You can also use the `forget` /// method on the handle to make the callback registered forever, but beware /// that it can easily lead to memory leaks. -#[derive(Derivative)] -#[derivative(Debug, Default, Clone)] +#[derive(Debug,Default,Clone)] pub struct EventLoop { rc: Rc>, } diff --git a/gui/lib/core/src/control/io/mouse.rs b/gui/lib/core/src/control/io/mouse.rs index 216984e2816..fec6a7290eb 100644 --- a/gui/lib/core/src/control/io/mouse.rs +++ b/gui/lib/core/src/control/io/mouse.rs @@ -1,6 +1,8 @@ //! This module contains the `MouseManager` implementation, its associated structs such as //! `MousePositionEvent`, `MouseClickEvent` and `MouseWheelEvent`. +use crate::prelude::*; + pub mod event; pub mod button; @@ -28,6 +30,7 @@ use std::cell::RefCell; // ===================== /// This struct keeps the register of the event listener and unregisters it when it's dropped. +#[derive(Debug)] pub struct EventListener { target : EventTarget, name : String, @@ -69,19 +72,9 @@ pub type WheelEventListener = EventListener; // FIXME: this does not handle all buttons (js defines 5 buttons) and assumes mouses for // FIXME: right hand people. /// An enumeration representing the mouse buttons. -pub enum MouseButton { - /// Left mouse button. - LEFT, - - /// Middle mouse button. - MIDDLE, - - /// Right mouse button. - RIGHT, - - /// For unknown mouse buttons IDs. - UNKNOWN -} +#[derive(Clone,Copy,Debug)] +#[allow(missing_docs)] +pub enum MouseButton {LEFT,MIDDLE,RIGHT,UNKNOWN} @@ -94,6 +87,7 @@ pub trait MouseClickCallback = FnMut(MouseClickEvent) + 'static; // FIXME: "click" means mouse down and then up. This is misleading. /// A struct storing information about mouse down and mouse up events. +#[derive(Clone,Copy,Debug)] pub struct MouseClickEvent { /// The position where the MouseClickEvent occurred. pub position : Vector2, @@ -131,6 +125,7 @@ impl MouseClickEvent { pub trait MousePositionCallback = FnMut(MousePositionEvent) + 'static; /// A struct storing information about mouse move, mouse enter and mouse leave events. +#[derive(Clone,Copy,Debug)] pub struct MousePositionEvent { /// The previous position where the mouse was. pub previous_position : Vector2, @@ -163,6 +158,7 @@ impl MousePositionEvent { pub trait MouseWheelCallback = FnMut(MouseWheelEvent) + 'static; /// A struct storing information about mouse wheel events. +#[derive(Clone,Copy,Debug)] pub struct MouseWheelEvent { /// A boolean indicating if the keyboard ctrl button is pressed. pub is_ctrl_pressed : bool, @@ -193,10 +189,13 @@ impl MouseWheelEvent { // === MouseManagerProperties === // ============================== +#[derive(Derivative)] +#[derivative(Debug)] struct MouseManagerProperties { dom : DomContainer, mouse_position : Option>, target : EventTarget, + #[derivative(Debug="ignore")] stop_tracking_listener : Option } @@ -207,8 +206,8 @@ struct MouseManagerProperties { // ======================== /// A struct used for storing shared MouseManager's mutable data. +#[derive(Debug)] struct MouseManagerData { - // FIXME: naked refcell properties : RefCell } @@ -299,6 +298,7 @@ macro_rules! add_callback { // ==================== /// This structs manages mouse events in a specified DOM object. +#[derive(Debug)] pub struct MouseManager { data : Rc } diff --git a/gui/lib/core/src/data/container.rs b/gui/lib/core/src/data/container.rs index 4e21aebed2e..2bd385bbafd 100644 --- a/gui/lib/core/src/data/container.rs +++ b/gui/lib/core/src/data/container.rs @@ -25,6 +25,7 @@ pub trait AddMut { /// The item type is `(Option, T)` where the second tuple element is /// a current value and first element is a previous one `None` on the first /// iteration. +#[derive(Debug)] pub struct CachingIterator> { last : Option, iter : It diff --git a/gui/lib/core/src/data/dirty.rs b/gui/lib/core/src/data/dirty.rs index 4a6026ee290..fcd91ff0bc7 100644 --- a/gui/lib/core/src/data/dirty.rs +++ b/gui/lib/core/src/data/dirty.rs @@ -311,7 +311,7 @@ pub type Bool = DirtyFlag ; pub type SharedBool = SharedDirtyFlag ; pub trait BoolCtx = where OnMut:Function0; -#[derive(Debug,Display,Default)] +#[derive(Clone,Copy,Debug,Display,Default)] pub struct BoolData { is_dirty: bool } impl HasCheckAll for BoolData { fn check_all (&self) -> bool { self.is_dirty } } impl HasUnsetAll for BoolData { fn unset_all (&mut self) { self.is_dirty = false } } diff --git a/gui/lib/core/src/debug/monitor.rs b/gui/lib/core/src/debug/monitor.rs index f3f7fe8a62c..aad1b9c7ef6 100644 --- a/gui/lib/core/src/debug/monitor.rs +++ b/gui/lib/core/src/debug/monitor.rs @@ -43,7 +43,7 @@ fn performance() -> Performance { // ============== /// Look and feel configuration for the performance monitor. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] #[allow(missing_docs)] pub struct ConfigTemplate { pub background_color : Str, @@ -585,7 +585,7 @@ impl PanelData { // ================= /// Sampler measuring the time for a given operation. -#[derive(Debug,Default)] +#[derive(Clone,Copy,Debug,Default)] pub struct FrameTime { begin_time : f64, value : f64, @@ -620,7 +620,7 @@ impl Sampler for FrameTime { // =========== /// Sampler measuring the frames per second count for a given operation. -#[derive(Debug,Default)] +#[derive(Clone,Copy,Debug,Default)] pub struct Fps { begin_time : f64, value : f64, @@ -657,7 +657,7 @@ impl Sampler for Fps { // ================== /// Sampler measuring the memory usage of the WebAssembly part of the program. -#[derive(Debug,Default)] +#[derive(Clone,Copy,Debug,Default)] pub struct WasmMemory { value : f64, value_check : ValueCheck, diff --git a/gui/lib/core/src/display/camera/camera2d.rs b/gui/lib/core/src/display/camera/camera2d.rs index 1b05a7defbb..52cb28fba1d 100644 --- a/gui/lib/core/src/display/camera/camera2d.rs +++ b/gui/lib/core/src/display/camera/camera2d.rs @@ -14,7 +14,7 @@ use crate::data::dirty::traits::*; // ================= /// Camera alignment. It describes where the origin of the camera should be aligned to. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub struct Alignment { /// Horizontal alignment. pub horizontal : HorizontalAlignment, @@ -24,12 +24,12 @@ pub struct Alignment { } /// Horizontal alignments. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] #[allow(missing_docs)] pub enum HorizontalAlignment {Left,Center,Right} /// Vertical alignments. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] #[allow(missing_docs)] pub enum VerticalAlignment {Top,Center,Bottom} @@ -50,7 +50,7 @@ impl Default for Alignment { // ============== /// Camera's frustum screen dimensions. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub struct Screen { /// Screen's width. pub width : f32, @@ -66,7 +66,7 @@ impl Screen { } /// Gets Screen's aspect ratio. - pub fn aspect(&self) -> f32 { + pub fn aspect(self) -> f32 { self.width / self.height } } @@ -78,7 +78,7 @@ impl Screen { // ================== /// Camera's projection type. -#[derive(Clone,Debug,Copy)] +#[derive(Clone,Copy,Debug)] pub enum Projection { /// Perspective projection. Perspective { @@ -103,7 +103,7 @@ impl Default for Projection { // ================ /// Camera's frustum clipping range. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub struct Clipping { /// Near clipping limit. pub near : f32, @@ -373,12 +373,12 @@ impl Camera2d { impl Camera2d { /// Gets `Clipping`. pub fn clipping(&self) -> Clipping { - self.rc.borrow().clipping.clone() + self.rc.borrow().clipping } /// Gets `Screen`. pub fn screen(&self) -> Screen { - self.rc.borrow().screen.clone() + self.rc.borrow().screen } /// Gets zoom. diff --git a/gui/lib/core/src/display/navigation/navigator.rs b/gui/lib/core/src/display/navigation/navigator.rs index c08070dbf9a..ff80f8254ff 100644 --- a/gui/lib/core/src/display/navigation/navigator.rs +++ b/gui/lib/core/src/display/navigation/navigator.rs @@ -24,6 +24,7 @@ use nalgebra::clamp; // ================= /// Navigator enables camera navigation with mouse interactions. +#[derive(Debug)] pub struct Navigator { _events : NavigatorEvents, _simulator : PhysicsSimulator, diff --git a/gui/lib/core/src/display/navigation/navigator/events.rs b/gui/lib/core/src/display/navigation/navigator/events.rs index 8241b44ceca..7fb0897bc63 100644 --- a/gui/lib/core/src/display/navigation/navigator/events.rs +++ b/gui/lib/core/src/display/navigation/navigator/events.rs @@ -1,3 +1,5 @@ +use crate::prelude::*; + use crate::control::io::mouse::MouseManager; use crate::control::io::mouse::MouseClickEvent; use crate::control::io::mouse::MouseWheelEvent; @@ -78,7 +80,7 @@ impl PanEvent { // === MovementType === // ==================== -#[derive(PartialEq, Clone, Copy)] +#[derive(PartialEq,Clone,Copy,Debug)] enum MovementType { Pan, Zoom { focus : Vector2 } @@ -90,10 +92,14 @@ enum MovementType { // === NavigatorEventsProperties === // ================================= +#[derive(Derivative)] +#[derivative(Debug)] struct NavigatorEventsProperties { movement_type : Option, mouse_position : Vector2, + #[derivative(Debug="ignore")] pan_callback : Box, + #[derivative(Debug="ignore")] zoom_callback : Box, zoom_speed : f32 } @@ -104,6 +110,7 @@ struct NavigatorEventsProperties { // === NavigatorEventsData === // =========================== +#[derive(Debug)] struct NavigatorEventsData { properties : RefCell } @@ -171,14 +178,22 @@ impl NavigatorEventsData { // ======================= /// Struct used to handle pan and zoom events from mouse interactions. +#[derive(Derivative)] +#[derivative(Debug)] pub struct NavigatorEvents { data : Rc, mouse_manager : MouseManager, + #[derivative(Debug="ignore")] mouse_down : Option, + #[derivative(Debug="ignore")] mouse_move : Option, + #[derivative(Debug="ignore")] mouse_up : Option, + #[derivative(Debug="ignore")] mouse_leave : Option, + #[derivative(Debug="ignore")] disable_context_menu : Option, + #[derivative(Debug="ignore")] wheel_zoom : Option } diff --git a/gui/lib/core/src/display/object/transform.rs b/gui/lib/core/src/display/object/transform.rs index be7dd443b72..30b6d2a5499 100644 --- a/gui/lib/core/src/display/object/transform.rs +++ b/gui/lib/core/src/display/object/transform.rs @@ -19,7 +19,7 @@ use crate::data::dirty::traits::*; /// Defines the order in which particular axis coordinates are processed. Used for example to define /// the rotation order in `DisplayObject`. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub enum AxisOrder {XYZ,XZY,YXZ,YZX,ZXY,ZYX} impl Default for AxisOrder { @@ -34,7 +34,7 @@ impl Default for AxisOrder { /// Defines the order in which transformations (scale, rotate, translate) are applied to a /// particular object. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub enum TransformOrder { ScaleRotateTranslate, ScaleTranslateRotate, @@ -58,7 +58,7 @@ impl Default for TransformOrder { /// You can use methods like `matrix` to get a combined transformation matrix. Bear in mind that /// the matrix will always be recomputed from scratch. This structure does not contain any caching /// mechanisms. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub struct Transform { pub position : Vector3, pub scale : Vector3, diff --git a/gui/lib/core/src/display/render/pipeline.rs b/gui/lib/core/src/display/render/pipeline.rs index 7289d4619b9..6d2bdc0f42b 100644 --- a/gui/lib/core/src/display/render/pipeline.rs +++ b/gui/lib/core/src/display/render/pipeline.rs @@ -48,6 +48,7 @@ impl Add for RenderPipeline { /// An output definition of a render pass. The output describes a format of framebuffer attachment, /// which will be the result of running the current pass. +#[derive(Debug)] pub struct RenderPassOutput { /// Name of the pass. pub name : String, diff --git a/gui/lib/core/src/display/scene.rs b/gui/lib/core/src/display/scene.rs index 160fffa7edc..6a222c82824 100644 --- a/gui/lib/core/src/display/scene.rs +++ b/gui/lib/core/src/display/scene.rs @@ -73,7 +73,7 @@ impl Shape { pub fn screen_shape(&self) -> ShapeData { - self.rc.borrow().clone() + *self.rc.borrow() } pub fn canvas_shape(&self) -> ShapeData { @@ -97,7 +97,7 @@ impl CloneRef for Shape {} // === ShapeData === -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub struct ShapeData { pub width : f32, pub height : f32, diff --git a/gui/lib/core/src/display/shape/primitive/def/transform.rs b/gui/lib/core/src/display/shape/primitive/def/transform.rs index 4426b627250..ebe9b7d810c 100644 --- a/gui/lib/core/src/display/shape/primitive/def/transform.rs +++ b/gui/lib/core/src/display/shape/primitive/def/transform.rs @@ -79,6 +79,7 @@ macro_rules! _define_compound_shape_data { /// Shape type definition. #[allow(missing_docs)] + #[derive(Debug)] pub struct $name<$($shape_field),*> { $(pub $shape_field : $shape_field),*, $(pub $field : Glsl),* diff --git a/gui/lib/core/src/display/shape/primitive/shader/builder.rs b/gui/lib/core/src/display/shape/primitive/shader/builder.rs index dd446536a3e..6b95660822d 100644 --- a/gui/lib/core/src/display/shape/primitive/shader/builder.rs +++ b/gui/lib/core/src/display/shape/primitive/shader/builder.rs @@ -27,6 +27,7 @@ const FRAGMENT_RUNNER :&str = include_str!("../glsl/fragment_runner.glsl"); // TODO: Consider removing this struct and moving the utils to functions. /// GLSL code builder. +#[derive(Clone,Copy,Debug)] pub struct Builder {} impl Builder { diff --git a/gui/lib/core/src/display/shape/primitive/shader/overload.rs b/gui/lib/core/src/display/shape/primitive/shader/overload.rs index a0a00c38903..c59787c30c8 100644 --- a/gui/lib/core/src/display/shape/primitive/shader/overload.rs +++ b/gui/lib/core/src/display/shape/primitive/shader/overload.rs @@ -8,8 +8,10 @@ use wasm_bindgen::prelude::*; extern "C" { /// Returns GLSL code which redirects mangled function names to their original primitive /// definitions. + #[allow(unsafe_code)] pub fn builtin_redirections() -> String; /// Mangles the provided GLSL code to allow primitive definitions overloading. + #[allow(unsafe_code)] pub fn allow_overloading(s:&str) -> String; } diff --git a/gui/lib/core/src/display/shape/text.rs b/gui/lib/core/src/display/shape/text.rs index 9aa6c7dd584..7cdf2cb9aef 100644 --- a/gui/lib/core/src/display/shape/text.rs +++ b/gui/lib/core/src/display/shape/text.rs @@ -139,7 +139,7 @@ impl TextComponent { pub fn navigate_cursors(&mut self, step:Step, selecting:bool, fonts:&mut Fonts) { let content = &mut self.content; let mut navigation = CursorNavigation {content,fonts,selecting}; - self.cursors.navigate_all_cursors(&mut navigation,&step); + self.cursors.navigate_all_cursors(&mut navigation,step); } fn refresh_content_buffers(&mut self, fonts:&mut Fonts) { @@ -248,6 +248,7 @@ impl TextComponent { // ============================ /// Text component builder +#[derive(Debug)] pub struct TextComponentBuilder<'a, 'b, Str:AsRef> { pub scene : &'a Scene, pub fonts : &'b mut Fonts, diff --git a/gui/lib/core/src/display/shape/text/buffer/fragment.rs b/gui/lib/core/src/display/shape/text/buffer/fragment.rs index 336ed864684..9d91df8272d 100644 --- a/gui/lib/core/src/display/shape/text/buffer/fragment.rs +++ b/gui/lib/core/src/display/shape/text/buffer/fragment.rs @@ -92,6 +92,7 @@ impl RenderedFragment { /// Builder of buffer data of some consecutive buffer fragments /// /// The result is stored in `vertex_position_data` and `texture_coords_data` fields. +#[derive(Debug)] pub struct FragmentsDataBuilder<'a> { pub vertex_position_data : Vec, pub texture_coords_data : Vec, @@ -176,7 +177,7 @@ impl<'a> FragmentsDataBuilder<'a> { /// During x scrolling we don't immediately refresh all the lines, but pick only one which is /// "centered" on current scroll - the rest of lines should still have data in buffers for /// shown glyphs. -#[derive(Debug)] +#[derive(Clone,Copy,Debug)] pub struct NextFragmentToRefreshAfterXScrolling { pub fragments_count : usize, pub next_fragment : usize diff --git a/gui/lib/core/src/display/shape/text/buffer/glyph_square.rs b/gui/lib/core/src/display/shape/text/buffer/glyph_square.rs index bc8ec20b6f8..05619e7da6e 100644 --- a/gui/lib/core/src/display/shape/text/buffer/glyph_square.rs +++ b/gui/lib/core/src/display/shape/text/buffer/glyph_square.rs @@ -43,8 +43,7 @@ pub fn point_to_iterable(p:Point2) -> SmallVec<[T;2]> { /// The pen is a font-specific term (see /// [freetype documentation](https://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html#section-1) /// for details). The structure keeps pen position _before_ rendering the `current_char`. -#[derive(Clone)] -#[derive(Debug)] +#[derive(Clone,Copy,Debug)] pub struct Pen { pub position : Point2, pub current_char : Option, @@ -126,6 +125,7 @@ pub trait GlyphAttributeBuilder { /// Builder for glyph square vertex positions /// /// `pen` field points to the position of last built glyph. +#[derive(Debug)] pub struct GlyphVertexPositionBuilder<'a,'b> { pub font : &'a mut FontRenderInfo, pub pen : &'b mut Pen, @@ -173,6 +173,7 @@ impl<'a,'b> GlyphAttributeBuilder for GlyphVertexPositionBuilder<'a,'b> { // ====================================== /// Builder for glyph MSDF texture coordinates +#[derive(Debug)] pub struct GlyphTextureCoordsBuilder<'a> { pub font : &'a mut FontRenderInfo } diff --git a/gui/lib/core/src/display/shape/text/buffer/line.rs b/gui/lib/core/src/display/shape/text/buffer/line.rs index 431f9f36ff7..a826537c6d8 100644 --- a/gui/lib/core/src/display/shape/text/buffer/line.rs +++ b/gui/lib/core/src/display/shape/text/buffer/line.rs @@ -17,6 +17,7 @@ use crate::display::shape::text::buffer::glyph_square::GlyphTextureCoordsBuilder /// texture coordinates) for one line. If line is longer than `max_line_size`, it is /// cut. When line is shorter, the buffer is padded with empty values (obtained from /// `GlyphAttributeBuilder::empty()`). +#[derive(Debug)] pub struct LineAttributeBuilder<'a,GlyphBuilder:GlyphAttributeBuilder> { max_line_size : usize, squares_produced : usize, diff --git a/gui/lib/core/src/display/shape/text/content.rs b/gui/lib/core/src/display/shape/text/content.rs index 1b2e39dc3d0..a87cd755a43 100644 --- a/gui/lib/core/src/display/shape/text/content.rs +++ b/gui/lib/core/src/display/shape/text/content.rs @@ -76,11 +76,13 @@ impl DirtyLines { /// /// A change is simple if it's replace a fragment of one line with text without new lines. Otherwise /// its a multiline change. +#[derive(Clone,Copy,Debug)] pub enum ChangeType { Simple, Multiline } /// A structure describing a text operation in one place. +#[derive(Debug)] pub struct TextChange { replaced : Range, lines : Vec>, @@ -175,6 +177,7 @@ pub struct TextComponentContent { } /// References to all needed stuff for generating buffer's data. +#[derive(Debug)] pub struct RefreshInfo<'a, 'b> { pub lines : &'a mut [Line], pub dirty_lines : DirtyLines, diff --git a/gui/lib/core/src/display/shape/text/content/line.rs b/gui/lib/core/src/display/shape/text/content/line.rs index 19ec0501c18..5ec6a768e9f 100644 --- a/gui/lib/core/src/display/shape/text/content/line.rs +++ b/gui/lib/core/src/display/shape/text/content/line.rs @@ -14,8 +14,7 @@ use std::ops::Range; /// position of the char in a _text space_ (where value of 1.0 is equal to lines height). The cache /// is initially empty and is load on demand - so the `char_x_position` vector will be often shorter /// than number of characters in line. -#[derive(Debug)] -#[derive(Clone)] +#[derive(Clone,Debug)] pub struct Line { chars : Vec, char_x_positions : Vec, @@ -143,7 +142,7 @@ impl Line { } /// A line reference with it's index. -#[derive(Shrinkwrap)] +#[derive(Shrinkwrap,Debug)] #[shrinkwrap(mutable)] pub struct LineRef<'a> { #[shrinkwrap(main_field)] diff --git a/gui/lib/core/src/display/shape/text/cursor.rs b/gui/lib/core/src/display/shape/text/cursor.rs index 1d60a3ae25f..907f36789f0 100644 --- a/gui/lib/core/src/display/shape/text/cursor.rs +++ b/gui/lib/core/src/display/shape/text/cursor.rs @@ -23,7 +23,7 @@ use web_sys::WebGlBuffer; // ============== /// Cursor in TextComponent with its selection -#[derive(Clone,Debug,Eq,PartialEq)] +#[derive(Clone,Copy,Debug,Eq,PartialEq)] pub struct Cursor { pub position : TextLocation, pub selected_to : TextLocation, @@ -102,10 +102,11 @@ impl Cursor { /// An enum representing cursor moving step. The steps are based of possible keystrokes (arrows, /// Home, End, Ctrl+Home, etc.) -#[derive(Debug,Eq,Hash,PartialEq)] +#[derive(Clone,Copy,Debug,Eq,Hash,PartialEq)] pub enum Step {Left,Right,Up,Down,LineBegin,LineEnd,DocBegin,DocEnd} /// A struct for cursor navigation process +#[derive(Debug)] pub struct CursorNavigation<'a,'b> { pub content : &'a mut TextComponentContent, pub fonts : &'b mut Fonts, @@ -122,8 +123,8 @@ impl<'a,'b> CursorNavigation<'a,'b> { } /// Move cursor by given step. - pub fn move_cursor(&mut self, cursor:&mut Cursor, step:&Step) { - let new_position = self.new_position(cursor.position,&step); + pub fn move_cursor(&mut self, cursor:&mut Cursor, step:Step) { + let new_position = self.new_position(cursor.position,step); self.move_cursor_to_position(cursor,new_position); } @@ -183,7 +184,7 @@ impl<'a,'b> CursorNavigation<'a,'b> { } /// New position of cursor at `position` after applying `step`. - fn new_position(&mut self, position: TextLocation, step:&Step) -> TextLocation { + fn new_position(&mut self, position: TextLocation, step:Step) -> TextLocation { match step { Step::Left => self.prev_char_position(&position).unwrap_or(position), Step::Right => self.next_char_position(&position).unwrap_or(position), @@ -291,8 +292,8 @@ impl Cursors { /// /// If after this operation some of the cursors occupies the same position, or their selected /// area overlap, they are irreversibly merged. - pub fn navigate_all_cursors(&mut self, navigaton:&mut CursorNavigation, step:&Step) { - self.cursors.iter_mut().for_each(|cursor| navigaton.move_cursor(cursor,&step)); + pub fn navigate_all_cursors(&mut self, navigaton:&mut CursorNavigation, step:Step) { + self.cursors.iter_mut().for_each(|cursor| navigaton.move_cursor(cursor,step)); self.merge_overlapping_cursors(); self.dirty = true; } @@ -411,7 +412,7 @@ mod test { for step in &[Left,Right,Up,Down,LineBegin,LineEnd,DocBegin,DocEnd] { let mut cursors = Cursors::mock(initial_cursors.clone()); - cursors.navigate_all_cursors(&mut navigation,step); + cursors.navigate_all_cursors(&mut navigation,*step); let expected = expected_positions.get(step).unwrap(); let current = cursors.cursors.iter().map(|c| (c.position.line, c.position.column)); assert_eq!(expected,¤t.collect_vec(), "Error for step {:?}", step); @@ -439,7 +440,7 @@ mod test { selecting: false }; let mut cursors = Cursors::mock(initial_cursors.clone()); - cursors.navigate_all_cursors(&mut navigation,&LineEnd); + cursors.navigate_all_cursors(&mut navigation,LineEnd); assert_eq!(new_position, cursors.cursors.first().unwrap().position); assert_eq!(new_position, cursors.cursors.first().unwrap().selected_to); }) @@ -462,7 +463,7 @@ mod test { selecting: true }; let mut cursors = Cursors::mock(initial_cursors.clone()); - cursors.navigate_all_cursors(&mut navigation,&LineEnd); + cursors.navigate_all_cursors(&mut navigation,LineEnd); assert_eq!(new_loc , cursors.cursors.first().unwrap().position); assert_eq!(initial_loc, cursors.cursors.first().unwrap().selected_to); }) diff --git a/gui/lib/core/src/display/symbol/shader/builder.rs b/gui/lib/core/src/display/symbol/shader/builder.rs index fe168df79b6..90633d346d8 100644 --- a/gui/lib/core/src/display/symbol/shader/builder.rs +++ b/gui/lib/core/src/display/symbol/shader/builder.rs @@ -108,11 +108,11 @@ pub struct AttributeQualifier { impl AttributeQualifier { pub fn to_input_var> (&self, name:Name) -> glsl::GlobalVar { - let storage = self.storage.clone(); + let storage = self.storage; glsl::GlobalVar { layout : None, storage : Some(glsl::GlobalVarStorage::InStorage(storage)), - prec : self.prec.clone(), + prec : self.prec, typ : self.typ.clone(), ident : name.into() } @@ -120,11 +120,11 @@ impl AttributeQualifier { pub fn to_output_var> (&self, name:Name) -> glsl::GlobalVar { - let storage = self.storage.clone(); + let storage = self.storage; glsl::GlobalVar { layout : None, storage : Some(glsl::GlobalVarStorage::OutStorage(storage)), - prec : self.prec.clone(), + prec : self.prec, typ : self.typ.clone(), ident : name.into() } @@ -175,7 +175,7 @@ impl UniformQualifier { glsl::GlobalVar{ layout : None, storage : Some(glsl::GlobalVarStorage::UniformStorage), - prec : self.prec.clone(), + prec : self.prec, typ : self.typ.clone(), ident : name.into() } diff --git a/gui/lib/core/src/display/world.rs b/gui/lib/core/src/display/world.rs index b1ffdaebc73..0683c9a1802 100644 --- a/gui/lib/core/src/display/world.rs +++ b/gui/lib/core/src/display/world.rs @@ -51,6 +51,7 @@ pub use stats::*; static mut SCENE: Option = None; /// Very unsafe function. Do not use. See documentation of `WORLD` to learn more. +#[allow(unsafe_code)] pub(crate) fn get_scene() -> Scene { unsafe { SCENE.as_ref().unwrap_or_else(|| panic!("World not initialized.")).clone_ref() @@ -58,6 +59,7 @@ pub(crate) fn get_scene() -> Scene { } /// Very unsafe function. Do not use. See documentation of `WORLD` to learn more. +#[allow(unsafe_code)] fn init_global_variables(world:&World) { unsafe { SCENE = Some(world.rc.borrow().scene.clone_ref()); diff --git a/gui/lib/core/src/examples/easing_animator.rs b/gui/lib/core/src/examples/easing_animator.rs index c3c51f4e669..58ecbffcccd 100644 --- a/gui/lib/core/src/examples/easing_animator.rs +++ b/gui/lib/core/src/examples/easing_animator.rs @@ -23,14 +23,14 @@ use js_sys::Math; use std::rc::Rc; use std::cell::RefCell; -#[derive(Clone)] +#[derive(Clone,Debug)] /// A simplified Canvas object used in the EasingAnimator example. pub struct Canvas { canvas : HtmlCanvasElement, context : CanvasRenderingContext2d } -#[derive(Clone, Copy)] +#[derive(Clone,Copy,Debug)] /// Interpolable properties for our example code. pub struct Properties { /// Position property. diff --git a/gui/lib/core/src/lib.rs b/gui/lib/core/src/lib.rs index 34fac800eef..3ce59229dac 100644 --- a/gui/lib/core/src/lib.rs +++ b/gui/lib/core/src/lib.rs @@ -4,6 +4,9 @@ #![allow(dead_code)] +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] #![warn(missing_docs)] #![warn(trivial_casts)] #![warn(trivial_numeric_casts)] diff --git a/gui/lib/core/src/system/gpu/data/buffer.rs b/gui/lib/core/src/system/gpu/data/buffer.rs index fbc520ca2dd..413ed7fa067 100644 --- a/gui/lib/core/src/system/gpu/data/buffer.rs +++ b/gui/lib/core/src/system/gpu/data/buffer.rs @@ -231,6 +231,7 @@ impl BufferData { } /// Replaces the whole GPU buffer by the local data. + #[allow(unsafe_code)] fn replace_gpu_buffer(&mut self) { let data = self.as_slice(); let gl_enum = self.usage.into_gl_enum().into(); @@ -251,6 +252,7 @@ impl BufferData { } /// Updates the GPU sub-buffer data by the provided index range. + #[allow(unsafe_code)] fn update_gpu_sub_buffer(&mut self, range:&RangeInclusive) { let data = self.as_slice(); let item_byte_size = T::item_gpu_byte_size() as u32; @@ -323,7 +325,7 @@ use crate::system::gpu::data::AttributeInstanceIndex; // === Macros === /// Variant mismatch error type. -#[derive(Debug)] +#[derive(Clone,Copy,Debug)] pub struct BadVariant; macro_rules! define_any_buffer { diff --git a/gui/lib/core/src/system/gpu/data/buffer/item.rs b/gui/lib/core/src/system/gpu/data/buffer/item.rs index 68834228e6f..02aed37fda5 100644 --- a/gui/lib/core/src/system/gpu/data/buffer/item.rs +++ b/gui/lib/core/src/system/gpu/data/buffer/item.rs @@ -177,6 +177,7 @@ impl,R,C> BufferItem for MatrixMN type Rows = R; type Cols = C; + #[allow(unsafe_code)] fn slice_from_items(buffer: &[Self::Item]) -> &[Self] { // This code casts slice to matrix. This is safe because `MatrixMN` // uses `nalgebra::Owned` allocator, which resolves to array defined as @@ -185,6 +186,7 @@ impl,R,C> BufferItem for MatrixMN unsafe { std::slice::from_raw_parts(buffer.as_ptr().cast(), len) } } + #[allow(unsafe_code)] fn slice_from_items_mut(buffer: &mut [Self::Item]) -> &mut [Self] { // This code casts slice to matrix. This is safe because `MatrixMN` // uses `nalgebra::Owned` allocator, which resolves to array defined as @@ -193,6 +195,7 @@ impl,R,C> BufferItem for MatrixMN unsafe { std::slice::from_raw_parts_mut(buffer.as_mut_ptr().cast(), len) } } + #[allow(unsafe_code)] fn slice_to_items(buffer: &[Self]) -> &[Self::Item] { // This code casts slice to matrix. This is safe because `MatrixMN` // uses `nalgebra::Owned` allocator, which resolves to array defined as @@ -201,6 +204,7 @@ impl,R,C> BufferItem for MatrixMN unsafe { std::slice::from_raw_parts(buffer.as_ptr().cast(), len) } } + #[allow(unsafe_code)] fn slice_to_items_mut(buffer: &mut [Self]) -> &mut [Self::Item] { // This code casts slice to matrix. This is safe because `MatrixMN` // uses `nalgebra::Owned` allocator, which resolves to array defined as @@ -217,6 +221,7 @@ impl,R,C> BufferItem for MatrixMN // ==================== /// Extension method for viewing into wasm's linear memory. +#[allow(unsafe_code)] pub trait JsBufferView { /// Creates a JS typed array which is a view into wasm's linear memory at the slice specified. /// @@ -240,6 +245,7 @@ pub trait JsBufferView { // === Instances === +#[allow(unsafe_code)] impl JsBufferView for [bool] { unsafe fn js_buffer_view(&self) -> js_sys::Object { let i32arr = self.iter().cloned().map(|t| if t {1} else {0}).collect::>(); @@ -247,30 +253,35 @@ impl JsBufferView for [bool] { } } +#[allow(unsafe_code)] impl JsBufferView for [i32] { unsafe fn js_buffer_view(&self) -> js_sys::Object { js_sys::Int32Array::view(self).into() } } +#[allow(unsafe_code)] impl JsBufferView for [u32] { unsafe fn js_buffer_view(&self) -> js_sys::Object { js_sys::Uint32Array::view(self).into() } } +#[allow(unsafe_code)] impl JsBufferView for [f32] { unsafe fn js_buffer_view(&self) -> js_sys::Object { js_sys::Float32Array::view(self).into() } } +#[allow(unsafe_code)] impl JsBufferView for [u8] { unsafe fn js_buffer_view(&self) -> js_sys::Object { js_sys::Uint8Array::view(self).into() } } +#[allow(unsafe_code)] impl,R,C> JsBufferView for [MatrixMN] where Self : MatrixCtx, T : ItemBounds, @@ -281,6 +292,7 @@ impl,R,C> JsBufferView for [MatrixMN] } } +#[allow(unsafe_code)] impl,R,C> JsBufferView for MatrixMN where Self:MatrixCtx, T:ItemBounds { unsafe fn js_buffer_view(&self) -> js_sys::Object { diff --git a/gui/lib/core/src/system/gpu/data/texture/class.rs b/gui/lib/core/src/system/gpu/data/texture/class.rs index 5ea5f4189c2..d9fd5bc7717 100644 --- a/gui/lib/core/src/system/gpu/data/texture/class.rs +++ b/gui/lib/core/src/system/gpu/data/texture/class.rs @@ -27,6 +27,7 @@ pub struct TextureUnit(u32); // ======================== /// Guard which unbinds texture in specific texture unit on drop. +#[derive(Debug)] pub struct TextureBindGuard { context : Context, target : u32, diff --git a/gui/lib/core/src/system/gpu/data/texture/storage/gpu_only.rs b/gui/lib/core/src/system/gpu/data/texture/storage/gpu_only.rs index 6affe5b4f84..498940c2ecd 100644 --- a/gui/lib/core/src/system/gpu/data/texture/storage/gpu_only.rs +++ b/gui/lib/core/src/system/gpu/data/texture/storage/gpu_only.rs @@ -15,7 +15,7 @@ use crate::system::gpu::data::texture::types::*; // =============== /// Sized, uninitialized texture. -#[derive(Debug)] +#[derive(Clone,Copy,Debug)] pub struct GpuOnlyData { /// Texture width. pub width : i32, diff --git a/gui/lib/core/src/system/gpu/data/texture/storage/owned.rs b/gui/lib/core/src/system/gpu/data/texture/storage/owned.rs index 0aac9fe2c17..18829189e75 100644 --- a/gui/lib/core/src/system/gpu/data/texture/storage/owned.rs +++ b/gui/lib/core/src/system/gpu/data/texture/storage/owned.rs @@ -43,6 +43,7 @@ impl OwnedData { impl TextureReload for Texture { + #[allow(unsafe_code)] fn reload(&self) { let width = self.storage().width; let height = self.storage().height; diff --git a/gui/lib/core/src/system/gpu/data/uniform.rs b/gui/lib/core/src/system/gpu/data/uniform.rs index b1766375e87..1e6866f41f3 100644 --- a/gui/lib/core/src/system/gpu/data/uniform.rs +++ b/gui/lib/core/src/system/gpu/data/uniform.rs @@ -249,6 +249,7 @@ impl WithContent for Uniform { // === AnyPrimUniform === // ====================== +#[derive(Clone,Copy,Debug)] pub struct TypeMismatch; macro_rules! define_any_prim_uniform { diff --git a/gui/lib/core/src/system/gpu/shader.rs b/gui/lib/core/src/system/gpu/shader.rs index 6f8f70dae3b..1cfea363920 100644 --- a/gui/lib/core/src/system/gpu/shader.rs +++ b/gui/lib/core/src/system/gpu/shader.rs @@ -172,6 +172,7 @@ pub fn set_buffer_data(gl_context:&Context, buffer:&WebGlBuffer, data:&[f32]) { /// until it is destroyed. This way of creating buffers were taken from /// wasm-bindgen examples /// (https://rustwasm.github.io/wasm-bindgen/examples/webgl.html) +#[allow(unsafe_code)] fn set_bound_buffer_data(gl_context:&Context, target:u32, data:&[f32]) { let usage = Context::STATIC_DRAW; unsafe { @@ -194,6 +195,7 @@ pub fn set_buffer_subdata(gl_context:&Context, buffer:&WebGlBuffer, offset:usize /// until it is destroyed. This way of creating buffers were taken from /// wasm-bindgen examples /// (https://rustwasm.github.io/wasm-bindgen/examples/webgl.html) +#[allow(unsafe_code)] fn set_bound_buffer_subdata(gl_context:&Context, target:u32, offset:i32, data:&[f32]) { unsafe { let float_array = Float32Array::view(&data); diff --git a/gui/lib/core/src/system/gpu/shader/glsl.rs b/gui/lib/core/src/system/gpu/shader/glsl.rs index 46cf74f61c0..afb420f036c 100644 --- a/gui/lib/core/src/system/gpu/shader/glsl.rs +++ b/gui/lib/core/src/system/gpu/shader/glsl.rs @@ -113,6 +113,7 @@ where Self:MatrixCtx, PhantomData>:Into { // === Wrong Conversions === /// Error indicating that a value cannot be converted to Glsl. +#[derive(Clone,Copy,Debug)] pub struct NotGlslError; @@ -539,13 +540,13 @@ pub struct GlobalVar { } /// Global variable layout definition. -#[derive(Clone,Debug,Default)] +#[derive(Clone,Copy,Debug,Default)] pub struct Layout { pub location: usize, } /// Global variable storage definition. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub enum GlobalVarStorage { ConstStorage, InStorage(LinkageStorage), @@ -554,14 +555,14 @@ pub enum GlobalVarStorage { } /// Storage definition for in- and out- attributes. -#[derive(Clone,Debug,Default)] +#[derive(Clone,Copy,Debug,Default)] pub struct LinkageStorage { pub centroid : bool, pub interpolation : Option, } /// Interpolation storage type for attributes. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub enum InterpolationStorage {Smooth, Flat} @@ -638,7 +639,7 @@ impl HasCodeRepr for LocalVar { // ================= /// Type precision definition. -#[derive(Clone,Debug)] +#[derive(Clone,Copy,Debug)] pub enum Precision { Low, Medium, High } impl Display for Precision { @@ -665,7 +666,7 @@ impl HasCodeRepr for Precision { impl From<&Precision> for Precision { fn from(t: &Precision) -> Self { - t.clone() + *t } } diff --git a/gui/lib/core/src/system/web/dom/html/html_renderer.rs b/gui/lib/core/src/system/web/dom/html/html_renderer.rs index 0c42f317e12..f71d7f31ea7 100644 --- a/gui/lib/core/src/system/web/dom/html/html_renderer.rs +++ b/gui/lib/core/src/system/web/dom/html/html_renderer.rs @@ -31,9 +31,16 @@ mod js { use super::*; #[wasm_bindgen(module = "/src/system/web/dom/html/snippets.js")] extern "C" { + #[allow(unsafe_code)] pub fn set_object_transform(dom:&JsValue, matrix_array:&Object); + + #[allow(unsafe_code)] pub fn setup_perspective(dom: &JsValue, znear: &JsValue); + + #[allow(unsafe_code)] pub fn setup_camera_orthographic(dom:&JsValue, matrix_array:&JsValue); + + #[allow(unsafe_code)] pub fn setup_camera_perspective ( dom : &JsValue , near : &JsValue @@ -55,6 +62,7 @@ pub fn invert_y(mut m: Matrix4) -> Matrix4 { m } +#[allow(unsafe_code)] fn set_object_transform(dom: &JsValue, matrix: &Matrix4) { // Views to WASM memory are only valid as long the backing buffer isn't // resized. Check documentation of IntoFloat32ArrayView trait for more @@ -65,6 +73,7 @@ fn set_object_transform(dom: &JsValue, matrix: &Matrix4) { } } +#[allow(unsafe_code)] fn setup_camera_perspective (dom:&JsValue, near:f32, matrix:&Matrix4) { // Views to WASM memory are only valid as long the backing buffer isn't // resized. Check documentation of IntoFloat32ArrayView trait for more @@ -79,6 +88,7 @@ fn setup_camera_perspective } } +#[allow(unsafe_code)] fn setup_camera_orthographic(dom:&JsValue, matrix:&Matrix4) { // Views to WASM memory are only valid as long the backing buffer isn't // resized. Check documentation of IntoFloat32ArrayView trait for more diff --git a/gui/lib/core/src/system/web/dom/html/html_scene.rs b/gui/lib/core/src/system/web/dom/html/html_scene.rs index 5b773b8b92a..18a12c1cb10 100644 --- a/gui/lib/core/src/system/web/dom/html/html_scene.rs +++ b/gui/lib/core/src/system/web/dom/html/html_scene.rs @@ -13,6 +13,7 @@ use data::opt_vec::*; // ================= /// A collection for holding 3D `Object`s. +#[derive(Debug)] pub struct HtmlScene { display_object : DisplayObjectData, objects : OptVec diff --git a/gui/lib/data/src/lib.rs b/gui/lib/data/src/lib.rs index a2c0a655eff..bf3e61ee06a 100644 --- a/gui/lib/data/src/lib.rs +++ b/gui/lib/data/src/lib.rs @@ -1,3 +1,7 @@ +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] + pub mod opt_vec; pub use basegl_prelude as prelude; \ No newline at end of file diff --git a/gui/lib/eval-tt/src/lib.rs b/gui/lib/eval-tt/src/lib.rs index 5dde02d47b0..b4ac502aa14 100644 --- a/gui/lib/eval-tt/src/lib.rs +++ b/gui/lib/eval-tt/src/lib.rs @@ -27,6 +27,10 @@ //! evaluated. This is just because the implementation is not finished and //! there are comments in code where it should be added. +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] + // ============ // === Eval === // ============ diff --git a/gui/lib/logger/src/lib.rs b/gui/lib/logger/src/lib.rs index f2d2ebcea7d..647b89f81eb 100644 --- a/gui/lib/logger/src/lib.rs +++ b/gui/lib/logger/src/lib.rs @@ -1,5 +1,8 @@ #![feature(trait_alias)] #![feature(set_stdio)] +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] use std::fmt::Debug; use wasm_bindgen::JsValue; diff --git a/gui/lib/optics/src/lib.rs b/gui/lib/optics/src/lib.rs index ddce4ece793..eabb2be099a 100644 --- a/gui/lib/optics/src/lib.rs +++ b/gui/lib/optics/src/lib.rs @@ -1,3 +1,6 @@ +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] #![allow(non_snake_case)] #![allow(non_camel_case_types)] #![allow(dead_code)] diff --git a/gui/lib/prelude/src/lib.rs b/gui/lib/prelude/src/lib.rs index 7df4c27ef59..02c44209b4d 100644 --- a/gui/lib/prelude/src/lib.rs +++ b/gui/lib/prelude/src/lib.rs @@ -3,6 +3,9 @@ //! defines several aliases and utils which may find their place in new //! libraries in the future. +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] #![feature(specialization)] #![feature(trait_alias)] @@ -443,9 +446,11 @@ pub trait Value { // ======================= /// Type level `true` value. +#[derive(Clone,Copy,Debug)] pub struct True {} /// Type level `false` value. +#[derive(Clone,Copy,Debug)] pub struct False {} impl Value for True { diff --git a/gui/lib/shapely/impl/src/lib.rs b/gui/lib/shapely/impl/src/lib.rs index 21c58bedc3e..e439456781d 100644 --- a/gui/lib/shapely/impl/src/lib.rs +++ b/gui/lib/shapely/impl/src/lib.rs @@ -5,6 +5,9 @@ // This library is in a very early stage. It will be refactored and improved // soon. It should not be reviewed now. +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] #![feature(generators, generator_trait)] #![feature(specialization)] #![feature(overlapping_marker_traits)] @@ -85,6 +88,7 @@ macro_rules! derive_clone_plus { // === IterForGenerator === // ======================== +#[derive(Debug)] pub struct IterForGenerator(pub G); impl Iterator for IterForGenerator @@ -104,7 +108,7 @@ where G: Generator + Unpin { // ====================== #[derive(Derivative)] -#[derivative(Default(bound=""))] +#[derivative(Debug,Default(bound=""))] pub struct EmptyGenerator(PhantomData); impl EmptyGenerator { diff --git a/gui/lib/shapely/impl/src/shared.rs b/gui/lib/shapely/impl/src/shared.rs index 9e4f46e2901..1f16ec692ce 100644 --- a/gui/lib/shapely/impl/src/shared.rs +++ b/gui/lib/shapely/impl/src/shared.rs @@ -20,7 +20,7 @@ /// ```compile_fail /// shared! { Uniform /// -/// #[derive(Clone,Debug)] +/// #[derive(Clone,Copy,Debug)] /// pub struct UniformData { /// value: Value, /// dirty: bool, @@ -49,7 +49,7 @@ /// The following output will be generated: /// /// ```compile_fail -/// #[derive(Clone,Debug)] +/// #[derive(Clone,Copy,Debug)] /// pub struct UniformData { /// value: Value, /// dirty: bool, @@ -74,7 +74,7 @@ /// } /// } /// -/// #[derive(Clone,Debug)] +/// #[derive(Clone,Copy,Debug)] /// pub struct Uniform { /// rc: Rc>> /// } diff --git a/gui/lib/shapely/macros/src/lib.rs b/gui/lib/shapely/macros/src/lib.rs index 917a67db878..37cb7105043 100644 --- a/gui/lib/shapely/macros/src/lib.rs +++ b/gui/lib/shapely/macros/src/lib.rs @@ -1,3 +1,7 @@ +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] + extern crate proc_macro; use basegl_prelude::*; @@ -7,7 +11,6 @@ use proc_macro2::{TokenStream, Ident, Span}; use quote::quote; use syn; - //////////////////////////////////////////////// /// In order to make the definition easier to read, an example expansion of the diff --git a/gui/lib/system/web/src/lib.rs b/gui/lib/system/web/src/lib.rs index 6b15007154a..e5c5f88549a 100644 --- a/gui/lib/system/web/src/lib.rs +++ b/gui/lib/system/web/src/lib.rs @@ -1,3 +1,6 @@ +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] #![feature(trait_alias)] #![feature(set_stdio)] @@ -241,6 +244,7 @@ impl NodeRemover for Node { #[wasm_bindgen(inline_js = "export function request_animation_frame2(f) { requestAnimationFrame(f) }")] extern "C" { + #[allow(unsafe_code)] pub fn request_animation_frame2(closure: &Closure) -> i32; } @@ -324,6 +328,7 @@ export function set_stack_trace_limit() { } ")] extern "C" { + #[allow(unsafe_code)] pub fn set_stack_trace_limit(); } diff --git a/gui/lib/system/web/src/resize_observer.rs b/gui/lib/system/web/src/resize_observer.rs index e92cd30bfce..0b52e8d2983 100644 --- a/gui/lib/system/web/src/resize_observer.rs +++ b/gui/lib/system/web/src/resize_observer.rs @@ -14,7 +14,10 @@ pub type Listener = Closure; #[wasm_bindgen(module = "/js/resize_observer.js")] extern "C" { + #[allow(unsafe_code)] fn resize_observe(target: &JsValue, closure: &Listener) -> usize; + + #[allow(unsafe_code)] fn resize_unobserve(id: usize); } diff --git a/gui/lib/web-test-proc-macro/src/lib.rs b/gui/lib/web-test-proc-macro/src/lib.rs index 5b43b469225..11ac34f6b32 100644 --- a/gui/lib/web-test-proc-macro/src/lib.rs +++ b/gui/lib/web-test-proc-macro/src/lib.rs @@ -1,3 +1,7 @@ +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] + extern crate proc_macro; use proc_macro::TokenStream; diff --git a/gui/lib/web-test/src/bench_container.rs b/gui/lib/web-test/src/bench_container.rs index f6281baef9a..4faaa9f89da 100644 --- a/gui/lib/web-test/src/bench_container.rs +++ b/gui/lib/web-test/src/bench_container.rs @@ -14,7 +14,7 @@ use web_sys::HtmlElement; // ====================== /// Html container displaying benchmark results. -#[derive(Shrinkwrap)] +#[derive(Shrinkwrap,Debug)] pub struct BenchContainer { #[shrinkwrap(main_field)] container : Container, diff --git a/gui/lib/web-test/src/bencher.rs b/gui/lib/web-test/src/bencher.rs index 3ac5257668f..60693709245 100644 --- a/gui/lib/web-test/src/bencher.rs +++ b/gui/lib/web-test/src/bencher.rs @@ -16,7 +16,10 @@ use std::cell::RefCell; // ========================= /// Cell, used to hold Bencher's data +#[derive(Derivative)] +#[derivative(Debug)] pub struct BencherProperties { + #[derivative(Debug="ignore")] callback : Box, container : BenchContainer, iterations : usize, @@ -54,7 +57,7 @@ impl BencherProperties { // === BencherData === // =================== -#[derive(Shrinkwrap)] +#[derive(Shrinkwrap,Debug)] pub struct BencherData { properties: RefCell } @@ -119,7 +122,7 @@ impl BencherData { // =============== /// The Bencher struct with an API compatible to Rust's test Bencher. -#[derive(Clone)] +#[derive(Clone,Debug)] pub struct Bencher { data : Rc } diff --git a/gui/lib/web-test/src/container.rs b/gui/lib/web-test/src/container.rs index 975fa6d5fd4..cb29c942382 100644 --- a/gui/lib/web-test/src/container.rs +++ b/gui/lib/web-test/src/container.rs @@ -13,6 +13,7 @@ use web_sys::HtmlElement; // ================= /// A container to hold tests in `wasm-pack test`. +#[derive(Clone,Debug)] pub struct Container { pub div : HtmlElement, pub header : HtmlElement, diff --git a/gui/lib/web-test/src/group.rs b/gui/lib/web-test/src/group.rs index 032312c1430..f84dc98ab39 100644 --- a/gui/lib/web-test/src/group.rs +++ b/gui/lib/web-test/src/group.rs @@ -14,6 +14,7 @@ use web_sys::HtmlElement; // ============= /// Helper to group test containers +#[derive(Clone,Debug)] pub struct Group { pub div : HtmlElement, } diff --git a/gui/lib/web-test/src/lib.rs b/gui/lib/web-test/src/lib.rs index e99311dae5b..c437d7bb3a0 100644 --- a/gui/lib/web-test/src/lib.rs +++ b/gui/lib/web-test/src/lib.rs @@ -1,4 +1,7 @@ #![feature(arbitrary_self_types)] +#![warn(unsafe_code)] +#![warn(missing_copy_implementations)] +#![warn(missing_debug_implementations)] mod system { pub use basegl_system_web as web;