macro_tt_utils
Procedural Macro Utilities (tt_ident
, throw_diagnostics
, deref_span
).
// Experimental API
tt_ident
Manipulation of input names in macros, currently only name comparison is possible.
use tt_ident;
use throw_compile_warning;
use throw_compile_error;
}
}
/*
warning: We are testing warning.
--> src/main.rs:21:2
|
21 | macros_generate! {
| _____^
22 | | fn name_checker(a) -> |a| {
23 | | ff
24 | | }
25 | | }
| |_____^
error: Perhaps undefined behavior
--> src/main.rs:21:2
|
21 | macros_generate! {
| _____^
22 | | fn name_checker(a) -> |a| {
23 | | ff
24 | | }
25 | | }
| |_____^
*/
throw_diagnostics
Macros to throw compiler errors or warnings (throw_compile_error
, throw_compile_warning
, throw_compile_note
, throw_compile_help
).
use throw_compile_warning;
=>
}
/*
warning: #1 We are testing warning.
--> src/main.rs:8:3
|
8 | throw_compile_warning!("#1 We are testing warning.");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
14 | macros_generate! {
| _____-
15 | | fn name_checker(a) -> |a| {}
16 | | }
| |_____- in this macro invocation
warning: #2 We are testing warning.
--> src/main.rs:14:2
|
14 | macros_generate! {
| _____^
15 | | fn name_checker(a) -> |a| {}
16 | | }
| |_____^
*/
deref_span
Unpacks the current span.
use deref_span;
=>
}
/*
error: #1 Test
--> src/main.rs:8:3
|
8 | compile_error!("#1 Test");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
...
17 | macros_generate! {
| _____-
18 | | fn name_checker(a) -> |a| {}
19 | | }
| |_____- in this macro invocation
error: #2 Test
--> src/main.rs:17:2
|
17 | macros_generate! {
| _____^
18 | | fn name_checker(a) -> |a| {}
19 | | }
| |_____^
error: aborting due to 2 previous errors
*/
License
Copyright 2019 #UlinProject (Denis Kotlyarov) Денис Котляров
Licensed under the MIT License
Licensed under the Apache License, Version 2.0