Skip to content

Commit b9f4f09

Browse files
committed
fix(validation): tie closure lifetimes to Semantic
`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`.
1 parent a7d87e4 commit b9f4f09

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎crates/oxc_angular_compiler/src/validation.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,19 @@ fn namespace_import_of<'a>(
115115
/// in `ns.f.required`) only when `ns` resolves to a namespace import of the
116116
/// module. Any other binding — a parameter, a local, an unrelated import —
117117
/// means the call isn't one of the API's.
118-
fn is_api_reference(callee: &Expression<'_>, api: InitializerApi, semantic: &Semantic<'_>) -> bool {
118+
fn is_api_reference<'a>(
119+
callee: &Expression<'a>,
120+
api: InitializerApi,
121+
semantic: &Semantic<'a>,
122+
) -> bool {
119123
// `f` — its binding must be the import.
120-
let named = |expr: &Expression<'_>| {
124+
let named = |expr: &Expression<'a>| {
121125
let Expression::Identifier(id) = expr else { return false };
122126
direct_import_of(id, semantic)
123127
.is_some_and(|(module, name)| module == api.1 && name == api.0)
124128
};
125129
// `ns.f` — `ns` must be a namespace import of the module.
126-
let namespaced = |expr: &Expression<'_>| {
130+
let namespaced = |expr: &Expression<'a>| {
127131
let Expression::StaticMemberExpression(member) = expr else { return false };
128132
let Expression::Identifier(ns) = &member.object else { return false };
129133
member.property.name == api.0 && namespace_import_of(ns, semantic) == Some(api.1)

0 commit comments

Comments
 (0)