Skip to content

Commit 1493072

Browse files
committed
Use prove/ObligationCtxt instead of can_eq
1 parent 2ca387e commit 1493072

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ use crate::errors::{
2626
AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError,
2727
SourceKindMultiSuggestion, SourceKindSubdiag,
2828
};
29-
use crate::infer::{InferCtxt, InferCtxtExt};
29+
use crate::infer::InferCtxt;
30+
use crate::traits::{ObligationCause, ObligationCtxt};
3031

3132
pub enum TypeAnnotationNeeded {
3233
/// ```compile_fail,E0282
@@ -757,7 +758,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
757758
let impl_trait_ref =
758759
tcx.impl_trait_ref(impl_def_id).unwrap().instantiate(tcx, impl_args);
759760
let impl_self_ty = impl_trait_ref.self_ty();
760-
if self.infcx.can_eq(param_env, impl_self_ty, self_ty) {
761+
if self.probe(|_| {
762+
ObligationCtxt::new(self.infcx)
763+
.eq(&ObligationCause::dummy(), param_env, self_ty, impl_self_ty)
764+
.is_ok()
765+
}) {
761766
// The expr's self type could conform to this impl's self type.
762767
} else {
763768
// Nope, don't bother.

0 commit comments

Comments
 (0)