diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-13 10:54:15 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-19 08:49:16 +0000 |
| commit | 56cd30104a0723cb2d74e9f48ad260414f1201fc (patch) | |
| tree | 1561e8a6c2e048bb14a798fe8f7b5119c23f2871 | |
| parent | 9889a6f5d3f07eb2c8480060f46d5c0e710bba8e (diff) | |
| download | rust-56cd30104a0723cb2d74e9f48ad260414f1201fc.tar.gz rust-56cd30104a0723cb2d74e9f48ad260414f1201fc.zip | |
Change a `DefineOpaqueTypes::No` to `Yes` in diagnostics code
| -rw-r--r-- | compiler/rustc_hir_typeck/src/method/probe.rs | 6 |
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, ); |
