Skip to content

fix(validation): tie closure lifetimes to Semantic - #581

Merged
Brooooooklyn merged 1 commit into
voidzero-dev:mainfrom
pkurcx:fix-semantic-lifetime-with-jsdoc
Oct 16, 2026
Merged

Brooooooklyn merged 1 commit into
voidzero-dev:mainfrom
pkurcx:fix-semantic-lifetime-with-jsdoc

Conversation

@pkurcx

@pkurcx pkurcx commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

is_api_reference doesn't compile when oxc_semantic's jsdoc feature is enabled, which happens for any crate that also depends on oxc_linter (it enables oxc_semantic/linter):

error[E0521]: borrowed data escapes outside of closure
   --> crates/oxc_angular_compiler/src/validation.rs:122:9
    |
118 | fn is_api_reference(callee: &Expression<'_>, api: InitializerApi, semantic: &Semantic<'_>) -> bool {
    |                                                                   -------- `semantic` declared here, outside of the closure body
...
122 |         direct_import_of(id, semantic)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `expr` escapes the closure body here
    = note: the struct `Semantic<'a>` is invariant over the parameter `'a`

(and the same at line 129). With jsdoc on, Semantic holds a JSDocFinder<'a>, which makes it invariant over 'a, so the closures' &Expression<'_> parameters can no longer be shortened to the lifetime of semantic.

The fix names the lifetime once and uses it for callee, semantic, and both closure parameters.

Reproduce on main:

cargo check -p oxc_angular_compiler --features oxc_semantic/jsdoc

Fails before this change and passes after; cargo test -p oxc_angular_compiler passes.

`Semantic` is invariant over its lifetime when oxc_semantic's `jsdoc`
feature is on, so the closures in `is_api_reference` must take
expressions of the same lifetime as `semantic`.
@pkurcx
pkurcx force-pushed the fix-semantic-lifetime-with-jsdoc branch from 47b1c11 to b9f4f09 Compare October 14, 2026 14:02
@Brooooooklyn
Brooooooklyn merged commit 7c84088 into voidzero-dev:main Oct 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants