Debian Codegraph @

debian/rust-vendor/codspeed-divan-compat-walltime/src/compile_fail.rs

raw
1 //! Private compile failure tests.
2 //!
3 //! # Repeated Options
4 //!
5 //! Options repeated in `#[divan::bench]` should cause a compile error, even if
6 //! they use raw identifiers. The initial implementation allowed raw identifiers
7 //! to slip through because `syn::Ident` does not consider them to be equal to
8 //! the normal form without the `r#` prefix.
9 //!
10 //! We don't include `r#crate` here because it's not a valid identifier.
11 //!
12 //! ```compile_fail
13 //! #[divan::bench(name = "x", r#name = "x")]
14 //! fn bench() {}
15 //! ```
16 //!
17 //! ```compile_fail
18 //! #[divan::bench(sample_count = 1, r#sample_count = 1)]
19 //! fn bench() {}
20 //! ```
21 //!
22 //! ```compile_fail
23 //! #[divan::bench(sample_size = 1, r#sample_size = 1)]
24 //! fn bench() {}
25 //! ```
26 //!
27 //! # Type Checking
28 //!
29 //! The following won't produce any benchmarks because `types = []`. However, we
30 //! still want to ensure that values in `consts = [...]` match the generic
31 //! const's type of `i32`.
32 //!
33 //! ```compile_fail
34 //! #[divan::bench(types = [], consts = ['a', 'b', 'c'])]
35 //! fn bench<T, const C: i32>() {}
36 //! ```