Skip to content

Commit b011a37

Browse files
committed
messy rebase & ci
1 parent 37d5a1a commit b011a37

File tree

10 files changed

+30
-35
lines changed

10 files changed

+30
-35
lines changed

crates/bevy_asset/src/asset_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub struct AssetServerInternal {
9797
/// use bevy_asset::{AssetServer, Handle};
9898
/// use bevy_ecs::prelude::{Commands, Res};
9999
///
100-
/// # #[derive(Debug, bevy_reflect::TypeUuid)]
100+
/// # #[derive(Debug, bevy_reflect::TypeUuid, bevy_reflect::TypePath)]
101101
/// # #[uuid = "00000000-0000-0000-0000-000000000000"]
102102
/// # struct Image;
103103
///

crates/bevy_pbr/src/material.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ use std::marker::PhantomData;
5959
/// ```
6060
/// # use bevy_pbr::{Material, MaterialMeshBundle};
6161
/// # use bevy_ecs::prelude::*;
62-
/// # use bevy_reflect::TypeUuid;
62+
/// # use bevy_reflect::{TypeUuid, TypePath};
6363
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color};
6464
/// # use bevy_asset::{Handle, AssetServer, Assets};
6565
///
66-
/// #[derive(AsBindGroup, TypeUuid, Debug, Clone)]
66+
/// #[derive(AsBindGroup, TypeUuid, TypePath, Debug, Clone)]
6767
/// #[uuid = "f690fdae-d598-45ab-8225-97e2a3f056e0"]
6868
/// pub struct CustomMaterial {
6969
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to

crates/bevy_reflect/bevy_reflect_derive/src/derive_data.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<'a> ReflectDerive<'a> {
215215
}
216216
}
217217
if let Some(path) = &mut alias_type_path {
218-
let ident = alias_type_name.unwrap_or(input.ident.clone());
218+
let ident = alias_type_name.unwrap_or_else(|| input.ident.clone());
219219
path.segments.push(PathSegment::from(ident));
220220
} else if let Some(name) = alias_type_name {
221221
return Err(syn::Error::new(
@@ -273,9 +273,9 @@ impl<'a> ReflectDerive<'a> {
273273

274274
pub fn meta(&self) -> &ReflectMeta<'a> {
275275
match self {
276-
ReflectDerive::Struct(data) => data.meta(),
277-
ReflectDerive::TupleStruct(data) => data.meta(),
278-
ReflectDerive::UnitStruct(data) => data.meta(),
276+
ReflectDerive::Struct(data)
277+
| ReflectDerive::TupleStruct(data)
278+
| ReflectDerive::UnitStruct(data) => data.meta(),
279279
ReflectDerive::Enum(data) => data.meta(),
280280
ReflectDerive::Value(meta) => meta,
281281
}
@@ -486,15 +486,16 @@ pub(crate) enum PathToType<'a> {
486486
/// The type must be able to be named from just its name.
487487
///
488488
/// May have a seperate alias path used for the `TypePath` implementation.
489-
///
489+
///
490490
/// Module and crate are found with [`module_path!()`](core::module_path),
491491
/// if there is no alias specified.
492492
Internal {
493493
name: &'a Ident,
494494
alias: Option<Path>,
495495
},
496496
/// Any [`syn::Type`] with only a defined `type_path` and `short_type_path`.
497-
#[allow(dead_code)] // Not currently used but may be useful in the future due to its generality.
497+
#[allow(dead_code)]
498+
// Not currently used but may be useful in the future due to its generality.
498499
Anonymous {
499500
qualified_type: Type,
500501
long_type_path: proc_macro2::TokenStream,
@@ -542,8 +543,7 @@ impl<'a> PathToType<'a> {
542543
/// [external]: PathToType::External
543544
pub fn is_aliased(&self) -> bool {
544545
match self {
545-
Self::Internal { alias, .. } => alias.is_some(),
546-
Self::External { alias, .. } => alias.is_some(),
546+
Self::Internal { alias, .. } | Self::External { alias, .. } => alias.is_some(),
547547
_ => false,
548548
}
549549
}
@@ -553,10 +553,7 @@ impl<'a> PathToType<'a> {
553553
///
554554
/// This is false for primitives and anonymous paths.
555555
pub fn is_named(&self) -> bool {
556-
match self {
557-
Self::Primitive(_) | Self::Anonymous { .. } => false,
558-
_ => true,
559-
}
556+
matches!(self, Self::Internal { .. } | Self::External { .. })
560557
}
561558

562559
/// Returns an expression for an `AsRef<str>`.
@@ -629,7 +626,7 @@ impl<'a> PathToType<'a> {
629626

630627
/// Returns the name of the type. This is not necessarily a valid qualified path to the type.
631628
pub fn ident(&self) -> Option<&Ident> {
632-
self.named_as_ident().or_else(|| match self {
629+
self.named_as_ident().or(match self {
633630
Self::Primitive(ident) => Some(ident),
634631
_ => None,
635632
})
@@ -644,4 +641,4 @@ impl<'a> ToTokens for PathToType<'a> {
644641
Self::Anonymous { qualified_type, .. } => qualified_type.to_tokens(tokens),
645642
}
646643
}
647-
}
644+
}

crates/bevy_reflect/bevy_reflect_derive/src/impls/typed.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use quote::quote;
2-
use syn::{GenericParam, LitStr, spanned::Spanned};
2+
use syn::{spanned::Spanned, GenericParam, LitStr};
33

44
use crate::derive_data::{PathToType, ReflectMeta};
55

@@ -8,14 +8,14 @@ pub(crate) fn type_path_generator(meta: &ReflectMeta) -> proc_macro2::TokenStrea
88
let path_to_type = meta.path_to_type();
99
let generics = meta.generics();
1010
let bevy_reflect_path = meta.bevy_reflect_path();
11-
11+
1212
if let PathToType::Primitive(name) = path_to_type {
1313
let name = LitStr::new(&name.to_string(), name.span());
1414
return quote! {
1515
#bevy_reflect_path::utility::TypePathStorage::new_primitive(#name)
1616
};
1717
}
18-
18+
1919
// Whether to use `GenericTypedCell` is not dependent on lifetimes
2020
// (which all have to be 'static anyway).
2121
let is_generic = !generics

crates/bevy_reflect/bevy_reflect_derive/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub fn impl_reflect_value(input: TokenStream) -> TokenStream {
120120
let def = parse_macro_input!(input as ReflectValueDef);
121121

122122
let default_name = &def.type_path.segments.last().unwrap().ident;
123-
let path_to_type = if !def.type_path.leading_colon.is_some() && def.alias.is_empty() {
123+
let path_to_type = if def.type_path.leading_colon.is_none() && def.alias.is_empty() {
124124
PathToType::Primitive(default_name)
125125
} else {
126126
PathToType::External {
@@ -217,7 +217,7 @@ pub fn impl_from_reflect_value(input: TokenStream) -> TokenStream {
217217
let def = parse_macro_input!(input as ReflectValueDef);
218218

219219
let default_name = &def.type_path.segments.last().unwrap().ident;
220-
let path_to_type = if !def.type_path.leading_colon.is_some() && def.alias.is_empty() {
220+
let path_to_type = if def.type_path.leading_colon.is_none() && def.alias.is_empty() {
221221
PathToType::Primitive(default_name)
222222
} else {
223223
PathToType::External {

crates/bevy_reflect/src/impls/glam.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ impl_reflect_struct!(
5959
w: u32,
6060
}
6161
);
62-
6362
impl_reflect_struct!(
6463
#[reflect(Debug, PartialEq, Default)]
6564
#[type_path = "glam"]

crates/bevy_reflect/src/impls/std.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,19 +1133,19 @@ impl_type_path_stored!(|| TypePathStorage::new_named(
11331133
"core::borrow"
11341134
), impl for Cow<'static, str>);
11351135

1136-
impl GetTypeRegistration for Cow<'static, str>c Path {
1136+
impl GetTypeRegistration for Cow<'static, str> {
11371137
fn get_type_registration() -> TypeRegistration {
1138-
let mut registration = TypeRegistration:Cow<'static, str>>();
1138+
let mut registration = TypeRegistration::of::<Cow<'static, str>>();
11391139
registration.insert::<ReflectDeserialize>(FromType::<Cow<'static, str>>::from_type());
11401140
registration.insert::<ReflectFromPtr>(FromType::<Cow<'static, str>>::from_type());
11411141
registration.insert::<ReflectSerialize>(FromType::<Cow<'static, str>>::from_type());
11421142
registration
11431143
}
11441144
}
11451145

1146-
impl FromReflect for Cow<'static, str>c Path {
1146+
impl FromReflect for Cow<'static, str> {
11471147
fn from_reflect(reflect: &dyn crate::Reflect) -> Option<Self> {
1148-
Some(
1148+
Some(
11491149
reflect
11501150
.as_any()
11511151
.downcast_ref::<Cow<'static, str>>()?
@@ -1243,8 +1243,6 @@ impl Typed for &'static Path {
12431243

12441244
impl_type_path_stored!(|| TypePathStorage::new_anonymous("&std::path::Path", "&Path"), impl for &'static Path);
12451245

1246-
impl
1247-
12481246
impl GetTypeRegistration for &'static Path {
12491247
fn get_type_registration() -> TypeRegistration {
12501248
let mut registration = TypeRegistration::of::<Self>();
@@ -1475,4 +1473,5 @@ mod tests {
14751473
let path = Path::new("hello_world.rs");
14761474
let output = <&'static Path as FromReflect>::from_reflect(&path).unwrap();
14771475
assert_eq!(path, output);
1478-
1476+
}
1477+
}

crates/bevy_reflect/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ mod tests {
10221022
struct SomePrimitive;
10231023
impl_reflect_value!(
10241024
/// Some primitive for which we have attributed custom documentation.
1025-
SomePrimitive
1025+
SomePrimitive in bevy_reflect::tests
10261026
);
10271027

10281028
let info = <SomePrimitive as Typed>::type_info();

crates/bevy_sprite/src/mesh2d/material.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ use crate::{
6060
/// ```
6161
/// # use bevy_sprite::{Material2d, MaterialMesh2dBundle};
6262
/// # use bevy_ecs::prelude::*;
63-
/// # use bevy_reflect::TypeUuid;
63+
/// # use bevy_reflect::{TypeUuid, TypePath};
6464
/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color};
6565
/// # use bevy_asset::{Handle, AssetServer, Assets};
6666
///
67-
/// #[derive(AsBindGroup, TypeUuid, Debug, Clone)]
67+
/// #[derive(AsBindGroup, TypeUuid, TypePath, Debug, Clone)]
6868
/// #[uuid = "f690fdae-d598-45ab-8225-97e2a3f056e0"]
6969
/// pub struct CustomMaterial {
7070
/// // Uniform bindings must implement `ShaderType`, which will be used to convert the value to

examples/3d/skybox.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bevy::{
77
input::mouse::MouseMotion,
88
pbr::{MaterialPipeline, MaterialPipelineKey},
99
prelude::*,
10-
reflect::TypeUuid,
10+
reflect::{TypePath, TypeUuid},
1111
render::{
1212
mesh::MeshVertexBufferLayout,
1313
render_asset::RenderAssets,
@@ -196,7 +196,7 @@ fn animate_light_direction(
196196
}
197197
}
198198

199-
#[derive(Debug, Clone, TypeUuid)]
199+
#[derive(Debug, Clone, TypeUuid, TypePath)]
200200
#[uuid = "9509a0f8-3c05-48ee-a13e-a93226c7f488"]
201201
struct CubemapMaterial {
202202
base_color_texture: Option<Handle<Image>>,

0 commit comments

Comments
 (0)