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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// devela::code::util::debug
//
//! Defines [`const_warn!`], [`fn_name`].
//
/// Emits a compile-time warning with a provided message.
///
/// # Example
/// ```
/// # use devela::const_warn;
/// fn main() {
/// const_warn!("hello warning!");
/// const_warn!(if size_of::<u8>() == 1, "byte alert!!");
/// }
/// ```
/// That may look as follows:
/// ```text
/// warning: use of deprecated associated constant `main::_::__::<true>::WARNING`: hello warning!
/// --> src/main.rs:3:5
/// |
/// 3 | const_warn!("hello warning!");
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// |
/// = note: `#[warn(deprecated)]` on by default
/// = note: this warning originates in the macro `$crate::const_warn` which comes from the expansion of the macro `const_warn` (in Nightly builds, run with -Z macro-backtrace for more info)
///
/// warning: use of deprecated associated constant `main::_::__::<true>::WARNING`: byte alert!!
/// --> src/main.rs:4:5
/// |
/// 4 | const_warn!(if size_of::<u8>() == 1, "byte alert!!");
/// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// ...
/// ```
// IMPROVE: use a proc-macro leveraging nightly feature proc_macro_diagnostics
;
}
pub use const_warn;
/// Returns a best-effort name of the enclosing function.
///
/// This is a diagnostic helper based on [`core::any::type_name_of_val`].
/// The exact format is not guaranteed by Rust, so this macro must not be
/// used for semantic program behavior.
///
/// ## Examples
/// ```
/// mod bar {
/// pub fn sample_function() {
/// # use devela::fn_name;
/// assert!(fn_name!().ends_with("bar::sample_function"));
/// }
/// }
/// bar::sample_function();
/// ```
pub use fn_name;