@@ -959,11 +959,21 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
959
959
if self . can_use_global_caches ( param_env) {
960
960
let mut cache = self . tcx ( ) . evaluation_cache . hashmap . borrow_mut ( ) ;
961
961
if let Some ( trait_ref) = self . tcx ( ) . lift_to_global ( & trait_ref) {
962
+ debug ! (
963
+ "insert_evaluation_cache(trait_ref={:?}, candidate={:?}) global" ,
964
+ trait_ref,
965
+ result,
966
+ ) ;
962
967
cache. insert ( trait_ref, WithDepNode :: new ( dep_node, result) ) ;
963
968
return ;
964
969
}
965
970
}
966
971
972
+ debug ! (
973
+ "insert_evaluation_cache(trait_ref={:?}, candidate={:?})" ,
974
+ trait_ref,
975
+ result,
976
+ ) ;
967
977
self . infcx . evaluation_cache . hashmap
968
978
. borrow_mut ( )
969
979
. insert ( trait_ref, WithDepNode :: new ( dep_node, result) ) ;
@@ -1067,25 +1077,29 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1067
1077
if self . intercrate_ambiguity_causes . is_some ( ) {
1068
1078
debug ! ( "evaluate_stack: intercrate_ambiguity_causes is some" ) ;
1069
1079
// Heuristics: show the diagnostics when there are no candidates in crate.
1070
- let candidate_set = self . assemble_candidates ( stack) ?;
1071
- if !candidate_set. ambiguous && candidate_set. vec . iter ( ) . all ( |c| {
1072
- !self . evaluate_candidate ( stack, & c) . may_apply ( )
1073
- } ) {
1074
- let trait_ref = stack. obligation . predicate . skip_binder ( ) . trait_ref ;
1075
- let self_ty = trait_ref. self_ty ( ) ;
1076
- let trait_desc = trait_ref. to_string ( ) ;
1077
- let self_desc = if self_ty. has_concrete_skeleton ( ) {
1078
- Some ( self_ty. to_string ( ) )
1079
- } else {
1080
- None
1081
- } ;
1082
- let cause = if let Conflict :: Upstream = conflict {
1083
- IntercrateAmbiguityCause :: UpstreamCrateUpdate { trait_desc, self_desc }
1084
- } else {
1085
- IntercrateAmbiguityCause :: DownstreamCrate { trait_desc, self_desc }
1086
- } ;
1087
- debug ! ( "evaluate_stack: pushing cause = {:?}" , cause) ;
1088
- self . intercrate_ambiguity_causes . as_mut ( ) . unwrap ( ) . push ( cause) ;
1080
+ if let Ok ( candidate_set) = self . assemble_candidates ( stack) {
1081
+ if !candidate_set. ambiguous && candidate_set. vec . iter ( ) . all ( |c| {
1082
+ !self . evaluate_candidate ( stack, & c) . may_apply ( )
1083
+ } ) {
1084
+ let trait_ref = stack. obligation . predicate . skip_binder ( ) . trait_ref ;
1085
+ let self_ty = trait_ref. self_ty ( ) ;
1086
+ let trait_desc = trait_ref. to_string ( ) ;
1087
+ let self_desc = if self_ty. has_concrete_skeleton ( ) {
1088
+ Some ( self_ty. to_string ( ) )
1089
+ } else {
1090
+ None
1091
+ } ;
1092
+ let cause = if let Conflict :: Upstream = conflict {
1093
+ IntercrateAmbiguityCause :: UpstreamCrateUpdate {
1094
+ trait_desc,
1095
+ self_desc,
1096
+ }
1097
+ } else {
1098
+ IntercrateAmbiguityCause :: DownstreamCrate { trait_desc, self_desc }
1099
+ } ;
1100
+ debug ! ( "evaluate_stack: pushing cause = {:?}" , cause) ;
1101
+ self . intercrate_ambiguity_causes . as_mut ( ) . unwrap ( ) . push ( cause) ;
1102
+ }
1089
1103
}
1090
1104
}
1091
1105
return Ok ( None ) ;
@@ -1283,12 +1297,22 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1283
1297
let mut cache = tcx. selection_cache . hashmap . borrow_mut ( ) ;
1284
1298
if let Some ( trait_ref) = tcx. lift_to_global ( & trait_ref) {
1285
1299
if let Some ( candidate) = tcx. lift_to_global ( & candidate) {
1300
+ debug ! (
1301
+ "insert_candidate_cache(trait_ref={:?}, candidate={:?}) global" ,
1302
+ trait_ref,
1303
+ candidate,
1304
+ ) ;
1286
1305
cache. insert ( trait_ref, WithDepNode :: new ( dep_node, candidate) ) ;
1287
1306
return ;
1288
1307
}
1289
1308
}
1290
1309
}
1291
1310
1311
+ debug ! (
1312
+ "insert_candidate_cache(trait_ref={:?}, candidate={:?}) local" ,
1313
+ trait_ref,
1314
+ candidate,
1315
+ ) ;
1292
1316
self . infcx . selection_cache . hashmap
1293
1317
. borrow_mut ( )
1294
1318
. insert ( trait_ref, WithDepNode :: new ( dep_node, candidate) ) ;
0 commit comments