xsd_schema/xpath/deps.rs
1//! Compile-time dependency analysis for compiled XPath expressions.
2//!
3//! After [`bind_node`](crate::xpath::bind::bind_node) has resolved variables,
4//! functions and name tests, [`analyze`] walks the bound AST once and records
5//! what the expression actually *depends on*:
6//!
7//! - which external variable slots are referenced (a bitset over the slots
8//! allocated before `NameBinder::mark_external_boundary()`),
9//! - whether evaluation reads the **initial focus** — the context item,
10//! `fn:position()` or `fn:last()` of the dynamic context that is in effect
11//! when the expression is entered,
12//! - the distinct `(namespace, local name, arity)` triples of every function
13//! called anywhere in the expression.
14//!
15//! The analysis runs once per compilation and adds nothing to the evaluation
16//! path; the result is stored in [`XPathExpr`](crate::xpath::api::XPathExpr)
17//! and exposed through its accessors.
18//!
19//! # The "initial focus" rule
20//!
21//! XPath 2.0 §2.1.2 defines the focus and names the only constructs that
22//! replace it: "Certain language constructs, notably the path expression
23//! `E1/E2` and the predicate `E1[E2]`, create a new focus for the evaluation
24//! of a sub-expression. In these constructs, `E2` is evaluated once for each
25//! item in the sequence that results from evaluating `E1`."
26//!
27//! So the walk carries a boolean "still in the initial focus" and clears it
28//! when it descends into
29//!
30//! - any predicate (§3.2.2: "the predicate expression is evaluated using an
31//! inner focus" whose context item "is the item currently being tested
32//! against the predicate"), including the predicates of a filter expression
33//! (§3.3.2),
34//! - every path step but the first of a relative path (§3.2: "Each node
35//! resulting from the evaluation of `E1` then serves in turn to provide an
36//! inner focus for an evaluation of `E2`"),
37//! - every step of an absolute path — `/` abbreviates
38//! `(fn:root(self::node()) treat as document-node())/` and `//` abbreviates
39//! `(fn:root(self::node()) treat as document-node())/descendant-or-self::node()/`
40//! (§3.2), so an absolute path *does* read the initial context node (to find
41//! its root) but its steps run in inner foci.
42//!
43//! Everything else keeps the enclosing focus: `for` (§3.7) and quantified
44//! (§3.9) expressions only bind variables, and `if`, function arguments,
45//! operators, ranges, type expressions and comma sequences do not mention the
46//! focus at all.
47
48use crate::xpath::arena::{AstArena, AstNodeId};
49use crate::xpath::ast::{AstNode, FunctionCallNode};
50use crate::xpath::context::{VarSlotId, XPathContext};
51use crate::xpath::functions::extensible::handle_to_function_id;
52use crate::xpath::functions::{FunctionId, FUNCTION_REGISTRY};
53
54// ============================================================================
55// FunctionCallRef
56// ============================================================================
57
58/// A distinct function call site found in a compiled XPath expression.
59///
60/// Produced by [`XPathExpr::function_calls`](crate::xpath::api::XPathExpr::function_calls),
61/// which reports one entry per distinct `(namespace, local_name, arity)` triple
62/// — including calls that appear inside predicates, `for` bodies and other
63/// nested foci. Callers use it to detect functions whose results are not a
64/// function of the focus and the arguments alone (`fn:doc`, `fn:collection`,
65/// `fn:unparsed-text`, a host language's `key()` …) without this crate having to take a
66/// position on what "impure" means.
67///
68/// `namespace` is the namespace the call actually **bound** to — the namespace
69/// of the resolved function's signature, not the way the call was spelled. So
70/// `count(...)` is reported in `http://www.w3.org/2005/xpath-functions` in both
71/// XPath 2.0 and XPath 1.0 mode, even though 1.0 mode looks core functions up
72/// without a namespace (`XPath10Catalog` resolves them through `FN_NAMESPACE`),
73/// and a call written against the `FN_2010_NAMESPACE` alias is reported under
74/// the canonical `fn:` namespace it resolves to. A test like
75/// `namespace == FN_NAMESPACE && local_name == "doc"` is therefore mode
76/// independent.
77///
78/// Only when no signature is reachable for the call — an unbound tree, or a
79/// catalog that does not describe its own handle — does this fall back to the
80/// lexical resolution of the prefix (or the static context's default function
81/// namespace for an unprefixed call).
82#[derive(Debug, Clone, PartialEq, Eq, Hash)]
83pub struct FunctionCallRef {
84 /// Namespace URI the call was bound in (may be empty).
85 pub namespace: String,
86 /// Local name of the called function.
87 pub local_name: String,
88 /// Number of arguments at the call site.
89 pub arity: usize,
90}
91
92// ============================================================================
93// ExprDependencies
94// ============================================================================
95
96/// Dependency metadata collected for one compiled expression.
97///
98/// Crate-internal: the public surface is the set of accessors on
99/// [`XPathExpr`](crate::xpath::api::XPathExpr).
100#[derive(Debug, Clone, Default)]
101pub(crate) struct ExprDependencies {
102 /// Bitset over external variable slots (slot `n` is bit `n % 64` of word
103 /// `n / 64`). Only slots below the external boundary are recorded.
104 referenced_vars: Vec<u64>,
105 /// The distinct slots **at or above** the external boundary that the
106 /// expression references, in first-occurrence order. For a whole compiled
107 /// expression these are its own `for`/`some`/`every` variables; analysing a
108 /// subtree with a boundary of `0` turns this into "every variable slot the
109 /// subtree reads".
110 inner_var_refs: Vec<VarSlotId>,
111 uses_focus: bool,
112 uses_position: bool,
113 uses_last: bool,
114 function_calls: Vec<FunctionCallRef>,
115}
116
117impl ExprDependencies {
118 /// Whether evaluation reads the initial context item.
119 #[inline]
120 pub(crate) fn uses_focus(&self) -> bool {
121 self.uses_focus
122 }
123
124 /// Whether `fn:position()` is evaluated against the initial focus.
125 #[inline]
126 pub(crate) fn uses_position(&self) -> bool {
127 self.uses_position
128 }
129
130 /// Whether `fn:last()` is evaluated against the initial focus.
131 #[inline]
132 pub(crate) fn uses_last(&self) -> bool {
133 self.uses_last
134 }
135
136 /// The distinct function calls of the expression.
137 #[inline]
138 pub(crate) fn function_calls(&self) -> &[FunctionCallRef] {
139 &self.function_calls
140 }
141
142 /// Whether the external variable in `slot` is referenced. O(1).
143 #[inline]
144 pub(crate) fn references_var(&self, slot: VarSlotId) -> bool {
145 let word = (slot / 64) as usize;
146 match self.referenced_vars.get(word) {
147 Some(bits) => bits & (1u64 << (slot % 64)) != 0,
148 None => false,
149 }
150 }
151}
152
153// ============================================================================
154// analyze
155// ============================================================================
156
157/// Analyze a **bound** expression tree rooted at `root`.
158///
159/// `external_slot_count` is the number of external variable slots, which
160/// `XPathExpr::compile_with_vars` allocates first (slots `0 .. count`) and
161/// closes with `NameBinder::mark_external_boundary()`; every variable the
162/// expression introduces itself (`for`, `some`, `every`) gets a fresh slot at
163/// or above that boundary, so a shadowing binding can never be mistaken for
164/// the external of the same name.
165///
166/// Must be called after binding: unbound `VarRef`/`FunctionCall` nodes carry no
167/// slot or handle, and the analysis then falls back to its conservative answer
168/// (see `call_focus_use`).
169pub(crate) fn analyze(
170 arena: &AstArena,
171 root: AstNodeId,
172 ctx: &XPathContext<'_>,
173 external_slot_count: usize,
174) -> ExprDependencies {
175 let mut analyzer = Analyzer {
176 arena,
177 ctx,
178 external_slot_count,
179 deps: ExprDependencies {
180 referenced_vars: vec![0u64; external_slot_count.div_ceil(64)],
181 ..Default::default()
182 },
183 };
184 analyzer.walk(root, true);
185 analyzer.deps
186}
187
188/// Which components of the focus a construct reads.
189#[derive(Debug, Clone, Copy, Default)]
190struct FocusUse {
191 /// Reads the context item (or context node).
192 item: bool,
193 /// Reads the context position (`fn:position()`).
194 position: bool,
195 /// Reads the context size (`fn:last()`).
196 size: bool,
197}
198
199impl FocusUse {
200 const NONE: Self = Self {
201 item: false,
202 position: false,
203 size: false,
204 };
205 const ITEM: Self = Self {
206 item: true,
207 position: false,
208 size: false,
209 };
210 const POSITION: Self = Self {
211 item: true,
212 position: true,
213 size: false,
214 };
215 const SIZE: Self = Self {
216 item: true,
217 position: false,
218 size: true,
219 };
220}
221
222struct Analyzer<'a, 'ctx> {
223 arena: &'a AstArena,
224 ctx: &'a XPathContext<'ctx>,
225 external_slot_count: usize,
226 deps: ExprDependencies,
227}
228
229impl Analyzer<'_, '_> {
230 /// Walk one node. `in_initial_focus` is true while the node is evaluated
231 /// with the dynamic context the whole expression was entered with.
232 fn walk(&mut self, id: AstNodeId, in_initial_focus: bool) {
233 // Copy the shared arena reference out of `self` so that the borrow of
234 // the node does not conflict with the `&mut self` recursion below.
235 let arena = self.arena;
236 let Some(node) = arena.try_get(id) else {
237 return;
238 };
239
240 match node {
241 // Comma sequences keep the enclosing focus.
242 AstNode::Expr(expr) => {
243 for &item_id in &expr.items {
244 self.walk(item_id, in_initial_focus);
245 }
246 }
247
248 AstNode::Value(_) => {}
249
250 // `.` is the context item (§2.1.2: "The context item is returned
251 // by an expression consisting of a single dot").
252 AstNode::ContextItem(_) => self.note_focus(FocusUse::ITEM, in_initial_focus),
253
254 AstNode::VarRef(var_ref) => {
255 if let Some(slot) = var_ref.slot {
256 self.mark_var(slot);
257 }
258 }
259
260 // `if` does not change the focus.
261 AstNode::If(if_node) => {
262 self.walk(if_node.test, in_initial_focus);
263 self.walk(if_node.then_branch, in_initial_focus);
264 self.walk(if_node.else_branch, in_initial_focus);
265 }
266
267 // §3.7: a `for` expression binds a range variable and evaluates the
268 // return expression once per item of the binding sequence — the
269 // focus is untouched in both.
270 AstNode::For(for_node) => {
271 for binding in &for_node.bindings {
272 self.walk(binding.in_expr, in_initial_focus);
273 }
274 self.walk(for_node.return_expr, in_initial_focus);
275 }
276
277 // §3.9: likewise for `some` / `every`.
278 AstNode::Quantified(quant) => {
279 for binding in &quant.bindings {
280 self.walk(binding.in_expr, in_initial_focus);
281 }
282 self.walk(quant.satisfies, in_initial_focus);
283 }
284
285 AstNode::FunctionCall(call) => {
286 self.record_call(call);
287 self.note_focus(call_focus_use(call), in_initial_focus);
288 // Arguments are evaluated in the enclosing focus.
289 for &arg_id in &call.args {
290 self.walk(arg_id, in_initial_focus);
291 }
292 }
293
294 AstNode::PathExpr(path) => {
295 if path.is_absolute {
296 // §3.2: a leading `/` or `//` abbreviates
297 // `(fn:root(self::node()) treat as document-node())/…`,
298 // so the initial context node is read to find its root —
299 // "The effect of this initial step is to begin the path at
300 // the root node of the tree that contains the context
301 // node." Every explicit step then runs in an inner focus.
302 self.note_focus(FocusUse::ITEM, in_initial_focus);
303 for &step_id in &path.steps {
304 self.walk(step_id, false);
305 }
306 } else {
307 // Only the first step of a relative path sees the initial
308 // focus; each following step is `E2` of some `E1/E2`.
309 for (index, &step_id) in path.steps.iter().enumerate() {
310 self.walk(step_id, in_initial_focus && index == 0);
311 }
312 }
313 }
314
315 // §3.3.2: the primary expression is evaluated in the enclosing
316 // focus, the predicates in an inner one.
317 AstNode::FilterExpr(filter) => {
318 self.walk(filter.base, in_initial_focus);
319 for &pred_id in &filter.predicates {
320 self.walk(pred_id, false);
321 }
322 }
323
324 AstNode::Range(range) => {
325 self.walk(range.start, in_initial_focus);
326 self.walk(range.end, in_initial_focus);
327 }
328
329 AstNode::UnaryOp(unary) => self.walk(unary.operand, in_initial_focus),
330
331 AstNode::BinaryOp(binary) => {
332 self.walk(binary.left, in_initial_focus);
333 self.walk(binary.right, in_initial_focus);
334 }
335
336 // An axis step evaluates its axis against the context node; it is
337 // only reached with `in_initial_focus` when it is the first step of
338 // a relative path. §3.2.2: its predicates get an inner focus.
339 AstNode::PathStep(step) => {
340 self.note_focus(FocusUse::ITEM, in_initial_focus);
341 for &pred_id in &step.predicates {
342 self.walk(pred_id, false);
343 }
344 }
345
346 // `instance of` / `treat as` / `cast as` / `castable as`, and the
347 // constructor functions the binder rewrites into `cast as`.
348 AstNode::TypeExpr(type_expr) => self.walk(type_expr.operand, in_initial_focus),
349 }
350 }
351
352 /// Record a focus read, but only when it happens in the initial focus.
353 #[inline]
354 fn note_focus(&mut self, use_: FocusUse, in_initial_focus: bool) {
355 if !in_initial_focus {
356 return;
357 }
358 self.deps.uses_focus |= use_.item;
359 self.deps.uses_position |= use_.position;
360 self.deps.uses_last |= use_.size;
361 }
362
363 /// Record a reference to an external variable slot; slots at or above the
364 /// external boundary belong to the expression itself and are collected
365 /// separately, in `inner_var_refs`.
366 #[inline]
367 fn mark_var(&mut self, slot: VarSlotId) {
368 if (slot as usize) >= self.external_slot_count {
369 // A handful of range variables at most, so a linear scan beats a
370 // set and keeps the order stable (source order).
371 if !self.deps.inner_var_refs.contains(&slot) {
372 self.deps.inner_var_refs.push(slot);
373 }
374 return;
375 }
376 let word = (slot / 64) as usize;
377 if let Some(bits) = self.deps.referenced_vars.get_mut(word) {
378 *bits |= 1u64 << (slot % 64);
379 }
380 }
381
382 /// Add a distinct `(namespace, local name, arity)` entry for a call site.
383 fn record_call(&mut self, call: &FunctionCallNode) {
384 let entry = FunctionCallRef {
385 namespace: self.bound_namespace(call),
386 local_name: call.local_name.clone(),
387 arity: call.args.len(),
388 };
389 // Expressions have a handful of distinct calls; a linear scan beats a
390 // hash set here and keeps the reported order stable (source order).
391 if !self.deps.function_calls.contains(&entry) {
392 self.deps.function_calls.push(entry);
393 }
394 }
395
396 /// The namespace the call actually **bound** to.
397 ///
398 /// Taken from the signature of the resolved function, so the reported
399 /// namespace is the one the function is declared in rather than the way
400 /// the call happened to be spelled. That matters in XPath 1.0 mode, where
401 /// `XPath10Catalog` resolves an unprefixed core function through
402 /// `FN_NAMESPACE` while the static context's default function namespace is
403 /// the empty string (`functions/extensible.rs:577-590`,
404 /// `context.rs:167-175`), and for the `FN_2010_NAMESPACE` alias, which the
405 /// registry maps onto the same entries (`functions/registry.rs:110-140`).
406 ///
407 /// Falls back to the lexical resolution — the same one `bind_node` uses
408 /// (`bind.rs:146-154`) — only when no signature is reachable, i.e. when the
409 /// node carries no handle (an unbound tree) or the catalog does not know
410 /// the handle.
411 fn bound_namespace(&self, call: &FunctionCallNode) -> String {
412 if let Some(handle) = call.function_handle {
413 // Ask the catalog that bound the call; it knows custom functions too.
414 if let Some(signature) = self.ctx.function_catalog().get_signature(handle) {
415 return signature.namespace.to_string();
416 }
417 // Defensive: a catalog that cannot describe its own built-in
418 // handles still resolves through the built-in registry.
419 if let Ok(id) = handle_to_function_id(handle) {
420 if let Some(entry) = FUNCTION_REGISTRY.by_id(id) {
421 return entry.signature.namespace.to_string();
422 }
423 }
424 }
425 if call.prefix.is_empty() {
426 self.ctx.default_function_namespace().to_string()
427 } else {
428 self.ctx.resolve_prefix(&call.prefix).unwrap_or_default()
429 }
430 }
431}
432
433/// Which focus components a *call site* of a built-in function reads.
434///
435/// Derived from the implementations, not from the specification's prose, so
436/// that the flags describe what this engine actually does. Every entry below
437/// was read off the source:
438///
439/// | Call | Reads | Source |
440/// |---|---|---|
441/// | `fn:position()` | context position | `functions/special.rs:38-43` (`context.context_position`) |
442/// | `fn:last()` | context size | `functions/special.rs:60-65` (`context.context_size`) |
443/// | `fn:string()` | context item | `functions/mod.rs:931-944` (`require_context_item`), XPath 1.0: `functions/extensible.rs:637-645` |
444/// | `fn:number()` | context item | `functions/mod.rs:958-974` (`require_context_item`), XPath 1.0: `functions/extensible.rs:661-672` |
445/// | `fn:string-length()` | context item | `functions/string.rs:122-146` (`context.context_item`) |
446/// | `fn:normalize-space()` | context item | `functions/string.rs:159-186` (`context.context_item`) |
447/// | `fn:name()` | context node | `functions/node.rs:35-43` → `get_node_arg`, `functions/node.rs:550-563` |
448/// | `fn:local-name()` | context node | `functions/node.rs:59-71` → `get_node_arg` |
449/// | `fn:namespace-uri()` | context node | `functions/node.rs:87-99` → `get_node_arg` |
450/// | `fn:base-uri()` | context node | `functions/node.rs:229-241` → `get_node_arg` |
451/// | `fn:root()` | context node | `functions/node.rs:362-370` → `get_node_arg` |
452/// | `fn:lang($testlang)` | context node | `functions/node.rs:301-325` (1-arity form falls back to `context.context_item`) |
453/// | `fn:id($arg)` | context node | `functions/node.rs` `id` → `target_document` (1-arity form takes the reference node from `context.context_item`) |
454/// | `fn:idref($arg)` | context node | `functions/node.rs` `idref` → `target_document` (likewise) |
455///
456/// Functions whose *only* registered form takes the node explicitly are
457/// deliberately absent even though their implementations route through
458/// `get_node_arg`: `fn:node-name`, `fn:nilled` and `fn:document-uri` are
459/// registered with `FunctionSignature::new` (exact arity 1) in
460/// `functions/registry.rs:617,623,645`, so a 0-arity call does not bind.
461///
462/// A call this function cannot classify — an unbound node, or a custom
463/// function registered through a [`FunctionCatalog`](crate::xpath::functions::FunctionCatalog)
464/// whose body this crate cannot inspect — is conservatively reported as
465/// reading the context item, so that a caller skipping focus setup on
466/// `uses_focus() == false` can never be wrong. `uses_position()` and
467/// `uses_last()` stay narrow by design: they mean "`fn:position()` /
468/// `fn:last()` is called in the initial focus".
469fn call_focus_use(call: &FunctionCallNode) -> FocusUse {
470 let Some(handle) = call.function_handle else {
471 // Not bound (or rewritten): assume the worst.
472 return FocusUse::ITEM;
473 };
474 if !handle.is_builtin() {
475 // Custom function: its body is opaque to this analysis.
476 return FocusUse::ITEM;
477 }
478 let Ok(id) = handle_to_function_id(handle) else {
479 return FocusUse::ITEM;
480 };
481
482 let arity = call.args.len();
483 match (id, arity) {
484 (FunctionId::Position, 0) => FocusUse::POSITION,
485 (FunctionId::Last, 0) => FocusUse::SIZE,
486 (
487 FunctionId::String
488 | FunctionId::Number
489 | FunctionId::StringLength
490 | FunctionId::NormalizeSpace
491 | FunctionId::Name
492 | FunctionId::LocalName
493 | FunctionId::NamespaceUri
494 | FunctionId::BaseUri
495 | FunctionId::Root,
496 0,
497 ) => FocusUse::ITEM,
498 (FunctionId::Lang | FunctionId::Id | FunctionId::Idref, 1) => FocusUse::ITEM,
499 _ => FocusUse::NONE,
500 }
501}
502
503// ============================================================================
504// Run invariance
505// ============================================================================
506
507/// A set of variable slots, held as a bitset.
508#[derive(Debug, Clone, Default)]
509pub(crate) struct SlotSet {
510 words: Vec<u64>,
511}
512
513impl SlotSet {
514 /// Whether `slot` is in the set. O(1).
515 #[inline]
516 pub(crate) fn contains(&self, slot: VarSlotId) -> bool {
517 let word = (slot / 64) as usize;
518 match self.words.get(word) {
519 Some(bits) => bits & (1u64 << (slot % 64)) != 0,
520 None => false,
521 }
522 }
523
524 fn insert(&mut self, slot: VarSlotId) {
525 let word = (slot / 64) as usize;
526 if self.words.len() <= word {
527 self.words.resize(word + 1, 0);
528 }
529 self.words[word] |= 1u64 << (slot % 64);
530 }
531}
532
533/// Every variable slot bound by a `for`, `some` or `every` **anywhere** in
534/// `arena`.
535///
536/// A slot outside this set is bound before evaluation starts — by
537/// `XPathEvaluator`'s pending variables or by a host's setup callback — and the
538/// engine never writes it again while the expression runs, so a reference to it
539/// yields the same value however often it is evaluated. A slot inside it is a
540/// range variable, whose value changes with the iteration it belongs to.
541///
542/// The set is deliberately a property of the whole arena rather than of one
543/// scope: a reference to a range variable is then rejected wherever it appears,
544/// which is conservative — a `for` wholly inside the analysed subtree is
545/// rejected as well — and cannot mistake an outer binding for an inner one.
546pub(crate) fn range_var_slots(arena: &AstArena) -> SlotSet {
547 let mut set = SlotSet::default();
548 for (_, node) in arena.iter() {
549 let bindings = match node {
550 AstNode::For(for_node) => &for_node.bindings,
551 AstNode::Quantified(quantified) => &quantified.bindings,
552 _ => continue,
553 };
554 for binding in bindings {
555 if let Some(slot) = binding.slot {
556 set.insert(slot);
557 }
558 }
559 }
560 set
561}
562
563/// The variable slots the subtree rooted at `root` reads, if that subtree
564/// produces the same value every time it is evaluated during one run of the
565/// enclosing expression — and `None` if it does not.
566///
567/// `Some` when the subtree
568///
569/// * reads no part of the focus it is entered with, so re-evaluating it in a
570/// predicate, a later path step, a `for` body or a quantified body cannot
571/// change its value — this is exactly [`ExprDependencies::uses_focus`] applied
572/// to the subtree, with the focus rules documented at the top of this module;
573/// * calls no function: a function result may depend on host state that this
574/// crate cannot inspect (a custom
575/// [`FunctionEvaluator`](crate::xpath::functions::FunctionEvaluator)), or on
576/// dynamic-context state this analysis does not model, and a call may have
577/// effects that skipping the evaluation would skip too;
578/// * references no range variable, i.e. no slot in `range_vars`.
579///
580/// What is left — variable references bound before the run, literals, ranges,
581/// sequence constructors, arithmetic, `if`, type expressions, and paths and
582/// predicates rooted in any of those — is a pure function of state that does not
583/// change while the expression runs. Note that the walk is conservative in the
584/// other direction too: an unclassifiable construct reports a focus read rather
585/// than staying silent.
586///
587/// The returned slots are the ones whose bindings the value depends on, which is
588/// what a caller that caches the value needs in order to notice a rebinding.
589pub(crate) fn run_invariant_vars(
590 arena: &AstArena,
591 root: AstNodeId,
592 ctx: &XPathContext<'_>,
593 range_vars: &SlotSet,
594) -> Option<Vec<VarSlotId>> {
595 // A boundary of 0 puts *every* variable reference of the subtree into
596 // `inner_var_refs`, which is what the range-variable test below needs.
597 let deps = analyze(arena, root, ctx, 0);
598 if deps.uses_focus() || !deps.function_calls().is_empty() {
599 return None;
600 }
601 if deps
602 .inner_var_refs
603 .iter()
604 .any(|&slot| range_vars.contains(slot))
605 {
606 return None;
607 }
608 Some(deps.inner_var_refs)
609}
610
611/// Whether the subtree rooted at `root` is run invariant; see
612/// [`run_invariant_vars`], of which this is the predicate form.
613#[cfg(test)]
614pub(crate) fn is_run_invariant(
615 arena: &AstArena,
616 root: AstNodeId,
617 ctx: &XPathContext<'_>,
618 range_vars: &SlotSet,
619) -> bool {
620 run_invariant_vars(arena, root, ctx, range_vars).is_some()
621}
622
623#[cfg(test)]
624#[path = "deps_tests.rs"]
625mod deps_tests;