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

Multiple Attributes in an Attribute Container #2600

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@Havvy
Contributor

Havvy commented Nov 24, 2018

Allow #[attr1, attr2] thingy.

Rendered

## Attribute Macro Input `TokenStream` Changes
Before this RFC, when an attriute macro is executed, it is passed two

This comment has been minimized.

@petrochenkov

petrochenkov Nov 24, 2018

Contributor

Typo: "attriute"

`#[attr1, macro_attr] thing` | `"#[attr1, ] thing"`
`#[macro_attr, attr1] thing` | `"#[attr1] thing"`
`#[attr1, macro_attr, attr2] thing` | `"#[attr1, attr2] thing"`
`#[] #[macro_attr] thing` | `"#[] thing"` or `"thing"` (see unresolved questions)

This comment has been minimized.

@petrochenkov

petrochenkov Nov 24, 2018

Contributor

I'm wary of guaranteeing contents of input streams with such precision (at least right now).

For example, we don't specify what cfg_attr(predicate, a, b) unwraps into - #[a, b] or #[a] #[b], but now it makes observable difference (it would be reasonable to expect the former, but it's actually the latter).
Also, it may be convenient to split all multi-attribute containers into single-attribute containers in the initial implementation.

Macro authors should not rely on differences between #[a] #[b] and #[a, b] in general, and should support both, so we don't get much from specifying precise tokens.

--- | ---
`#[macro_attr] thing` | `"thing"`
`#[attr1] #[macro_attr] thing` | `"#[attr1] thing"`
`#[attr1, macro_attr] thing` | `"#[attr1, ] thing"`

This comment has been minimized.

@Centril

Centril Nov 25, 2018

Contributor

What is the rationale for including the , here? Why not normalize the input before by having "#[attr1] thing" instead?

The changes are as follows:
* _Attribute_ becomes _AttributeContainer_ (Or removed? Is it actually used?)

This comment has been minimized.

@Centril

Centril Nov 25, 2018

Contributor

Elaborate on the question here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment