Skip to content

Move fulfillment into rustc_next_trait_solver - #160485

Open
amirHdev wants to merge 2 commits into
rust-lang:mainfrom
amirHdev:move-fulfill-next-solver
Open

Move fulfillment into rustc_next_trait_solver#160485
amirHdev wants to merge 2 commits into
rust-lang:mainfrom
amirHdev:move-fulfill-next-solver

Conversation

@amirHdev

@amirHdev amirHdev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

It moves the rustc fulfillment implementation into the shared crate
migrating rust-analyzer to the shared implementation will require the updated shared crates to be published and may need frontend specific adjustments
Part of #159654

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 4, 2026
@rust-log-analyzer

This comment has been minimized.

@amirHdev
amirHdev force-pushed the move-fulfill-next-solver branch from d614184 to 499da05 Compare August 4, 2026 09:11
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
@amirHdev
amirHdev force-pushed the move-fulfill-next-solver branch from 499da05 to 247c257 Compare August 4, 2026 09:12
@amirHdev
amirHdev marked this pull request as ready for review August 4, 2026 10:41
@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 4, 2026
@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

r? @ShoyuVanilla

rustbot has assigned @ShoyuVanilla.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, types
  • compiler, types expanded to 75 candidates
  • Random selection from 21 candidates

@amirHdev

amirHdev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

r? lcnr

@rustbot rustbot assigned lcnr and unassigned ShoyuVanilla Aug 4, 2026
use super::delegate::SolverDelegate;
use crate::traits::{FulfillmentError, ScrubbedTraitError};

#[path = "fulfill/derive_errors.rs"]

@Jamesbarford Jamesbarford Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need this?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I renamed the wrapper file. needed because the rustc-specific wrapper module was named rustc_fulfill while its file was still solve/fulfill.rs

mod fulfill;
pub mod inspect;
mod normalize;
#[path = "solve/fulfill.rs"]

@Jamesbarford Jamesbarford Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure I quite understand this

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this was selecting file while exposing it locally as rustc_fulfill which wrapper renamed now


/// An obligation that can be processed by the shared fulfillment engine.
///
/// The concrete obligation and its diagnostic cause remain owned by the

@Jamesbarford Jamesbarford Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is merely curiosity, what would the alternative be to the diagnostic being owned by the frontend?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

would be for the shared fulfillment layer to own the complete obligation representation, including diagnostic metadata or even separate abstraction for constructing that metadata. the shared engine only accesses the parts needed for fulfillment through FulfillmentObligation

}
}

fn into_rustc_solver_error<'tcx>(

@Jamesbarford Jamesbarford Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be a trait?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that is cleaner , I did

Overflow(O),
}

type PendingObligations<I, O> = ThinVec<(O, Option<GoalStalledOn<I>>)>;

@Jamesbarford Jamesbarford Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Firstly I'm not overly familiar with this area of codebase, however, if I am not mistaken it looks like the type is PredicateObligation<'tcx>? Or an Obligation do we have something that O needs to implement or be constrained by? This applies to all instances of O, not exclusively this type definition.

View changes since the review

@amirHdev amirHdev Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As shared engine only require the <I> while PredicateObligation<'tcx> not required.
I moved that bound onto FulfillmentCtxt<I, O> itself instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you cut yourself off mid-sentence?

@amirHdev amirHdev Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the unclear wording :)
for rustc O is PredicateObligation<'tcx> but the shared engine only requires O: FulfillmentObligation<I> which moved that bound onto FulfillmentCtxt<I, O> itself now and it applies to every instance of the context.

Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
@amirHdev
amirHdev requested a review from Jamesbarford August 4, 2026 17:00
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants