@@ -846,20 +846,6 @@ impl ToPredicate<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
846846 }
847847}
848848
849- impl < ' tcx > ToPredicate < ' tcx > for ConstnessAnd < PolyTraitRef < ' tcx > > {
850- fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
851- self . value
852- . map_bound ( |trait_ref| {
853- PredicateKind :: Trait ( ty:: TraitPredicate {
854- trait_ref,
855- constness : self . constness ,
856- polarity : ty:: ImplPolarity :: Positive ,
857- } )
858- } )
859- . to_predicate ( tcx)
860- }
861- }
862-
863849impl < ' tcx > ToPredicate < ' tcx > for PolyTraitPredicate < ' tcx > {
864850 fn to_predicate ( self , tcx : TyCtxt < ' tcx > ) -> Predicate < ' tcx > {
865851 self . map_bound ( PredicateKind :: Trait ) . to_predicate ( tcx)
@@ -1391,33 +1377,23 @@ impl<'tcx> ParamEnv<'tcx> {
13911377 }
13921378}
13931379
1394- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , TypeFoldable ) ]
1395- pub struct ConstnessAnd < T > {
1396- pub constness : BoundConstness ,
1397- pub value : T ,
1398- }
1399-
14001380// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate(tcx)` to ensure that
14011381// the constness of trait bounds is being propagated correctly.
1402- pub trait WithConstness : Sized {
1403- #[ inline]
1404- fn with_constness ( self , constness : BoundConstness ) -> ConstnessAnd < Self > {
1405- ConstnessAnd { constness, value : self }
1406- }
1407-
1382+ impl PolyTraitRef < ' tcx > {
14081383 #[ inline]
1409- fn with_const_if_const ( self ) -> ConstnessAnd < Self > {
1410- self . with_constness ( BoundConstness :: ConstIfConst )
1384+ pub fn with_constness ( self , constness : BoundConstness ) -> PolyTraitPredicate < ' tcx > {
1385+ self . map_bound ( |trait_ref| ty:: TraitPredicate {
1386+ trait_ref,
1387+ constness,
1388+ polarity : ty:: ImplPolarity :: Positive ,
1389+ } )
14111390 }
1412-
14131391 #[ inline]
1414- fn without_const ( self ) -> ConstnessAnd < Self > {
1392+ pub fn without_const ( self ) -> PolyTraitPredicate < ' tcx > {
14151393 self . with_constness ( BoundConstness :: NotConst )
14161394 }
14171395}
14181396
1419- impl < T > WithConstness for T { }
1420-
14211397#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , TypeFoldable ) ]
14221398pub struct ParamEnvAnd < ' tcx , T > {
14231399 pub param_env : ParamEnv < ' tcx > ,
0 commit comments