SourceAnalyzer

Struct SourceAnalyzer 

Source
pub(crate) struct SourceAnalyzer<'db> {
    pub(crate) file_id: HirFileId,
    pub(crate) resolver: Resolver<'db>,
    pub(crate) body_or_sig: Option<BodyOrSig<'db>>,
}
Expand description

SourceAnalyzer is a convenience wrapper which exposes HIR API in terms of original source files. It should not be used inside the HIR itself.

Fields§

§file_id: HirFileId§resolver: Resolver<'db>§body_or_sig: Option<BodyOrSig<'db>>

Implementations§

Source§

impl<'db> SourceAnalyzer<'db>

Source

pub(crate) fn new_for_body( db: &'db dyn HirDatabase, def: DefWithBodyId, node: InFile<&SyntaxNode>, offset: Option<TextSize>, ) -> SourceAnalyzer<'db>

Source

pub(crate) fn new_for_body_no_infer( db: &'db dyn HirDatabase, def: DefWithBodyId, node: InFile<&SyntaxNode>, offset: Option<TextSize>, ) -> SourceAnalyzer<'db>

Source

pub(crate) fn new_for_body_( db: &'db dyn HirDatabase, def: DefWithBodyId, node: InFile<&SyntaxNode>, offset: Option<TextSize>, infer: Option<&'db InferenceResult>, ) -> SourceAnalyzer<'db>

Source

pub(crate) fn new_generic_def( db: &'db dyn HirDatabase, def: GenericDefId, _: InFile<&SyntaxNode>, _offset: Option<TextSize>, ) -> SourceAnalyzer<'db>

Source

pub(crate) fn new_variant_body( db: &'db dyn HirDatabase, def: VariantId, _: InFile<&SyntaxNode>, _offset: Option<TextSize>, ) -> SourceAnalyzer<'db>

Source

pub(crate) fn new_for_resolver( resolver: Resolver<'db>, node: InFile<&SyntaxNode>, ) -> SourceAnalyzer<'db>

Source

fn body_( &self, ) -> Option<(DefWithBodyId, &Body, &BodySourceMap, Option<&InferenceResult>)>

Source

fn infer(&self) -> Option<&InferenceResult>

Source

fn body(&self) -> Option<&Body>

Source

pub(crate) fn store(&self) -> Option<&ExpressionStore>

Source

pub(crate) fn store_sm(&self) -> Option<&ExpressionStoreSourceMap>

Source

fn param_and<'a>(&self, param_env: ParamEnv<'a>) -> ParamEnvAndCrate<'a>

Source

fn trait_environment(&self, db: &'db dyn HirDatabase) -> ParamEnvAndCrate<'db>

Source

pub(crate) fn expr_id(&self, expr: Expr) -> Option<ExprOrPatId>

Source

fn pat_id(&self, pat: &Pat) -> Option<ExprOrPatId>

Source

fn type_id(&self, pat: &Type) -> Option<TypeRefId>

Source

fn binding_id_of_pat(&self, pat: &IdentPat) -> Option<BindingId>

Source

pub(crate) fn expr_adjustments(&self, expr: &Expr) -> Option<&[Adjustment]>

Source

pub(crate) fn type_of_type( &self, db: &'db dyn HirDatabase, ty: &Type, ) -> Option<Type<'db>>

Source

pub(crate) fn type_of_expr( &self, db: &'db dyn HirDatabase, expr: &Expr, ) -> Option<(Type<'db>, Option<Type<'db>>)>

Source

pub(crate) fn type_of_pat( &self, db: &'db dyn HirDatabase, pat: &Pat, ) -> Option<(Type<'db>, Option<Type<'db>>)>

Source

pub(crate) fn type_of_binding_in_pat( &self, db: &'db dyn HirDatabase, pat: &IdentPat, ) -> Option<Type<'db>>

Source

pub(crate) fn type_of_self( &self, db: &'db dyn HirDatabase, _param: &SelfParam, ) -> Option<Type<'db>>

Source

pub(crate) fn binding_mode_of_pat( &self, _db: &'db dyn HirDatabase, pat: &IdentPat, ) -> Option<BindingMode>

Source

pub(crate) fn pattern_adjustments( &self, db: &'db dyn HirDatabase, pat: &Pat, ) -> Option<SmallVec<[Type<'db>; 1]>>

Source

pub(crate) fn resolve_method_call_as_callable( &self, db: &'db dyn HirDatabase, call: &MethodCallExpr, ) -> Option<Callable<'db>>

Source

pub(crate) fn resolve_method_call( &self, db: &'db dyn HirDatabase, call: &MethodCallExpr, ) -> Option<Function>

Source

pub(crate) fn resolve_method_call_fallback( &self, db: &'db dyn HirDatabase, call: &MethodCallExpr, ) -> Option<(Either<Function, Field>, Option<GenericSubstitution<'db>>)>

Source

pub(crate) fn resolve_expr_as_callable( &self, db: &'db dyn HirDatabase, call: &Expr, ) -> Option<Callable<'db>>

Source

pub(crate) fn resolve_field( &self, field: &FieldExpr, ) -> Option<Either<Field, TupleField>>

Source

fn field_subst( &self, field_expr: ExprId, infer: &InferenceResult, db: &'db dyn HirDatabase, ) -> Option<GenericSubstitution<'db>>

Source

pub(crate) fn resolve_field_fallback( &self, db: &'db dyn HirDatabase, field: &FieldExpr, ) -> Option<(Either<Either<Field, TupleField>, Function>, Option<GenericSubstitution<'db>>)>

Source

pub(crate) fn resolve_range_pat( &self, db: &'db dyn HirDatabase, range_pat: &RangePat, ) -> Option<StructId>

Source

pub(crate) fn resolve_range_expr( &self, db: &'db dyn HirDatabase, range_expr: &RangeExpr, ) -> Option<StructId>

Source

pub(crate) fn resolve_await_to_poll( &self, db: &'db dyn HirDatabase, await_expr: &AwaitExpr, ) -> Option<Function>

Source

pub(crate) fn resolve_prefix_expr( &self, db: &'db dyn HirDatabase, prefix_expr: &PrefixExpr, ) -> Option<Function>

Source

pub(crate) fn resolve_index_expr( &self, db: &'db dyn HirDatabase, index_expr: &IndexExpr, ) -> Option<Function>

Source

pub(crate) fn resolve_bin_expr( &self, db: &'db dyn HirDatabase, binop_expr: &BinExpr, ) -> Option<Function>

Source

pub(crate) fn resolve_try_expr( &self, db: &'db dyn HirDatabase, try_expr: &TryExpr, ) -> Option<Function>

Source

pub(crate) fn resolve_record_field( &self, db: &'db dyn HirDatabase, field: &RecordExprField, ) -> Option<(Field, Option<Local>, Type<'db>, GenericSubstitution<'db>)>

Source

pub(crate) fn resolve_record_pat_field( &self, db: &'db dyn HirDatabase, field: &RecordPatField, ) -> Option<(Field, Type<'db>, GenericSubstitution<'db>)>

Source

pub(crate) fn resolve_bind_pat_to_const( &self, db: &'db dyn HirDatabase, pat: &IdentPat, ) -> Option<ModuleDef>

Source

pub(crate) fn resolve_use_type_arg(&self, name: &NameRef) -> Option<TypeParam>

Source

pub(crate) fn resolve_offset_of_field( &self, db: &'db dyn HirDatabase, name_ref: &NameRef, ) -> Option<(Either<Variant, Field>, GenericSubstitution<'db>)>

Source

pub(crate) fn resolve_path( &self, db: &'db dyn HirDatabase, path: &Path, ) -> Option<(PathResolution, Option<GenericSubstitution<'db>>)>

Source

pub(crate) fn resolve_hir_path_per_ns( &self, db: &dyn HirDatabase, path: &Path, ) -> Option<PathResolutionPerNs>

Source

pub(crate) fn record_literal_missing_fields( &self, db: &'db dyn HirDatabase, literal: &RecordExpr, ) -> Option<Vec<(Field, Type<'db>)>>

Source

pub(crate) fn record_pattern_missing_fields( &self, db: &'db dyn HirDatabase, pattern: &RecordPat, ) -> Option<Vec<(Field, Type<'db>)>>

Source

fn missing_fields( &self, db: &'db dyn HirDatabase, substs: GenericArgs<'db>, variant: VariantId, missing_fields: Vec<LocalFieldId>, ) -> Vec<(Field, Type<'db>)>

Source

pub(crate) fn resolve_variant( &self, record_lit: RecordExpr, ) -> Option<VariantId>

Source

pub(crate) fn is_unsafe_macro_call_expr( &self, db: &'db dyn HirDatabase, macro_expr: InFile<&MacroExpr>, ) -> bool

Source

pub(crate) fn resolve_offset_in_format_args( &self, db: &'db dyn HirDatabase, format_args: InFile<&FormatArgsExpr>, offset: TextSize, ) -> Option<(TextRange, Option<PathResolution>)>

Returns the range of the implicit template argument and its resolution at the given offset

Source

pub(crate) fn resolve_offset_in_asm_template( &self, asm: InFile<&AsmExpr>, line: usize, offset: TextSize, ) -> Option<(DefWithBodyId, (ExprId, TextRange, usize))>

Source

pub(crate) fn as_format_args_parts<'a>( &'a self, db: &'a dyn HirDatabase, format_args: InFile<&FormatArgsExpr>, ) -> Option<impl Iterator<Item = (TextRange, Option<PathResolution>)> + 'a>

Source

pub(crate) fn as_asm_parts( &self, asm: InFile<&AsmExpr>, ) -> Option<(DefWithBodyId, (ExprId, &[Vec<(TextRange, usize)>]))>

Source

fn resolve_impl_method_or_trait_def( &self, db: &'db dyn HirDatabase, func: FunctionId, substs: GenericArgs<'db>, ) -> Function

Source

fn resolve_impl_method_or_trait_def_with_subst( &self, db: &'db dyn HirDatabase, func: FunctionId, substs: GenericArgs<'db>, ) -> (Function, GenericArgs<'db>)

Source

fn resolve_impl_const_or_trait_def_with_subst( &self, db: &'db dyn HirDatabase, const_id: ConstId, subs: GenericArgs<'db>, ) -> (ConstId, GenericArgs<'db>)

Source

fn lang_items<'a>(&self, db: &'a dyn HirDatabase) -> &'a LangItems

Source

fn lang_trait_fn( &self, db: &'db dyn HirDatabase, lang_trait: Option<TraitId>, method_name: &Name, ) -> Option<(TraitId, FunctionId)>

Source

fn ty_of_expr(&self, expr: Expr) -> Option<Ty<'db>>

Trait Implementations§

Source§

impl<'db> Debug for SourceAnalyzer<'db>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'db> Freeze for SourceAnalyzer<'db>

§

impl<'db> !RefUnwindSafe for SourceAnalyzer<'db>

§

impl<'db> Send for SourceAnalyzer<'db>

§

impl<'db> Sync for SourceAnalyzer<'db>

§

impl<'db> Unpin for SourceAnalyzer<'db>

§

impl<'db> !UnwindSafe for SourceAnalyzer<'db>

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
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send + Sync> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Send + Sync>

Convert self into the appropriate boxed form.
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,