Skip to content

Commit bd0b407

Browse files
committed
merge fixes
1 parent 469c927 commit bd0b407

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

crates/bevy_reflect/src/impls/std.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ impl_reflect_value!(isize(
8787
));
8888
impl_reflect_value!(f32(Debug, PartialEq, Serialize, Deserialize, Default));
8989
impl_reflect_value!(f64(Debug, PartialEq, Serialize, Deserialize, Default));
90+
impl_type_path!(str);
9091
impl_reflect_value!(::alloc::string::String(
9192
Debug,
9293
Hash,
@@ -1071,8 +1072,6 @@ impl<T: TypePath + ?Sized> TypePath for &'static T {
10711072
static CELL: GenericTypePathCell = GenericTypePathCell::new();
10721073
CELL.get_or_insert::<Self, _>(|| format!("&{}", T::short_type_path()))
10731074
}
1074-
1075-
const TYPE_PATH_ID: TypePathId = TypePathId::from_base("&").with_generics(&[T::TYPE_PATH_ID]);
10761075
}
10771076

10781077
impl Reflect for Cow<'static, str> {
@@ -1179,8 +1178,6 @@ impl FromReflect for Cow<'static, str> {
11791178
}
11801179
}
11811180

1182-
impl<T: PathOnly> PathOnly for [T] where [T]: ToOwned {}
1183-
11841181
impl<T: TypePath> TypePath for [T]
11851182
where
11861183
[T]: ToOwned,
@@ -1196,8 +1193,6 @@ where
11961193
}
11971194
}
11981195

1199-
impl<T: ToOwned> PathOnly for T {}
1200-
12011196
impl<T: FromReflect + Clone + TypePath> List for Cow<'static, [T]> {
12021197
fn get(&self, index: usize) -> Option<&dyn Reflect> {
12031198
self.as_ref().get(index).map(|x| x as &dyn Reflect)
@@ -1229,7 +1224,7 @@ impl<T: FromReflect + Clone + TypePath> List for Cow<'static, [T]> {
12291224
T::from_reflect(&*value).unwrap_or_else(|| {
12301225
panic!(
12311226
"Attempted to insert invalid value of type {}.",
1232-
value.type_name()
1227+
value.reflect_type_path()
12331228
)
12341229
})
12351230
});
@@ -1244,7 +1239,7 @@ impl<T: FromReflect + Clone + TypePath> List for Cow<'static, [T]> {
12441239
let value = T::take_from_reflect(value).unwrap_or_else(|value| {
12451240
panic!(
12461241
"Attempted to push invalid value of type {}.",
1247-
value.type_name()
1242+
value.reflect_type_path()
12481243
)
12491244
});
12501245
self.to_mut().push(value);
@@ -1258,10 +1253,6 @@ impl<T: FromReflect + Clone + TypePath> List for Cow<'static, [T]> {
12581253
}
12591254

12601255
impl<T: FromReflect + Clone + TypePath> Reflect for Cow<'static, [T]> {
1261-
fn type_name(&self) -> &str {
1262-
std::any::type_name::<Self>()
1263-
}
1264-
12651256
fn into_any(self: Box<Self>) -> Box<dyn Any> {
12661257
self
12671258
}
@@ -1434,18 +1425,6 @@ impl Typed for &'static Path {
14341425
}
14351426
}
14361427

1437-
impl TypePath for &'static Path {
1438-
fn type_path() -> &'static str {
1439-
static CELL: GenericTypePathCell = GenericTypePathCell::new();
1440-
CELL.get_or_insert::<Self, _>(|| "&std::path::Path".to_owned())
1441-
}
1442-
1443-
fn short_type_path() -> &'static str {
1444-
static CELL: GenericTypePathCell = GenericTypePathCell::new();
1445-
CELL.get_or_insert::<Self, _>(|| "&Path".to_owned())
1446-
}
1447-
}
1448-
14491428
impl GetTypeRegistration for &'static Path {
14501429
fn get_type_registration() -> TypeRegistration {
14511430
let mut registration = TypeRegistration::of::<Self>();
@@ -1547,6 +1526,7 @@ impl Typed for Cow<'static, Path> {
15471526
}
15481527
}
15491528

1529+
impl_type_path!(::std::path::Path);
15501530
impl_type_path!(::alloc::borrow::Cow<'a: 'static, T: ToOwned + ?Sized>);
15511531

15521532
impl FromReflect for Cow<'static, Path> {

crates/bevy_reflect/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ mod tests {
13891389
let info = MyCowStr::type_info();
13901390
if let TypeInfo::Value(info) = info {
13911391
assert!(info.is::<MyCowStr>());
1392-
assert_eq!(std::any::type_name::<MyCowStr>(), info.type_name());
1392+
assert_eq!(std::any::type_name::<MyCowStr>(), info.type_path());
13931393
} else {
13941394
panic!("Expected `TypeInfo::Value`");
13951395
}
@@ -1405,8 +1405,11 @@ mod tests {
14051405
if let TypeInfo::List(info) = info {
14061406
assert!(info.is::<MyCowSlice>());
14071407
assert!(info.item_is::<u8>());
1408-
assert_eq!(std::any::type_name::<MyCowSlice>(), info.type_name());
1409-
assert_eq!(std::any::type_name::<u8>(), info.item_type_name());
1408+
assert_eq!(std::any::type_name::<MyCowSlice>(), info.type_path());
1409+
assert_eq!(
1410+
std::any::type_name::<u8>(),
1411+
info.item_type_path_vtable().path()
1412+
);
14101413
} else {
14111414
panic!("Expected `TypeInfo::List`");
14121415
}

crates/bevy_reflect/src/type_path.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt;
2+
13
/// A static accessor to type paths and names.
24
///
35
/// The engine uses this trait over [`std::any::type_name`] for stability and flexibility.

0 commit comments

Comments
 (0)