Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1f82e22
rebasing detached (step 1)
ranjitjhala Jun 26, 2025
51815ed
update convert with cast (only)
ranjitjhala Jul 14, 2025
2945adb
DONE: pat
ranjitjhala Jul 15, 2025
2f0f212
DONE: bstr
ranjitjhala Jul 15, 2025
ff6b39d
PAUSE: flux #1185
ranjitjhala Jul 15, 2025
857825e
DONE: hash
ranjitjhala Jul 15, 2025
beaa970
NEXT: NANOSEC invariant
ranjitjhala Jul 15, 2025
8c29de8
NEXT: time -- needs `%` properties
ranjitjhala Jul 15, 2025
c1e89cc
DONE: time
ranjitjhala Jul 16, 2025
9357e64
temp
ranjitjhala Jul 29, 2025
27ebaaf
yay, detached a trait-impl!
ranjitjhala Jul 29, 2025
5e49876
last: pat.rs
ranjitjhala Jul 30, 2025
d6cad50
done detach2
ranjitjhala Jul 30, 2025
aed746a
remove detached
ranjitjhala Jul 30, 2025
2104303
format
ranjitjhala Jul 30, 2025
77aa659
format
ranjitjhala Jul 30, 2025
b7affa6
format
ranjitjhala Jul 30, 2025
800d19a
restore time
ranjitjhala Jul 30, 2025
6ddfc77
restore time remove flux
ranjitjhala Jul 30, 2025
c942c6b
sigh
ranjitjhala Jul 30, 2025
b249426
Merge branch 'main' of https://github.com/flux-rs/verify-rust-std
ranjitjhala Jul 30, 2025
83cfb47
rebasing detached (step 1)
ranjitjhala Jun 26, 2025
e10ddf4
update convert with cast (only)
ranjitjhala Jul 14, 2025
ff1157c
DONE: pat
ranjitjhala Jul 15, 2025
b2048f4
DONE: bstr
ranjitjhala Jul 15, 2025
b904224
PAUSE: flux #1185
ranjitjhala Jul 15, 2025
ec773f7
DONE: hash
ranjitjhala Jul 15, 2025
94c18c1
NEXT: NANOSEC invariant
ranjitjhala Jul 15, 2025
e65a2e5
NEXT: time -- needs `%` properties
ranjitjhala Jul 15, 2025
3777a6c
DONE: time
ranjitjhala Jul 16, 2025
b0a9792
temp
ranjitjhala Jul 29, 2025
ee73964
yay, detached a trait-impl!
ranjitjhala Jul 29, 2025
b5b68a6
last: pat.rs
ranjitjhala Jul 30, 2025
f2cd607
done detach2
ranjitjhala Jul 30, 2025
52648dd
remove detached
ranjitjhala Jul 30, 2025
fb2ae3f
format
ranjitjhala Jul 30, 2025
546269e
format
ranjitjhala Jul 30, 2025
e3f5408
format
ranjitjhala Jul 30, 2025
6a42b17
restore time
ranjitjhala Jul 30, 2025
265fc8c
restore time remove flux
ranjitjhala Jul 30, 2025
227037b
asd Merge branch 'flux-submission2-detached' of https://github.com/fl…
ranjitjhala Jul 30, 2025
426b5ae
use main Cargo.lock
ranjitjhala Jul 30, 2025
f5168e9
bump flux version in yml
ranjitjhala Jul 30, 2025
d70c5de
re-attach flux::spec
ranjitjhala Jul 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/flux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
FIXPOINT_VERSION: "556104ba5508891c357b0bdf819ce706e93d9349"
FLUX_VERSION: "ebafb8d0ca32d8c0fcd2a0cfef6b1b4bd4dc4a6f"
FLUX_VERSION: "eb448b89b2caf3bb9d3e1ee41d1087d4651934c6"

jobs:
check-flux-on-core:
Expand Down
90 changes: 90 additions & 0 deletions library/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ check-cfg = [

[package.metadata.flux]
enabled = true
include = [ "src/ascii{*.rs,/**/*.rs}" ]
include = [ "src/ascii{*.rs,/**/*.rs}",
"src/pat{*.rs,/**/*.rs}",
"src/bstr{*.rs,/**/*.rs}",
"src/hash{*.rs,/**/*.rs}",
"src/time{*.rs,/**/*.rs}",
]
2 changes: 1 addition & 1 deletion library/core/src/ascii/ascii_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ impl AsciiChar {
}

/// Gets this ASCII character as a byte.
#[cfg_attr(flux, flux::spec(fn (Self) -> u8{v: v <= 127}))]
#[unstable(feature = "ascii_char", issue = "110998")]
#[cfg_attr(flux, flux::spec(fn(Self) -> u8{v: v <= 127}))]
#[inline]
pub const fn to_u8(self) -> u8 {
self as u8
Expand Down
51 changes: 49 additions & 2 deletions library/core/src/flux_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,59 @@
/// See the following link for more information on how extensible properties for primitive operations work:
/// <https://flux-rs.github.io/flux/guide/specifications.html#extensible-properties-for-primitive-ops>
#[flux::defs {

fn as_int(x:int) -> int {
x
}

fn char_to_int(x:char) -> int {
cast(x)
}

property ShiftRightByFour[>>](x, y) {
16 * [>>](x, 4) == x
}

property MaskBy15[&](x, y) {
[&](x, y) <= y
property MaskLess[&](x, y) {
[&](x, y) <= x && [&](x, y) <= y
}

property ShiftLeft[<<](n, k) {
0 < k => n <= [<<](n, k)
}
}]
#[flux::specs {
mod hash {
mod sip {
struct Hasher {
k0: u64,
k1: u64,
length: usize, // how many bytes we've processed
state: State, // hash State
tail: u64, // unprocessed bytes le
ntail: usize{v: v <= 8}, // how many bytes in tail are valid
_marker: PhantomData<S>,
}
}

impl BuildHasherDefault {
#[trusted] // https://github.com/flux-rs/flux/issues/1185
fn new() -> Self;
}
}

impl Hasher for hash::sip::Hasher {
fn write(self: &mut Self, msg: &[u8]) ensures self: Self; // mut-ref-unfolding
}

impl Clone for hash::BuildHasherDefault {
#[trusted] // https://github.com/flux-rs/flux/issues/1185
fn clone(self: &Self) -> Self;
}

impl Debug for time::Duration {
#[trusted] // modular arithmetic invariant inside nested fmt_decimal
fn fmt(self: &Self, f: &mut fmt::Formatter) -> fmt::Result;
}
}]
const _: () = {};
6 changes: 6 additions & 0 deletions library/core/src/num/niche_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ macro_rules! define_valid_range_type {
$(#[$m:meta])*
$vis:vis struct $name:ident($int:ident as $uint:ident in $low:literal..=$high:literal);
)+) => {$(
#[cfg_attr(flux, flux::opaque)]
#[cfg_attr(flux, flux::refined_by(val: int))]
#[cfg_attr(flux, flux::invariant(as_int($low) <= cast(val) && cast(val) <= as_int($high)))]
#[derive(Clone, Copy, Eq)]
#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start($low)]
Expand All @@ -33,6 +36,7 @@ macro_rules! define_valid_range_type {

impl $name {
#[inline]
#[cfg_attr(flux, flux::spec(fn (val: $int) -> Option<Self[{val: cast(val)}]>))]
pub const fn new(val: $int) -> Option<Self> {
if (val as $uint) >= ($low as $uint) && (val as $uint) <= ($high as $uint) {
// SAFETY: just checked the inclusive range
Expand All @@ -49,12 +53,14 @@ macro_rules! define_valid_range_type {
/// Immediate language UB if `val == 0`, as it violates the validity
/// invariant of this type.
#[inline]
#[cfg_attr(flux, flux::spec(fn (val: $int{ as_int($low) <= cast(val) && cast(val) <= as_int($high) }) -> Self[{val:cast(val)}]))] // NOTE: `val == 0` comments are stale(?)
pub const unsafe fn new_unchecked(val: $int) -> Self {
// SAFETY: Caller promised that `val` is non-zero.
unsafe { $name(val) }
}

#[inline]
#[cfg_attr(flux, flux::spec(fn (self: Self) -> $int[cast(self.val)] ensures as_int($low) <= cast(self.val) && cast(self.val) <= as_int($high)))]
pub const fn as_inner(self) -> $int {
// SAFETY: This is a transparent wrapper, so unwrapping it is sound
// (Not using `.0` due to MCP#807.)
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ macro_rules! pattern_type {
/// A trait implemented for integer types and `char`.
/// Useful in the future for generic pattern types, but
/// used right now to simplify ast lowering of pattern type ranges.
#[cfg_attr(flux, flux::assoc(fn sub_ok(self: Self) -> bool { true }))]
#[unstable(feature = "pattern_type_range_trait", issue = "123646")]
#[rustc_const_unstable(feature = "pattern_type_range_trait", issue = "123646")]
#[const_trait]
Expand All @@ -33,6 +34,7 @@ pub trait RangePattern {
const MAX: Self;

/// A compile-time helper to subtract 1 for exclusive ranges.
#[cfg_attr(flux, flux::spec(fn (self: Self{<Self as RangePattern>::sub_ok(self)}) -> Self))]
#[lang = "RangeSub"]
#[track_caller]
fn sub_one(self) -> Self;
Expand Down Expand Up @@ -61,12 +63,14 @@ impl_range_pat! {
u8, u16, u32, u64, u128, usize,
}

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

const MAX: Self = char::MAX;

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