diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml new file mode 100644 index 0000000000..0c2656f946 --- /dev/null +++ b/.github/workflows/autofix.yml @@ -0,0 +1,48 @@ +name: autofix.ci +on: + workflow_call: + pull_request: + push: + branches: ["main"] +permissions: + contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 +jobs: + autofix: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: {toolchain: nightly, components: "rustfmt, clippy", target: "wasm32-unknown-unknown", rustflags: ""} + - name: Install jq + run: sudo apt-get install jq + - run: | + echo "Formatting the workspace" + cargo fmt --all + + echo "Running Clippy against each member's features (default features included)" + for member in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | .name'); do + echo "Working on member $member": + echo -e "\tdefault-features/no-features:" + # this will also run on members with no features or default features + cargo clippy --allow-dirty --fix --lib --package "$member" + + features=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[] | select(.name == \"$member\") | .features | keys[]") + for feature in $features; do + if [ "$feature" = "default" ]; then + continue + fi + echo -e "\tfeature $feature" + cargo clippy --allow-dirty --fix --lib --package "$member" --features "$feature" + done + done + - uses: autofix-ci/action@v1.3.1 + if: ${{ always() }} + with: + fail-fast: false diff --git a/leptos/src/callback.rs b/leptos/src/callback.rs index 332ff6853f..8444c71558 100644 --- a/leptos/src/callback.rs +++ b/leptos/src/callback.rs @@ -223,14 +223,14 @@ mod tests { #[test] fn clone_callback() { let callback = Callback::new(move |_no_clone: NoClone| NoClone {}); - let _cloned = callback.clone(); + let _cloned = callback; } #[test] fn clone_unsync_callback() { let callback = UnsyncCallback::new(move |_no_clone: NoClone| NoClone {}); - let _cloned = callback.clone(); + let _cloned = callback; } #[test] diff --git a/leptos_config/src/tests.rs b/leptos_config/src/tests.rs index 21d3ddfc98..9648f0098d 100644 --- a/leptos_config/src/tests.rs +++ b/leptos_config/src/tests.rs @@ -30,14 +30,14 @@ fn ws_from_str_test() { #[test] fn env_w_default_test() { - _ = temp_env::with_var("LEPTOS_CONFIG_ENV_TEST", Some("custom"), || { + temp_env::with_var("LEPTOS_CONFIG_ENV_TEST", Some("custom"), || { assert_eq!( env_w_default("LEPTOS_CONFIG_ENV_TEST", "default").unwrap(), String::from("custom") ); }); - _ = temp_env::with_var_unset("LEPTOS_CONFIG_ENV_TEST", || { + temp_env::with_var_unset("LEPTOS_CONFIG_ENV_TEST", || { assert_eq!( env_w_default("LEPTOS_CONFIG_ENV_TEST", "default").unwrap(), String::from("default") @@ -47,14 +47,14 @@ fn env_w_default_test() { #[test] fn env_wo_default_test() { - _ = temp_env::with_var("LEPTOS_CONFIG_ENV_TEST", Some("custom"), || { + temp_env::with_var("LEPTOS_CONFIG_ENV_TEST", Some("custom"), || { assert_eq!( env_wo_default("LEPTOS_CONFIG_ENV_TEST").unwrap(), Some(String::from("custom")) ); }); - _ = temp_env::with_var_unset("LEPTOS_CONFIG_ENV_TEST", || { + temp_env::with_var_unset("LEPTOS_CONFIG_ENV_TEST", || { assert_eq!(env_wo_default("LEPTOS_CONFIG_ENV_TEST").unwrap(), None); }); } diff --git a/leptos_macro/src/view/mod.rs b/leptos_macro/src/view/mod.rs index d3bf8b49b4..84ca852a24 100644 --- a/leptos_macro/src/view/mod.rs +++ b/leptos_macro/src/view/mod.rs @@ -197,7 +197,7 @@ enum InertElementBuilder<'a> { }, } -impl<'a> ToTokens for InertElementBuilder<'a> { +impl ToTokens for InertElementBuilder<'_> { fn to_tokens(&self, tokens: &mut TokenStream) { match self { InertElementBuilder::GlobalClass { strs, .. } => { @@ -219,7 +219,7 @@ enum GlobalClassItem<'a> { String(String), } -impl<'a> ToTokens for GlobalClassItem<'a> { +impl ToTokens for GlobalClassItem<'_> { fn to_tokens(&self, tokens: &mut TokenStream) { let addl_tokens = match self { GlobalClassItem::Global(v) => v.to_token_stream(), diff --git a/oco/src/lib.rs b/oco/src/lib.rs index 97bc595252..549142db3f 100644 --- a/oco/src/lib.rs +++ b/oco/src/lib.rs @@ -70,7 +70,7 @@ pub enum Oco<'a, T: ?Sized + ToOwned + 'a> { Owned(::Owned), } -impl<'a, T: ?Sized + ToOwned> Oco<'a, T> { +impl Oco<'_, T> { /// Converts the value into an owned value. pub fn into_owned(self) -> ::Owned { match self { @@ -339,7 +339,7 @@ where } } -impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq> for Oco<'a, A> +impl<'b, A: ?Sized, B: ?Sized> PartialEq> for Oco<'_, A> where A: PartialEq, A: ToOwned, @@ -352,7 +352,7 @@ where impl Eq for Oco<'_, T> {} -impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd> for Oco<'a, A> +impl<'b, A: ?Sized, B: ?Sized> PartialOrd> for Oco<'_, A> where A: PartialOrd, A: ToOwned, @@ -551,7 +551,7 @@ impl_slice_eq!(['a, 'b, T: PartialEq] (where [T]: ToOwned), Oco<'a, [T]>, &'b [T impl_slice_eq!([T: PartialEq] (where [T]: ToOwned), Oco<'_, [T]>, Vec); impl_slice_eq!(['a, 'b, T: PartialEq] (where [T]: ToOwned), Oco<'a, [T]>, Cow<'b, [T]>); -impl<'a, 'b> Add<&'b str> for Oco<'a, str> { +impl<'b> Add<&'b str> for Oco<'_, str> { type Output = Oco<'static, str>; fn add(self, rhs: &'b str) -> Self::Output { @@ -559,7 +559,7 @@ impl<'a, 'b> Add<&'b str> for Oco<'a, str> { } } -impl<'a, 'b> Add> for Oco<'a, str> { +impl<'b> Add> for Oco<'_, str> { type Output = Oco<'static, str>; fn add(self, rhs: Cow<'b, str>) -> Self::Output { @@ -567,7 +567,7 @@ impl<'a, 'b> Add> for Oco<'a, str> { } } -impl<'a, 'b> Add> for Oco<'a, str> { +impl<'b> Add> for Oco<'_, str> { type Output = Oco<'static, str>; fn add(self, rhs: Oco<'b, str>) -> Self::Output { diff --git a/router/src/ssr_mode.rs b/router/src/ssr_mode.rs index 37a6d8e4e6..37dece75d0 100644 --- a/router/src/ssr_mode.rs +++ b/router/src/ssr_mode.rs @@ -44,8 +44,8 @@ pub enum SsrMode { /// of the page will not be interactive until the suspended chunks have loaded. InOrder, /// **`Async`**: Load all resources on the server. Wait until all data are loaded, and render HTML in one sweep. - /// - *Pros*: Better handling for meta tags (because you know async data even before you render the ``). Faster complete load than **synchronous** because async resources begin loading on server. - /// - *Cons*: Slower load time/TTFB: you need to wait for all async resources to load before displaying anything on the client. + /// - *Pros*: Better handling for meta tags (because you know async data even before you render the ``). Faster complete load than **synchronous** because async resources begin loading on server. + /// - *Cons*: Slower load time/TTFB: you need to wait for all async resources to load before displaying anything on the client. Async, /// **`Static`**: Renders the page when the server starts up, or incrementally, using the /// configuration provided by a [`StaticRoute`]. diff --git a/tachys/src/html/class.rs b/tachys/src/html/class.rs index 09daa2f3a5..73040774c6 100644 --- a/tachys/src/html/class.rs +++ b/tachys/src/html/class.rs @@ -267,7 +267,7 @@ impl IntoClass for Option { } } -impl<'a> IntoClass for &'a str { +impl IntoClass for &str { type AsyncOutput = Self; type State = (crate::renderer::types::Element, Self); type Cloneable = Self; diff --git a/tachys/src/html/element/inner_html.rs b/tachys/src/html/element/inner_html.rs index dfb9fcd690..f4d05ec22e 100644 --- a/tachys/src/html/element/inner_html.rs +++ b/tachys/src/html/element/inner_html.rs @@ -308,7 +308,7 @@ impl InnerHtmlValue for Arc { } } -impl<'a> InnerHtmlValue for &'a str { +impl InnerHtmlValue for &str { type AsyncOutput = Self; type State = (crate::renderer::types::Element, Self); type Cloneable = Self; diff --git a/tachys/src/html/style.rs b/tachys/src/html/style.rs index a0125c2c84..4e80d75c36 100644 --- a/tachys/src/html/style.rs +++ b/tachys/src/html/style.rs @@ -606,7 +606,7 @@ impl<'a> IntoStyle for (&'a str, String) { } #[cfg(feature = "nightly")] -impl<'a, const V: &'static str> IntoStyle for (&'a str, Static) { +impl IntoStyle for (&str, Static) { type AsyncOutput = Self; type State = (); type Cloneable = (Arc, Static); diff --git a/tachys/src/renderer/mod.rs b/tachys/src/renderer/mod.rs index 2d643d7f63..84dd5df9e3 100644 --- a/tachys/src/renderer/mod.rs +++ b/tachys/src/renderer/mod.rs @@ -209,7 +209,6 @@ pub trait DomRenderer: Renderer { /// This works in a similar way to `TryFrom`. We implement it as a separate trait /// simply so we don't have to create wrappers for the `web_sys` types; it can't be /// implemented on them directly because of the orphan rules. - pub trait CastFrom where Self: Sized, diff --git a/tachys/src/view/mod.rs b/tachys/src/view/mod.rs index 61651d1e71..4d3ae8d0b3 100644 --- a/tachys/src/view/mod.rs +++ b/tachys/src/view/mod.rs @@ -197,7 +197,6 @@ where /// Renders a view to an out-of-order stream of HTML with branch markers. This can be used to support libraries that diff /// HTML pages against one another, by marking sections of the view that branch to different /// types with marker comments. - fn to_html_stream_out_of_order_branching(self) -> StreamBuilder where Self: Sized, diff --git a/tachys/src/view/strings.rs b/tachys/src/view/strings.rs index 743902a762..902e4bbf73 100644 --- a/tachys/src/view/strings.rs +++ b/tachys/src/view/strings.rs @@ -36,7 +36,7 @@ impl<'a> Render for &'a str { } } -impl<'a> RenderHtml for &'a str { +impl RenderHtml for &str { type AsyncOutput = Self; const MIN_LENGTH: usize = 0; @@ -102,7 +102,7 @@ impl<'a> RenderHtml for &'a str { } } -impl<'a> ToTemplate for &'a str { +impl ToTemplate for &str { const TEMPLATE: &'static str = " "; fn to_template( @@ -120,7 +120,7 @@ impl<'a> ToTemplate for &'a str { } } -impl<'a> Mountable for StrState<'a> { +impl Mountable for StrState<'_> { fn unmount(&mut self) { self.node.unmount() } @@ -451,7 +451,7 @@ impl<'a> Render for Cow<'a, str> { } } -impl<'a> RenderHtml for Cow<'a, str> { +impl RenderHtml for Cow<'_, str> { type AsyncOutput = Self; const MIN_LENGTH: usize = 0; @@ -494,7 +494,7 @@ impl<'a> RenderHtml for Cow<'a, str> { } } -impl<'a> ToTemplate for Cow<'a, str> { +impl ToTemplate for Cow<'_, str> { const TEMPLATE: &'static str = <&str as ToTemplate>::TEMPLATE; fn to_template( @@ -510,7 +510,7 @@ impl<'a> ToTemplate for Cow<'a, str> { } } -impl<'a> Mountable for CowStrState<'a> { +impl Mountable for CowStrState<'_> { fn unmount(&mut self) { self.node.unmount() }