Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

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!

david-boles pushed a commit to david-boles/paste that referenced this pull request Oct 4, 2024
david-boles pushed a commit to david-boles/paste that referenced this pull request Oct 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support paste in cfg feature context
3 participants