Skip to content

Switch from Chalk to the next trait solver #20329

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

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

jackh726
Copy link
Member

@jackh726 jackh726 commented Jul 28, 2025

At this point, opening up for general review, though I don't think this is fully ready to merge.

Some checklist (non-exhaustive) of things to do before/after merge (feel free to edit):

Before:

  • Fix the tidy lints (currently, I see that we need to add doc tests to the new files)
  • Squash (or just rework) commits
  • Review all the changed tests, open an issue to track the "real" regressions
  • Go through the todo!()s and FIXMEs and decide which are needed/useful to fix prior to merge
  • Decide what (if anything) should get upstreamed in a separate PR(s) first
  • Switch with_db calls to ScopedDb::set_db (or decide on a better API)

After (before stable):

  • Test across different projects, find things that are "blocking" (probably after merge)
  • Figure out where memory opts can be made

After (any time):

  • Transition things to from chalk_ir to rustc_type_ir
    • Inference table blocks a lot of things (e.g. normalization)
    • Some queries are "easy" like layout_of_ty

Mixed:

  • General cleanup of things
    • Reduce/remove allow(unused)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 28, 2025
@@ -48,7 +48,8 @@ impl ToTokens for TrackedQuery {
quote!(#(#options),*)
})
.into_iter()
.chain(self.lru.map(|lru| quote!(lru = #lru)));
.chain(self.lru.map(|lru| quote!(lru = #lru)))
.chain(Some(quote!(unsafe(non_update_return_type))));
Copy link
Contributor

Choose a reason for hiding this comment

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

That should be changed before merge, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, if someone can point me to how to fix it.

Copy link
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

First round of review, I think that's what I will be able to do today.

@@ -29,20 +47,24 @@ mod infer;
mod inhabitedness;
mod interner;
mod lower;
mod lower_nextsolver;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are all those X_nextsolver modules supposed to replace their original before merge?

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 think that's pretty much impossible if we want this to land anytime soon. There is so much that relies on the non-next solver modules that goes beyond trait solving.


#[salsa::invoke(crate::drop::has_drop_glue)]
#[salsa::cycle(cycle_result = crate::drop::has_drop_glue_cycle_result)]
fn has_drop_glue(&self, ty: Ty, env: Arc<TraitEnvironment>) -> DropGlue;

#[salsa::invoke(crate::layout_nextsolver::layout_of_adt_query)]
Copy link
Contributor

Choose a reason for hiding this comment

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

The fully qualified names everywhere (crate::X_nextsolver::X) make the code harder to read, but I suppose we'll get rid of that once we remove the Chalk types.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, if there are specific places that make sense to remove them, let me know. But unfortunately a lot of them are kind of necessary.

@rust-cloud-vms rust-cloud-vms bot force-pushed the next-trait-solver-querify branch from 0c5be1c to 57c7b7d Compare July 31, 2025 21:36
@jackh726
Copy link
Member Author

jackh726 commented Aug 1, 2025

Squashed and rebased version here: jackh726@5fa8436

Will switch this PR after a bit of review, just so people can see commits if they need.

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

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

Just a quick glance

@rust-cloud-vms rust-cloud-vms bot force-pushed the next-trait-solver-querify branch from 8c0dd60 to eb38567 Compare August 2, 2025 01:15
@rust-cloud-vms rust-cloud-vms bot force-pushed the next-trait-solver-querify branch from eb38567 to ab8258d Compare August 2, 2025 01:18
@Veykril Veykril force-pushed the next-trait-solver-querify branch from 93688bb to fbf45f7 Compare August 2, 2025 07:23
if GLOBAL_CACHE.is_set() {
GLOBAL_CACHE.with(call)
} else {
GLOBAL_CACHE.set(&RefCell::new(GlobalCache::default()), || GLOBAL_CACHE.with(call))
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting the TLS without context seems like it may cause (hard-to-debug) problems by sharing the cache across revisions, when things have changed.

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.

6 participants