@@ -866,34 +866,39 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
866
866
// precise still.
867
867
let unbound_input_types =
868
868
stack. fresh_trait_ref . value . skip_binder ( ) . substs . types ( ) . any ( |ty| ty. is_fresh ( ) ) ;
869
- // This check was an imperfect workaround for a bug in the old
870
- // intercrate mode; it should be removed when that goes away.
871
- if unbound_input_types && self . intercrate {
872
- debug ! ( "evaluate_stack --> unbound argument, intercrate --> ambiguous" , ) ;
873
- // Heuristics: show the diagnostics when there are no candidates in crate.
874
- if self . intercrate_ambiguity_causes . is_some ( ) {
875
- debug ! ( "evaluate_stack: intercrate_ambiguity_causes is some" ) ;
876
- if let Ok ( candidate_set) = self . assemble_candidates ( stack) {
877
- if !candidate_set. ambiguous && candidate_set. vec . is_empty ( ) {
878
- let trait_ref = stack. obligation . predicate . skip_binder ( ) . trait_ref ;
879
- let self_ty = trait_ref. self_ty ( ) ;
880
- let cause =
881
- with_no_trimmed_paths ( || IntercrateAmbiguityCause :: DownstreamCrate {
882
- trait_desc : trait_ref. print_only_trait_path ( ) . to_string ( ) ,
883
- self_desc : if self_ty. has_concrete_skeleton ( ) {
884
- Some ( self_ty. to_string ( ) )
885
- } else {
886
- None
887
- } ,
869
+
870
+ if stack. obligation . predicate . skip_binder ( ) . polarity != ty:: ImplPolarity :: Negative {
871
+ // This check was an imperfect workaround for a bug in the old
872
+ // intercrate mode; it should be removed when that goes away.
873
+ if unbound_input_types && self . intercrate {
874
+ debug ! ( "evaluate_stack --> unbound argument, intercrate --> ambiguous" , ) ;
875
+ // Heuristics: show the diagnostics when there are no candidates in crate.
876
+ if self . intercrate_ambiguity_causes . is_some ( ) {
877
+ debug ! ( "evaluate_stack: intercrate_ambiguity_causes is some" ) ;
878
+ if let Ok ( candidate_set) = self . assemble_candidates ( stack) {
879
+ if !candidate_set. ambiguous && candidate_set. vec . is_empty ( ) {
880
+ let trait_ref = stack. obligation . predicate . skip_binder ( ) . trait_ref ;
881
+ let self_ty = trait_ref. self_ty ( ) ;
882
+ let cause = with_no_trimmed_paths ( || {
883
+ IntercrateAmbiguityCause :: DownstreamCrate {
884
+ trait_desc : trait_ref. print_only_trait_path ( ) . to_string ( ) ,
885
+ self_desc : if self_ty. has_concrete_skeleton ( ) {
886
+ Some ( self_ty. to_string ( ) )
887
+ } else {
888
+ None
889
+ } ,
890
+ }
888
891
} ) ;
889
892
890
- debug ! ( ?cause, "evaluate_stack: pushing cause" ) ;
891
- self . intercrate_ambiguity_causes . as_mut ( ) . unwrap ( ) . push ( cause) ;
893
+ debug ! ( ?cause, "evaluate_stack: pushing cause" ) ;
894
+ self . intercrate_ambiguity_causes . as_mut ( ) . unwrap ( ) . push ( cause) ;
895
+ }
892
896
}
893
897
}
898
+ return Ok ( EvaluatedToAmbig ) ;
894
899
}
895
- return Ok ( EvaluatedToAmbig ) ;
896
900
}
901
+
897
902
if unbound_input_types
898
903
&& stack. iter ( ) . skip ( 1 ) . any ( |prev| {
899
904
stack. obligation . param_env == prev. obligation . param_env
@@ -1178,7 +1183,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1178
1183
fn is_knowable < ' o > ( & mut self , stack : & TraitObligationStack < ' o , ' tcx > ) -> Option < Conflict > {
1179
1184
debug ! ( "is_knowable(intercrate={:?})" , self . intercrate) ;
1180
1185
1181
- if !self . intercrate {
1186
+ if !self . intercrate
1187
+ || stack. obligation . predicate . skip_binder ( ) . polarity == ty:: ImplPolarity :: Negative
1188
+ {
1182
1189
return None ;
1183
1190
}
1184
1191
0 commit comments