File tree 1 file changed +11
-0
lines changed
compiler/rustc_trait_selection/src/traits/error_reporting 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ pub fn recompute_applicable_impls<'tcx>(
19
19
let tcx = infcx. tcx ;
20
20
let param_env = obligation. param_env ;
21
21
22
+ let predicate_polarity = obligation. predicate . skip_binder ( ) . polarity ;
23
+
22
24
let impl_may_apply = |impl_def_id| {
23
25
let ocx = ObligationCtxt :: new ( infcx) ;
24
26
infcx. enter_forall ( obligation. predicate , |placeholder_obligation| {
@@ -40,6 +42,15 @@ pub fn recompute_applicable_impls<'tcx>(
40
42
return false ;
41
43
}
42
44
45
+ let impl_trait_header = tcx. impl_trait_header ( impl_def_id) . unwrap ( ) ;
46
+ let impl_polarity = impl_trait_header. polarity ;
47
+
48
+ match ( impl_polarity, predicate_polarity) {
49
+ ( ty:: ImplPolarity :: Positive , ty:: PredicatePolarity :: Positive )
50
+ | ( ty:: ImplPolarity :: Negative , ty:: PredicatePolarity :: Negative ) => { }
51
+ _ => return false ,
52
+ }
53
+
43
54
let impl_predicates = tcx. predicates_of ( impl_def_id) . instantiate ( tcx, impl_args) ;
44
55
ocx. register_obligations ( impl_predicates. predicates . iter ( ) . map ( |& predicate| {
45
56
Obligation :: new ( tcx, ObligationCause :: dummy ( ) , param_env, predicate)
You can’t perform that action at this time.
0 commit comments