@@ -1097,18 +1097,34 @@ fn activate_deps_loop(
1097
1097
has_past_conflicting_dep = true ;
1098
1098
}
1099
1099
}
1100
- // if not has_another we we activate for the better error messages
1101
- frame. just_for_error_messages = has_past_conflicting_dep;
1102
- if !has_past_conflicting_dep
1103
- || ( !has_another && ( just_here_for_the_error_messages || {
1100
+ let activate_for_error_message = has_past_conflicting_dep && !has_another && {
1101
+ // has_past_conflicting_dep -> One of this candidate deps will fail.
1102
+ // !has_another -> If the candidate is not accepted we will backtrack.
1103
+
1104
+ // So the question is will the user see that we skipped this candidate?
1105
+ just_here_for_the_error_messages || {
1106
+ // make sure we know about all the possible conflicts
1104
1107
conflicting_activations
1105
1108
. extend ( remaining_candidates. conflicting_prev_active . clone ( ) ) ;
1109
+ // test if backtracking will get to the user
1106
1110
find_candidate (
1107
1111
& mut backtrack_stack. clone ( ) ,
1108
1112
& parent,
1109
1113
& conflicting_activations,
1110
1114
) . is_none ( )
1111
- } ) ) {
1115
+ }
1116
+ } ;
1117
+ if activate_for_error_message {
1118
+ // We know one of this candidate deps will fail,
1119
+ // which means we will fail,
1120
+ // and that none of the backtrack frames will
1121
+ // find a candidate that will help.
1122
+ // So lets clean up the useless backtrack frames.
1123
+ backtrack_stack. clear ( ) ;
1124
+ }
1125
+ // if not has_another we we activate for the better error messages
1126
+ frame. just_for_error_messages = has_past_conflicting_dep;
1127
+ if !has_past_conflicting_dep || activate_for_error_message {
1112
1128
remaining_deps. push ( frame) ;
1113
1129
} else {
1114
1130
trace ! (
0 commit comments