Make Semantics<'db, DB>
support Semantics<'db, dyn HirDatabase>
, take two
#19930
+18
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(This is a follow-up for #19850)
@ChayimFriedman2 it looks like I was a bit too quick trusting the suggested fix of just replacing
DB
withDB: ?Sized
: it doesn't work, theSemantics<'_, dyn HirDatabase>
isn't actually constructible.I only did a quick type-level check like this on the previous PR, following your change request, which compiled just fine:
But replacing
todo!()
withSemantics::new(db)
would have quickly shown that a couple ofimpl
s would requireDB: ?Sized
as well (iirc I had those initially, but clippy complained about them being unnecessary, so I removed them).That said: even with those fixed, the "just change
DB
toDB: ?Sized
doesn't work, due to this:So I'd like to re-propose either:
DynSemantics<'db>
in addition to the existing sema types (as I initially proposed), orSemanticsImpl<'db>
withDynSemantics<'db>
(or rather refactoring it into that shape).I've pushed the missing
DB: ?Sized
changes as a commit to this PR to illustrate the issue.I'll replace it with whatever approach gets picked.