Skip to content
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

Implement should_continue in chalk-recursive #774

Merged
merged 5 commits into from
Nov 29, 2022

Conversation

detrumi
Copy link
Member

@detrumi detrumi commented Aug 23, 2022

This just returns NoSolution if it shouldn't continue, but that should already be useful to rust-analyzer.

Note: Cloning of should_continue is a workaround to a rustc bug (#95734)

@detrumi
Copy link
Member Author

detrumi commented Aug 24, 2022

Build failed because of #775

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

So, returning NoSolution when stopping because should_continue returns false is inaccurate.

This should maybe be refactored a bit, but None means we know there is no solution. Ok(Ambig) means "there might be solution or there might not be, we don't know". Stopping solving early falls under that.

Depending on how helpful this really is, I might be okay with landing this with really strong comments to make the above limitation clear.

@detrumi
Copy link
Member Author

detrumi commented Nov 29, 2022

Alright, changed it to Ok(Ambig). As for refactoring, would it be useful to add Solution::QuantumExceeded, like AnswerResult::QuantumExceeded in chalk-engine?

@@ -17,7 +17,7 @@ pub trait AggregateOps<I: Interner> {
&self,
root_goal: &UCanonical<InEnvironment<Goal<I>>>,
answers: impl context::AnswerStream<I>,
should_continue: impl std::ops::Fn() -> bool,
should_continue: impl std::ops::Fn() -> bool + Clone,
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this clone bound? You should be able to pass in &should_continue to any functions to avoid a move

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I tried that in commit 8da2e1d, and that runs into a rustc bug

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add a comment so the workaround can be removed when that's fixed.

@jackh726
Copy link
Member

Alright, changed it to Ok(Ambig). As for refactoring, would it be useful to add Solution::QuantumExceeded, like AnswerResult::QuantumExceeded in chalk-engine?

yeah probably

@bors r+

@bors
Copy link
Contributor

bors commented Nov 29, 2022

📌 Commit f6ac6f5 has been approved by jackh726

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Nov 29, 2022

⌛ Testing commit f6ac6f5 with merge 75aa6cf...

@bors
Copy link
Contributor

bors commented Nov 29, 2022

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing 75aa6cf to master...

@bors bors merged commit 75aa6cf into rust-lang:master Nov 29, 2022
@detrumi detrumi deleted the should-continue branch November 30, 2022 07:25
bors added a commit to rust-lang/rust-analyzer that referenced this pull request Dec 5, 2022
Update to Chalk 88

This Chalk release introduces fuel for the recursive solver ([chalk#774](rust-lang/chalk#774)).
I'm not sure how often it calls `should_continue` compared to the other solver, so we might want to increase `CHALK_SOLVER_FUEL`, the current default value of 100 might be too low.

This should fix a lot of hangs and crashes, for example this solves the hang in #12897.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants