Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions compiler/rustc_trait_selection/src/solve/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,27 +515,24 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<

fn emit_next_solver_overflow_fcw(&self, goal: Goal<'tcx, ty::Predicate<'tcx>>, span: Span) {
let tcx = self.tcx;
let goal = self.deeply_resolve_ignoring_regions(goal);
let mut visitor = OverflowedGoalChain {
span,
predicates: vec![],
recursion_limit: usize::min(16, tcx.recursion_limit().0),
};

// HACK: avoid computing goal chains for dependencies by relying on the fact that
// `cargo` passes `lint_cap=allow` to deps. This should mitigate some of the perf/rss
// regression when compiling crates whose deps trigger a large number of these FCWs.
if !matches!(tcx.sess.opts.lint_cap, Some(rustc_lint_defs::Level::Allow)) {
let _ = self.with_disabled_next_solver_overflow_fcw(|| {
self.visit_proof_tree(goal, &mut visitor)
});
}

tcx.emit_node_span_lint(
RECURSION_DEPTH_EXCEEDING_LIMIT,
CRATE_HIR_ID,
span,
rustc_errors::DiagDecorator(|diag| {
// We do this in the decorator as that avoids the work
// if we don't actually emit the lint.
let goal = self.deeply_resolve_ignoring_regions(goal);
let mut visitor = OverflowedGoalChain {
span,
predicates: vec![],
recursion_limit: usize::min(16, tcx.recursion_limit().0),
};

let _ = self.with_disabled_next_solver_overflow_fcw(|| {
self.visit_proof_tree(goal, &mut visitor)
});

// FIXME: share this with overflow error in fulfillment instead of duplicating.
let pred_str = |pred: ty::Predicate<'tcx>| {
let s = pred.to_string();
Expand Down
Loading