Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support paste in arbitrary name-value attributes #57

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

scalexm
Copy link
Contributor

@scalexm scalexm commented Nov 1, 2020

Fixes #56.

@scalexm
Copy link
Contributor Author

scalexm commented Nov 10, 2020

Ping @dtolnay, I would like to know whether you like the idea, or if you think this is inappropriate for paste.

@dtolnay
Copy link
Owner

dtolnay commented Nov 10, 2020

I am on board with this. The PR is marked experimental. Are you planning changes or is this ready for review?

@scalexm
Copy link
Contributor Author

scalexm commented Nov 10, 2020

I’ve tested it on my side and it covers my use case, so ready for review. Cc @frol.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this turns all values in key/value attributes into strings, which is likely to break some macros.

#[proc_macro_attribute]
pub fn debug(_args: TokenStream, input: TokenStream) -> TokenStream {
    println!("{}", input);
    TokenStream::new()
}
paste! {
    #[debug]
    #[xyz = 123]
    struct S;
}
#[xyz = "123"] struct S ;

@scalexm
Copy link
Contributor Author

scalexm commented Nov 10, 2020

I restored the previous behavior which was to have at least two tokens after the = sign.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 4d04c18 into dtolnay:master Nov 10, 2020
@frol
Copy link

frol commented Nov 10, 2020

@scalexm @dtolnay Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support paste in cfg feature context
3 participants