Requests for commonly used rust/cargo #1129
Replies: 4 comments 1 reply
-
Verification on explicit type conversion is not supportedIn rust language, However, the verus compiler cannot correctly handle these two traits. A minimal example is provided below: use vstd::prelude::*;
use vstd::string::new_strlit;
verus! {
#[repr(u8)]
#[derive(Debug, PartialEq, Eq)]
pub enum FileType {
Dir = 1,
File = 2,
}
impl From<u32> for FileType {
#[verifier(external_body)]
fn from(val: u32) -> Self {
match val {
1 => FileType::Dir,
2 => FileType::File,
_ => panic!("Invalid file type"),
}
}
}
impl From<FileType> for u32 {
#[verifier(external_body)]
fn from(val: FileType) -> Self {
match val {
FileType::Dir => 1,
FileType::File => 2,
}
}
}
fn main() {
let val = FileType::Dir;
let t: u32 = val.into();
assert(t >= 1 && t <= 2);
}
} When one attempts to verify the file with verus, the following error is generated, indicating that verus does not correctly handle
|
Beta Was this translation helpful? Give feedback.
-
Vector literal is not supportedIt is common in rust code that a vector is define with macros. For instance, use vstd::prelude::*;
use vstd::std_specs::core;
verus! {
fn main() {
let v = vec![1, 2, 3];
}
} For this file, verus halts with the following error:
|
Beta Was this translation helpful? Give feedback.
-
Integration with cargoIt would be better if we can add some documentation on using verus with cargo, so cargo can add all build arguments about dependencies to the verus call. This seems to be doable with [custom toolchains](https://rust-lang.github.io/rustup/concepts/toolchains.html#custom-toolchains), but we need better documentation about this. If we look into [source code of rustup](https://github.com/rust-lang/rustup/blob/2a5a69e0914ff419554d684ca71eb1d72c72bcb3/src/cli/rustup_mode.rs#L1240), we can note that a valid rust toolchain only requires the |
Beta Was this translation helpful? Give feedback.
-
Basic vstd functions for (debug) printing in verified code
|
Beta Was this translation helpful? Give feedback.
-
This discussion collects a list of rust language features frequently used in coding, yet unsupported by verus.
Beta Was this translation helpful? Give feedback.
All reactions