Skip to content

Rename RMC prelude functions to more user-friendly names and to avoid warnings #589

Closed

Description

@zhassan-aws

Compiling pretty much any project with RMC results in warnings related to snake case name and unused variables, e.g.:

warning: unused variable: `cond`
 --> src/lib.rs:1:22
  |
1 | fn __VERIFIER_assume(cond: bool) {
  |                      ^^^^ help: if this is intentional, prefix it with an underscore: `_cond`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `cond`
 --> src/lib.rs:5:27
  |
5 | fn __VERIFIER_expect_fail(cond: bool, message: &str) {
  |                           ^^^^ help: if this is intentional, prefix it with an underscore: `_cond`

warning: unused variable: `message`
 --> src/lib.rs:5:39
  |
5 | fn __VERIFIER_expect_fail(cond: bool, message: &str) {
  |                                       ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_message`

warning: function `__VERIFIER_assume` should have a snake case name
 --> src/lib.rs:1:4
  |
1 | fn __VERIFIER_assume(cond: bool) {
  |    ^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `__verifier_assume`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: function `__VERIFIER_expect_fail` should have a snake case name
 --> src/lib.rs:5:4
  |
5 | fn __VERIFIER_expect_fail(cond: bool, message: &str) {
  |    ^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `__verifier_expect_fail`

In addition, the double underscore prefix (e.g. in __nondet()) seems unnecessary. We need to rename the functions and update them to avoid those warnings.

Here are example steps to reproduce the above warnings:

  1. cargo new --lib foo
  2. cd foo
  3. Put the following in src/lib.rs:
fn __VERIFIER_assume(cond: bool) {
    unimplemented!()
}

fn __VERIFIER_expect_fail(cond: bool, message: &str) {
    unimplemented!()
}

fn __nondet<T>() -> T {
    unimplemented!()
}

pub fn main() {
    let x: u32 = __nondet();
    __VERIFIER_assume(x < 10);
    let y: u32 = x * 2;
    assert!(y < 19);
}
  1. Compile using:
RUSTFLAGS="-Z trim-diagnostic-paths=no -Z codegen-backend=gotoc" RUSTC=rmc-rustc cargo build --target x86_64-unknown-linux-gnu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions