Skip to content

Show the nested goal chain for the next solver overflow FCW - #161341

Open
adwinwhite wants to merge 5 commits into
rust-lang:mainfrom
adwinwhite:overflow-fcw-chain
Open

Show the nested goal chain for the next solver overflow FCW#161341
adwinwhite wants to merge 5 commits into
rust-lang:mainfrom
adwinwhite:overflow-fcw-chain

Conversation

@adwinwhite

@adwinwhite adwinwhite commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Previously we only showed a single root goal for the FCW. It was difficult to find out how the goal overflowed.
We display a proving chain now which should help users identify relevant types or auto traits.

This will affect perf for crates emitting the FCW. E.g. calimero-store goes from 4.7s -> 5.7s in local testing since it emits thousands of FCWs internally. The FCW is a mitigation of future hard error and authors are expected to resolve it so it's probably acceptable. It doesn't affect crates without the FCW.

r? lcnr

@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 19, 2026
Comment thread compiler/rustc_infer/src/infer/mod.rs Outdated
@@ -344,6 +344,10 @@ pub struct InferCtxt<'tcx> {
/// checking so we disable the FCW there as well.
enable_next_solver_overflow_fcw: bool,

@lcnr lcnr Aug 20, 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.

change this to a Cell instead? 🤔

View changes since the review

Comment thread compiler/rustc_infer/src/infer/mod.rs Outdated
{
self.in_next_solver_overflow_fcw.set(true);
let ret = f();
self.in_next_solver_overflow_fcw.set(false);

@lcnr lcnr Aug 20, 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.

feels safer to replace previous entry and then revert to that one in functions like this, otherwise nesting it twice breaks the outer call

View changes since the review

@rust-log-analyzer

This comment has been minimized.

@adwinwhite
adwinwhite marked this pull request as ready for review August 20, 2026 08:35
@rustbot

rustbot commented Aug 20, 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 20, 2026
@rust-bors

rust-bors Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #161043) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.


/// We need to disable the fcw if we're already in a fcw emitting to avoid
/// indefinite triggering.
pub fn enter_next_solver_overflow_fcw<F, R>(&self, mut f: F) -> R

@lcnr lcnr Aug 21, 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.

Suggested change
pub fn enter_next_solver_overflow_fcw<F, R>(&self, mut f: F) -> R
pub fn with_disabled_next_solver_overflow_fcw<F, R>(&self, mut f: F) -> R

maybe? the current name feels a bit unclear to me

View changes since the review

nested_goals: &evaluation_result.nested_goals,
min_reachable_available_depth: AvailableDepth(
available_depth.0 - evaluation_result.required_depth,
available_depth.0 - evaluation_result.required_depth.0,

@lcnr lcnr Aug 21, 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.

impl Sub<RequiredDepth> for AvailableDepth and use it in these 2 places

View changes since the review

= help: consider increasing the recursion limit by adding a `#![recursion_limit = "16"]` attribute to your crate (`fcw_on_normalization`)
= help: or consider adding a manual `impl` of auto traits like `Send` for intermediate types, if auto traits are involved
= note: which requires <W<W<W<W<W<W<W<W<W<()>>>>>>>>> as HasAssoc>::Assoc == ()
= note: which requires <W<W<W<W<W<W<W<W<()>>>>>>>> as HasAssoc>::Assoc == ()

@lcnr lcnr Aug 21, 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 does this stop after 2 goals? that's surprising

View changes since the review

}

fn visit_goal(&mut self, goal: &inspect::InspectGoal<'_, 'tcx>) -> Self::Result {
self.predicates.push(goal.goal().predicate);

@lcnr lcnr Aug 21, 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.

does this currently print both NormalizesTo and the Projection goal? if so, we should probably filter the NormalizesTo goal here :>

View changes since the review

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.

4 participants