1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! COMPAT CORPUS for the macros facade.
//!
//! Re-exporting a proc macro and being able to INVOKE it through the re-export
//! are different claims: the attribute path has to resolve at expansion time,
//! and a `proc-macro = true` crate cannot forward someone else's macros at all.
//! This file invokes all five of `provable-contracts-macros 0.3.1`'s attribute
//! macros through the facade path and asserts the behaviour each one is
//! documented to inject. It is primarily a COMPILE-time assertion.
//!
//! The five, verbatim from 0.3.1's `#[proc_macro_attribute]` list:
//! `contract`, `requires`, `ensures`, `invariant`, `must_contract`.
//!
//! Non-vacuity control: `scripts/check_facade_compat.sh --mutate` breaks the
//! facade's re-export and requires this target to go RED. A corpus that has
//! only ever been green proves nothing.
use ;
/// `#[contract]` — the flagship. Binds a function to a YAML contract equation
/// and injects `debug_assert!`s from build-script env vars. With no env vars
/// set it degrades to `option_env!`, so it compiles standalone here.
/// `#[requires]` — precondition, `debug_assert!`ed at entry.
/// `#[ensures]` — postcondition. 0.3.1 binds the return value to `ret`; that
/// binding name is part of the compatibility surface, so it is asserted here.
/// `#[invariant]` — checked before AND after. Applies to a fn, not a type.
/// `#[must_contract]` — marks an unbound `pub fn`, emitting `#[deprecated]`
/// when no `CONTRACT_*` env var names it. The deprecation IS the macro working.
/// `#[requires]` must EXCLUDE an outcome, not merely compile. A debug build
/// panics when the precondition is false; if the facade forwarded a no-op
/// macro this test would fail rather than pass silently.