@@ -69,6 +69,12 @@ pub fn evaluate_host_effect_obligation<'tcx>(
6969 Err ( EvaluationFailure :: NoSolution ) => { }
7070 }
7171
72+ match evaluate_host_effect_from_trait_alias ( selcx, obligation) {
73+ Ok ( result) => return Ok ( result) ,
74+ Err ( EvaluationFailure :: Ambiguous ) => return Err ( EvaluationFailure :: Ambiguous ) ,
75+ Err ( EvaluationFailure :: NoSolution ) => { }
76+ }
77+
7278 Err ( EvaluationFailure :: NoSolution )
7379}
7480
@@ -498,3 +504,37 @@ fn evaluate_host_effect_from_selection_candidate<'tcx>(
498504 }
499505 } )
500506}
507+
508+ fn evaluate_host_effect_from_trait_alias < ' tcx > (
509+ selcx : & mut SelectionContext < ' _ , ' tcx > ,
510+ obligation : & HostEffectObligation < ' tcx > ,
511+ ) -> Result < ThinVec < PredicateObligation < ' tcx > > , EvaluationFailure > {
512+ let tcx = selcx. tcx ( ) ;
513+ let def_id = obligation. predicate . def_id ( ) ;
514+ if !tcx. trait_is_alias ( def_id) {
515+ return Err ( EvaluationFailure :: NoSolution ) ;
516+ }
517+
518+ Ok ( tcx
519+ . const_conditions ( def_id)
520+ . instantiate ( tcx, obligation. predicate . trait_ref . args )
521+ . into_iter ( )
522+ . map ( |( trait_ref, span) | {
523+ Obligation :: new (
524+ tcx,
525+ obligation. cause . clone ( ) . derived_host_cause (
526+ ty:: Binder :: dummy ( obligation. predicate ) ,
527+ |derived| {
528+ ObligationCauseCode :: ImplDerivedHost ( Box :: new ( ImplDerivedHostCause {
529+ derived,
530+ impl_def_id : def_id,
531+ span,
532+ } ) )
533+ } ,
534+ ) ,
535+ obligation. param_env ,
536+ trait_ref. to_host_effect_clause ( tcx, obligation. predicate . constness ) ,
537+ )
538+ } )
539+ . collect ( ) )
540+ }
0 commit comments