File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
compiler/rustc_trait_selection/src/traits/error_reporting Expand file tree Collapse file tree 1 file changed +17
-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,21 @@ 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
+
47
+ let impl_polarity = impl_trait_header. polarity ;
48
+ match impl_polarity {
49
+ ty:: ImplPolarity :: Positive | ty:: ImplPolarity :: Negative => {
50
+ match impl_polarity == predicate_polarity {
51
+ true => { }
52
+ false => return false ,
53
+ }
54
+ }
55
+ ty:: ImplPolarity :: Reservation => {
56
+ return false ;
57
+ }
58
+ }
59
+
43
60
let impl_predicates = tcx. predicates_of ( impl_def_id) . instantiate ( tcx, impl_args) ;
44
61
ocx. register_obligations ( impl_predicates. predicates . iter ( ) . map ( |& predicate| {
45
62
Obligation :: new ( tcx, ObligationCause :: dummy ( ) , param_env, predicate)
You can’t perform that action at this time.
0 commit comments