@@ -16,6 +16,7 @@ macro_rules! pattern_type {
16
16
/// A trait implemented for integer types and `char`.
17
17
/// Useful in the future for generic pattern types, but
18
18
/// used right now to simplify ast lowering of pattern type ranges.
19
+ #[ cfg_attr( flux, flux:: assoc( fn sub_ok( self : Self ) -> bool { true } ) ) ]
19
20
#[ unstable( feature = "pattern_type_range_trait" , issue = "123646" ) ]
20
21
#[ rustc_const_unstable( feature = "pattern_type_range_trait" , issue = "123646" ) ]
21
22
#[ const_trait]
@@ -33,6 +34,7 @@ pub trait RangePattern {
33
34
const MAX : Self ;
34
35
35
36
/// A compile-time helper to subtract 1 for exclusive ranges.
37
+ #[ cfg_attr( flux, flux:: spec( fn ( self : Self { <Self as RangePattern >:: sub_ok( self ) } ) -> Self ) ) ]
36
38
#[ lang = "RangeSub" ]
37
39
#[ track_caller]
38
40
fn sub_one ( self ) -> Self ;
@@ -61,12 +63,14 @@ impl_range_pat! {
61
63
u8 , u16 , u32 , u64 , u128 , usize ,
62
64
}
63
65
66
+ #[ cfg_attr( flux, flux:: assoc( fn sub_ok( self : char ) -> bool { 0 < char_to_int( self ) } ) ) ]
64
67
#[ rustc_const_unstable( feature = "pattern_type_range_trait" , issue = "123646" ) ]
65
68
impl const RangePattern for char {
66
69
const MIN : Self = char:: MIN ;
67
70
68
71
const MAX : Self = char:: MAX ;
69
72
73
+ #[ cfg_attr( flux, flux:: spec( fn ( self : char { <char as RangePattern >:: sub_ok( self ) } ) -> char ) ) ]
70
74
fn sub_one ( self ) -> Self {
71
75
match char:: from_u32 ( self as u32 - 1 ) {
72
76
None => panic ! ( "exclusive range to start of valid chars" ) ,
0 commit comments