pub struct VariableTracker<'ctx> { /* private fields */ }Expand description
Tracks variable definitions and their mutability state.
Implementations§
Source§impl<'ctx> VariableTracker<'ctx>
impl<'ctx> VariableTracker<'ctx>
Sourcepub fn extend_from_environment(&mut self, environment: &Environment<'ctx>)
pub fn extend_from_environment(&mut self, environment: &Environment<'ctx>)
Extends the variable tracker from the variables present in the environment.
Sourcepub fn insert(&mut self, var: Binding<'ctx>) -> Option<Binding<'ctx>>
pub fn insert(&mut self, var: Binding<'ctx>) -> Option<Binding<'ctx>>
Inserts a semantic definition for a variable. Returns the old value if the variable was already defined.
Sourcepub fn is_mut(&self, var_id: &VarId<'ctx>) -> bool
pub fn is_mut(&self, var_id: &VarId<'ctx>) -> bool
Returns true if the variable is currently mutable. A variable is mutable only if declared mutable AND not referenced.
Sourcepub fn is_mut_expr(&self, expr: &ExprAndId<'ctx>) -> bool
pub fn is_mut_expr(&self, expr: &ExprAndId<'ctx>) -> bool
Returns true if the expression is a variable or a member access of a mutable variable.
Sourcepub fn report_var_mutability_error(
&self,
db: &'ctx dyn Database,
diagnostics: &mut SemanticDiagnostics<'ctx>,
var_id: &VarId<'ctx>,
error_ptr: impl Into<SyntaxStablePtrId<'ctx>>,
immutable_diagnostic: SemanticDiagnosticKind<'ctx>,
)
pub fn report_var_mutability_error( &self, db: &'ctx dyn Database, diagnostics: &mut SemanticDiagnostics<'ctx>, var_id: &VarId<'ctx>, error_ptr: impl Into<SyntaxStablePtrId<'ctx>>, immutable_diagnostic: SemanticDiagnosticKind<'ctx>, )
Reports a mutability error if the variable cannot be modified.
Sourcepub fn mark_referenced(
&mut self,
expr: &ExprAndId<'ctx>,
reference_location: SyntaxStablePtrId<'ctx>,
)
pub fn mark_referenced( &mut self, expr: &ExprAndId<'ctx>, reference_location: SyntaxStablePtrId<'ctx>, )
Marks an expression as pointed to if it refers to a mutable variable.
Trait Implementations§
Source§impl<'ctx> Debug for VariableTracker<'ctx>
impl<'ctx> Debug for VariableTracker<'ctx>
Source§impl<'ctx> Default for VariableTracker<'ctx>
impl<'ctx> Default for VariableTracker<'ctx>
Source§fn default() -> VariableTracker<'ctx>
fn default() -> VariableTracker<'ctx>
Returns the “default value” for a type. Read more
Source§impl<'ctx> PartialEq for VariableTracker<'ctx>
impl<'ctx> PartialEq for VariableTracker<'ctx>
impl<'ctx> Eq for VariableTracker<'ctx>
impl<'ctx> StructuralPartialEq for VariableTracker<'ctx>
Auto Trait Implementations§
impl<'ctx> Freeze for VariableTracker<'ctx>
impl<'ctx> RefUnwindSafe for VariableTracker<'ctx>
impl<'ctx> Send for VariableTracker<'ctx>
impl<'ctx> Sync for VariableTracker<'ctx>
impl<'ctx> Unpin for VariableTracker<'ctx>
impl<'ctx> UnwindSafe for VariableTracker<'ctx>
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
Mutably borrows from an owned value. Read more
Source§impl<'db, T> DebugDbUpcast<'db, T> for Twhere
T: ?Sized,
impl<'db, T> DebugDbUpcast<'db, T> for Twhere
T: ?Sized,
fn debug_db_upcast(&'db self) -> &'db T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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