Skip to content
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

Add safety preconditions to alloc/src/collections/binary_heap/mod.rs #120

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tautschnig
Copy link
Member

This diff adds #[requires(...)] attributes to the unsafe functions, translating the "SAFETY:" comments into code contracts. These contracts specify the preconditions that must be met for the function to be safely called.

This diff adds `#[requires(...)]` attributes to the unsafe functions, translating the "SAFETY:" comments into code contracts. These contracts specify the preconditions that must be met for the function to be safely called.
@tautschnig tautschnig force-pushed the bedrock-library/alloc/src/collections/binary_heap/mod.rs branch from 29b2c87 to 8e6b212 Compare October 17, 2024 14:05

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these function require self to be safe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you asking whether there are requirements that the object is in some sort of sane state? I would believe so, but why would we ever permit for that not to be the case?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we shouldn't, but we do.

Conceptually, internal functions can temporary break the safety invariants of the types.

mod verify {
use super::*;

// TODO: Kani reports as failing property "Only a single top-level call", which does not

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly is the error?

@tautschnig tautschnig self-assigned this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants