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