Skip to main content

pedant_core/resolution/rust/resolve/
resolver.rs

1//! The public resolver entry points.
2
3#[cfg(feature = "semantic")]
4use crate::ir::semantic::SemanticContext;
5use crate::resolution::rust::snapshot::RustResolutionSnapshot;
6
7use super::error::RustResolutionError;
8#[cfg(feature = "semantic")]
9use super::semantic;
10use super::syntactic;
11use super::target::RustTargetResolution;
12
13/// Symbol resolution over one bounded Rust resolution snapshot.
14///
15/// Every entry point returns a [`RustTargetResolution`], so a report is never
16/// separated from the snapshot whose sources and coordinates it describes.
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub struct RustResolver;
19
20impl RustResolver {
21    /// Resolve `snapshot` from its stored IR alone.
22    ///
23    /// This tier parses nothing a second time, reads no path, and invokes no
24    /// toolchain. Names it cannot prove become possible candidates or explicit
25    /// gaps rather than errors.
26    pub fn resolve_syntactic(
27        snapshot: &RustResolutionSnapshot,
28    ) -> Result<RustTargetResolution, RustResolutionError> {
29        syntactic::resolve(snapshot)
30    }
31
32    /// Resolve `snapshot` through the semantic database `context` holds.
33    ///
34    /// The database must already describe this exact snapshot: the same root,
35    /// requested target, unit graph, activation, source set, and source bytes.
36    /// Every difference is a `SemanticContextMismatch` refusal taken before a
37    /// query runs, and there is no fallback to the parse-only tier. What the
38    /// database does not prove keeps the answer Tier 1 gave it, so this tier
39    /// changes candidates, gaps, and the report tier alone. A physical source
40    /// instantiated under multiple snapshot units returns
41    /// `SemanticSharedSourceMismatch` before the database is queried.
42    #[cfg(feature = "semantic")]
43    pub fn resolve_semantic(
44        snapshot: &RustResolutionSnapshot,
45        context: &SemanticContext,
46    ) -> Result<RustTargetResolution, RustResolutionError> {
47        semantic::resolve(snapshot, context)
48    }
49}