Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(turbo-tasks): Add a lint for Vc<T> in turbo-tasks types #73298

Merged
merged 2 commits into from
Nov 28, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .config/ast-grep/rules/resolved-vc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json

id: no-vc-struct
message: Don't use a Vc directly in a struct
note: 'Prefer using ResolvedVc, or add a `// no-resolved-vc(<AUTHOR>): <REASON>` comment'
severity: warning
language: rust

rule:
pattern:
context: 'let x: Vc<$A> = 1;'
selector: generic_type
inside:
stopBy: end
not:
follows:
kind: line_comment
regex: \s*//\s*no-resolved-vc\((.+)\):.+
inside:
inside:
any:
- kind: struct_item
follows:
stopBy:
not:
kind: attribute_item
kind: attribute_item
has:
kind: attribute
regex: '^turbo_tasks::value(\(.*\))?$'
- inside:
kind: enum_variant_list
inside:
follows:
stopBy:
not:
kind: attribute_item
kind: attribute_item
has:
kind: attribute
regex: '^turbo_tasks::value(\(.*\))?$'
fix: ResolvedVc<$A>
1 change: 1 addition & 0 deletions turbopack/crates/turbo-tasks/src/vc/resolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct ResolvedVc<T>
where
T: ?Sized,
{
// no-resolved-vc(kdy1): This is a resolved Vc, so we don't need to resolve it again
pub(crate) node: Vc<T>,
}

Expand Down
Loading