Add #[verifier::allow(...)] to suppress warnings#2284
Open
Chris-Hawblitzel wants to merge 5 commits into
Open
Conversation
parno
approved these changes
Mar 30, 2026
Collaborator
parno
left a comment
There was a problem hiding this comment.
Thanks, this looks like an elegant framework. It'll be nice to silence some of the warnings that have persistently cluttered some of my projects for a while now.
| ), | ||
| ))); | ||
| "unknown_automatic_derive", | ||
| || "Verus doesn't known how to handle this automatically derived item; ignoring it", |
| ctx.warning( | ||
| &exp.span, | ||
| "assert_compute_unsimplified", | ||
| || "Failed to simplify expression <<{}>> before sending to Z3", |
Collaborator
There was a problem hiding this comment.
I think we might need a format!(...) here, so that the "<<{}>>" gets resolved properly
tjhance
reviewed
Mar 30, 2026
| } | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub struct WarningConfig(pub Vec<String>); |
Collaborator
There was a problem hiding this comment.
should we use an enum instead of String for the warning names?
Collaborator
Author
There was a problem hiding this comment.
Ok, I switched it to an enum.
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.
This adds a
#[verifier::allow(...)]attribute to suppress warnings generated by Verus. For now, the attribute is only implemented for items like functions and modules, not for expressions, so you have to suppress warnings across entire functions or modules.Example:
This generates:
Rewriting the code as:
removes the warning.
The implementation works differently for rust_verify and vir. In rust_verify, for each warning, the implementation walks up the DefId tree on demand to look for matching
verifier::allowattributes. For vir, the implementation preemptively walks up the DefId tree from each function during translation to vir, keeping all theverifier::allowattributes in a table for later reference, and then uses the table to handle any warnings generated inside vir.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.