Debian Codegraph @

third_party/rust/rustversion/tests/test_const.rs

raw
1 #![allow(
2 clippy::semicolon_if_nothing_returned, // https://github.com/rust-lang/rust-clippy/issues/7324
3 clippy::used_underscore_items,
4 )]
5
6 #[rustversion::attr(all(), const)]
7 fn _basic() {}
8 const _BASIC: () = _basic();
9
10 #[rustversion::attr(all(), const)]
11 unsafe fn _unsafe() {}
12 const _UNSAFE: () = unsafe { _unsafe() };
13
14 macro_rules! item {
15 ($i:item) => {
16 #[rustversion::attr(all(), const)]
17 $i
18 };
19 }
20
21 item! {fn _item() {}}
22 const _ITEM: () = _item();
23
24 macro_rules! ident {
25 ($fn:ident) => {
26 #[rustversion::attr(all(), const)]
27 $fn _ident() {}
28 };
29 }
30
31 ident! {fn}
32 const _IDENT: () = _ident();
33
34 #[rustversion::attr(all(), const)]
35 /// doc
36 fn _doc_below() {}
37 const _DOC_BELOW: () = _doc_below();
38
39 /// doc
40 #[rustversion::attr(all(), const)]
41 fn _doc_above() {}
42 const _DOC_ABOVE: () = _doc_above();