Skip to content

Commit

Permalink
Fix elided_lifetimes_in_path in Xilem Core (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab authored Nov 12, 2024
1 parent 2b509fb commit 751bd62
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 94 deletions.
7 changes: 3 additions & 4 deletions xilem_core/examples/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! An example using Xilem Core to manipulate a filesystem.

#![expect(clippy::use_self, reason = "Deferred: Noisy")]
#![expect(elided_lifetimes_in_paths, reason = "Deferred: Noisy")]
#![expect(let_underscore_drop, reason = "Deferred: Noisy")]

use std::io::stdin;
Expand Down Expand Up @@ -112,7 +111,7 @@ impl SuperElement<FsPath, ViewCtx> for FsPath {

fn with_downcast_val<R>(
this: Self::Mut<'_>,
f: impl FnOnce(Mut<FsPath>) -> R,
f: impl FnOnce(Mut<'_, FsPath>) -> R,
) -> (Self::Mut<'_>, R) {
let ret = f(this);
(this, ret)
Expand Down Expand Up @@ -170,7 +169,7 @@ impl<State, Action> View<State, Action, ViewCtx> for File {
prev: &Self,
_view_state: &mut Self::ViewState,
ctx: &mut ViewCtx,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
if prev.name != self.name {
let new_path = ctx.current_folder_path.join(&*self.name);
Expand All @@ -186,7 +185,7 @@ impl<State, Action> View<State, Action, ViewCtx> for File {
&self,
_view_state: &mut Self::ViewState,
_ctx: &mut ViewCtx,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
let _ = std::fs::remove_file(element);
}
Expand Down
6 changes: 2 additions & 4 deletions xilem_core/examples/user_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

//! Model version of Masonry for exploration

#![expect(elided_lifetimes_in_paths, reason = "Deferred: Noisy")]

use core::any::Any;

use xilem_core::{
Expand Down Expand Up @@ -66,7 +64,7 @@ impl<State, Action> View<State, Action, ViewCtx> for Button {
_prev: &Self,
_view_state: &mut Self::ViewState,
_ctx: &mut ViewCtx,
_element: Mut<Self::Element>,
_element: Mut<'_, Self::Element>,
) {
// Nothing to do
}
Expand All @@ -75,7 +73,7 @@ impl<State, Action> View<State, Action, ViewCtx> for Button {
&self,
_view_state: &mut Self::ViewState,
_ctx: &mut ViewCtx,
_element: Mut<Self::Element>,
_element: Mut<'_, Self::Element>,
) {
// Nothing to do
}
Expand Down
16 changes: 8 additions & 8 deletions xilem_core/src/any_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_rebuild(view_state, ctx, prev, element);
}
Expand All @@ -209,7 +209,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_teardown(view_state, ctx, element);
}
Expand Down Expand Up @@ -254,7 +254,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_rebuild(view_state, ctx, prev, element);
}
Expand All @@ -263,7 +263,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_teardown(view_state, ctx, element);
}
Expand Down Expand Up @@ -306,7 +306,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_rebuild(view_state, ctx, prev, element);
}
Expand All @@ -315,7 +315,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_teardown(view_state, ctx, element);
}
Expand Down Expand Up @@ -358,7 +358,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_rebuild(view_state, ctx, prev, element);
}
Expand All @@ -367,7 +367,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.dyn_teardown(view_state, ctx, element);
}
Expand Down
12 changes: 7 additions & 5 deletions xilem_core/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ where
/// You can safely use this methods in contexts where it is known that the
///
/// If you need to return a value, see [`with_downcast_val`](SuperElement::with_downcast_val).
fn with_downcast(this: Mut<Self>, f: impl FnOnce(Mut<Child>)) -> Mut<Self> {
fn with_downcast(this: Mut<'_, Self>, f: impl FnOnce(Mut<'_, Child>)) -> Mut<'_, Self> {
let (this, ()) = Self::with_downcast_val(this, f);
this
}
Expand All @@ -68,8 +68,10 @@ where
/// `Self::upcast`.
///
/// If you don't need to return a value, see [`with_downcast`](SuperElement::with_downcast).
fn with_downcast_val<R>(this: Mut<Self>, f: impl FnOnce(Mut<Child>) -> R)
-> (Self::Mut<'_>, R);
fn with_downcast_val<R>(
this: Mut<'_, Self>,
f: impl FnOnce(Mut<'_, Child>) -> R,
) -> (Self::Mut<'_>, R);
}

/// An element which can be used for an [`AnyView`](crate::AnyView) containing `Child`.
Expand Down Expand Up @@ -100,8 +102,8 @@ impl<Context> SuperElement<NoElement, Context> for NoElement {
}

fn with_downcast_val<R>(
this: Mut<Self>,
f: impl FnOnce(Mut<NoElement>) -> R,
this: Mut<'_, Self>,
f: impl FnOnce(Mut<'_, NoElement>) -> R,
) -> (Self::Mut<'_>, R) {
((), f(this))
}
Expand Down
1 change: 0 additions & 1 deletion xilem_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#![expect(single_use_lifetimes, reason = "Deferred: Noisy")]
#![expect(clippy::exhaustive_enums, reason = "Deferred: Noisy")]
#![expect(clippy::missing_assert_message, reason = "Deferred: Noisy")]
#![expect(elided_lifetimes_in_paths, reason = "Deferred: Noisy")]
#![expect(clippy::use_self, reason = "Deferred: Noisy")]
#![expect(clippy::missing_errors_doc, reason = "Can be quite noisy?")]
#![expect(
Expand Down
16 changes: 8 additions & 8 deletions xilem_core/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub trait View<State, Action, Context: ViewPathTracker, Message = DynMessage>:
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
);

/// Handle `element` being removed from the tree.
Expand All @@ -95,7 +95,7 @@ pub trait View<State, Action, Context: ViewPathTracker, Message = DynMessage>:
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
);

/// Route `message` to `id_path`, if that is still a valid path.
Expand Down Expand Up @@ -179,7 +179,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.deref().rebuild(prev, view_state, ctx, element);
}
Expand All @@ -188,7 +188,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.deref().teardown(view_state, ctx, element);
}
Expand Down Expand Up @@ -242,7 +242,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
if core::mem::take(&mut view_state.dirty) || !Arc::ptr_eq(self, prev) {
self.deref()
Expand All @@ -254,7 +254,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.deref()
.teardown(&mut view_state.view_state, ctx, element);
Expand Down Expand Up @@ -303,7 +303,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
if core::mem::take(&mut view_state.dirty) || !Rc::ptr_eq(self, prev) {
self.deref()
Expand All @@ -315,7 +315,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.deref()
.teardown(&mut view_state.view_state, ctx, element);
Expand Down
10 changes: 5 additions & 5 deletions xilem_core/src/views/adapt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Adapt<
Message,
ProxyFn = fn(
&mut ParentState,
AdaptThunk<ChildState, ChildAction, Context, ChildView, Message>,
AdaptThunk<'_, ChildState, ChildAction, Context, ChildView, Message>,
) -> MessageResult<ParentAction>,
> {
proxy_fn: ProxyFn,
Expand Down Expand Up @@ -120,7 +120,7 @@ where
ChildView: View<ChildState, ChildAction, Context, Message>,
ProxyFn: Fn(
&mut ParentState,
AdaptThunk<ChildState, ChildAction, Context, ChildView, Message>,
AdaptThunk<'_, ChildState, ChildAction, Context, ChildView, Message>,
) -> MessageResult<ParentAction, Message>
+ 'static,
{
Expand Down Expand Up @@ -163,7 +163,7 @@ where
V: View<ChildState, ChildAction, Context, Message>,
F: Fn(
&mut ParentState,
AdaptThunk<ChildState, ChildAction, Context, V, Message>,
AdaptThunk<'_, ChildState, ChildAction, Context, V, Message>,
) -> MessageResult<ParentAction, Message>
+ 'static,
{
Expand All @@ -180,7 +180,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.child.rebuild(&prev.child, view_state, ctx, element);
}
Expand All @@ -189,7 +189,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.child.teardown(view_state, ctx, element);
}
Expand Down
4 changes: 2 additions & 2 deletions xilem_core/src/views/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
prev: &Self,
(active_state, alongside_state): &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
ctx.with_id(ViewId::new(0), |ctx| {
self.active_view
Expand All @@ -73,7 +73,7 @@ where
&self,
(active_state, alongside_state): &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
ctx.with_id(ViewId::new(0), |ctx| {
self.alongside_view
Expand Down
4 changes: 2 additions & 2 deletions xilem_core/src/views/map_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.child.rebuild(&prev.child, view_state, ctx, element);
}
Expand All @@ -119,7 +119,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.child.teardown(view_state, ctx, element);
}
Expand Down
4 changes: 2 additions & 2 deletions xilem_core/src/views/map_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.child.rebuild(&prev.child, view_state, ctx, element);
}
Expand All @@ -161,7 +161,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
self.child.teardown(view_state, ctx, element);
}
Expand Down
8 changes: 4 additions & 4 deletions xilem_core/src/views/memoize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ where
prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
if core::mem::take(&mut view_state.dirty) || prev.data != self.data {
let view = (self.init_view)(&self.data);
Expand Down Expand Up @@ -143,7 +143,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
view_state
.view
Expand Down Expand Up @@ -224,7 +224,7 @@ where
_prev: &Self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
if core::mem::take(&mut view_state.dirty) {
let view = (self.init_view)();
Expand All @@ -239,7 +239,7 @@ where
&self,
view_state: &mut Self::ViewState,
ctx: &mut Context,
element: Mut<Self::Element>,
element: Mut<'_, Self::Element>,
) {
view_state
.view
Expand Down
Loading

0 comments on commit 751bd62

Please sign in to comment.