Skip to content

Commit 8eefd1d

Browse files
ranjitjhalanilehmann
authored andcommitted
Add Flux
1 parent 94c1dc1 commit 8eefd1d

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

library/core/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,10 @@ check-cfg = [
4545
'cfg(target_has_reliable_f16_math)',
4646
'cfg(target_has_reliable_f128)',
4747
'cfg(target_has_reliable_f128_math)',
48+
'cfg(kani)',
49+
'cfg(flux)'
4850
]
51+
52+
[package.metadata.flux]
53+
enabled = true
54+
include = [ "src/ascii/*" ]

library/core/src/ascii/ascii_char.rs

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

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

library/core/src/convert/num.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,21 @@ macro_rules! impl_from {
6969
),
7070
);
7171
};
72-
($Small:ty => $Large:ty, #[$attr:meta] $(,)?) => {
72+
($Small:ty => $Large:ty, #[$attr:meta] $(, #[$flux_attr:meta])? $(,)?) => {
7373
impl_from!(
7474
$Small => $Large,
7575
#[$attr],
7676
concat!("Converts [`", stringify!($Small), "`] to [`", stringify!($Large), "`] losslessly."),
77+
$(#[$flux_attr],)?
7778
);
7879
};
79-
($Small:ty => $Large:ty, #[$attr:meta], $doc:expr $(,)?) => {
80+
($Small:ty => $Large:ty, #[$attr:meta], $doc:expr $(, #[$flux_attr:meta])? $(,)?) => {
8081
#[$attr]
8182
impl From<$Small> for $Large {
8283
// Rustdocs on the impl block show a "[+] show undocumented items" toggle.
8384
// Rustdocs on functions do not.
8485
#[doc = $doc]
86+
$(#[$flux_attr])?
8587
#[inline(always)]
8688
fn from(small: $Small) -> Self {
8789
small as Self
@@ -109,7 +111,7 @@ impl_from!(u8 => u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")])
109111
impl_from!(u8 => u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
110112
impl_from!(u8 => u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
111113
impl_from!(u8 => u128, #[stable(feature = "i128", since = "1.26.0")]);
112-
impl_from!(u8 => usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
114+
impl_from!(u8 => usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")], #[cfg_attr(flux, flux::spec(fn(x:u8) -> usize[x]))]);
113115
impl_from!(u16 => u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
114116
impl_from!(u16 => u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")]);
115117
impl_from!(u16 => u128, #[stable(feature = "i128", since = "1.26.0")]);

library/core/src/flux_info.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[flux::defs {
2+
property ShiftRightByFour[>>](x, y) {
3+
16 * [>>](x, 4) == x
4+
}
5+
6+
property MaskBy15[&](x, y) {
7+
[&](x, y) <= y
8+
}
9+
}]
10+
const _: () = {};

library/core/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,6 @@ pub mod simd {
421421
}
422422

423423
include!("primitive_docs.rs");
424+
425+
#[cfg(flux)]
426+
mod flux_info;

0 commit comments

Comments
 (0)