Skip to content

LLBC backend: uses of const items produce LLBC that Charon and Aeneas reject #5046

Open

Description

@feliperodri

Any use of a const item makes the LLBC backend's output unusable:

pub const N: u32 = 5;
pub fn f() -> u32 { N + 1 }

#[kani::proof]
fn main() { let _ = f(); }

kani test.rs -Zlean writes the file, but charon pretty-print on it panics (called Option::unwrap() on a None value in TranslatedCrate::item_name), and Aeneas fails with an uncaught Not_found exception. This happens on main and on #5045.

translate_constant_value translates ConstantKind::Unevaluated as a reference to a global (register_global_decl_id), but the backend never translates the global itself, so the crate refers to an item it doesn't declare. At rustc's default MIR optimization level, many such constants are folded into plain values before the backend sees them; at -Zmir-opt-level=0, which #5045 uses for LLBC runs, they stay unevaluated, so this comes up for more code (for example a zero-sized const item, which is how I hit it while reviewing #5045).

Two ways to fix it: translate the referenced globals as GlobalDecls (with their initializer bodies, as Charon does), or evaluate constants that have no generic parameters and emit their value. The first matches Charon's output; the second is simpler but loses the link to the item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Z-UnstableFeatureIssues that only occur if a unstable feature is enabled[C] BugThis is a bug. Something isn't working.[E] Unsupported ConstructAdd support to an unsupported construct

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions