@@ -1697,6 +1697,25 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
1697
1697
} )
1698
1698
}
1699
1699
1700
+ fn pretty_print_bound_constness (
1701
+ & mut self ,
1702
+ trait_ref : ty:: TraitRef < ' tcx > ,
1703
+ ) -> Result < ( ) , PrintError > {
1704
+ define_scoped_cx ! ( self ) ;
1705
+
1706
+ let Some ( idx) = self . tcx ( ) . generics_of ( trait_ref. def_id ) . host_effect_index else {
1707
+ return Ok ( ( ) ) ;
1708
+ } ;
1709
+ let arg = trait_ref. args . const_at ( idx) ;
1710
+
1711
+ if arg == self . tcx ( ) . consts . false_ {
1712
+ p ! ( "const " ) ;
1713
+ } else if arg != self . tcx ( ) . consts . true_ && !arg. has_infer ( ) {
1714
+ p ! ( "~const " ) ;
1715
+ }
1716
+ Ok ( ( ) )
1717
+ }
1718
+
1700
1719
fn should_print_verbose ( & self ) -> bool {
1701
1720
self . tcx ( ) . sess . verbose_internals ( )
1702
1721
}
@@ -2866,13 +2885,7 @@ define_print_and_forward_display! {
2866
2885
}
2867
2886
2868
2887
TraitPredPrintModifiersAndPath <' tcx> {
2869
- if let Some ( idx) = cx. tcx( ) . generics_of( self . 0 . trait_ref. def_id) . host_effect_index
2870
- {
2871
- let arg = self . 0 . trait_ref. args. const_at( idx) ;
2872
- if arg != cx. tcx( ) . consts. true_ && !arg. has_infer( ) {
2873
- p!( "~const " ) ;
2874
- }
2875
- }
2888
+ p!( pretty_print_bound_constness( self . 0 . trait_ref) ) ;
2876
2889
if let ty:: ImplPolarity :: Negative = self . 0 . polarity {
2877
2890
p!( "!" )
2878
2891
}
@@ -2905,11 +2918,7 @@ define_print_and_forward_display! {
2905
2918
2906
2919
ty:: TraitPredicate <' tcx> {
2907
2920
p!( print( self . trait_ref. self_ty( ) ) , ": " ) ;
2908
- if let Some ( idx) = cx. tcx( ) . generics_of( self . trait_ref. def_id) . host_effect_index {
2909
- if self . trait_ref. args. const_at( idx) != cx. tcx( ) . consts. true_ {
2910
- p!( "~const " ) ;
2911
- }
2912
- }
2921
+ p!( pretty_print_bound_constness( self . trait_ref) ) ;
2913
2922
if let ty:: ImplPolarity :: Negative = self . polarity {
2914
2923
p!( "!" ) ;
2915
2924
}
0 commit comments