|
1 | 1 | //! Runtime helpers for [turbo-tasks-macro]. |
2 | 2 |
|
| 3 | +use std::any::TypeId; |
| 4 | + |
3 | 5 | pub use async_trait::async_trait; |
4 | 6 | pub use bincode; |
5 | 7 | pub use once_cell::sync::{Lazy, OnceCell}; |
@@ -144,29 +146,29 @@ inventory::collect! {CollectableTraitCastFunctions} |
144 | 146 | #[allow(clippy::type_complexity)] |
145 | 147 | pub struct CollectableTraitMethods( |
146 | 148 | pub fn() -> ( |
147 | | - &'static str, // A value type name |
| 149 | + TypeId, |
148 | 150 | TraitTypeId, |
149 | 151 | Vec<(&'static str, &'static NativeFunction)>, |
150 | 152 | ), |
151 | 153 | ); |
152 | 154 | inventory::collect!(CollectableTraitMethods); |
153 | 155 |
|
154 | 156 | // Called when initializing ValueTypes by value_impl |
155 | | -pub fn register_trait_methods(value_type: &mut ValueType) { |
| 157 | +pub fn register_trait_methods(type_id: TypeId, value_type: &mut ValueType) { |
156 | 158 | #[allow(clippy::type_complexity)] |
157 | 159 | static TRAIT_METHODS_BY_VALUE: Lazy< |
158 | | - FxDashMap<&'static str, Vec<(TraitTypeId, Vec<(&'static str, &'static NativeFunction)>)>>, |
| 160 | + FxDashMap<TypeId, Vec<(TraitTypeId, Vec<(&'static str, &'static NativeFunction)>)>>, |
159 | 161 | > = Lazy::new(|| { |
160 | | - let map: FxDashMap<&'static str, Vec<_>> = FxDashMap::default(); |
| 162 | + let map: FxDashMap<TypeId, Vec<_>> = FxDashMap::default(); |
161 | 163 | for CollectableTraitMethods(thunk) in inventory::iter::<CollectableTraitMethods> { |
162 | | - let (value_name, trait_type_id, fn_items) = thunk(); |
163 | | - map.entry(value_name) |
| 164 | + let (type_id, trait_type_id, fn_items) = thunk(); |
| 165 | + map.entry(type_id) |
164 | 166 | .or_default() |
165 | 167 | .push((trait_type_id, fn_items)); |
166 | 168 | } |
167 | 169 | map |
168 | 170 | }); |
169 | | - match TRAIT_METHODS_BY_VALUE.remove(value_type.global_name) { |
| 171 | + match TRAIT_METHODS_BY_VALUE.remove(&type_id) { |
170 | 172 | Some((_, traits)) => { |
171 | 173 | for (trait_type_id, methods) in traits { |
172 | 174 | let trait_type = crate::registry::get_trait(trait_type_id); |
|
0 commit comments