Skip to content

Commit 5c61ac1

Browse files
authored
Fix missing_debug_implementations in Xilem Core (#739)
This also updates to use `core::error::Error` now that it is stable.
1 parent 23f04ca commit 5c61ac1

File tree

17 files changed

+119
-36
lines changed

17 files changed

+119
-36
lines changed

xilem/src/driver.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ impl RawProxy for MasonryProxy {
5252
}
5353
}
5454
}
55+
fn dyn_debug(&self) -> &dyn std::fmt::Debug {
56+
self
57+
}
5558
}
5659

60+
#[derive(Debug)]
5761
pub struct MasonryProxy(pub(crate) EventLoopProxy);
5862

5963
impl MasonryProxy {

xilem_core/src/any_view.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ where
166166
/// The state used by [`AnyView`].
167167
#[doc(hidden)]
168168
#[allow(unnameable_types)] // reason: Implementation detail, public because of trait visibility rules
169+
#[derive(Debug)]
169170
pub struct AnyViewState {
170171
inner_state: Box<dyn Any>,
171172
/// The generation is the value which is shown

xilem_core/src/deferred.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use alloc::boxed::Box;
55
use alloc::sync::Arc;
6-
use core::fmt::Display;
6+
use core::fmt::{Debug, Display};
77
use core::marker::PhantomData;
88

99
use crate::{DynMessage, Message, NoElement, View, ViewId, ViewPathTracker};
@@ -47,9 +47,18 @@ pub trait RawProxy<Message = DynMessage>: Send + Sync + 'static {
4747
//
4848
// e.g. an `Option<Arc<dyn FnMut(ProxyError, ProxyMessageId?)>>`?
4949
fn send_message(&self, path: Arc<[ViewId]>, message: Message) -> Result<(), ProxyError>;
50+
/// Get the debug formatter for this proxy type.
51+
fn dyn_debug(&self) -> &dyn Debug;
52+
}
53+
54+
impl<Message: 'static> Debug for dyn RawProxy<Message> {
55+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56+
self.dyn_debug().fmt(f)
57+
}
5058
}
5159

5260
/// A way to send a message of an expected type to a specific view.
61+
#[derive(Debug)]
5362
pub struct MessageProxy<M: Message> {
5463
proxy: Arc<dyn RawProxy<DynMessage>>,
5564
path: Arc<[ViewId]>,
@@ -109,10 +118,8 @@ pub enum ProxyError {
109118
///
110119
/// This likely requires async error handling to happen.
111120
ViewExpired(DynMessage, Arc<[ViewId]>),
112-
#[allow(missing_docs)]
113-
Other(&'static str),
114-
// TODO: When core::error::Error is stabilised
115-
// Other(Box<dyn core::error::Error + Send>),
121+
/// An error specific to the driver being used.
122+
Other(Box<dyn core::error::Error + Send>),
116123
}
117124

118125
// Is it fine to use thiserror in this crate?
@@ -123,17 +130,16 @@ impl Display for ProxyError {
123130
ProxyError::ViewExpired(_, _) => {
124131
f.write_fmt(format_args!("the corresponding view is no longer present"))
125132
}
126-
127-
ProxyError::Other(inner) => inner.fmt(f),
133+
ProxyError::Other(inner) => Display::fmt(inner, f),
128134
}
129135
}
130136
}
131137

132-
// impl std::error::Error for ProxyError {
133-
// fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
134-
// match self {
135-
// ProxyError::Other(inner) => inner.source(),
136-
// _ => None,
137-
// }
138-
// }
139-
// }
138+
impl core::error::Error for ProxyError {
139+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
140+
match self {
141+
ProxyError::Other(inner) => inner.source(),
142+
_ => None,
143+
}
144+
}
145+
}

xilem_core/src/docs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use crate::{run_once, View, ViewPathTracker};
3939

4040
/// A type used for documentation
41+
#[derive(Debug)]
4142
pub enum Fake {}
4243

4344
impl ViewPathTracker for Fake {
@@ -63,6 +64,7 @@ pub trait DocsView<State, Action = ()>: View<State, Action, Fake> {}
6364
impl<V, State, Action> DocsView<State, Action> for V where V: View<State, Action, Fake> {}
6465

6566
/// A state type usable in a component
67+
#[derive(Debug)]
6668
pub struct State;
6769

6870
/// A minimal component.

xilem_core/src/element.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ where
8787
/// correct `State` and `Action` types), as they do not need to actually add an element to the sequence.
8888
///
8989
/// These views can also as the `alongside_view` in [`fork`](crate::fork).
90+
#[derive(Debug)]
9091
pub struct NoElement;
9192

9293
impl ViewElement for NoElement {

xilem_core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![warn(clippy::print_stdout, clippy::print_stderr)]
2525
// TODO: Remove any items listed as "Deferred"
2626
#![deny(clippy::trivially_copy_pass_by_ref)]
27-
#![expect(missing_debug_implementations, reason = "Deferred: Noisy")]
2827
#![expect(unused_qualifications, reason = "Deferred: Noisy")]
2928
#![expect(single_use_lifetimes, reason = "Deferred: Noisy")]
3029
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]

xilem_core/src/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use core::ops::Deref;
1111
/// The possible outcomes from a [`View::message`]
1212
///
1313
/// [`View::message`]: crate::View::message
14-
#[derive(Default)]
14+
#[derive(Default, Debug)]
1515
pub enum MessageResult<Action, Message = DynMessage> {
1616
/// An action for a parent message handler to use
1717
///

xilem_core/src/sequence.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ where
197197

198198
/// The state used to implement `ViewSequence` for `Option<impl ViewSequence>`
199199
#[allow(unnameable_types)] // reason: Implementation detail, public because of trait visibility rules
200+
#[derive(Debug)]
200201
pub struct OptionSeqState<InnerState> {
201202
/// The current state.
202203
///
@@ -341,6 +342,7 @@ where
341342
// This is managed in [`create_generational_view_id`] and [`view_id_to_index_generation`]
342343
#[doc(hidden)]
343344
#[allow(unnameable_types)] // reason: Implementation detail, public because of trait visibility rules
345+
#[derive(Debug)]
344346
pub struct VecViewState<InnerState> {
345347
inner_states: Vec<InnerState>,
346348

xilem_core/src/view.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ where
206206
}
207207

208208
#[allow(unnameable_types)] // reason: Implementation detail, public because of trait visibility rules
209+
#[derive(Debug)]
209210
pub struct RcState<ViewState> {
210211
view_state: ViewState,
211212
/// This is a flag that is set, when an inner view signifies that it requires a rebuild (via [`MessageResult::RequestRebuild`]).

xilem_core/src/views/adapt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use core::marker::PhantomData;
66
use crate::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};
77

88
/// A view that wraps a child view and modifies the state that callbacks have access to.
9+
#[derive(Debug)]
910
pub struct Adapt<
1011
ParentState,
1112
ParentAction,
@@ -37,6 +38,7 @@ pub struct Adapt<
3738
///
3839
/// The closure passed to [`Adapt`] should call this thunk with the child's
3940
/// app state.
41+
#[derive(Debug)]
4042
pub struct AdaptThunk<'a, ChildState, ChildAction, Context, ChildView, Message>
4143
where
4244
Context: ViewPathTracker,

0 commit comments

Comments
 (0)