@@ -574,9 +574,8 @@ impl<'tcx> InferCtxt<'tcx> {
574574 // unexpected region errors.
575575 goals. push ( Goal :: new ( tcx, param_env, ty:: ClauseKind :: WellFormed ( hidden_ty. into ( ) ) ) ) ;
576576
577- let item_bounds = tcx. explicit_item_bounds ( def_id) ;
578- for ( predicate, _) in item_bounds. iter_instantiated_copied ( tcx, args) {
579- let predicate = predicate. fold_with ( & mut BottomUpFolder {
577+ let replace_opaques_in = |clause : ty:: Clause < ' tcx > , goals : & mut Vec < _ > | {
578+ clause. fold_with ( & mut BottomUpFolder {
580579 tcx,
581580 ty_op : |ty| match * ty. kind ( ) {
582581 // We can't normalize associated types from `rustc_infer`,
@@ -612,11 +611,31 @@ impl<'tcx> InferCtxt<'tcx> {
612611 } ,
613612 lt_op : |lt| lt,
614613 ct_op : |ct| ct,
615- } ) ;
614+ } )
615+ } ;
616+
617+ let item_bounds = tcx. explicit_item_bounds ( def_id) ;
618+ for ( predicate, _) in item_bounds. iter_instantiated_copied ( tcx, args) {
619+ let predicate = replace_opaques_in ( predicate, goals) ;
616620
617621 // Require that the predicate holds for the concrete type.
618622 debug ! ( ?predicate) ;
619623 goals. push ( Goal :: new ( self . tcx , param_env, predicate) ) ;
620624 }
625+
626+ // If this opaque is being defined and it's conditionally const,
627+ if self . tcx . is_conditionally_const ( def_id) {
628+ let item_bounds = tcx. explicit_implied_const_bounds ( def_id) ;
629+ for ( predicate, _) in item_bounds. iter_instantiated_copied ( tcx, args) {
630+ let predicate = replace_opaques_in (
631+ predicate. to_host_effect_clause ( self . tcx , ty:: BoundConstness :: Maybe ) ,
632+ goals,
633+ ) ;
634+
635+ // Require that the predicate holds for the concrete type.
636+ debug ! ( ?predicate) ;
637+ goals. push ( Goal :: new ( self . tcx , param_env, predicate) ) ;
638+ }
639+ }
621640 }
622641}
0 commit comments