Skip to main content

CodeResolver

Struct CodeResolver 

Source
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<'_>

Source

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.

Source

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.

Source

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<'_>

Source

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<'_>

Source

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>

Source

pub const fn usage(&self) -> Usage

The original load plus this query’s retained reading-table allowance.

Source

pub fn indexed_imports(&self) -> impl Iterator<Item = IndexedImport<'_, 'a>>

Every flattened module import in its exact admitted reading context.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.