Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/ui/contracts/cross-crate-checks/auxiliary/id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//@ [unchk_pass] compile-flags: -Zcontract-checks=no
//@ [unchk_fail] compile-flags: -Zcontract-checks=yes
//@ [chk_pass] compile-flags: -Zcontract-checks=no
//@ [chk_fail] compile-flags: -Zcontract-checks=yes
Comment on lines +1 to +4
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't realize it was possible to make aux tests also handle revisions from the aux-test user. Considering the main test properly crashes or passes in all the cases configured here, it does seem to work flawlessly


#![crate_type = "lib"]
#![feature(contracts)]

extern crate core;
use core::contracts::requires;

/// Example function with a spec to be called across a crate boundary.
#[requires(x > 0)]
pub fn id_if_positive(x: u32) -> u32 {
x
}
26 changes: 26 additions & 0 deletions tests/ui/contracts/cross-crate-checks/cross-crate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//@ aux-build:id.rs
//@ revisions: unchk_pass unchk_fail chk_pass chk_fail
//
// The dependency crate `id` can be compiled with runtime contract checking
// enabled independently of whether this crate is compiled with contract checks
// or not.
//
// chk/unchk indicates whether this crate is compiled with contracts or not
// and pass/fail indicates whether the `id` crate is compiled with contract checks.
//
//@ [unchk_pass] run-pass
//@ [unchk_fail] run-crash
//@ [chk_pass] run-pass
//@ [chk_fail] run-crash
//
//
//@ [unchk_pass] compile-flags: -Zcontract-checks=no
//@ [unchk_fail] compile-flags: -Zcontract-checks=no
//@ [chk_pass] compile-flags: -Zcontract-checks=yes
//@ [chk_fail] compile-flags: -Zcontract-checks=yes

extern crate id;

fn main() {
id::id_if_positive(0);
}
Loading