File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
compiler/rustc_trait_selection/src/traits/error_reporting Expand file tree Collapse file tree 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>(
1919 let tcx = infcx. tcx ;
2020 let param_env = obligation. param_env ;
2121
22+ let predicate_polarity = obligation. predicate . skip_binder ( ) . polarity ;
23+
2224 let impl_may_apply = |impl_def_id| {
2325 let ocx = ObligationCtxt :: new ( infcx) ;
2426 infcx. enter_forall ( obligation. predicate , |placeholder_obligation| {
@@ -40,6 +42,15 @@ pub fn recompute_applicable_impls<'tcx>(
4042 return false ;
4143 }
4244
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+
4354 let impl_predicates = tcx. predicates_of ( impl_def_id) . instantiate ( tcx, impl_args) ;
4455 ocx. register_obligations ( impl_predicates. predicates . iter ( ) . map ( |& predicate| {
4556 Obligation :: new ( tcx, ObligationCause :: dummy ( ) , param_env, predicate)
You can’t perform that action at this time.
0 commit comments