1use std::fmt::Debug;
8
9use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
10use rustc_errors::{Diag, EmissionGuarantee};
11use rustc_hir::def::DefKind;
12use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
13use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt};
14use rustc_infer::traits::PredicateObligations;
15use rustc_middle::bug;
16use rustc_middle::traits::query::NoSolution;
17use rustc_middle::traits::solve::{CandidateSource, Certainty, Goal};
18use rustc_middle::traits::specialization_graph::OverlapMode;
19use rustc_middle::ty::fast_reject::DeepRejectCtxt;
20use rustc_middle::ty::{
21 self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode,
22};
23pub use rustc_next_trait_solver::coherence::*;
24use rustc_next_trait_solver::solve::SolverDelegateEvalExt;
25use rustc_span::{DUMMY_SP, Span, sym};
26use tracing::{debug, instrument, warn};
27
28use super::ObligationCtxt;
29use crate::error_reporting::traits::suggest_new_overflow_limit;
30use crate::infer::InferOk;
31use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor};
32use crate::solve::{SolverDelegate, deeply_normalize_for_diagnostics, inspect};
33use crate::traits::query::evaluate_obligation::InferCtxtExt;
34use crate::traits::select::IntercrateAmbiguityCause;
35use crate::traits::{
36 FulfillmentErrorCode, NormalizeExt, Obligation, ObligationCause, PredicateObligation,
37 SelectionContext, SkipLeakCheck, util,
38};
39
40pub struct OverlapResult<'tcx> {
41 pub impl_header: ty::ImplHeader<'tcx>,
42 pub intercrate_ambiguity_causes: FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
43
44 pub involves_placeholder: bool,
47
48 pub overflowing_predicates: Vec<ty::Predicate<'tcx>>,
50}
51
52pub fn add_placeholder_note<G: EmissionGuarantee>(err: &mut Diag<'_, G>) {
53 err.note(
54 "this behavior recently changed as a result of a bug fix; \
55 see rust-lang/rust#56105 for details",
56 );
57}
58
59pub(crate) fn suggest_increasing_recursion_limit<'tcx, G: EmissionGuarantee>(
60 tcx: TyCtxt<'tcx>,
61 err: &mut Diag<'_, G>,
62 overflowing_predicates: &[ty::Predicate<'tcx>],
63) {
64 for pred in overflowing_predicates {
65 err.note(format!("overflow evaluating the requirement `{}`", pred));
66 }
67
68 suggest_new_overflow_limit(tcx, err);
69}
70
71#[derive(Debug, Clone, Copy)]
72enum TrackAmbiguityCauses {
73 Yes,
74 No,
75}
76
77impl TrackAmbiguityCauses {
78 fn is_yes(self) -> bool {
79 match self {
80 TrackAmbiguityCauses::Yes => true,
81 TrackAmbiguityCauses::No => false,
82 }
83 }
84}
85
86#[instrument(skip(tcx, skip_leak_check), level = "debug")]
90pub fn overlapping_impls(
91 tcx: TyCtxt<'_>,
92 impl1_def_id: DefId,
93 impl2_def_id: DefId,
94 skip_leak_check: SkipLeakCheck,
95 overlap_mode: OverlapMode,
96) -> Option<OverlapResult<'_>> {
97 let drcx = DeepRejectCtxt::relate_infer_infer(tcx);
101 let impl1_ref = tcx.impl_trait_ref(impl1_def_id);
102 let impl2_ref = tcx.impl_trait_ref(impl2_def_id);
103 let may_overlap = match (impl1_ref, impl2_ref) {
104 (Some(a), Some(b)) => drcx.args_may_unify(a.skip_binder().args, b.skip_binder().args),
105 (None, None) => {
106 let self_ty1 = tcx.type_of(impl1_def_id).skip_binder();
107 let self_ty2 = tcx.type_of(impl2_def_id).skip_binder();
108 drcx.types_may_unify(self_ty1, self_ty2)
109 }
110 _ => bug!("unexpected impls: {impl1_def_id:?} {impl2_def_id:?}"),
111 };
112
113 if !may_overlap {
114 debug!("overlapping_impls: fast_reject early-exit");
116 return None;
117 }
118
119 if tcx.next_trait_solver_in_coherence() {
120 overlap(
121 tcx,
122 TrackAmbiguityCauses::Yes,
123 skip_leak_check,
124 impl1_def_id,
125 impl2_def_id,
126 overlap_mode,
127 )
128 } else {
129 let _overlap_with_bad_diagnostics = overlap(
130 tcx,
131 TrackAmbiguityCauses::No,
132 skip_leak_check,
133 impl1_def_id,
134 impl2_def_id,
135 overlap_mode,
136 )?;
137
138 let overlap = overlap(
142 tcx,
143 TrackAmbiguityCauses::Yes,
144 skip_leak_check,
145 impl1_def_id,
146 impl2_def_id,
147 overlap_mode,
148 )
149 .unwrap();
150 Some(overlap)
151 }
152}
153
154fn fresh_impl_header<'tcx>(infcx: &InferCtxt<'tcx>, impl_def_id: DefId) -> ty::ImplHeader<'tcx> {
155 let tcx = infcx.tcx;
156 let impl_args = infcx.fresh_args_for_item(DUMMY_SP, impl_def_id);
157
158 ty::ImplHeader {
159 impl_def_id,
160 impl_args,
161 self_ty: tcx.type_of(impl_def_id).instantiate(tcx, impl_args),
162 trait_ref: tcx.impl_trait_ref(impl_def_id).map(|i| i.instantiate(tcx, impl_args)),
163 predicates: tcx
164 .predicates_of(impl_def_id)
165 .instantiate(tcx, impl_args)
166 .iter()
167 .map(|(c, _)| c.as_predicate())
168 .collect(),
169 }
170}
171
172fn fresh_impl_header_normalized<'tcx>(
173 infcx: &InferCtxt<'tcx>,
174 param_env: ty::ParamEnv<'tcx>,
175 impl_def_id: DefId,
176) -> ty::ImplHeader<'tcx> {
177 let header = fresh_impl_header(infcx, impl_def_id);
178
179 let InferOk { value: mut header, obligations } =
180 infcx.at(&ObligationCause::dummy(), param_env).normalize(header);
181
182 header.predicates.extend(obligations.into_iter().map(|o| o.predicate));
183 header
184}
185
186#[instrument(level = "debug", skip(tcx))]
189fn overlap<'tcx>(
190 tcx: TyCtxt<'tcx>,
191 track_ambiguity_causes: TrackAmbiguityCauses,
192 skip_leak_check: SkipLeakCheck,
193 impl1_def_id: DefId,
194 impl2_def_id: DefId,
195 overlap_mode: OverlapMode,
196) -> Option<OverlapResult<'tcx>> {
197 if overlap_mode.use_negative_impl() {
198 if impl_intersection_has_negative_obligation(tcx, impl1_def_id, impl2_def_id)
199 || impl_intersection_has_negative_obligation(tcx, impl2_def_id, impl1_def_id)
200 {
201 return None;
202 }
203 }
204
205 let infcx = tcx
206 .infer_ctxt()
207 .skip_leak_check(skip_leak_check.is_yes())
208 .with_next_trait_solver(tcx.next_trait_solver_in_coherence())
209 .build(TypingMode::Coherence);
210 let selcx = &mut SelectionContext::new(&infcx);
211 if track_ambiguity_causes.is_yes() {
212 selcx.enable_tracking_intercrate_ambiguity_causes();
213 }
214
215 let param_env = ty::ParamEnv::empty();
220
221 let impl1_header = fresh_impl_header_normalized(selcx.infcx, param_env, impl1_def_id);
222 let impl2_header = fresh_impl_header_normalized(selcx.infcx, param_env, impl2_def_id);
223
224 let mut obligations =
227 equate_impl_headers(selcx.infcx, param_env, &impl1_header, &impl2_header)?;
228 debug!("overlap: unification check succeeded");
229
230 obligations.extend(
231 [&impl1_header.predicates, &impl2_header.predicates].into_iter().flatten().map(
232 |&predicate| Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, predicate),
233 ),
234 );
235
236 let mut overflowing_predicates = Vec::new();
237 if overlap_mode.use_implicit_negative() {
238 match impl_intersection_has_impossible_obligation(selcx, &obligations) {
239 IntersectionHasImpossibleObligations::Yes => return None,
240 IntersectionHasImpossibleObligations::No { overflowing_predicates: p } => {
241 overflowing_predicates = p
242 }
243 }
244 }
245
246 if infcx.leak_check(ty::UniverseIndex::ROOT, None).is_err() {
249 debug!("overlap: leak check failed");
250 return None;
251 }
252
253 let intercrate_ambiguity_causes = if !overlap_mode.use_implicit_negative() {
254 Default::default()
255 } else if infcx.next_trait_solver() {
256 compute_intercrate_ambiguity_causes(&infcx, &obligations)
257 } else {
258 selcx.take_intercrate_ambiguity_causes()
259 };
260
261 debug!("overlap: intercrate_ambiguity_causes={:#?}", intercrate_ambiguity_causes);
262 let involves_placeholder = infcx
263 .inner
264 .borrow_mut()
265 .unwrap_region_constraints()
266 .data()
267 .constraints
268 .iter()
269 .any(|c| c.0.involves_placeholders());
270
271 let mut impl_header = infcx.resolve_vars_if_possible(impl1_header);
272
273 if infcx.next_trait_solver() {
275 impl_header = deeply_normalize_for_diagnostics(&infcx, param_env, impl_header);
276 }
277
278 Some(OverlapResult {
279 impl_header,
280 intercrate_ambiguity_causes,
281 involves_placeholder,
282 overflowing_predicates,
283 })
284}
285
286#[instrument(level = "debug", skip(infcx), ret)]
287fn equate_impl_headers<'tcx>(
288 infcx: &InferCtxt<'tcx>,
289 param_env: ty::ParamEnv<'tcx>,
290 impl1: &ty::ImplHeader<'tcx>,
291 impl2: &ty::ImplHeader<'tcx>,
292) -> Option<PredicateObligations<'tcx>> {
293 let result =
294 match (impl1.trait_ref, impl2.trait_ref) {
295 (Some(impl1_ref), Some(impl2_ref)) => infcx
296 .at(&ObligationCause::dummy(), param_env)
297 .eq(DefineOpaqueTypes::Yes, impl1_ref, impl2_ref),
298 (None, None) => infcx.at(&ObligationCause::dummy(), param_env).eq(
299 DefineOpaqueTypes::Yes,
300 impl1.self_ty,
301 impl2.self_ty,
302 ),
303 _ => bug!("equate_impl_headers given mismatched impl kinds"),
304 };
305
306 result.map(|infer_ok| infer_ok.obligations).ok()
307}
308
309#[derive(Debug)]
311enum IntersectionHasImpossibleObligations<'tcx> {
312 Yes,
313 No {
314 overflowing_predicates: Vec<ty::Predicate<'tcx>>,
320 },
321}
322
323#[instrument(level = "debug", skip(selcx), ret)]
342fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
343 selcx: &mut SelectionContext<'cx, 'tcx>,
344 obligations: &'a [PredicateObligation<'tcx>],
345) -> IntersectionHasImpossibleObligations<'tcx> {
346 let infcx = selcx.infcx;
347
348 if infcx.next_trait_solver() {
349 if !obligations.iter().all(|o| {
353 <&SolverDelegate<'tcx>>::from(infcx)
354 .root_goal_may_hold_with_depth(8, Goal::new(infcx.tcx, o.param_env, o.predicate))
355 }) {
356 return IntersectionHasImpossibleObligations::Yes;
357 }
358
359 let ocx = ObligationCtxt::new(infcx);
360 ocx.register_obligations(obligations.iter().cloned());
361 let hard_errors = ocx.select_where_possible();
362 if !hard_errors.is_empty() {
363 assert!(
364 hard_errors.iter().all(|e| e.is_true_error()),
365 "should not have detected ambiguity during first pass"
366 );
367 return IntersectionHasImpossibleObligations::Yes;
368 }
369
370 let ambiguities = ocx.into_pending_obligations();
374 let ocx = ObligationCtxt::new_with_diagnostics(infcx);
375 ocx.register_obligations(ambiguities);
376 let errors_and_ambiguities = ocx.select_all_or_error();
377 let (errors, ambiguities): (Vec<_>, Vec<_>) =
380 errors_and_ambiguities.into_iter().partition(|error| error.is_true_error());
381 assert!(errors.is_empty(), "should not have ambiguities during second pass");
382
383 IntersectionHasImpossibleObligations::No {
384 overflowing_predicates: ambiguities
385 .into_iter()
386 .filter(|error| {
387 matches!(error.code, FulfillmentErrorCode::Ambiguity { overflow: Some(true) })
388 })
389 .map(|e| infcx.resolve_vars_if_possible(e.obligation.predicate))
390 .collect(),
391 }
392 } else {
393 for obligation in obligations {
394 let evaluation_result = selcx.evaluate_root_obligation(obligation);
397
398 match evaluation_result {
399 Ok(result) => {
400 if !result.may_apply() {
401 return IntersectionHasImpossibleObligations::Yes;
402 }
403 }
404 Err(_overflow) => {}
409 }
410 }
411
412 IntersectionHasImpossibleObligations::No { overflowing_predicates: Vec::new() }
413 }
414}
415
416fn impl_intersection_has_negative_obligation(
433 tcx: TyCtxt<'_>,
434 impl1_def_id: DefId,
435 impl2_def_id: DefId,
436) -> bool {
437 debug!("negative_impl(impl1_def_id={:?}, impl2_def_id={:?})", impl1_def_id, impl2_def_id);
438
439 let ref infcx = tcx.infer_ctxt().with_next_trait_solver(true).build(TypingMode::Coherence);
442 let root_universe = infcx.universe();
443 assert_eq!(root_universe, ty::UniverseIndex::ROOT);
444
445 let impl1_header = fresh_impl_header(infcx, impl1_def_id);
446 let param_env =
447 ty::EarlyBinder::bind(tcx.param_env(impl1_def_id)).instantiate(tcx, impl1_header.impl_args);
448
449 let impl2_header = fresh_impl_header(infcx, impl2_def_id);
450
451 let Some(equate_obligations) =
454 equate_impl_headers(infcx, param_env, &impl1_header, &impl2_header)
455 else {
456 return false;
457 };
458
459 drop(equate_obligations);
463 drop(infcx.take_registered_region_obligations());
464 drop(infcx.take_registered_region_assumptions());
465 drop(infcx.take_and_reset_region_constraints());
466
467 plug_infer_with_placeholders(
468 infcx,
469 root_universe,
470 (impl1_header.impl_args, impl2_header.impl_args),
471 );
472 let param_env = infcx.resolve_vars_if_possible(param_env);
473
474 util::elaborate(tcx, tcx.predicates_of(impl2_def_id).instantiate(tcx, impl2_header.impl_args))
475 .elaborate_sized()
476 .any(|(clause, _)| try_prove_negated_where_clause(infcx, clause, param_env))
477}
478
479fn plug_infer_with_placeholders<'tcx>(
480 infcx: &InferCtxt<'tcx>,
481 universe: ty::UniverseIndex,
482 value: impl TypeVisitable<TyCtxt<'tcx>>,
483) {
484 struct PlugInferWithPlaceholder<'a, 'tcx> {
485 infcx: &'a InferCtxt<'tcx>,
486 universe: ty::UniverseIndex,
487 var: ty::BoundVar,
488 }
489
490 impl<'tcx> PlugInferWithPlaceholder<'_, 'tcx> {
491 fn next_var(&mut self) -> ty::BoundVar {
492 let var = self.var;
493 self.var = self.var + 1;
494 var
495 }
496 }
497
498 impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for PlugInferWithPlaceholder<'_, 'tcx> {
499 fn visit_ty(&mut self, ty: Ty<'tcx>) {
500 let ty = self.infcx.shallow_resolve(ty);
501 if ty.is_ty_var() {
502 let Ok(InferOk { value: (), obligations }) =
503 self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
504 DefineOpaqueTypes::Yes,
506 ty,
507 Ty::new_placeholder(
508 self.infcx.tcx,
509 ty::Placeholder {
510 universe: self.universe,
511 bound: ty::BoundTy {
512 var: self.next_var(),
513 kind: ty::BoundTyKind::Anon,
514 },
515 },
516 ),
517 )
518 else {
519 bug!("we always expect to be able to plug an infer var with placeholder")
520 };
521 assert_eq!(obligations.len(), 0);
522 } else {
523 ty.super_visit_with(self);
524 }
525 }
526
527 fn visit_const(&mut self, ct: ty::Const<'tcx>) {
528 let ct = self.infcx.shallow_resolve_const(ct);
529 if ct.is_ct_infer() {
530 let Ok(InferOk { value: (), obligations }) =
531 self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
532 DefineOpaqueTypes::Yes,
535 ct,
536 ty::Const::new_placeholder(
537 self.infcx.tcx,
538 ty::Placeholder { universe: self.universe, bound: self.next_var() },
539 ),
540 )
541 else {
542 bug!("we always expect to be able to plug an infer var with placeholder")
543 };
544 assert_eq!(obligations.len(), 0);
545 } else {
546 ct.super_visit_with(self);
547 }
548 }
549
550 fn visit_region(&mut self, r: ty::Region<'tcx>) {
551 if let ty::ReVar(vid) = r.kind() {
552 let r = self
553 .infcx
554 .inner
555 .borrow_mut()
556 .unwrap_region_constraints()
557 .opportunistic_resolve_var(self.infcx.tcx, vid);
558 if r.is_var() {
559 let Ok(InferOk { value: (), obligations }) =
560 self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
561 DefineOpaqueTypes::Yes,
563 r,
564 ty::Region::new_placeholder(
565 self.infcx.tcx,
566 ty::Placeholder {
567 universe: self.universe,
568 bound: ty::BoundRegion {
569 var: self.next_var(),
570 kind: ty::BoundRegionKind::Anon,
571 },
572 },
573 ),
574 )
575 else {
576 bug!("we always expect to be able to plug an infer var with placeholder")
577 };
578 assert_eq!(obligations.len(), 0);
579 }
580 }
581 }
582 }
583
584 value.visit_with(&mut PlugInferWithPlaceholder { infcx, universe, var: ty::BoundVar::ZERO });
585}
586
587fn try_prove_negated_where_clause<'tcx>(
588 root_infcx: &InferCtxt<'tcx>,
589 clause: ty::Clause<'tcx>,
590 param_env: ty::ParamEnv<'tcx>,
591) -> bool {
592 let Some(negative_predicate) = clause.as_predicate().flip_polarity(root_infcx.tcx) else {
593 return false;
594 };
595
596 let ref infcx = root_infcx.fork_with_typing_mode(TypingMode::non_body_analysis());
603 let ocx = ObligationCtxt::new(infcx);
604 ocx.register_obligation(Obligation::new(
605 infcx.tcx,
606 ObligationCause::dummy(),
607 param_env,
608 negative_predicate,
609 ));
610 if !ocx.select_all_or_error().is_empty() {
611 return false;
612 }
613
614 let errors = ocx.resolve_regions(CRATE_DEF_ID, param_env, []);
618 if !errors.is_empty() {
619 return false;
620 }
621
622 true
623}
624
625fn compute_intercrate_ambiguity_causes<'tcx>(
633 infcx: &InferCtxt<'tcx>,
634 obligations: &[PredicateObligation<'tcx>],
635) -> FxIndexSet<IntercrateAmbiguityCause<'tcx>> {
636 let mut causes: FxIndexSet<IntercrateAmbiguityCause<'tcx>> = Default::default();
637
638 for obligation in obligations {
639 search_ambiguity_causes(infcx, obligation.as_goal(), &mut causes);
640 }
641
642 causes
643}
644
645struct AmbiguityCausesVisitor<'a, 'tcx> {
646 cache: FxHashSet<Goal<'tcx, ty::Predicate<'tcx>>>,
647 causes: &'a mut FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
648}
649
650impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
651 fn span(&self) -> Span {
652 DUMMY_SP
653 }
654
655 fn visit_goal(&mut self, goal: &InspectGoal<'_, 'tcx>) {
656 if !self.cache.insert(goal.goal()) {
657 return;
658 }
659
660 let infcx = goal.infcx();
661 for cand in goal.candidates() {
662 cand.visit_nested_in_probe(self);
663 }
664 match goal.result() {
668 Ok(Certainty::Yes) | Err(NoSolution) => return,
669 Ok(Certainty::Maybe(_)) => {}
670 }
671
672 let Goal { param_env, predicate } = goal.goal();
675 let trait_ref = match predicate.kind().no_bound_vars() {
676 Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr))) => tr.trait_ref,
677 Some(ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)))
678 if matches!(
679 infcx.tcx.def_kind(proj.projection_term.def_id),
680 DefKind::AssocTy | DefKind::AssocConst
681 ) =>
682 {
683 proj.projection_term.trait_ref(infcx.tcx)
684 }
685 _ => return,
686 };
687
688 if trait_ref.references_error() {
689 return;
690 }
691
692 let mut candidates = goal.candidates();
693 for cand in goal.candidates() {
694 if let inspect::ProbeKind::TraitCandidate {
695 source: CandidateSource::Impl(def_id),
696 result: Ok(_),
697 } = cand.kind()
698 {
699 if let ty::ImplPolarity::Reservation = infcx.tcx.impl_polarity(def_id) {
700 let message = infcx
701 .tcx
702 .get_attr(def_id, sym::rustc_reservation_impl)
703 .and_then(|a| a.value_str());
704 if let Some(message) = message {
705 self.causes.insert(IntercrateAmbiguityCause::ReservationImpl { message });
706 }
707 }
708 }
709 }
710
711 let Some(cand) = candidates.pop() else {
714 return;
715 };
716
717 let inspect::ProbeKind::TraitCandidate {
718 source: CandidateSource::CoherenceUnknowable,
719 result: Ok(_),
720 } = cand.kind()
721 else {
722 return;
723 };
724
725 let lazily_normalize_ty = |mut ty: Ty<'tcx>| {
726 if matches!(ty.kind(), ty::Alias(..)) {
727 let ocx = ObligationCtxt::new(infcx);
728 ty = ocx
729 .structurally_normalize_ty(&ObligationCause::dummy(), param_env, ty)
730 .map_err(|_| ())?;
731 if !ocx.select_where_possible().is_empty() {
732 return Err(());
733 }
734 }
735 Ok(ty)
736 };
737
738 infcx.probe(|_| {
739 let conflict = match trait_ref_is_knowable(infcx, trait_ref, lazily_normalize_ty) {
740 Err(()) => return,
741 Ok(Ok(())) => {
742 warn!("expected an unknowable trait ref: {trait_ref:?}");
743 return;
744 }
745 Ok(Err(conflict)) => conflict,
746 };
747
748 let non_intercrate_infcx = infcx.fork_with_typing_mode(TypingMode::non_body_analysis());
754 if non_intercrate_infcx.predicate_may_hold(&Obligation::new(
755 infcx.tcx,
756 ObligationCause::dummy(),
757 param_env,
758 predicate,
759 )) {
760 return;
761 }
762
763 let trait_ref = deeply_normalize_for_diagnostics(infcx, param_env, trait_ref);
765 let self_ty = trait_ref.self_ty();
766 let self_ty = self_ty.has_concrete_skeleton().then(|| self_ty);
767 self.causes.insert(match conflict {
768 Conflict::Upstream => {
769 IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty }
770 }
771 Conflict::Downstream => {
772 IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty }
773 }
774 });
775 });
776 }
777}
778
779fn search_ambiguity_causes<'tcx>(
780 infcx: &InferCtxt<'tcx>,
781 goal: Goal<'tcx, ty::Predicate<'tcx>>,
782 causes: &mut FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
783) {
784 infcx.probe(|_| {
785 infcx.visit_proof_tree(
786 goal,
787 &mut AmbiguityCausesVisitor { cache: Default::default(), causes },
788 )
789 });
790}