Doctests with #[proc_macro] attribute in non-procmacro crate

I have a crate that is intended to be used in proc-macro crates but it's not a proc-macro on itself. So when I try to write an example in doc comments, say

extern crate proc_macro; 
extern crate my_lib;

fn hello(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
   // examples ...

cargo test fails with something like

error: the #[proc_macro_derive] attribute is only usable with crates of the proc-macro crate type
--> src/
7 | #[proc_macro_derive(Hello)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

So i had to mark all such examples as ignore.

Is there any way to make this work?

I usually write:

# const IGNORE: &str = stringify! {
# };
fn demo(input: TokenStream) -> TokenStream {

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.