pub struct CodeResolver<'a> { /* private fields */ }Expand description
Module-level code lookup with source-owned item/module/target association.
A lookup uses code-head edition and dev/test rules, rather than use rules.
The caller must first classify lexical locals, parameters, generic bindings
and block imports. This query does not infer those scopes, expand macros,
resolve Self or authenticate an unindexed dependency from its spelling.
Item identities belong to the workspace that constructed this query.
Implementations§
Source§impl CodeResolver<'_>
impl CodeResolver<'_>
Sourcepub fn unconditional_enum_alias(
&self,
alias: ItemId,
) -> Result<Option<ItemId>, CodeResolveError>
pub fn unconditional_enum_alias( &self, alias: ItemId, ) -> Result<Option<ItemId>, CodeResolveError>
Resolve a plain type alias to its enum through unconditional named paths. The query admits the same bounded const argument forms as associated member lookup. Other nominal types supply no enum identity.
§Errors
Refuses an absent alias, an uncertain or unsupported alias chain and exhausted query resources.
Sourcepub fn unconditional_nominal_alias(
&self,
alias: ItemId,
) -> Result<(Option<ItemId>, Usage), CodeResolveError>
pub fn unconditional_nominal_alias( &self, alias: ItemId, ) -> Result<(Option<ItemId>, Usage), CodeResolveError>
Resolve a written first-party alias to its indexed struct, enum or union.
Returns no identity for an unindexed target or a form outside the zero-parameter named alias and literal const argument profile. The returned usage includes the work of an unsuccessful supported probe.
§Errors
Refuses absent items, ambiguous, cyclic or conditional indexed routes, broken explicitly local paths and exhausted query resources.
Sourcepub fn require_unconditional_inherent_method(
&self,
site: ItemId,
) -> Result<(), CodeResolveError>
pub fn require_unconditional_inherent_method( &self, site: ItemId, ) -> Result<(), CodeResolveError>
Require a method whose self type applies without generic inference.
Admits direct nominal types with no parameters, or the exact forwarding of all unconstrained nominal const parameters. General bounds, defaults, type/lifetime substitution and aliased impl headers need more evidence. Configuration and unexpanded declaration attributes remain caller audits.
§Errors
Refuses absent items and every method outside that proven header subset.
Source§impl CodeResolver<'_>
impl CodeResolver<'_>
Sourcepub fn extern_libraries_at(
&self,
owner: ItemId,
byte: usize,
) -> Result<impl Iterator<Item = ExternLibrary<'_>> + '_, CodeResolveError>
pub fn extern_libraries_at( &self, owner: ItemId, byte: usize, ) -> Result<impl Iterator<Item = ExternLibrary<'_>> + '_, CodeResolveError>
Borrow every actual external library candidate from the owner’s admitted tables.
Uses existing target/dev/test filtering and settled Cargo names; custom library
names, renames and explicit extern crate aliases are retained. Unindexed
external names yield no library receipt. Every original-name candidate is
preserved; choosing a receipt does not remove its group’s ambiguity.
§Errors
Refuses absent/outside owners, missing context and macro definition bodies.
Source§impl CodeResolver<'_>
impl CodeResolver<'_>
Sourcepub fn with_configured_syntax<R: Send>(
&self,
target: TargetId,
path: &RelPath,
inspect: impl FnOnce(&SourceFile, &File) -> R + Send,
) -> Result<R, CodeResolveError>
pub fn with_configured_syntax<R: Send>( &self, target: TargetId, path: &RelPath, inspect: impl FnOnce(&SourceFile, &File) -> R + Send, ) -> Result<R, CodeResolveError>
Inspect an actual loaded file after its target’s declared header selection.
Uses the same parser and configuration filter as indexing. Spans retain their original physical bytes. Selection covers modeled declaration headers, not conditional body expressions or macro expansion. Borrowed syntax cannot escape the parse worker. Temporary selection uses the original load allowance after this query’s retained reading table; it never receives a fresh allowance.
§Errors
Refuses absent/unconfigured targets, files not reached by that target, and original bounded parser/configuration failures with their typed causes.
Source§impl<'a> CodeResolver<'a>
impl<'a> CodeResolver<'a>
Sourcepub const fn usage(&self) -> Usage
pub const fn usage(&self) -> Usage
The original load plus this query’s retained reading-table allowance.
Sourcepub fn indexed_imports(&self) -> impl Iterator<Item = IndexedImport<'_, 'a>>
pub fn indexed_imports(&self) -> impl Iterator<Item = IndexedImport<'_, 'a>>
Every flattened module import in its exact admitted reading context.
Sourcepub fn resolve_from_file_reach(
&self,
reach: &Reach,
path: &str,
namespace: Namespace,
) -> Result<Resolution, CodeResolveError>
pub fn resolve_from_file_reach( &self, reach: &Reach, path: &str, namespace: Namespace, ) -> Result<Resolution, CodeResolveError>
Resolve a name at the file’s own module, as reached by this workspace. Use this for file-level syntax that has no named item of its own.
§Errors
Refuses a reach whose target or module is absent from this index. Preserves every shared resolver error.
Sourcepub fn resolve_import_from_file_reach(
&self,
reach: &Reach,
path: &str,
namespace: Namespace,
) -> Result<Resolution, CodeResolveError>
pub fn resolve_import_from_file_reach( &self, reach: &Reach, path: &str, namespace: Namespace, ) -> Result<Resolution, CodeResolveError>
Resolve an import spelling in a file’s own module and target.
§Errors
Refuses an absent reach and preserves the shared resolver errors.
Sourcepub fn resolve_from_impl(
&self,
implementation: ImplId,
path: &str,
namespace: Namespace,
import: bool,
) -> Result<Resolution, CodeResolveError>
pub fn resolve_from_impl( &self, implementation: ImplId, path: &str, namespace: Namespace, import: bool, ) -> Result<Resolution, CodeResolveError>
Read a module-level path in the lexical module of an indexed impl. Use this for the impl header, which has no named item of its own.
§Errors
Refuses an unknown impl and preserves every shared resolver error.
Sourcepub fn reading_module(
&self,
owner: ItemId,
byte: usize,
) -> Result<&str, CodeResolveError>
pub fn reading_module( &self, owner: ItemId, byte: usize, ) -> Result<&str, CodeResolveError>
The actual reading module of a byte within an indexed owner. Inline module bodies read their own module; their declaration headers read the containing module. Method and trait ownership comes from Source.
§Errors
Refuses an absent owner, outside byte or missing reading context.
Sourcepub fn has_unconditional_reading_module(
&self,
owner: ItemId,
byte: usize,
) -> Result<bool, CodeResolveError>
pub fn has_unconditional_reading_module( &self, owner: ItemId, byte: usize, ) -> Result<bool, CodeResolveError>
Whether an owner’s reading module and its ancestors have no indexed configuration-dependent declarations or file reaches.
This classifies the module route. The caller still checks the syntax of the occurrence and its enclosing items.
§Errors
Refuses an absent owner, outside byte, missing context or exceeded query grant.
Sourcepub fn has_unconditional_file_reach(
&self,
reach: &Reach,
) -> Result<bool, CodeResolveError>
pub fn has_unconditional_file_reach( &self, reach: &Reach, ) -> Result<bool, CodeResolveError>
Check a file reach’s module and ancestor declarations for configuration dependence.
§Errors
Refuses an absent reach or an exceeded query grant.
Sourcepub fn is_defined_in(
&self,
owner: ItemId,
scope: ItemId,
) -> Result<bool, CodeResolveError>
pub fn is_defined_in( &self, owner: ItemId, scope: ItemId, ) -> Result<bool, CodeResolveError>
Whether an indexed item is defined in this actual module or a descendant. A relocated export and an impl member keep their lexical defining module. Distinct targets never share scope merely because their paths agree.
§Errors
Refuses absent identities, a non-module scope or missing reading context.
Sourcepub fn resolve_from_item_at(
&self,
owner: ItemId,
byte: usize,
path: &str,
namespace: Namespace,
) -> Result<Resolution, CodeResolveError>
pub fn resolve_from_item_at( &self, owner: ItemId, byte: usize, path: &str, namespace: Namespace, ) -> Result<Resolution, CodeResolveError>
Resolve a module-level code path in one namespace from its actual owner. Lexical shadow classification is a separate prerequisite; successful module lookup alone is not proof that an occurrence names that item.
§Errors
Refuses missing reading context and preserves every shared resolver error.
Sourcepub fn resolve_import_from_item_at(
&self,
owner: ItemId,
byte: usize,
path: &str,
namespace: Namespace,
) -> Result<Resolution, CodeResolveError>
pub fn resolve_import_from_item_at( &self, owner: ItemId, byte: usize, path: &str, namespace: Namespace, ) -> Result<Resolution, CodeResolveError>
Resolve an import spelling from an actual source owner’s reading module.
This preserves edition-specific use roots for block import observations;
it does not register a lexical import or infer a missing external namespace.
§Errors
The owner, macro-body and shared resolver refusals of code lookup.
Sourcepub fn enum_member_imports_from_item_at(
&self,
owner: ItemId,
byte: usize,
path: &str,
namespace: Namespace,
import: bool,
) -> Result<Option<Vec<(ItemId, String)>>, CodeResolveError>
pub fn enum_member_imports_from_item_at( &self, owner: ItemId, byte: usize, path: &str, namespace: Namespace, import: bool, ) -> Result<Option<Vec<(ItemId, String)>>, CodeResolveError>
Follow visible imports to candidate members of indexed enums.
Each candidate carries an enum identity and the terminal spelling in
the import. The caller validates the declaration and constructor form
and requires a unique surviving definition. Classify lexical shadowing before
asking this module-level query. Set import when the spelling was
written in an import declaration, to preserve its edition rules.
An empty candidate list means the inspected routes supply no variants.
An existing definition or an inconclusive or conditional route returns
None, so the caller cannot infer the name is available to another route.
§Errors
Refuses missing owner context, invalid paths and native resource exhaustion.
Sourcepub fn enum_member_imports_from_file_reach(
&self,
reach: &Reach,
path: &str,
namespace: Namespace,
import: bool,
) -> Result<Option<Vec<(ItemId, String)>>, CodeResolveError>
pub fn enum_member_imports_from_file_reach( &self, reach: &Reach, path: &str, namespace: Namespace, import: bool, ) -> Result<Option<Vec<(ItemId, String)>>, CodeResolveError>
Follow visible enum member imports from a file’s own module and target.
As Self::enum_member_imports_from_item_at, validate candidates against the
enum declaration and set import for a spelling read in an import.
§Errors
Refuses an absent reach, invalid path or exhausted query resources.
Sourcepub fn unconditional_type_from_item_at(
&self,
owner: ItemId,
byte: usize,
path: &str,
import: bool,
) -> Result<Option<ItemId>, CodeResolveError>
pub fn unconditional_type_from_item_at( &self, owner: ItemId, byte: usize, path: &str, import: bool, ) -> Result<Option<ItemId>, CodeResolveError>
Find a single named type whose module and import route is unconditional. Lexical bindings inside blocks and type alias substitution belong to the caller.
§Errors
Refuses an invalid reading context or path and native resource exhaustion.
Sourcepub fn unconditional_type_from_file_reach(
&self,
reach: &Reach,
path: &str,
import: bool,
) -> Result<Option<ItemId>, CodeResolveError>
pub fn unconditional_type_from_file_reach( &self, reach: &Reach, path: &str, import: bool, ) -> Result<Option<ItemId>, CodeResolveError>
Find a single named type by an unconditional route from a file’s own module.
§Errors
Refuses an absent reach, invalid path or exhausted query resources.
Auto Trait Implementations§
impl<'a> Forget for CodeResolver<'a>
impl<'a> Freeze for CodeResolver<'a>
impl<'a> Move for CodeResolver<'a>
impl<'a> RefUnwindSafe for CodeResolver<'a>
impl<'a> Send for CodeResolver<'a>
impl<'a> Sync for CodeResolver<'a>
impl<'a> Unpin for CodeResolver<'a>
impl<'a> UnsafeUnpin for CodeResolver<'a>
impl<'a> UnwindSafe for CodeResolver<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more