Skip to content

Commit a0c4e7e

Browse files
committed
wip
1 parent 644a025 commit a0c4e7e

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

turbopack/crates/turbo-tasks-macros/src/value_trait_macro.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ pub fn value_trait(args: TokenStream, input: TokenStream) -> TokenStream {
284284
});
285285

286286
impl turbo_tasks::VcValueTrait for Box<dyn #trait_ident> {
287+
// type Read = dyn #trait_ident;
287288
fn get_trait_type_id() -> turbo_tasks::TraitTypeId {
288289
*#trait_type_id_ident
289290
}

turbopack/crates/turbo-tasks/src/trait_ref.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::Result;
44
use serde::{Deserialize, Serialize};
55

66
use crate::{
7-
Vc, VcValueTrait,
7+
Vc, VcRead, VcValueTrait, VcValueType,
88
registry::get_value_type,
99
task::shared_reference::TypedSharedReference,
1010
vc::{ReadVcFuture, VcValueTraitCast, cast::VcCast},
@@ -72,6 +72,17 @@ impl<'de, T> Deserialize<'de> for TraitRef<T> {
7272
}
7373
}
7474

75+
// impl<T> std::ops::Deref for TraitRef<T>
76+
// where
77+
// T: VcValueTrait,
78+
// {
79+
// type Target = <T as VcValueTrait>::Read;
80+
81+
// fn deref(&self) -> &Self::Target {
82+
// &*self.shared_reference.1.0 as &Self::Target
83+
// }
84+
// }
85+
7586
// Otherwise, TraitRef<Box<dyn Trait>> would not be Sync.
7687
// SAFETY: TraitRef doesn't actually contain a T.
7788
unsafe impl<T> Sync for TraitRef<T> where T: ?Sized {}

turbopack/crates/turbo-tasks/src/vc/traits.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::any::Any;
2+
13
use crate::{
24
NonLocalValue, ShrinkToFit, TraitTypeId, ValueTypeId, VcRead, vc::cell_mode::VcCellMode,
35
};
@@ -26,6 +28,8 @@ pub unsafe trait VcValueType: ShrinkToFit + Sized + Send + Sync + 'static {
2628
/// A trait implemented on all values trait object references that can be put
2729
/// into a Value Cell ([`Vc<Box<dyn Trait>>`][crate::Vc]).
2830
pub trait VcValueTrait: NonLocalValue + Send + Sync + 'static {
31+
// type Read: ?Sized;
32+
/// Returns the type id of the trait object.
2933
fn get_trait_type_id() -> TraitTypeId;
3034
}
3135

0 commit comments

Comments
 (0)