@@ -79,27 +79,24 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
79
79
Invert :: Yes ,
80
80
) ) ;
81
81
// Relate via args
82
- candidates. extend (
83
- self . assemble_subst_relate_candidate (
84
- param_env, alias_lhs, alias_rhs, direction,
85
- ) ,
86
- ) ;
82
+ let subst_relate_response = self
83
+ . assemble_subst_relate_candidate ( param_env, alias_lhs, alias_rhs, direction) ;
84
+ candidates. extend ( subst_relate_response) ;
87
85
debug ! ( ?candidates) ;
88
86
89
87
if let Some ( merged) = self . try_merge_responses ( & candidates) {
90
88
Ok ( merged)
91
89
} else {
92
- // When relating two aliases and we have ambiguity, if both
93
- // aliases can be normalized to something, we prefer
94
- // "bidirectionally normalizing" both of them within the same
95
- // candidate.
96
- //
97
- // See <https://github.com/rust-lang/trait-system-refactor-initiative/issues/25>.
90
+ // When relating two aliases and we have ambiguity, we prefer
91
+ // relating the generic arguments of the aliases over normalizing
92
+ // them. This is necessary for inference during typeck.
98
93
//
99
94
// As this is incomplete, we must not do so during coherence.
100
95
match self . solver_mode ( ) {
101
96
SolverMode :: Normal => {
102
- if let Ok ( bidirectional_normalizes_to_response) = self
97
+ if let Ok ( subst_relate_response) = subst_relate_response {
98
+ Ok ( subst_relate_response)
99
+ } else if let Ok ( bidirectional_normalizes_to_response) = self
103
100
. assemble_bidirectional_normalizes_to_candidate (
104
101
param_env, lhs, rhs, direction,
105
102
)
0 commit comments