Skip to content

Implement rust-analyzer/evaluatePredicate lsp extension#22448

Open
Veykril wants to merge 3 commits into
rust-lang:masterfrom
Veykril:push-lupoxknmnkvo
Open

Implement rust-analyzer/evaluatePredicate lsp extension#22448
Veykril wants to merge 3 commits into
rust-lang:masterfrom
Veykril:push-lupoxknmnkvo

Conversation

@Veykril
Copy link
Copy Markdown
Member

@Veykril Veykril commented May 25, 2026

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

@Veykril Veykril force-pushed the push-lupoxknmnkvo branch from ee229e6 to 1f32056 Compare May 25, 2026 15:19
@Veykril Veykril marked this pull request as ready for review May 25, 2026 15:21
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 25, 2026
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(
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

View changes since the review

Comment thread crates/hir-ty/src/traits.rs Outdated
@Veykril Veykril force-pushed the push-lupoxknmnkvo branch from 1f32056 to 3ae6afb Compare May 30, 2026 11:52
@rustbot

This comment has been minimized.

Comment thread crates/hir-ty/src/consteval.rs Outdated
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum AnonConstInterning {
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }?

View changes since the review

Copy link
Copy Markdown
Member Author

@Veykril Veykril May 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@Veykril Veykril force-pushed the push-lupoxknmnkvo branch from 3ae6afb to c6c0bab Compare June 1, 2026 10:04
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 1, 2026

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.

@Veykril Veykril force-pushed the push-lupoxknmnkvo branch from c6c0bab to b569a4f Compare June 1, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants