Skip to content

Commit

Permalink
Rollup merge of rust-lang#126675 - oli-obk:diagnostics_opaque, r=jack…
Browse files Browse the repository at this point in the history
…h726

Change a `DefineOpaqueTypes::No` to `Yes` in diagnostics code

Explanation in comments of the function.

r? ```@compiler-errors```

cc rust-lang#116652
  • Loading branch information
fee1-dead committed Jun 19, 2024
2 parents cc4ace3 + 56cd301 commit e649eca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,8 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
traits::SelectionContext::new(self).select(&obligation)
}

/// Used for ambiguous method call error reporting. Uses probing that throws away the result internally,
/// so do not use to make a decision that may lead to a successful compilation.
fn candidate_source(&self, candidate: &Candidate<'tcx>, self_ty: Ty<'tcx>) -> CandidateSource {
match candidate.kind {
InherentImplCandidate(_) => {
Expand All @@ -1370,8 +1372,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
self.instantiate_binder_with_fresh_vars(self.span, infer::FnCall, trait_ref);
let (xform_self_ty, _) =
self.xform_self_ty(candidate.item, trait_ref.self_ty(), trait_ref.args);
// Guide the trait selection to show impls that have methods whose type matches
// up with the `self` parameter of the method.
let _ = self.at(&ObligationCause::dummy(), self.param_env).sup(
DefineOpaqueTypes::No,
DefineOpaqueTypes::Yes,
xform_self_ty,
self_ty,
);
Expand Down

0 comments on commit e649eca

Please sign in to comment.