Skip to content

Commit

Permalink
formatting and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
makspll committed Apr 3, 2024
1 parent 075dca8 commit 35d6443
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 112 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
use bevy_api_gen::*;
use cargo_metadata::camino::Utf8Path;
use clap::Parser;
use log::{debug, info, trace};
use log::{debug, info};
use strum::VariantNames;
use tera::Context;

Expand Down
11 changes: 4 additions & 7 deletions crates/bevy_api_gen/src/passes/find_trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ use std::collections::HashMap;
use log::trace;
use rustc_hir::def_id::DefId;
use rustc_infer::{
infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, TyCtxtInferExt},
traits::{Obligation, ObligationCause, PolyTraitObligation},
infer::{InferCtxt, TyCtxtInferExt},
traits::{Obligation, ObligationCause},
};
use rustc_middle::ty::{Binder, ClauseKind, ImplPolarity, PolyTraitPredicate, TraitPredicate, Ty};
use rustc_middle::ty::Ty;
use rustc_span::DUMMY_SP;
use rustc_trait_selection::{
infer::InferCtxtExt,
traits::{elaborate, ObligationCtxt},
};
use rustc_trait_selection::traits::ObligationCtxt;

use crate::{Args, BevyCtxt};

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_api_gen/templates/header.tera
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::all, unused_imports, deprecated, dead_code)]
#![allow(clippy::all, unused_imports, deprecated, dead_code, unused_variables)]
#![cfg_attr(rustfmt, rustfmt_skip)]
// @generated by cargo bevy-api-gen generate, modify the templates not this file

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_mod_scripting_common/src/input.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use darling::{util::Flag, FromDeriveInput, FromMeta};
use proc_macro2::Ident;
use quote::{format_ident, ToTokens};
use quote::format_ident;
use std::{
collections::HashMap,
ops::{Deref, DerefMut},
Expand Down
98 changes: 0 additions & 98 deletions crates/bevy_mod_scripting_common/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,101 +1,3 @@
/// Utility for parsing enums based on the variant identifier first
macro_rules! impl_parse_enum {
(
$input_stream:ident,$parsed_ident:ident:
$($(#[$($meta:meta)*])+)?
$vis:vis enum $name:ident {
$(
$($(#[$($meta_inner:meta)*])+)?
$field:ident $(
{
$(
$arg_name:ident : $arg_type:ty
),*
}

)? => {$($parser:tt)*}
),*
$(,)?
}

$(
impl $_:ident {
$($other_impls:tt)*
}
)?
) => {
$($(#[$($meta)*])+)?
$vis enum $name {
$(
$($(#[$($meta_inner)*])+)?
$field {
/// The identifier of the enum variant
ident: syn::Ident,
$(
$(
$arg_name : $arg_type
),*
)?
}
),*

}
#[allow(clippy::mixed_read_write_in_expression)]
impl Parse for $name {
fn parse($input_stream: ParseStream) -> Result<Self,syn::Error> {
let $parsed_ident : syn::Ident = $input_stream.parse()?;

match $parsed_ident.to_string().as_str() {
$(
stringify!($field) => {$($parser)*},
)*
_ => Err(syn::Error::new_spanned($parsed_ident, format!("Invalid derive flag, try one of [{}]",Self::variants()))),
}
}
}

impl ToTokens for $name {
fn to_tokens(&self, ts: &mut proc_macro2::TokenStream) {
let ident = syn::Ident::new(self.to_str(),Span::call_site());
ts.extend(quote::quote_spanned!{syn::spanned::Spanned::span(ts)=> #ident});
}
}

#[allow(unused_variables)]
impl $name {
paste::paste!{
$($($other_impls)*)?

pub fn variants() -> &'static str{
concat!($(
stringify!($field),","
),*
)
}

pub fn to_str(&self) -> &'static str {
match self {
$(
Self::$field{ident,$($($arg_name),*)?} => stringify!($field)
),*
}
}

$(
pub fn [<is_ $field:snake>](&self) -> bool{
if let Self::$field{ident,$($($arg_name),*)?} = self{
return true
} else {
return false
}
}
)*
}

}
};
}

use proc_macro2::{Ident, TokenStream};
use quote::ToTokens;
use syn::{
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_mod_scripting_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use proc_macro::TokenStream;

use quote::ToTokens;
use syn::{parse::Parse, spanned::Spanned, Attribute};
use syn::{parse::Parse, Attribute};

/// A convenience macro which derives a lotta things to make your type work in all supported/enabled scripting languages, and provide static typing where possible.
///
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_script_api/src/providers/bevy_core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::all, unused_imports, deprecated, dead_code)]
#![allow(clippy::all, unused_imports, deprecated, dead_code, unused_variables)]
#![cfg_attr(rustfmt, rustfmt_skip)]
use super::bevy_ecs::*;
use super::bevy_reflect::*;
Expand Down Expand Up @@ -46,7 +46,7 @@ impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
fn add_instances<
'lua,
T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>,
>(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> {
>(self, _instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> {
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lua/bevy_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy::app::AppExit;
use bevy::prelude::*;
use bevy_mod_scripting::prelude::*;

use bevy_script_api::{lua::RegisterForeignLuaType, prelude::*};
use bevy_script_api::{lua::RegisterForeignLuaType};

#[derive(Component, Default, Reflect)]
#[reflect(Component)]
Expand Down

0 comments on commit 35d6443

Please sign in to comment.