Skip to content

Formal parameter attributes won't be passed into proc-macro #63210

Closed
@Hexilee

Description

@Hexilee

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)

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.F-param_attrs`#![feature(param_attrs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions