Skip to content

Commit

Permalink
Add double-attr-invariant test
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Jul 9, 2024
1 parent 52273cb commit ea33b42
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! Check that there is a compilation error when the predicate passed to
//! `kani::invariant` attribute would result in a compiler error.

extern crate kani;
use kani::Invariant;

// Note: The struct fields `x` and `y` are references in this context, we should
// refer to `*x` and `*y` instead.
#[kani::invariant(*x >= 0)]
#[kani::invariant(*y >= 0)]
struct Point {
x: i32,
y: i32,
}
6 changes: 6 additions & 0 deletions tests/ui/attr-invariant/double-attr-invariant/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
error[E0119]: conflicting implementations of trait `kani::Invariant` for type `Point`
|
12 | #[kani::invariant(*x >= 0)]
| --------------------------- first implementation here
13 | #[kani::invariant(*y >= 0)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Point`

0 comments on commit ea33b42

Please sign in to comment.