Fix `missing_assert_message` and `missing_errors_doc` in Xilem Core (#748)

This commit is contained in:
Daniel McNab 2024-11-14 10:33:05 +00:00 committed by GitHub
parent 628659d35c
commit ecc7217808
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 5 deletions

View File

@ -86,6 +86,13 @@ impl<M: Message> MessageProxy<M> {
}
/// Send `message` to the `View` which created this `MessageProxy`
///
/// # Errors
///
/// - `DriverFinished`: If the main thread event loop couldn't receive the message (for example if it was shut down).
/// - `Other`: As determined by the Xilem implementation.
///
/// This method is currently not expected to return `ViewExpired`, as it does not block.
pub fn message(&self, message: M) -> Result<(), ProxyError> {
self.proxy
.send_message(self.path.clone(), Box::new(message))

View File

@ -26,8 +26,6 @@
#![deny(clippy::trivially_copy_pass_by_ref)]
#![expect(single_use_lifetimes, reason = "Deferred: Noisy")]
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]
#![expect(clippy::missing_errors_doc, reason = "Can be quite noisy?")]
#![expect(
clippy::shadow_unrelated,
reason = "Potentially controversial code style"

View File

@ -256,7 +256,11 @@ where
// If `prev` was `Some`, we set `seq_state` in reacting to it (and building the inner view)
// This could only fail if some malicious parent view was messing with our internal state
// (i.e. mixing up the state from different instances)
assert_eq!(prev.is_some(), seq_state.inner.is_some());
assert_eq!(
prev.is_some(),
seq_state.inner.is_some(),
"Inconsistent ViewSequence state. Perhaps the parent is mixing up children"
);
match (self, prev.as_ref().zip(seq_state.inner.as_mut())) {
(None, None) => {
// Nothing to do, there is no corresponding element
@ -301,7 +305,11 @@ where
ctx: &mut Context,
elements: &mut impl ElementSplice<Element>,
) {
assert_eq!(self.is_some(), seq_state.inner.is_some());
assert_eq!(
self.is_some(),
seq_state.inner.is_some(),
"Inconsistent ViewSequence state. Perhaps the parent is mixing up children"
);
if let Some((seq, inner_state)) = self.as_ref().zip(seq_state.inner.as_mut()) {
ctx.with_id(ViewId::new(seq_state.generation), |ctx| {
seq.seq_teardown(inner_state, ctx, elements);
@ -324,7 +332,11 @@ where
// The message was sent to a previous edition of the inner value
return MessageResult::Stale(message);
}
assert_eq!(self.is_some(), seq_state.inner.is_some());
assert_eq!(
self.is_some(),
seq_state.inner.is_some(),
"Inconsistent ViewSequence state. Perhaps the parent is mixing up children"
);
if let Some((seq, inner_state)) = self.as_ref().zip(seq_state.inner.as_mut()) {
seq.seq_message(inner_state, rest, message, app_state)
} else {