diff --git a/examples/tui_all_events.rs b/examples/tui_all_events.rs index 732b62532..546a6f6f0 100644 --- a/examples/tui_all_events.rs +++ b/examples/tui_all_events.rs @@ -27,7 +27,7 @@ enum Event { const MAX_EVENTS: usize = 8; fn app(cx: Scope) -> Element { - let events = use_ref(&cx, || Vec::new()); + let events = use_ref(&cx, Vec::new); let events_lock = events.read(); let first_index = events_lock.len().saturating_sub(MAX_EVENTS); diff --git a/packages/autofmt/tests/sample.rs b/packages/autofmt/tests/sample.rs index 6b6b7d244..83b9c4831 100644 --- a/packages/autofmt/tests/sample.rs +++ b/packages/autofmt/tests/sample.rs @@ -1,3 +1,5 @@ +#![allow(unused)] + const SRC: &str = include_str!("./samples/all.rs"); fn body() -> &'static str { diff --git a/packages/core-macro/tests/ifmt.rs b/packages/core-macro/tests/ifmt.rs index 52ac347b3..62cbe8217 100644 --- a/packages/core-macro/tests/ifmt.rs +++ b/packages/core-macro/tests/ifmt.rs @@ -8,22 +8,19 @@ fn formatting_compiles() { // escape sequences work assert_eq!( format_args_f!("{x:?} {{}}}}").to_string(), - format!("{:?} {{}}}}", x).to_string() + format!("{:?} {{}}}}", x) ); assert_eq!( format_args_f!("{{{{}} {x:?}").to_string(), - format!("{{{{}} {:?}", x).to_string() + format!("{{{{}} {:?}", x) ); // paths in formating works - assert_eq!( - format_args_f!("{x.0}").to_string(), - format!("{}", x.0).to_string() - ); + assert_eq!(format_args_f!("{x.0}").to_string(), format!("{}", x.0)); // function calls in formatings work assert_eq!( format_args_f!("{x.borrow():?}").to_string(), - format!("{:?}", x.borrow()).to_string() + format!("{:?}", x.borrow()) ); } diff --git a/packages/fermi/src/hooks/read.rs b/packages/fermi/src/hooks/read.rs index b231c74d3..9b66d7bc6 100644 --- a/packages/fermi/src/hooks/read.rs +++ b/packages/fermi/src/hooks/read.rs @@ -2,11 +2,11 @@ use crate::{use_atom_root, AtomId, AtomRoot, Readable}; use dioxus_core::{ScopeId, ScopeState}; use std::rc::Rc; -pub fn use_read<'a, V: 'static>(cx: &'a ScopeState, f: impl Readable) -> &'a V { +pub fn use_read(cx: &ScopeState, f: impl Readable) -> &V { use_read_rc(cx, f).as_ref() } -pub fn use_read_rc<'a, V: 'static>(cx: &'a ScopeState, f: impl Readable) -> &'a Rc { +pub fn use_read_rc(cx: &ScopeState, f: impl Readable) -> &Rc { let root = use_atom_root(cx); struct UseReadInner { diff --git a/packages/fermi/src/hooks/set.rs b/packages/fermi/src/hooks/set.rs index 6d77fbf8c..fa1db9129 100644 --- a/packages/fermi/src/hooks/set.rs +++ b/packages/fermi/src/hooks/set.rs @@ -2,7 +2,7 @@ use crate::{use_atom_root, Writable}; use dioxus_core::ScopeState; use std::rc::Rc; -pub fn use_set<'a, T: 'static>(cx: &'a ScopeState, f: impl Writable) -> &'a Rc { +pub fn use_set(cx: &ScopeState, f: impl Writable) -> &Rc { let root = use_atom_root(cx); cx.use_hook(|_| { let id = f.unique_id(); diff --git a/packages/fermi/src/hooks/state.rs b/packages/fermi/src/hooks/state.rs index 9db9a9fdf..b698bb3c3 100644 --- a/packages/fermi/src/hooks/state.rs +++ b/packages/fermi/src/hooks/state.rs @@ -30,7 +30,7 @@ use std::{ /// )) /// } /// ``` -pub fn use_atom_state<'a, T: 'static>(cx: &'a ScopeState, f: impl Writable) -> &'a AtomState { +pub fn use_atom_state(cx: &ScopeState, f: impl Writable) -> &AtomState { let root = crate::use_atom_root(cx); let inner = cx.use_hook(|_| AtomState { @@ -279,13 +279,13 @@ impl Clone for AtomState { } } -impl<'a, T: 'static + Display> std::fmt::Display for AtomState { +impl std::fmt::Display for AtomState { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.value.as_ref().unwrap()) } } -impl<'a, T: std::fmt::Binary> std::fmt::Binary for AtomState { +impl std::fmt::Binary for AtomState { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:b}", self.value.as_ref().unwrap().as_ref()) } @@ -316,7 +316,7 @@ impl Debug for AtomState { } } -impl<'a, T> std::ops::Deref for AtomState { +impl std::ops::Deref for AtomState { type Target = T; fn deref(&self) -> &Self::Target { diff --git a/packages/rsx_interpreter/src/captuered_context.rs b/packages/rsx_interpreter/src/captuered_context.rs index e05957787..af205749b 100644 --- a/packages/rsx_interpreter/src/captuered_context.rs +++ b/packages/rsx_interpreter/src/captuered_context.rs @@ -124,9 +124,9 @@ impl ToTokens for CapturedContextBuilder { let expr = segment.to_token_stream(); let as_string = expr.to_string(); let format_expr = if format_args.is_empty() { - "{".to_string() + &format_args + "}" + "{".to_string() + format_args + "}" } else { - "{".to_string() + ":" + &format_args + "}" + "{".to_string() + ":" + format_args + "}" }; Some(quote! { FormattedArg{ diff --git a/packages/rsx_interpreter/src/error.rs b/packages/rsx_interpreter/src/error.rs index d2ec06b8d..84cc69294 100644 --- a/packages/rsx_interpreter/src/error.rs +++ b/packages/rsx_interpreter/src/error.rs @@ -44,13 +44,13 @@ impl ParseError { impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Error::ParseError(error) => write!( + Error::ParseError(error) => writeln!( f, - "parse error:\n--> at {}:{}:{}\n\t{:?}\n", + "parse error:\n--> at {}:{}:{}\n\t{:?}", error.location.file_path, error.location.line, error.location.column, error.message ), Error::RecompileRequiredError(reason) => { - write!(f, "recompile required: {:?}\n", reason) + writeln!(f, "recompile required: {:?}", reason) } } } diff --git a/packages/rsx_interpreter/src/interperter.rs b/packages/rsx_interpreter/src/interperter.rs index e143fa907..b9c1e0cd9 100644 --- a/packages/rsx_interpreter/src/interperter.rs +++ b/packages/rsx_interpreter/src/interperter.rs @@ -38,7 +38,7 @@ fn resolve_ifmt(ifmt: &IfmtInput, captured: &IfmtArgs) -> Result } } } - Segment::Literal(lit) => result.push_str(&lit), + Segment::Literal(lit) => result.push_str(lit), } } Ok(result) @@ -119,21 +119,16 @@ fn build_node<'a>( is_volatile: false, namespace, }); + } else if literal { + // literals will be captured when a full recompile is triggered + return Err(Error::RecompileRequiredError( + RecompileReason::CapturedAttribute(name.to_string()), + )); } else { - if literal { - // literals will be captured when a full recompile is triggered - return Err(Error::RecompileRequiredError( - RecompileReason::CapturedAttribute(name.to_string()), - )); - } else { - return Err(Error::ParseError(ParseError::new( - syn::Error::new( - span, - format!("unknown attribute: {}", name), - ), - ctx.location.clone(), - ))); - } + return Err(Error::ParseError(ParseError::new( + syn::Error::new(span, format!("unknown attribute: {}", name)), + ctx.location.clone(), + ))); } } @@ -164,21 +159,19 @@ fn build_node<'a>( is_volatile: false, namespace, }); + } else if literal { + // literals will be captured when a full recompile is triggered + return Err(Error::RecompileRequiredError( + RecompileReason::CapturedAttribute(name.to_string()), + )); } else { - if literal { - // literals will be captured when a full recompile is triggered - return Err(Error::RecompileRequiredError( - RecompileReason::CapturedAttribute(name.to_string()), - )); - } else { - return Err(Error::ParseError(ParseError::new( - syn::Error::new( - span, - format!("unknown attribute: {}", name), - ), - ctx.location.clone(), - ))); - } + return Err(Error::ParseError(ParseError::new( + syn::Error::new( + span, + format!("unknown attribute: {}", name), + ), + ctx.location.clone(), + ))); } } } diff --git a/packages/rsx_interpreter/src/lib.rs b/packages/rsx_interpreter/src/lib.rs index b5e596865..0c88a25cc 100644 --- a/packages/rsx_interpreter/src/lib.rs +++ b/packages/rsx_interpreter/src/lib.rs @@ -65,7 +65,7 @@ pub fn resolve_scope<'a>( } } -fn interpert_rsx<'a, 'b>( +fn interpert_rsx<'a>( factory: dioxus_core::NodeFactory<'a>, text: &str, context: captuered_context::CapturedContext<'a>,