Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
makspll committed Sep 7, 2024
1 parent 897497b commit 3dedf87
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 18 deletions.
4 changes: 3 additions & 1 deletion crates/bevy_api_gen/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
};
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_mod_scripting_common/src/input.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -537,6 +539,8 @@ impl VisitSimpleType<Type> 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,
Expand Down
7 changes: 6 additions & 1 deletion crates/languages/bevy_mod_scripting_lua/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Asset, Self::Error>> {
) -> impl bevy::utils::ConditionalSendFuture<
Output = std::result::Result<
<Self as bevy::asset::AssetLoader>::Asset,
<Self as bevy::asset::AssetLoader>::Error,
>,
> {
bevy::prelude::info!("lua loader invoked: {:#}", load_context.asset_path());
Box::pin(async move {
let mut bytes = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/languages/bevy_mod_scripting_lua_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions crates/languages/bevy_mod_scripting_lua_derive/src/arg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::manual_unwrap_or_default)] // from darling

use std::collections::HashMap;

use bevy_mod_scripting_common::input::{SimpleType, VisitSimpleType};
Expand All @@ -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<Mut>,
/// the type of the argument, only suported patterns are allowed
pub name: Ident,
Expand All @@ -32,14 +34,14 @@ pub struct Arg {

impl Arg {
pub fn new(
attrs: ArgAttributes,
// attrs: ArgAttributes,
name: Ident,
mutability: Option<Mut>,
type_: SimpleType,
is_raw: bool,
) -> Self {
Self {
attrs,
// attrs,
mutability,
span: name.span(),
name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::manual_unwrap_or_default)] // from darling

use bevy_mod_scripting_common::input::{
DuoPath, IdentifierRenamingVisitor, Reference, SimpleType, VisitSimpleType,
};
Expand Down Expand Up @@ -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<Function>,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/languages/bevy_mod_scripting_lua_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ fn extract_composite_functions(functions: &mut Vec<Function>) -> Vec<CompositeFu
}

composites
.into_iter()
.map(|(id, functions)| CompositeFunction { id, functions })
.into_values()
.map(|functions| CompositeFunction { functions })
.collect()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ impl Signature {
FnArg::Receiver(ref receiver) => {
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_,
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Signature {
};

Ok(Arg::new(
attrs,
// attrs,
arg_name,
mutability,
type_,
Expand Down
7 changes: 6 additions & 1 deletion crates/languages/bevy_mod_scripting_rune/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Asset, Self::Error>> {
) -> impl bevy::utils::ConditionalSendFuture<
Output = std::result::Result<
<Self as bevy::asset::AssetLoader>::Asset,
<Self as bevy::asset::AssetLoader>::Error,
>,
> {
Box::pin(async move {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
Expand Down
4 changes: 2 additions & 2 deletions examples/lua/console_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl APIProvider for LuaAPIProvider {

let mut events: Mut<Events<PrintConsoleLine>> =
world.get_resource_mut().unwrap();
events.send(PrintConsoleLine { line: msg.into() });
events.send(PrintConsoleLine { line: msg });

// return something
Ok(())
Expand Down Expand Up @@ -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),
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/rhai/console_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl APIProvider for RhaiAPI {
let mut world = world.write();

let mut events: Mut<Events<PrintConsoleLine>> = world.get_resource_mut().unwrap();
events.send(PrintConsoleLine { line: msg.into() });
events.send(PrintConsoleLine { line: msg });
},
);

Expand Down Expand Up @@ -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),
});
}
}
Expand Down

0 comments on commit 3dedf87

Please sign in to comment.