-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Extract struct DynSemantics<'db>
from struct Semantics<'db, DB>
#19850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
First, that type already exists, it's Second, |
Yes and no. The
Outside projects that are using rust-analyzer as a library. |
That means that if we want to have a no-db wrapper, we can transfer them to
And why can't they just use |
That would work for me as well. Looks like the only one using
In some contexts you only have access to the database via |
That has a much simpler solution: add a |
Whatever works, works for me. 👍🏻 @Veykril any preference from your side? |
The
Semantics<'db, DB>
type is currently defined like this:I was surprised to find that
Semantics<'db, DB>
never actually accessesself.db
(nor does any other code inra_ap_hir
). So I removed thepub
fromdb
to see who (if anybody) was actually using that field: Turns out the only crates that actually accesssema.db
arera_ap_ide
/ra_ap_ide_db
/rust_analyzer
.As such it is rather unfortunate for all those useful methods on
Semantics<'db, DB>
, of which none actually need access to the typeDb
, are inaccessible in contexts where onlydb: &dyn HirDatabase
is available (e.g. in salsa's tracked functions).I would thus like to propose a refactoring of
Semantics<'db, Db>
, extracting thedyn
-compatible logic intoDynSemantics<'db>
(with a plea to try to prefer the latter where applicable):The motivation behind this change is to make the resolution logic of
Semantics<'db, DB>
available indyn
contexts and to provideDynSemantics<'db>
as an alternative to the tightly coupledSemantics<'db, DB>
.(the PR is motivated by an outside use of the
ra_ap_hir
crate that would benefit from being able to accessSemantics<'db, Db>
indyn
contexts)