Skip to content

align_to and align_to_mut contract and harnesses #405

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 8 commits into
base: main
Choose a base branch
from

Conversation

AlexLB99
Copy link

@AlexLB99 AlexLB99 commented Jul 2, 2025

Towards solving #19

This PR adds harnesses and contracts for align_to() and align_to_mut(). For the contract for align_to_mut(), we're using a wrapper and writing a contract for that instead, due to model-checking/kani#3764.

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

@AlexLB99 AlexLB99 requested a review from a team as a code owner July 2, 2025 16:01
@tautschnig
Copy link
Member

Thank you! We should have a fix for the Kani issue with model-checking/kani#4151 really soon, so I'd love to hold off on this one for about a week so that we can get the Kani fix merged and have this repository use the updated Kani version.

@tautschnig tautschnig self-assigned this Jul 3, 2025
@tautschnig
Copy link
Member

Thank you! We should have a fix for the Kani issue with model-checking/kani#4151 really soon, so I'd love to hold off on this one for about a week so that we can get the Kani fix merged and have this repository use the updated Kani version.

@AlexLB99 We now have the Kani fix merged and the version of Kani that this repository uses includes this fix. Could you please adjust your implementation so as not to use a workaround anymore?

@tautschnig tautschnig assigned AlexLB99 and unassigned tautschnig Jul 10, 2025
@AlexLB99
Copy link
Author

Thank you! We should have a fix for the Kani issue with model-checking/kani#4151 really soon, so I'd love to hold off on this one for about a week so that we can get the Kani fix merged and have this repository use the updated Kani version.

@AlexLB99 We now have the Kani fix merged and the version of Kani that this repository uses includes this fix. Could you please adjust your implementation so as not to use a workaround anymore?

Thanks for letting me know -- I've added a new commit that removes the workaround (so now align_to_mut itself has a contract)

Copy link
Member

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Please review what changes are actually intended.

@@ -1316,7 +1320,7 @@ impl<T> [T] {
assert_unsafe_precondition!(
check_language_ub,
"slice::as_chunks_unchecked requires `N != 0` and the slice to split exactly into `N`-element chunks",
(n: usize = N, len: usize = self.len()) => n != 0 && len.is_multiple_of(n),
(n: usize = N, len: usize = self.len()) => n != 0 && len % n == 0,
Copy link
Member

Choose a reason for hiding this comment

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

Is this an intentional change or the effect of a mis-merge?

Comment on lines 2767 to 2808
/// Returns a subslice with the optional prefix removed.
///
/// If the slice starts with `prefix`, returns the subslice after the prefix. If `prefix`
/// is empty or the slice does not start with `prefix`, simply returns the original slice.
/// If `prefix` is equal to the original slice, returns an empty slice.
///
/// # Examples
///
/// ```
/// #![feature(trim_prefix_suffix)]
Copy link
Member

Choose a reason for hiding this comment

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

Looks like a merge having gone wrong? I don't think this piece should be removed.

Comment on lines 5161 to 5196
#[rustc_const_unstable(feature = "const_default", issue = "67792")]
impl<T> const Default for &[T] {
Copy link
Member

Choose a reason for hiding this comment

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

Mis-merge?

@AlexLB99
Copy link
Author

Yes those were definitely the result of a mis-merge; it sohuld be fixed now

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.

3 participants