about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorfee1-dead <ent3rm4n@gmail.com>2024-06-19 22:51:05 +0800
committerGitHub <noreply@github.com>2024-06-19 22:51:05 +0800
commite649eca1d2dc266b9b38f207500648cbb295cb1a (patch)
tree9eb3934b727b83cca36ae5505d3997ca498b3e00 /compiler
parentcc4ace33cfce8e1e3bba067206f9a1203d4ea170 (diff)
parent56cd30104a0723cb2d74e9f48ad260414f1201fc (diff)
downloadrust-e649eca1d2dc266b9b38f207500648cbb295cb1a.tar.gz
rust-e649eca1d2dc266b9b38f207500648cbb295cb1a.zip
Rollup merge of #126675 - oli-obk:diagnostics_opaque, r=jackh726
Change a `DefineOpaqueTypes::No` to `Yes` in diagnostics code

Explanation in comments of the function.

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

cc https://github.com/rust-lang/rust/issues/116652
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/method/probe.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs
index 3986374a343..47ea221d1a1 100644
--- a/compiler/rustc_hir_typeck/src/method/probe.rs
+++ b/compiler/rustc_hir_typeck/src/method/probe.rs
@@ -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(_) => {
@@ -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,
                 );