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_and_reset_region_constraints());
465
466 plug_infer_with_placeholders(
467 infcx,
468 root_universe,
469 (impl1_header.impl_args, impl2_header.impl_args),
470 );
471 let param_env = infcx.resolve_vars_if_possible(param_env);
472
473 util::elaborate(tcx, tcx.predicates_of(impl2_def_id).instantiate(tcx, impl2_header.impl_args))
474 .elaborate_sized()
475 .any(|(clause, _)| try_prove_negated_where_clause(infcx, clause, param_env))
476}
477
478fn plug_infer_with_placeholders<'tcx>(
479 infcx: &InferCtxt<'tcx>,
480 universe: ty::UniverseIndex,
481 value: impl TypeVisitable<TyCtxt<'tcx>>,
482) {
483 struct PlugInferWithPlaceholder<'a, 'tcx> {
484 infcx: &'a InferCtxt<'tcx>,
485 universe: ty::UniverseIndex,
486 var: ty::BoundVar,
487 }
488
489 impl<'tcx> PlugInferWithPlaceholder<'_, 'tcx> {
490 fn next_var(&mut self) -> ty::BoundVar {
491 let var = self.var;
492 self.var = self.var + 1;
493 var
494 }
495 }
496
497 impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for PlugInferWithPlaceholder<'_, 'tcx> {
498 fn visit_ty(&mut self, ty: Ty<'tcx>) {
499 let ty = self.infcx.shallow_resolve(ty);
500 if ty.is_ty_var() {
501 let Ok(InferOk { value: (), obligations }) =
502 self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
503 DefineOpaqueTypes::Yes,
505 ty,
506 Ty::new_placeholder(
507 self.infcx.tcx,
508 ty::Placeholder {
509 universe: self.universe,
510 bound: ty::BoundTy {
511 var: self.next_var(),
512 kind: ty::BoundTyKind::Anon,
513 },
514 },
515 ),
516 )
517 else {
518 bug!("we always expect to be able to plug an infer var with placeholder")
519 };
520 assert_eq!(obligations.len(), 0);
521 } else {
522 ty.super_visit_with(self);
523 }
524 }
525
526 fn visit_const(&mut self, ct: ty::Const<'tcx>) {
527 let ct = self.infcx.shallow_resolve_const(ct);
528 if ct.is_ct_infer() {
529 let Ok(InferOk { value: (), obligations }) =
530 self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
531 DefineOpaqueTypes::Yes,
534 ct,
535 ty::Const::new_placeholder(
536 self.infcx.tcx,
537 ty::Placeholder { universe: self.universe, bound: self.next_var() },
538 ),
539 )
540 else {
541 bug!("we always expect to be able to plug an infer var with placeholder")
542 };
543 assert_eq!(obligations.len(), 0);
544 } else {
545 ct.super_visit_with(self);
546 }
547 }
548
549 fn visit_region(&mut self, r: ty::Region<'tcx>) {
550 if let ty::ReVar(vid) = r.kind() {
551 let r = self
552 .infcx
553 .inner
554 .borrow_mut()
555 .unwrap_region_constraints()
556 .opportunistic_resolve_var(self.infcx.tcx, vid);
557 if r.is_var() {
558 let Ok(InferOk { value: (), obligations }) =
559 self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
560 DefineOpaqueTypes::Yes,
562 r,
563 ty::Region::new_placeholder(
564 self.infcx.tcx,
565 ty::Placeholder {
566 universe: self.universe,
567 bound: ty::BoundRegion {
568 var: self.next_var(),
569 kind: ty::BoundRegionKind::Anon,
570 },
571 },
572 ),
573 )
574 else {
575 bug!("we always expect to be able to plug an infer var with placeholder")
576 };
577 assert_eq!(obligations.len(), 0);
578 }
579 }
580 }
581 }
582
583 value.visit_with(&mut PlugInferWithPlaceholder { infcx, universe, var: ty::BoundVar::ZERO });
584}
585
586fn try_prove_negated_where_clause<'tcx>(
587 root_infcx: &InferCtxt<'tcx>,
588 clause: ty::Clause<'tcx>,
589 param_env: ty::ParamEnv<'tcx>,
590) -> bool {
591 let Some(negative_predicate) = clause.as_predicate().flip_polarity(root_infcx.tcx) else {
592 return false;
593 };
594
595 let ref infcx = root_infcx.fork_with_typing_mode(TypingMode::non_body_analysis());
602 let ocx = ObligationCtxt::new(infcx);
603 ocx.register_obligation(Obligation::new(
604 infcx.tcx,
605 ObligationCause::dummy(),
606 param_env,
607 negative_predicate,
608 ));
609 if !ocx.select_all_or_error().is_empty() {
610 return false;
611 }
612
613 let errors = ocx.resolve_regions(CRATE_DEF_ID, param_env, []);
617 if !errors.is_empty() {
618 return false;
619 }
620
621 true
622}
623
624fn compute_intercrate_ambiguity_causes<'tcx>(
632 infcx: &InferCtxt<'tcx>,
633 obligations: &[PredicateObligation<'tcx>],
634) -> FxIndexSet<IntercrateAmbiguityCause<'tcx>> {
635 let mut causes: FxIndexSet<IntercrateAmbiguityCause<'tcx>> = Default::default();
636
637 for obligation in obligations {
638 search_ambiguity_causes(infcx, obligation.as_goal(), &mut causes);
639 }
640
641 causes
642}
643
644struct AmbiguityCausesVisitor<'a, 'tcx> {
645 cache: FxHashSet<Goal<'tcx, ty::Predicate<'tcx>>>,
646 causes: &'a mut FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
647}
648
649impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a, 'tcx> {
650 fn span(&self) -> Span {
651 DUMMY_SP
652 }
653
654 fn visit_goal(&mut self, goal: &InspectGoal<'_, 'tcx>) {
655 if !self.cache.insert(goal.goal()) {
656 return;
657 }
658
659 let infcx = goal.infcx();
660 for cand in goal.candidates() {
661 cand.visit_nested_in_probe(self);
662 }
663 match goal.result() {
667 Ok(Certainty::Yes) | Err(NoSolution) => return,
668 Ok(Certainty::Maybe(_)) => {}
669 }
670
671 let Goal { param_env, predicate } = goal.goal();
674 let trait_ref = match predicate.kind().no_bound_vars() {
675 Some(ty::PredicateKind::Clause(ty::ClauseKind::Trait(tr))) => tr.trait_ref,
676 Some(ty::PredicateKind::Clause(ty::ClauseKind::Projection(proj)))
677 if matches!(
678 infcx.tcx.def_kind(proj.projection_term.def_id),
679 DefKind::AssocTy | DefKind::AssocConst
680 ) =>
681 {
682 proj.projection_term.trait_ref(infcx.tcx)
683 }
684 _ => return,
685 };
686
687 if trait_ref.references_error() {
688 return;
689 }
690
691 let mut candidates = goal.candidates();
692 for cand in goal.candidates() {
693 if let inspect::ProbeKind::TraitCandidate {
694 source: CandidateSource::Impl(def_id),
695 result: Ok(_),
696 } = cand.kind()
697 {
698 if let ty::ImplPolarity::Reservation = infcx.tcx.impl_polarity(def_id) {
699 let message = infcx
700 .tcx
701 .get_attr(def_id, sym::rustc_reservation_impl)
702 .and_then(|a| a.value_str());
703 if let Some(message) = message {
704 self.causes.insert(IntercrateAmbiguityCause::ReservationImpl { message });
705 }
706 }
707 }
708 }
709
710 let Some(cand) = candidates.pop() else {
713 return;
714 };
715
716 let inspect::ProbeKind::TraitCandidate {
717 source: CandidateSource::CoherenceUnknowable,
718 result: Ok(_),
719 } = cand.kind()
720 else {
721 return;
722 };
723
724 let lazily_normalize_ty = |mut ty: Ty<'tcx>| {
725 if matches!(ty.kind(), ty::Alias(..)) {
726 let ocx = ObligationCtxt::new(infcx);
727 ty = ocx
728 .structurally_normalize_ty(&ObligationCause::dummy(), param_env, ty)
729 .map_err(|_| ())?;
730 if !ocx.select_where_possible().is_empty() {
731 return Err(());
732 }
733 }
734 Ok(ty)
735 };
736
737 infcx.probe(|_| {
738 let conflict = match trait_ref_is_knowable(infcx, trait_ref, lazily_normalize_ty) {
739 Err(()) => return,
740 Ok(Ok(())) => {
741 warn!("expected an unknowable trait ref: {trait_ref:?}");
742 return;
743 }
744 Ok(Err(conflict)) => conflict,
745 };
746
747 let non_intercrate_infcx = infcx.fork_with_typing_mode(TypingMode::non_body_analysis());
753 if non_intercrate_infcx.predicate_may_hold(&Obligation::new(
754 infcx.tcx,
755 ObligationCause::dummy(),
756 param_env,
757 predicate,
758 )) {
759 return;
760 }
761
762 let trait_ref = deeply_normalize_for_diagnostics(infcx, param_env, trait_ref);
764 let self_ty = trait_ref.self_ty();
765 let self_ty = self_ty.has_concrete_skeleton().then(|| self_ty);
766 self.causes.insert(match conflict {
767 Conflict::Upstream => {
768 IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_ref, self_ty }
769 }
770 Conflict::Downstream => {
771 IntercrateAmbiguityCause::DownstreamCrate { trait_ref, self_ty }
772 }
773 });
774 });
775 }
776}
777
778fn search_ambiguity_causes<'tcx>(
779 infcx: &InferCtxt<'tcx>,
780 goal: Goal<'tcx, ty::Predicate<'tcx>>,
781 causes: &mut FxIndexSet<IntercrateAmbiguityCause<'tcx>>,
782) {
783 infcx.probe(|_| {
784 infcx.visit_proof_tree(
785 goal,
786 &mut AmbiguityCausesVisitor { cache: Default::default(), causes },
787 )
788 });
789}