Skip to content

Commit b3edd9f

Browse files
Use predicate_must_hold_modulo_regions
1 parent 63be7a2 commit b3edd9f

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ pub mod on_unimplemented;
22
pub mod suggestions;
33

44
use super::{
5-
EvaluationResult, FulfillmentContext, FulfillmentError, FulfillmentErrorCode,
6-
MismatchedProjectionTypes, Obligation, ObligationCause, ObligationCauseCode,
7-
OnUnimplementedDirective, OnUnimplementedNote, OutputTypeParameterMismatch, Overflow,
8-
PredicateObligation, SelectionContext, SelectionError, TraitNotObjectSafe,
5+
FulfillmentContext, FulfillmentError, FulfillmentErrorCode, MismatchedProjectionTypes,
6+
Obligation, ObligationCause, ObligationCauseCode, OnUnimplementedDirective,
7+
OnUnimplementedNote, OutputTypeParameterMismatch, Overflow, PredicateObligation,
8+
SelectionContext, SelectionError, TraitNotObjectSafe,
99
};
1010

1111
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::{
2-
EvaluationResult, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation,
3-
SelectionContext,
2+
Obligation, ObligationCause, ObligationCauseCode, PredicateObligation, SelectionContext,
43
};
54

65
use crate::autoderef::Autoderef;
@@ -839,15 +838,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
839838
let new_obligation =
840839
self.mk_trait_obligation_with_new_self_ty(obligation.param_env, trait_pred_and_self);
841840

842-
match self.evaluate_obligation(&new_obligation) {
843-
Ok(
844-
EvaluationResult::EvaluatedToOk
845-
| EvaluationResult::EvaluatedToOkModuloRegions
846-
| EvaluationResult::EvaluatedToOkModuloOpaqueTypes
847-
| EvaluationResult::EvaluatedToAmbig,
848-
) => {}
849-
_ => return false,
841+
if !self.predicate_must_hold_modulo_regions(&new_obligation) {
842+
return false;
850843
}
844+
851845
let hir = self.tcx.hir();
852846
// Get the name of the callable and the arguments to be used in the suggestion.
853847
let (snippet, sugg) = match hir.get_if_local(def_id) {

0 commit comments

Comments
 (0)