@@ -456,7 +456,7 @@ pub enum PredicateKind<'tcx> {
456456 /// A trait predicate will have `Constness::Const` if it originates
457457 /// from a bound on a `const fn` without the `?const` opt-out (e.g.,
458458 /// `const fn foobar<Foo: Bar>() {}`).
459- Trait ( TraitPredicate < ' tcx > , Constness ) ,
459+ Trait ( TraitPredicate < ' tcx > ) ,
460460
461461 /// `where 'a: 'b`
462462 RegionOutlives ( RegionOutlivesPredicate < ' tcx > ) ,
@@ -612,6 +612,11 @@ impl<'tcx> Predicate<'tcx> {
612612#[ derive( HashStable , TypeFoldable ) ]
613613pub struct TraitPredicate < ' tcx > {
614614 pub trait_ref : TraitRef < ' tcx > ,
615+
616+ /// A trait predicate will have `Constness::Const` if it originates
617+ /// from a bound on a `const fn` without the `?const` opt-out (e.g.,
618+ /// `const fn foobar<Foo: Bar>() {}`).
619+ pub constness : hir:: Constness ,
615620}
616621
617622pub type PolyTraitPredicate < ' tcx > = ty:: Binder < ' tcx , TraitPredicate < ' tcx > > ;
@@ -745,24 +750,27 @@ impl ToPredicate<'tcx> for PredicateKind<'tcx> {
745750
746751impl < ' tcx > ToPredicate < ' tcx > for ConstnessAnd < TraitRef < ' tcx > > {
747752 fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
748- PredicateKind :: Trait ( ty:: TraitPredicate { trait_ref : self . value } , self . constness )
749- . to_predicate ( tcx)
753+ PredicateKind :: Trait ( ty:: TraitPredicate {
754+ trait_ref : self . value ,
755+ constness : self . constness ,
756+ } )
757+ . to_predicate ( tcx)
750758 }
751759}
752760
753761impl < ' tcx > ToPredicate < ' tcx > for ConstnessAnd < PolyTraitRef < ' tcx > > {
754762 fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
755763 self . value
756764 . map_bound ( |trait_ref| {
757- PredicateKind :: Trait ( ty:: TraitPredicate { trait_ref } , self . constness )
765+ PredicateKind :: Trait ( ty:: TraitPredicate { trait_ref, constness : self . constness } )
758766 } )
759767 . to_predicate ( tcx)
760768 }
761769}
762770
763- impl < ' tcx > ToPredicate < ' tcx > for ConstnessAnd < PolyTraitPredicate < ' tcx > > {
771+ impl < ' tcx > ToPredicate < ' tcx > for PolyTraitPredicate < ' tcx > {
764772 fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
765- self . value . map_bound ( |value| PredicateKind :: Trait ( value , self . constness ) ) . to_predicate ( tcx)
773+ self . map_bound ( PredicateKind :: Trait ) . to_predicate ( tcx)
766774 }
767775}
768776
@@ -788,8 +796,8 @@ impl<'tcx> Predicate<'tcx> {
788796 pub fn to_opt_poly_trait_ref ( self ) -> Option < ConstnessAnd < PolyTraitRef < ' tcx > > > {
789797 let predicate = self . kind ( ) ;
790798 match predicate. skip_binder ( ) {
791- PredicateKind :: Trait ( t, constness ) => {
792- Some ( ConstnessAnd { constness, value : predicate. rebind ( t. trait_ref ) } )
799+ PredicateKind :: Trait ( t) => {
800+ Some ( ConstnessAnd { constness : t . constness , value : predicate. rebind ( t. trait_ref ) } )
793801 }
794802 PredicateKind :: Projection ( ..)
795803 | PredicateKind :: Subtype ( ..)
0 commit comments