@@ -461,7 +461,7 @@ pub enum PredicateKind<'tcx> {
461
461
/// A trait predicate will have `Constness::Const` if it originates
462
462
/// from a bound on a `const fn` without the `?const` opt-out (e.g.,
463
463
/// `const fn foobar<Foo: Bar>() {}`).
464
- Trait ( TraitPredicate < ' tcx > , Constness ) ,
464
+ Trait ( TraitPredicate < ' tcx > ) ,
465
465
466
466
/// `where 'a: 'b`
467
467
RegionOutlives ( RegionOutlivesPredicate < ' tcx > ) ,
@@ -617,6 +617,11 @@ impl<'tcx> Predicate<'tcx> {
617
617
#[ derive( HashStable , TypeFoldable ) ]
618
618
pub struct TraitPredicate < ' tcx > {
619
619
pub trait_ref : TraitRef < ' tcx > ,
620
+
621
+ /// A trait predicate will have `Constness::Const` if it originates
622
+ /// from a bound on a `const fn` without the `?const` opt-out (e.g.,
623
+ /// `const fn foobar<Foo: Bar>() {}`).
624
+ pub constness : hir:: Constness ,
620
625
}
621
626
622
627
pub type PolyTraitPredicate < ' tcx > = ty:: Binder < ' tcx , TraitPredicate < ' tcx > > ;
@@ -750,24 +755,27 @@ impl ToPredicate<'tcx> for PredicateKind<'tcx> {
750
755
751
756
impl < ' tcx > ToPredicate < ' tcx > for ConstnessAnd < TraitRef < ' tcx > > {
752
757
fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
753
- PredicateKind :: Trait ( ty:: TraitPredicate { trait_ref : self . value } , self . constness )
754
- . to_predicate ( tcx)
758
+ PredicateKind :: Trait ( ty:: TraitPredicate {
759
+ trait_ref : self . value ,
760
+ constness : self . constness ,
761
+ } )
762
+ . to_predicate ( tcx)
755
763
}
756
764
}
757
765
758
766
impl < ' tcx > ToPredicate < ' tcx > for ConstnessAnd < PolyTraitRef < ' tcx > > {
759
767
fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
760
768
self . value
761
769
. map_bound ( |trait_ref| {
762
- PredicateKind :: Trait ( ty:: TraitPredicate { trait_ref } , self . constness )
770
+ PredicateKind :: Trait ( ty:: TraitPredicate { trait_ref, constness : self . constness } )
763
771
} )
764
772
. to_predicate ( tcx)
765
773
}
766
774
}
767
775
768
- impl < ' tcx > ToPredicate < ' tcx > for ConstnessAnd < PolyTraitPredicate < ' tcx > > {
776
+ impl < ' tcx > ToPredicate < ' tcx > for PolyTraitPredicate < ' tcx > {
769
777
fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
770
- self . value . map_bound ( |value| PredicateKind :: Trait ( value , self . constness ) ) . to_predicate ( tcx)
778
+ self . map_bound ( PredicateKind :: Trait ) . to_predicate ( tcx)
771
779
}
772
780
}
773
781
@@ -793,8 +801,8 @@ impl<'tcx> Predicate<'tcx> {
793
801
pub fn to_opt_poly_trait_ref ( self ) -> Option < ConstnessAnd < PolyTraitRef < ' tcx > > > {
794
802
let predicate = self . kind ( ) ;
795
803
match predicate. skip_binder ( ) {
796
- PredicateKind :: Trait ( t, constness ) => {
797
- Some ( ConstnessAnd { constness, value : predicate. rebind ( t. trait_ref ) } )
804
+ PredicateKind :: Trait ( t) => {
805
+ Some ( ConstnessAnd { constness : t . constness , value : predicate. rebind ( t. trait_ref ) } )
798
806
}
799
807
PredicateKind :: Projection ( ..)
800
808
| PredicateKind :: Subtype ( ..)
0 commit comments