mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
clippy on azalea-ecs-macros
This commit is contained in:
parent
27fce90682
commit
d4c8707e64
4 changed files with 10 additions and 15 deletions
|
@ -88,8 +88,7 @@ fn parse_component_attr(ast: &DeriveInput) -> Result<Attrs> {
|
||||||
return Err(Error::new_spanned(
|
return Err(Error::new_spanned(
|
||||||
m.lit,
|
m.lit,
|
||||||
format!(
|
format!(
|
||||||
"Invalid storage type `{}`, expected '{}' or '{}'.",
|
"Invalid storage type `{s}`, expected '{TABLE}' or '{SPARSE_SET}'."
|
||||||
s, TABLE, SPARSE_SET
|
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
||||||
fetch_struct_attributes.is_mutable = true;
|
fetch_struct_attributes.is_mutable = true;
|
||||||
} else {
|
} else {
|
||||||
panic!(
|
panic!(
|
||||||
"The `{}` attribute is expected to have no value or arguments",
|
"The `{MUTABLE_ATTRIBUTE_NAME}` attribute is expected to have no value or arguments"
|
||||||
MUTABLE_ATTRIBUTE_NAME
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if ident == DERIVE_ATTRIBUTE_NAME {
|
} else if ident == DERIVE_ATTRIBUTE_NAME {
|
||||||
|
@ -63,8 +62,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
||||||
.extend(meta_list.nested.iter().cloned());
|
.extend(meta_list.nested.iter().cloned());
|
||||||
} else {
|
} else {
|
||||||
panic!(
|
panic!(
|
||||||
"Expected a structured list within the `{}` attribute",
|
"Expected a structured list within the `{DERIVE_ATTRIBUTE_NAME}` attribute"
|
||||||
DERIVE_ATTRIBUTE_NAME
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,8 +27,7 @@ pub fn get_lit_str(attr_name: Symbol, lit: &syn::Lit) -> syn::Result<&syn::LitSt
|
||||||
Err(syn::Error::new_spanned(
|
Err(syn::Error::new_spanned(
|
||||||
lit,
|
lit,
|
||||||
format!(
|
format!(
|
||||||
"expected {} attribute to be a string: `{} = \"...\"`",
|
"expected {attr_name} attribute to be a string: `{attr_name} = \"...\"`"
|
||||||
attr_name, attr_name
|
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -41,8 +40,7 @@ pub fn get_lit_bool(attr_name: Symbol, lit: &syn::Lit) -> syn::Result<bool> {
|
||||||
Err(syn::Error::new_spanned(
|
Err(syn::Error::new_spanned(
|
||||||
lit,
|
lit,
|
||||||
format!(
|
format!(
|
||||||
"expected {} attribute to be a bool value, `true` or `false`: `{} = ...`",
|
"expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`"
|
||||||
attr_name, attr_name
|
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,13 +354,13 @@ mod tests {
|
||||||
))
|
))
|
||||||
.id();
|
.id();
|
||||||
{
|
{
|
||||||
let entity_pos = app.world.get::<Position>(entity).unwrap().clone();
|
let entity_pos = *app.world.get::<Position>(entity).unwrap();
|
||||||
// y should start at 70
|
// y should start at 70
|
||||||
assert_eq!(entity_pos.y, 70.);
|
assert_eq!(entity_pos.y, 70.);
|
||||||
}
|
}
|
||||||
app.update();
|
app.update();
|
||||||
{
|
{
|
||||||
let entity_pos = app.world.get::<Position>(entity).unwrap().clone();
|
let entity_pos = *app.world.get::<Position>(entity).unwrap();
|
||||||
// delta is applied before gravity, so the first tick only sets the delta
|
// delta is applied before gravity, so the first tick only sets the delta
|
||||||
assert_eq!(entity_pos.y, 70.);
|
assert_eq!(entity_pos.y, 70.);
|
||||||
let entity_physics = app.world.get::<Physics>(entity).unwrap().clone();
|
let entity_physics = app.world.get::<Physics>(entity).unwrap().clone();
|
||||||
|
@ -368,7 +368,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
app.update();
|
app.update();
|
||||||
{
|
{
|
||||||
let entity_pos = app.world.get::<Position>(entity).unwrap().clone();
|
let entity_pos = *app.world.get::<Position>(entity).unwrap();
|
||||||
// the second tick applies the delta to the position, so now it should go down
|
// the second tick applies the delta to the position, so now it should go down
|
||||||
assert!(
|
assert!(
|
||||||
entity_pos.y < 70.,
|
entity_pos.y < 70.,
|
||||||
|
@ -420,7 +420,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
app.update();
|
app.update();
|
||||||
{
|
{
|
||||||
let entity_pos = app.world.get::<Position>(entity).unwrap().clone();
|
let entity_pos = *app.world.get::<Position>(entity).unwrap();
|
||||||
// delta will change, but it won't move until next tick
|
// delta will change, but it won't move until next tick
|
||||||
assert_eq!(entity_pos.y, 70.);
|
assert_eq!(entity_pos.y, 70.);
|
||||||
let entity_physics = app.world.get::<Physics>(entity).unwrap().clone();
|
let entity_physics = app.world.get::<Physics>(entity).unwrap().clone();
|
||||||
|
@ -428,7 +428,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
app.update();
|
app.update();
|
||||||
{
|
{
|
||||||
let entity_pos = app.world.get::<Position>(entity).unwrap().clone();
|
let entity_pos = *app.world.get::<Position>(entity).unwrap();
|
||||||
// the second tick applies the delta to the position, but it also does collision
|
// the second tick applies the delta to the position, but it also does collision
|
||||||
assert_eq!(entity_pos.y, 70.);
|
assert_eq!(entity_pos.y, 70.);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue