Implement rust-analyzer/evaluatePredicate lsp extension#22448
Conversation
ee229e6 to
1f32056
Compare
| let interner = DbInterner::new_with(db, env.krate); | ||
| let infcx = interner.infer_ctxt().build(TypingMode::PostAnalysis); | ||
| let generics = OnceCell::<Generics<'db>>::new(); | ||
| let mut ctx = TyLoweringContext::new( |
There was a problem hiding this comment.
The problem with lowering here is that it may intern some things (blocks, anon consts, items). This amplifies the problem we already have by lowering in hir.
IMO the only solution is to have a mode for TyLoweringContext where it never interns anything.
1f32056 to
3ae6afb
Compare
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub(crate) enum AnonConstInterning { |
There was a problem hiding this comment.
I feel this is a bit too specific given we only have the distinction between lowering during analysis and lowering for IDE, and that there are many forms of lowering we use (e.g. hir-def). Maybe something like enum LoweringMode { Analysis, Ide }?
There was a problem hiding this comment.
Yea definitely, was just not planning into looking into this more than that right now. Will do another pass and generalize that later (or I guess rename for now and add a fixme)
There was a problem hiding this comment.
Changed this a to single LoweringMode enum, currently only tracks anon consts. Will move blocks over to this in a separate PR (and then try turning the blocks back into tracked structs in fact).
3ae6afb to
c6c0bab
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
c6c0bab to
b569a4f
Compare
Allows you to have rust-analyzer solve an arbitrary predicate for the cursor position, telling you whether the predicate definitely holds.
2026_05_25_17-20__53m.mp4
Authored with gpt-5.5 and manual reviews / touch ups