Proc Macro Warning

Emit warnings from inside proc macros.

License: GPL v3

Rust does not have native functions to produce warnings from inside proc macros. This crate provides "deprecated" warnings for your proc macro use-cases.

Example

Building a warning is easy with the builder pattern.

```rust use procmacrowarning::Warning; let warning = Warning::newdeprecated("mymacro") .old("mymacro()") .new("mymacro::new()") .helplink("https:://example.com") .span(procmacro2::Span::call_site()) .build();

// Use the warning in a proc macro let tokens = quote::quote!(#warning); ```

Used In

Substrate (not yet, but hopefully soon 😉) uses this to emit warnings for its FRAME eDSL on deprecated behaviour.

For example not putting a call_index on your functions produces: ``pre warning: use of deprecated constantpallet::warnings::ImplicitCallIndex0::w: It is deprecated to use implicit call indices. Please instead ensure that all calls have thepallet::call_indexattribute or that thedev-mode` of the pallet is enabled.

             For more info see:
                 <https://github.com/paritytech/substrate/pull/12891>
                 <https://github.com/paritytech/substrate/pull/11381>
--> frame/nomination-pools/src/lib.rs:2621:10
 |

2621 | pub fn claimcommission(origin: OriginFor, poolid: PoolId) -> DispatchResult { | ^^^^^^^^^^^^^^^^ | ```

Or using a hard-coded weight: ``pre warning: use of deprecated constantpallet::warnings::ConstantWeight0::w: It is deprecated to use hard-coded constant as call weight. Please instead benchmark all calls or put the pallet intodev` mode.

             For more info see:
                 <https://github.com/paritytech/substrate/pull/13798>
--> frame/nomination-pools/src/lib.rs:2620:20
 |

2620 | #[pallet::weight(0)] |
```