Skip to content

Commit

Permalink
Fix generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
bgw committed Jul 24, 2024
1 parent 9705696 commit b635026
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions crates/turbo-tasks-memory/tests/local_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ async fn store_and_read() {
assert_eq!(*c.await.unwrap(), 42);
}
}

#[tokio::test]
async fn store_and_read_generic() {
run! {
// `Vc<Vec<Vc<T>>>` is stored as `Vc<Vec<Vc<()>>>` and requires special transmute handling
let cells: Vc<Vec<Vc<u32>>> =
Vc::local_cell(vec![Vc::local_cell(1), Vc::local_cell(2), Vc::cell(3)]);

let mut output = Vec::new();
for el in cells.await.unwrap() {
output.push(*el.await.unwrap());
}

assert_eq!(output, vec![1, 2, 3]);
}
}
2 changes: 1 addition & 1 deletion crates/turbo-tasks/src/vc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ where
// "updating" the cell across multiple executions.
let (execution_id, local_cell_id) = create_local_cell(SharedReference::new(
Some(T::get_value_type_id()),
triomphe::Arc::new(inner),
triomphe::Arc::new(T::Read::target_to_repr(inner)),
));
Vc {
node: RawVc::LocalCell(execution_id, local_cell_id),
Expand Down

0 comments on commit b635026

Please sign in to comment.