@@ -889,20 +889,48 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
889
889
SolverMode :: Normal => return ,
890
890
SolverMode :: Coherence => {
891
891
let trait_ref = goal. predicate . trait_ref ( self . tcx ( ) ) ;
892
- match coherence:: trait_ref_is_knowable ( self . tcx ( ) , trait_ref) {
893
- Ok ( ( ) ) => { }
894
- Err ( _) => match self
895
- . evaluate_added_goals_and_make_canonical_response ( Certainty :: AMBIGUOUS )
896
- {
897
- Ok ( result) => candidates. push ( Candidate {
898
- source : CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Ambiguity ) ,
899
- result,
900
- } ) ,
901
- // FIXME: This will be reachable at some point if we're in
902
- // `assemble_candidates_after_normalizing_self_ty` and we get a
903
- // universe error. We'll deal with it at this point.
904
- Err ( NoSolution ) => bug ! ( "coherence candidate resulted in NoSolution" ) ,
905
- } ,
892
+ // will assemble in `assemble_candidates_after_normalizing_self_ty`
893
+ if matches ! ( trait_ref. self_ty( ) . kind( ) , ty:: Alias ( ..) ) {
894
+ return ;
895
+ }
896
+ let result = self . probe_candidate ( "unknowable candidate" ) . enter ( |ecx| {
897
+ let mut args = trait_ref. args . to_vec ( ) ;
898
+ for arg in args. iter_mut ( ) . skip ( 1 ) {
899
+ let Some ( ty) = arg. as_type ( ) else {
900
+ continue ;
901
+ } ;
902
+ let Some ( normalized_ty) = ecx. normalize_non_self_ty ( ty, goal. param_env ) ?
903
+ else {
904
+ return Ok ( ecx
905
+ . evaluate_added_goals_and_make_canonical_response (
906
+ Certainty :: AMBIGUOUS ,
907
+ )
908
+ . unwrap ( ) ) ;
909
+ } ;
910
+ * arg = normalized_ty. into ( ) ;
911
+ }
912
+ match coherence:: trait_ref_is_knowable ( ecx. tcx ( ) , trait_ref) {
913
+ Ok ( ( ) ) => Err ( NoSolution ) ,
914
+ Err ( _) => {
915
+ match ecx. evaluate_added_goals_and_make_canonical_response (
916
+ Certainty :: AMBIGUOUS ,
917
+ ) {
918
+ Ok ( result) => Ok ( result) ,
919
+ // FIXME: This will be reachable at some point if we're in
920
+ // `assemble_candidates_after_normalizing_self_ty` and we get a
921
+ // universe error. We'll deal with it at this point.
922
+ Err ( NoSolution ) => {
923
+ bug ! ( "coherence candidate resulted in NoSolution" )
924
+ }
925
+ }
926
+ }
927
+ }
928
+ } ) ;
929
+ if let Ok ( result) = result {
930
+ candidates. push ( Candidate {
931
+ source : CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Ambiguity ) ,
932
+ result,
933
+ } ) ;
906
934
}
907
935
}
908
936
}
0 commit comments