Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
id: no-map-async-cell
snapshots:
? |
items.into_iter()
.map(async |item| Ok(item.process().await?.cell()))
.try_join()
.await
: labels:
- source: item.process().await?.cell()
style: primary
start: 43
end: 71
- source: |-
items.into_iter()
.map(async |item| Ok(item.process().await?.cell()))
style: secondary
start: 0
end: 73
- source: async |item| Ok(item.process().await?.cell())
style: secondary
start: 27
end: 72
? |
items.into_iter()
.map(async |item| item.process().await.cell())
.try_join()
.await
: labels:
- source: |-
items.into_iter()
.map(async |item| item.process().await.cell())
style: primary
start: 0
end: 68
- source: item.process().await.cell()
style: secondary
start: 40
end: 67
? |
items.into_iter()
.map(async |item| {
Ok(item.process().await?.cell())
})
.try_join()
.await
: labels:
- source: item.process().await?.cell()
style: primary
start: 53
end: 81
- source: |-
items.into_iter()
.map(async |item| {
Ok(item.process().await?.cell())
})
style: secondary
start: 0
end: 89
- source: |-
async |item| {
Ok(item.process().await?.cell())
}
style: secondary
start: 27
end: 88
? |
items.into_iter()
.map(async |item| {
item.process().await.cell()
})
.try_join()
.await
: labels:
- source: |-
items.into_iter()
.map(async |item| {
item.process().await.cell()
})
style: primary
start: 0
end: 84
- source: item.process().await.cell()
style: secondary
start: 50
end: 77
? |
items.into_iter()
.map(|item| async move {
Ok(item.process().await?.cell())
})
.try_join()
.await
: labels:
- source: item.process().await?.cell()
style: primary
start: 58
end: 86
- source: |-
items.into_iter()
.map(|item| async move {
Ok(item.process().await?.cell())
})
style: secondary
start: 0
end: 94
- source: |-
|item| async move {
Ok(item.process().await?.cell())
}
style: secondary
start: 27
end: 93
? |
items.into_iter()
.map(|item| async {
Ok(item.process().await?.cell())
})
.try_join()
.await
: labels:
- source: item.process().await?.cell()
style: primary
start: 53
end: 81
- source: |-
items.into_iter()
.map(|item| async {
Ok(item.process().await?.cell())
})
style: secondary
start: 0
end: 89
- source: |-
|item| async {
Ok(item.process().await?.cell())
}
style: secondary
start: 27
end: 88
? |
map.into_iter()
.map(|(ty, items)| {
(
ty,
ChunkItemBatchGroup {
items,
chunk_groups: this.chunk_groups.clone(),
},
)
})
.map(async |(ty, batch_group)| Ok((ty, batch_group.resolved_cell())))
.try_join()
: labels:
- source: batch_group.resolved_cell()
style: primary
start: 256
end: 283
- source: |-
map.into_iter()
.map(|(ty, items)| {
(
ty,
ChunkItemBatchGroup {
items,
chunk_groups: this.chunk_groups.clone(),
},
)
})
.map(async |(ty, batch_group)| Ok((ty, batch_group.resolved_cell())))
style: secondary
start: 0
end: 286
- source: async |(ty, batch_group)| Ok((ty, batch_group.resolved_cell()))
style: secondary
start: 222
end: 285
? |
modules
.map(async |module| {
let result = module.compute().await?;
result.into_value().cell()
})
: labels:
- source: result.into_value().cell()
style: primary
start: 88
end: 114
- source: |-
modules
.map(async |module| {
let result = module.compute().await?;
result.into_value().cell()
})
style: secondary
start: 0
end: 121
- source: |-
async |module| {
let result = module.compute().await?;
result.into_value().cell()
}
style: secondary
start: 17
end: 120
? |
modules
.map(async |module| {
let result = module.compute().await?;
result.into_value().cell()
})
.try_join()
: labels:
- source: |-
modules
.map(async |module| {
let result = module.compute().await?;
result.into_value().cell()
})
style: primary
start: 0
end: 121
- source: result.into_value().cell()
style: secondary
start: 88
end: 114
? |
paths.map(async |(path, asset)| {
AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell()
})
: labels:
- source: |-
paths.map(async |(path, asset)| {
AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell()
})
style: primary
start: 0
end: 137
- source: |-
AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell()
style: secondary
start: 38
end: 134
? |
paths.map(async |(path, asset)| {
Ok(AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell())
})
.try_join()
.await
: labels:
- source: |-
AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell()
style: primary
start: 41
end: 137
- source: |-
paths.map(async |(path, asset)| {
Ok(AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell())
})
style: secondary
start: 0
end: 141
- source: |-
async |(path, asset)| {
Ok(AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell())
}
style: secondary
start: 10
end: 140
70 changes: 70 additions & 0 deletions .config/ast-grep/rule-tests/no-map-async-cell-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
id: no-map-async-cell
valid:
- |
items.into_iter()
.map(|item| item.process())
.collect()
- |
items.into_iter()
.map(|item| {
SomeStruct { field: item }.cell()
})
.collect()
- |
call_once(|| async {
X{}.cell()
})
invalid:
- |
items.into_iter()
.map(|item| async move {
Ok(item.process().await?.cell())
})
.try_join()
.await
- |
items.into_iter()
.map(|item| async {
Ok(item.process().await?.cell())
})
.try_join()
.await
- |
items.into_iter()
.map(async |item| {
Ok(item.process().await?.cell())
})
.try_join()
.await
- |
items.into_iter()
.map(async |item| Ok(item.process().await?.cell()))
.try_join()
.await
- |
paths.map(async |(path, asset)| {
Ok(AssetBinding {
name: wasm_edge_var_name(Vc::upcast(*asset)).owned().await?,
}.cell())
})
.try_join()
.await
- |
modules
.map(async |module| {
let result = module.compute().await?;
result.into_value().cell()
})
- |
map.into_iter()
.map(|(ty, items)| {
(
ty,
ChunkItemBatchGroup {
items,
chunk_groups: this.chunk_groups.clone(),
},
)
})
.map(async |(ty, batch_group)| Ok((ty, batch_group.resolved_cell())))
.try_join()
26 changes: 26 additions & 0 deletions .config/ast-grep/rules/no-map-async-cell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json

id: no-map-async-cell
message: Using `.map(async |...| { ...cell() })` causes non-deterministic cell order
note: You probably want to first `try_join()` the async computations before wrapping them in a cell.
severity: error
language: Rust
rule:
all:
- any:
- pattern: $_X.cell()
- pattern: $_X.resolved_cell()
- pattern: ResolvedVc::cell($_X)
- pattern: Vc::cell($_X)
- inside:
stopBy: end
all:
- any:
- pattern: 'async |$$$ARGS| $BODY'
- pattern: 'async move |$$$ARGS| $BODY'
- pattern: '|$$$ARGS| async { $$$BODY }'
- pattern: '|$$$ARGS| async move { $$$BODY }'
- inside:
stopBy: end
field: arguments
pattern: $EXPR.map($$$CLOSURE)
1 change: 1 addition & 0 deletions .github/labeler.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
{ "type": "user", "pattern": "bgw" },
{ "type": "user", "pattern": "lukesandberg" },
{ "type": "user", "pattern": "mischnic" },
{ "type": "user", "pattern": "mmastrac" },
{ "type": "user", "pattern": "sokra" },
{ "type": "user", "pattern": "timneutkens" },
{ "type": "user", "pattern": "wbinnssmith" }
Expand Down
Loading