Avoid using 'macro' items on stable.

This gets rid of the warning message on stable when building examples.
This commit is contained in:
Sergio Benitez 2023-09-20 15:33:54 -07:00
parent 2cf38a5aa3
commit 28de15858e
2 changed files with 19 additions and 8 deletions

View File

@ -23,6 +23,7 @@ proc-macro2 = "1.0.27"
devise = "0.4" devise = "0.4"
rocket_http = { version = "=0.5.0-rc.3", path = "../http/" } rocket_http = { version = "=0.5.0-rc.3", path = "../http/" }
unicode-xid = "0.2" unicode-xid = "0.2"
version_check = "0.9"
glob = "0.3" glob = "0.3"
[dev-dependencies] [dev-dependencies]

View File

@ -31,6 +31,23 @@ pub fn _macro(input: proc_macro::TokenStream) -> devise::Result<TokenStream> {
}) })
.collect(); .collect();
// Only try using the `macro` syntax on nightly/dev or when we don't know.
let export = match version_check::is_feature_flaggable() {
Some(true) | None => quote! {
#(#attrs)*
#[cfg(all(nightly, doc))]
pub macro #macro_name {
#decl_macro_tokens
}
#[cfg(not(all(nightly, doc)))]
pub use #mod_name::#internal_name as #macro_name;
},
Some(false) => quote! {
pub use #mod_name::#internal_name as #macro_name;
}
};
Ok(quote! { Ok(quote! {
#[allow(non_snake_case)] #[allow(non_snake_case)]
mod #mod_name { mod #mod_name {
@ -43,13 +60,6 @@ pub fn _macro(input: proc_macro::TokenStream) -> devise::Result<TokenStream> {
pub use #internal_name; pub use #internal_name;
} }
#(#attrs)* #export
#[cfg(all(nightly, doc))]
pub macro #macro_name {
#decl_macro_tokens
}
#[cfg(not(all(nightly, doc)))]
pub use #mod_name::#internal_name as #macro_name;
}) })
} }