@@ -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
@@ -496,3 +502,37 @@ fn evaluate_host_effect_from_selection_candidate<'tcx>(
496502 }
497503 } )
498504}
505+
506+ fn evaluate_host_effect_from_trait_alias < ' tcx > (
507+ selcx : & mut SelectionContext < ' _ , ' tcx > ,
508+ obligation : & HostEffectObligation < ' tcx > ,
509+ ) -> Result < ThinVec < PredicateObligation < ' tcx > > , EvaluationFailure > {
510+ let tcx = selcx. tcx ( ) ;
511+ let def_id = obligation. predicate . def_id ( ) ;
512+ if !tcx. trait_is_alias ( def_id) {
513+ return Err ( EvaluationFailure :: NoSolution ) ;
514+ }
515+
516+ Ok ( tcx
517+ . const_conditions ( def_id)
518+ . instantiate ( tcx, obligation. predicate . trait_ref . args )
519+ . into_iter ( )
520+ . map ( |( trait_ref, span) | {
521+ Obligation :: new (
522+ tcx,
523+ obligation. cause . clone ( ) . derived_host_cause (
524+ ty:: Binder :: dummy ( obligation. predicate ) ,
525+ |derived| {
526+ ObligationCauseCode :: ImplDerivedHost ( Box :: new ( ImplDerivedHostCause {
527+ derived,
528+ impl_def_id : def_id,
529+ span,
530+ } ) )
531+ } ,
532+ ) ,
533+ obligation. param_env ,
534+ trait_ref. to_host_effect_clause ( tcx, obligation. predicate . constness ) ,
535+ )
536+ } )
537+ . collect ( ) )
538+ }
0 commit comments