Skip to content

Ensuring that MIR constants are marked as static consts #4233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vonaka
Copy link
Contributor

@vonaka vonaka commented Jul 23, 2025

This is an attempt to resolve #3905

Currently, we rely on the mutability of the Allocation when marking constants. However, my understanding is that for various internal reasons the compiler may use mutable allocations even for constants. Instead, we should probably track whether a variable is constant ourselves.

Currently, some tests are failing. Specifically, tests/expected/function-contract/valid_ptr.rs fails because, while checking pre_condition::harness_invalid_ptr, the output doesn't include

Failed Checks: assertion failed: unsafe { read_ptr(ptr) } == -20

Instead, the assertion is UNREACHABLE, which honestly makes perfect sense to me (since the precondition doesn't hold for any input, we'll never get a chance to actually verify this assertion).

tests/kani-fixme/FunctionContracts/modify_slice_elem_fixme.rs also fails, which hopefully indicates that this also resolves #4029 (though the relation between the issue and the PR is not obvious to me).

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@vonaka vonaka requested a review from a team as a code owner July 23, 2025 23:41
@github-actions github-actions bot added Z-EndToEndBenchCI Tag a PR to run benchmark CI Z-CompilerBenchCI Tag a PR to run benchmark CI labels Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-CompilerBenchCI Tag a PR to run benchmark CI Z-EndToEndBenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spurious failure in tests/kani/FunctionContracts/modify_slice_elem.rs Function contract doesn't propagate const function bodies correctly
1 participant