Autoharness: support pattern types (RigidTy::Pat) - #4780
Draft
Tianshu-Huang wants to merge 1 commit into
Draft
Conversation
Teach autoharness to recognize and generate values for pattern types, since nightly-2026-04-01. Without this, any function taking a NonNull argument (or a struct containing one) is skipped with 'Missing Arbitrary'. Resolves model-checking#4758
Author
Tianshu-Huang
marked this pull request as draft
September 3, 2026 23:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since
nightly-2026-04-01,NonNull<T>wraps apattern_type!(*const T is !null)instead of a bare*const T. Sincenightly-2026-06-01(#4760),rustc_layout_scalar_valid_range_start/endattributes were replaced by pattern types more broadly. Autoharness does not recognizeRigidTy::Pat— any function whose signature involves a pattern type (directly or through a struct field) is skipped with "Missing Arbitrary implementation".Solution
can_derive_arbitrary(mod.rs) — recognizeRigidTy::Patin both the struct-field iteration loop and the top-level type match, delegating to a new helperpat_base_is_derivable. For raw-pointer bases (*const T), the pointeeTmust be derivable (because the raw-pointer codegen allocates storage for it); for any other base (integers, etc.) the base itself must be derivable.call_kani_any_for_ty(automatic.rs) — generate a nondeterministic value of the base type, transmute it to the pattern type, then constrain it to the pattern's validity range via the existingassume_scalar_niche.Tests
Updated
autoharness_niche:Month,Schedule,PosI8, andcheck_monthly::<Month>move from skipped to verified (10/10 functions pass), satisfying the acceptance criteria in #4758.New
autoharness_pattern_type: coversNonNull<u8>as a direct argument,NonNull<u32>inside a struct field, and a cover check verifying the generated value is non-null.Resolves #4758
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.