Skip to content

Commit d70c5de

Browse files
committed
re-attach flux::spec
1 parent f5168e9 commit d70c5de

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

library/core/src/ascii/ascii_char.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ impl AsciiChar {
528528
}
529529

530530
/// Gets this ASCII character as a byte.
531+
#[cfg_attr(flux, flux::spec(fn (Self) -> u8{v: v <= 127}))]
531532
#[unstable(feature = "ascii_char", issue = "110998")]
532533
#[inline]
533534
pub const fn to_u8(self) -> u8 {

library/core/src/flux_info.rs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
}
2727
}]
2828
#[flux::specs {
29-
mod ascii {
30-
// AsciiChar is `crate::ascii::Char`
31-
impl Char {
32-
fn to_u8(Self) -> u8{v: v <= 127};
33-
}
34-
}
35-
3629
mod hash {
3730
mod sip {
3831
struct Hasher {
@@ -44,47 +37,26 @@
4437
ntail: usize{v: v <= 8}, // how many bytes in tail are valid
4538
_marker: PhantomData<S>,
4639
}
47-
48-
4940
}
5041
5142
impl BuildHasherDefault {
52-
#[trusted] // reason = https://github.com/flux-rs/flux/issues/1185
43+
#[trusted] // https://github.com/flux-rs/flux/issues/1185
5344
fn new() -> Self;
5445
}
5546
}
5647
5748
impl Hasher for hash::sip::Hasher {
58-
fn write(self: &mut Self, msg: &[u8]) ensures self: Self; // FLUX:mut-ref-unfolding
49+
fn write(self: &mut Self, msg: &[u8]) ensures self: Self; // mut-ref-unfolding
5950
}
6051
6152
impl Clone for hash::BuildHasherDefault {
62-
#[trusted] // reason = https://github.com/flux-rs/flux/issues/1185
53+
#[trusted] // https://github.com/flux-rs/flux/issues/1185
6354
fn clone(self: &Self) -> Self;
6455
}
6556
6657
impl Debug for time::Duration {
67-
#[trusted] // reason = modular arithmetic invariant inside nested fmt_decimal
58+
#[trusted] // modular arithmetic invariant inside nested fmt_decimal
6859
fn fmt(self: &Self, f: &mut fmt::Formatter) -> fmt::Result;
6960
}
70-
71-
mod pat {
72-
trait RangePattern {
73-
#[reft]
74-
fn sub_ok(self: Self) -> bool { true }
75-
76-
fn sub_one(self: Self{<Self as RangePattern>::sub_ok(self)}) -> Self;
77-
}
78-
}
79-
80-
impl RangePattern for char {
81-
#[reft]
82-
fn sub_ok(self: char) -> bool {
83-
0 < char_to_int(self)
84-
}
85-
86-
fn sub_one(self: char{<char as RangePattern>::sub_ok(self)}) -> char;
87-
88-
}
8961
}]
9062
const _: () = {};

library/core/src/pat.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ macro_rules! pattern_type {
1616
/// A trait implemented for integer types and `char`.
1717
/// Useful in the future for generic pattern types, but
1818
/// used right now to simplify ast lowering of pattern type ranges.
19+
#[cfg_attr(flux, flux::assoc(fn sub_ok(self: Self) -> bool { true }))]
1920
#[unstable(feature = "pattern_type_range_trait", issue = "123646")]
2021
#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")]
2122
#[const_trait]
@@ -33,6 +34,7 @@ pub trait RangePattern {
3334
const MAX: Self;
3435

3536
/// 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))]
3638
#[lang = "RangeSub"]
3739
#[track_caller]
3840
fn sub_one(self) -> Self;
@@ -61,12 +63,14 @@ impl_range_pat! {
6163
u8, u16, u32, u64, u128, usize,
6264
}
6365

66+
#[cfg_attr(flux, flux::assoc(fn sub_ok(self: char) -> bool { 0 < char_to_int(self)}))]
6467
#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")]
6568
impl const RangePattern for char {
6669
const MIN: Self = char::MIN;
6770

6871
const MAX: Self = char::MAX;
6972

73+
#[cfg_attr(flux, flux::spec(fn (self: char{<char as RangePattern>::sub_ok(self)}) -> char))]
7074
fn sub_one(self) -> Self {
7175
match char::from_u32(self as u32 - 1) {
7276
None => panic!("exclusive range to start of valid chars"),

0 commit comments

Comments
 (0)