From 3dedf878ae30f96e5543d926c23b34e84b35be89 Mon Sep 17 00:00:00 2001 From: makspll Date: Sat, 7 Sep 2024 17:21:12 +0100 Subject: [PATCH] fix clippy warnings --- crates/bevy_api_gen/src/bin/main.rs | 4 +++- crates/bevy_api_gen/src/callback.rs | 2 +- crates/bevy_mod_scripting_common/src/input.rs | 4 ++++ crates/languages/bevy_mod_scripting_lua/src/assets.rs | 7 ++++++- crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml | 2 +- crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs | 8 +++++--- .../bevy_mod_scripting_lua_derive/src/function.rs | 3 ++- crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs | 4 ++-- .../bevy_mod_scripting_lua_derive/src/signature.rs | 6 +++--- crates/languages/bevy_mod_scripting_rune/src/assets.rs | 7 ++++++- examples/lua/console_integration.rs | 4 ++-- examples/rhai/console_integration.rs | 4 ++-- 12 files changed, 37 insertions(+), 18 deletions(-) diff --git a/crates/bevy_api_gen/src/bin/main.rs b/crates/bevy_api_gen/src/bin/main.rs index 62332e01..626e1169 100644 --- a/crates/bevy_api_gen/src/bin/main.rs +++ b/crates/bevy_api_gen/src/bin/main.rs @@ -308,8 +308,10 @@ fn find_bootstrap_dir() -> PathBuf { loop { if path.join("target").exists() { break; + } else if let Some(parent) = path.parent() { + path = parent.to_path_buf(); } else { - path = path.parent().unwrap().to_owned(); + panic!("Could not find `target` directory"); } } diff --git a/crates/bevy_api_gen/src/callback.rs b/crates/bevy_api_gen/src/callback.rs index 6174de20..a762ed76 100644 --- a/crates/bevy_api_gen/src/callback.rs +++ b/crates/bevy_api_gen/src/callback.rs @@ -42,7 +42,7 @@ impl rustc_driver::Callbacks for BevyAnalyzerCallbacks { .. } = &self.args.cmd { - templates_dir = templates.to_owned(); + templates.clone_into(&mut templates_dir); if let Some(meta_output) = meta_output { meta_dirs.push(meta_output.to_owned()) }; diff --git a/crates/bevy_mod_scripting_common/src/input.rs b/crates/bevy_mod_scripting_common/src/input.rs index 57aaac37..4ba284dd 100644 --- a/crates/bevy_mod_scripting_common/src/input.rs +++ b/crates/bevy_mod_scripting_common/src/input.rs @@ -1,3 +1,4 @@ +#![allow(clippy::manual_unwrap_or_default)] // from darling use darling::{util::Flag, FromDeriveInput, FromMeta}; use proc_macro2::Ident; use quote::format_ident; @@ -94,6 +95,7 @@ pub struct ProxyType { /// - Result /// - Vec /// - Tuple +/// /// This type helps us destructure these patterns and unwrap/wrap proxies fully without dealing with the full syn::Type enum #[derive(Debug, Clone)] pub enum SimpleType { @@ -537,6 +539,8 @@ impl VisitSimpleType for TypeConstructorVisitor { #[derive(FromDeriveInput)] #[darling(attributes(proxy), forward_attrs(allow, doc, cfg))] +#[allow(clippy::manual_unwrap_or_default)] + pub struct ProxyInput { /// The name of the type for which we are generating a proxy pub ident: syn::Ident, diff --git a/crates/languages/bevy_mod_scripting_lua/src/assets.rs b/crates/languages/bevy_mod_scripting_lua/src/assets.rs index 5deee1eb..2b87fcdf 100644 --- a/crates/languages/bevy_mod_scripting_lua/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_lua/src/assets.rs @@ -135,7 +135,12 @@ impl AssetLoader for LuaLoader { reader: &'a mut Reader, //bytes: &'a [u8], _settings: &'a (), load_context: &'a mut bevy::asset::LoadContext, - ) -> bevy::utils::BoxedFuture<'a, Result> { + ) -> impl bevy::utils::ConditionalSendFuture< + Output = std::result::Result< + ::Asset, + ::Error, + >, + > { bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path()); Box::pin(async move { let mut bytes = Vec::new(); diff --git a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml index 56104dd0..fbb92b2f 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml +++ b/crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml @@ -25,7 +25,7 @@ proc-macro = true [dependencies] bevy_mod_scripting_common = { path = "../../bevy_mod_scripting_common", version = "0.6.0" } paste = "1.0.7" -darling = "0.20.3" +darling = "0.20" syn = { version = "2.0.38", features = ["full", "fold", "extra-traits"] } quote = "1.0.8" proc-macro2 = "1.0" diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs index 9e0cd6d6..ece327f3 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_unwrap_or_default)] // from darling + use std::collections::HashMap; use bevy_mod_scripting_common::input::{SimpleType, VisitSimpleType}; @@ -18,7 +20,7 @@ pub struct ArgAttributes { /// Struct for holding argument/output information in functions passed via `functions[..]` meta #[derive(Debug)] pub struct Arg { - pub attrs: ArgAttributes, + // pub attrs: ArgAttributes, pub mutability: Option, /// the type of the argument, only suported patterns are allowed pub name: Ident, @@ -32,14 +34,14 @@ pub struct Arg { impl Arg { pub fn new( - attrs: ArgAttributes, + // attrs: ArgAttributes, name: Ident, mutability: Option, type_: SimpleType, is_raw: bool, ) -> Self { Self { - attrs, + // attrs, mutability, span: name.span(), name, diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs index 631f4216..29241a91 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/function.rs @@ -1,3 +1,5 @@ +#![allow(clippy::manual_unwrap_or_default)] // from darling + use bevy_mod_scripting_common::input::{ DuoPath, IdentifierRenamingVisitor, Reference, SimpleType, VisitSimpleType, }; @@ -125,7 +127,6 @@ pub struct FunctionAttributes { /// Useful for binary operators which can accept many types on both sides #[derive(Debug)] pub struct CompositeFunction { - pub id: String, pub functions: Vec1, } diff --git a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs index 439075b9..1b919e15 100644 --- a/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs +++ b/crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs @@ -109,8 +109,8 @@ fn extract_composite_functions(functions: &mut Vec) -> Vec { let type_ = SimpleType::new_from_fn_arg(PROXY_PREFIX, &arg, proxied_type_path, &type_map)?; - let attrs = ArgAttributes::from_attributes(&receiver.attrs)?; + // let attrs = ArgAttributes::from_attributes(&receiver.attrs)?; Arg::new( - attrs, + // attrs, Ident::new(SELF_ALIAS, receiver.span()), receiver.mutability, type_, @@ -133,7 +133,7 @@ impl Signature { }; Ok(Arg::new( - attrs, + // attrs, arg_name, mutability, type_, diff --git a/crates/languages/bevy_mod_scripting_rune/src/assets.rs b/crates/languages/bevy_mod_scripting_rune/src/assets.rs index 23be9f0f..e0527227 100644 --- a/crates/languages/bevy_mod_scripting_rune/src/assets.rs +++ b/crates/languages/bevy_mod_scripting_rune/src/assets.rs @@ -32,7 +32,12 @@ impl AssetLoader for RuneLoader { reader: &'a mut Reader, _settings: &'a (), _load_context: &'a mut bevy::asset::LoadContext, - ) -> bevy::utils::BoxedFuture<'a, Result> { + ) -> impl bevy::utils::ConditionalSendFuture< + Output = std::result::Result< + ::Asset, + ::Error, + >, + > { Box::pin(async move { let mut bytes = Vec::new(); reader.read_to_end(&mut bytes).await?; diff --git a/examples/lua/console_integration.rs b/examples/lua/console_integration.rs index 1b64efe3..ca1711d2 100644 --- a/examples/lua/console_integration.rs +++ b/examples/lua/console_integration.rs @@ -32,7 +32,7 @@ impl APIProvider for LuaAPIProvider { let mut events: Mut> = world.get_resource_mut().unwrap(); - events.send(PrintConsoleLine { line: msg.into() }); + events.send(PrintConsoleLine { line: msg }); // return something Ok(()) @@ -71,7 +71,7 @@ pub fn forward_script_err_to_console( ) { for e in r.read() { w.send(PrintConsoleLine { - line: format!("ERROR:{}", e.error).into(), + line: format!("ERROR:{}", e.error), }); } } diff --git a/examples/rhai/console_integration.rs b/examples/rhai/console_integration.rs index fdb13fda..caeef239 100644 --- a/examples/rhai/console_integration.rs +++ b/examples/rhai/console_integration.rs @@ -27,7 +27,7 @@ impl APIProvider for RhaiAPI { let mut world = world.write(); let mut events: Mut> = world.get_resource_mut().unwrap(); - events.send(PrintConsoleLine { line: msg.into() }); + events.send(PrintConsoleLine { line: msg }); }, ); @@ -63,7 +63,7 @@ pub fn forward_script_err_to_console( ) { for e in r.read() { w.send(PrintConsoleLine { - line: format!("ERROR:{}", e.error).into(), + line: format!("ERROR:{}", e.error), }); } }