struct LookupTable<'db> {
data: FxHashMap<Type<'db>, AlternativeExprs<'db>>,
new_types: FxHashMap<NewTypesKey, Vec<Type<'db>>>,
types_wishlist: FxHashSet<Type<'db>>,
many_threshold: usize,
}Expand description
§Lookup table for term search
Lookup table keeps all the state during term search. This means it knows what types and how are reachable.
The secondary functionality for lookup table is to keep track of new types reached since last
iteration as well as keeping track of which ScopeDef items have been used.
Both of them are to speed up the term search by leaving out types / ScopeDefs that likely do
not produce any new results.
Fields§
§data: FxHashMap<Type<'db>, AlternativeExprs<'db>>All the Exprs in “value” produce the type of “key”
new_types: FxHashMap<NewTypesKey, Vec<Type<'db>>>New types reached since last query by the NewTypesKey
types_wishlist: FxHashSet<Type<'db>>Types queried but not present
many_threshold: usizeThreshold to squash trees to Many
Implementations§
Source§impl<'db> LookupTable<'db>
impl<'db> LookupTable<'db>
Sourcefn find(
&mut self,
db: &'db dyn HirDatabase,
ty: &Type<'db>,
) -> Option<Vec<Expr<'db>>>
fn find( &mut self, db: &'db dyn HirDatabase, ty: &Type<'db>, ) -> Option<Vec<Expr<'db>>>
Find all Exprs that unify with the ty
Sourcefn find_autoref(
&mut self,
db: &'db dyn HirDatabase,
ty: &Type<'db>,
) -> Option<Vec<Expr<'db>>>
fn find_autoref( &mut self, db: &'db dyn HirDatabase, ty: &Type<'db>, ) -> Option<Vec<Expr<'db>>>
Same as find but automatically creates shared reference of types in the lookup
For example if we have type i32 in data and we query for &i32 it map all the type
trees we have for i32 with Expr::Reference and returns them.
Sourcefn insert(&mut self, ty: Type<'db>, exprs: impl Iterator<Item = Expr<'db>>)
fn insert(&mut self, ty: Type<'db>, exprs: impl Iterator<Item = Expr<'db>>)
Insert new type trees for type
Note that the types have to be the same, unification is not enough as unification is not
transitive. For example Vec<i32> and FxHashSet<i32> both unify with Iterator<Item = i32>,
but they clearly do not unify themselves.
Sourcefn iter_types(&self) -> impl Iterator<Item = Type<'db>> + '_
fn iter_types(&self) -> impl Iterator<Item = Type<'db>> + '_
Iterate all the reachable types
Sourcefn new_types(&mut self, key: NewTypesKey) -> Vec<Type<'db>>
fn new_types(&mut self, key: NewTypesKey) -> Vec<Type<'db>>
Query new types reached since last query by key
Create new key if you wish to query it to avoid conflicting with existing queries.
Sourcefn types_wishlist(&mut self) -> &FxHashSet<Type<'db>>
fn types_wishlist(&mut self) -> &FxHashSet<Type<'db>>
Types queried but not found
Trait Implementations§
Source§impl<'db> Debug for LookupTable<'db>
impl<'db> Debug for LookupTable<'db>
Source§impl<'db> Default for LookupTable<'db>
impl<'db> Default for LookupTable<'db>
Source§fn default() -> LookupTable<'db>
fn default() -> LookupTable<'db>
Auto Trait Implementations§
impl<'db> Freeze for LookupTable<'db>
impl<'db> RefUnwindSafe for LookupTable<'db>
impl<'db> Send for LookupTable<'db>
impl<'db> Sync for LookupTable<'db>
impl<'db> Unpin for LookupTable<'db>
impl<'db> UnwindSafe for LookupTable<'db>
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
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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