Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Rust Formal VerificationNew to Visual Studio Code? Get it now.
Rust Formal Verification

Rust Formal Verification

Hapyy

|
2 installs
| (0) | Free
Real-time formal verification feedback for Rust
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Rust Formal Verification

Mathematically prove properties about your Rust code. This extension integrates with cargo verify to provide real-time formal verification feedback directly in VS Code.

Features

  • Inline Diagnostics — Verification failures appear as squiggly underlines with counterexamples
  • SMT TreeView — Browse generated SMT-LIB2 scripts organized by module / function / verification condition
  • Counterexample Display — See concrete inputs that violate your specifications
  • Auto-Refresh — Results update automatically when you save or run cargo verify
  • rust-analyzer Integration — Works alongside rust-analyzer via check.overrideCommand

Requirements

  • cargo-verify installed (cargo install --path crates/driver --bin cargo-verify)
  • Z3 SMT solver (installed automatically with platform-specific builds, or install manually)
  • Rust nightly toolchain (specified in rust-toolchain.toml)

Quick Start

  1. Install the extension
  2. Open a Rust project with verification annotations:
    #[doc = "rust_fv::requires::a <= u32::MAX - b"]
    #[doc = "rust_fv::ensures::result == a + b"]
    pub fn add(a: u32, b: u32) -> u32 {
        a + b
    }
    
  3. Run Rust FV: Run Verification from the command palette (or save the file)
  4. See results in the Rust FV sidebar and inline diagnostics

Supported Annotations

Annotation Purpose
requires Precondition — must hold when function is called
ensures Postcondition — must hold when function returns
invariant Loop or struct invariant
decreases Termination measure for recursive functions
pure Pure function usable in specifications
ghost Ghost code for verification only
trusted Skip verification for this function

How It Works

rust-fv hooks into the Rust compiler (rustc) via rustc_driver::Callbacks, extracts MIR (Mid-level Intermediate Representation), translates it to SMT-LIB2, and verifies properties using the Z3 theorem prover. If Z3 finds a counterexample, you get a concrete input showing exactly how your specification can be violated.

Extension Settings

Setting Description Default
rust-fv.raMode Integration mode: standalone or rust-analyzer standalone
rust-fv.autoRun Automatically run verification on file save true

Commands

Command Description
Rust FV: Run Verification Run cargo verify on the current workspace
Rust FV: Show Verification Report Open the verification output panel
Rust FV: View SMT Script Browse generated SMT-LIB2 scripts

Links

  • GitHub Repository
  • Report Issues

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft