Closed
Description
As this example repo
This is the example proc-macro:
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn rename_params(_args: TokenStream, input: TokenStream) -> TokenStream {
println!("{}", &input);
input
}
This is the test:
#![feature(param_attrs)]
use params_attribute_example::rename_params;
#[rename_params]
fn hello(a: i32, #[val] b: i32) {}
Run cargo expand --test rename-params
,both of println
result and expand
result are:
fn hello(a: i32, b: i32) {}
Formal parameter attributes disappear in proc-macro.
Toolchain: nightly-x86_64-apple-darwin(8a58268b5 2019-07-31)