@@ -1068,7 +1068,11 @@ pub enum Predicate<'tcx> {
10681068 /// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
10691069 /// the `Self` type of the trait reference and `A`, `B`, and `C`
10701070 /// would be the type parameters.
1071- Trait ( PolyTraitPredicate < ' tcx > ) ,
1071+ ///
1072+ /// A trait predicate will have `Constness::Const` if it originates
1073+ /// from a bound on a `const fn` without the `?const` opt-out (e.g.,
1074+ /// `const fn foobar<Foo: Bar>() {}`).
1075+ Trait ( PolyTraitPredicate < ' tcx > , ast:: Constness ) ,
10721076
10731077 /// `where 'a: 'b`
10741078 RegionOutlives ( PolyRegionOutlivesPredicate < ' tcx > ) ,
@@ -1191,8 +1195,8 @@ impl<'tcx> Predicate<'tcx> {
11911195
11921196 let substs = & trait_ref. skip_binder ( ) . substs ;
11931197 match * self {
1194- Predicate :: Trait ( ref binder) => {
1195- Predicate :: Trait ( binder. map_bound ( |data| data. subst ( tcx, substs) ) )
1198+ Predicate :: Trait ( ref binder, constness ) => {
1199+ Predicate :: Trait ( binder. map_bound ( |data| data. subst ( tcx, substs) ) , constness )
11961200 }
11971201 Predicate :: Subtype ( ref binder) => {
11981202 Predicate :: Subtype ( binder. map_bound ( |data| data. subst ( tcx, substs) ) )
@@ -1338,13 +1342,16 @@ pub trait ToPredicate<'tcx> {
13381342
13391343impl < ' tcx > ToPredicate < ' tcx > for TraitRef < ' tcx > {
13401344 fn to_predicate ( & self ) -> Predicate < ' tcx > {
1341- ty:: Predicate :: Trait ( ty:: Binder :: dummy ( ty:: TraitPredicate { trait_ref : self . clone ( ) } ) )
1345+ ty:: Predicate :: Trait (
1346+ ty:: Binder :: dummy ( ty:: TraitPredicate { trait_ref : self . clone ( ) } ) ,
1347+ ast:: Constness :: NotConst ,
1348+ )
13421349 }
13431350}
13441351
13451352impl < ' tcx > ToPredicate < ' tcx > for PolyTraitRef < ' tcx > {
13461353 fn to_predicate ( & self ) -> Predicate < ' tcx > {
1347- ty:: Predicate :: Trait ( self . to_poly_trait_predicate ( ) )
1354+ ty:: Predicate :: Trait ( self . to_poly_trait_predicate ( ) , ast :: Constness :: NotConst )
13481355 }
13491356}
13501357
@@ -1413,7 +1420,7 @@ impl<'tcx> Predicate<'tcx> {
14131420 /// with depth 0 are bound by the predicate.
14141421 pub fn walk_tys ( & ' a self ) -> impl Iterator < Item = Ty < ' tcx > > + ' a {
14151422 match * self {
1416- ty:: Predicate :: Trait ( ref data) => {
1423+ ty:: Predicate :: Trait ( ref data, _ ) => {
14171424 WalkTysIter :: InputTypes ( data. skip_binder ( ) . input_types ( ) )
14181425 }
14191426 ty:: Predicate :: Subtype ( binder) => {
@@ -1439,7 +1446,7 @@ impl<'tcx> Predicate<'tcx> {
14391446
14401447 pub fn to_opt_poly_trait_ref ( & self ) -> Option < PolyTraitRef < ' tcx > > {
14411448 match * self {
1442- Predicate :: Trait ( ref t) => Some ( t. to_poly_trait_ref ( ) ) ,
1449+ Predicate :: Trait ( ref t, _ ) => Some ( t. to_poly_trait_ref ( ) ) ,
14431450 Predicate :: Projection ( ..)
14441451 | Predicate :: Subtype ( ..)
14451452 | Predicate :: RegionOutlives ( ..)
0 commit comments