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

Allow multiple annotations, but check for duplicate targets. #3808

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

remi-delmas-3000
Copy link
Contributor

Resolves #3804.

Enables multiple stub_verified(TARGET) annotations on a harness, but still detect and report duplicate targets.

Adds positive and negative tests.

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

@remi-delmas-3000 remi-delmas-3000 requested a review from a team as a code owner January 2, 2025 18:41
@github-actions github-actions bot added the Z-BenchCI Tag a PR to run benchmark CI label Jan 2, 2025
@remi-delmas-3000 remi-delmas-3000 removed the Z-BenchCI Tag a PR to run benchmark CI label Jan 2, 2025
@zhassan-aws
Copy link
Contributor

Is this a duplicate of #3805?

@ShoyuVanilla
Copy link
Contributor

Is this a duplicate of #3805?

I think that this one supersedes mine(#3805)😅

Comment on lines 573 to 583
if seen.contains(&name) {
dcx.struct_span_err(
span,
format!("Multiple occurrences of `stub_verified({})`.", name),
)
.with_span_note(
self.tcx.def_span(def_id),
format!("Use a single `stub_verified({})` annotation.", name),
)
.emit();
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be a warning instead? They will be redundant, but they can be safely ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to a warning, and moved the checks earlier in the process.

@@ -371,7 +371,7 @@ impl<'tcx> KaniAttributes<'tcx> {
attrs.iter().for_each(|attr| self.check_proof_attribute(kind, attr))
}
KaniAttributeKind::StubVerified => {
expect_single(self.tcx, kind, &attrs);
// Actual validation happens when the annotation are handled
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, this should be similar to parse_stubs so we can emit as many errors as possible, and sooner rather than later. Can you please add a test to see if that is the case today. Something like:

#[kani::proof]
#[kani::stub_verified(dummy)]
fn stub_does_not_exist() { }

#[kani::proof]
#[kani::stub_verified(dummy, dummy2)]
fn stub_invalid_args() { }

That said, for this PR, I think a TODO comment should suffice, since you are not introducing this limitation. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have tests for these cases in missing_contracts_for_check.rs and missing_contracts_for_replace.rs

@github-actions github-actions bot added the Z-BenchCI Tag a PR to run benchmark CI label Jan 6, 2025
Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-BenchCI Tag a PR to run benchmark CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use multiple #[stub_verified(..)] attributes to a single harness
4 participants