title: How to provide attributes for fields for struct annotated with an attribute itself?
body: <p>I wanted to implement a <code>proc_macro_attribute</code> such that:</p>
  
  <pre><code>#[component]
  struct Div {
      #[prop]
      color: String,
      clicked: bool
  }
  </code></pre>
  
  <p>Where the impl of both the attributes are:</p>
  
  <pre><code>#[proc_macro_attribute]
  pub fn component(_attribute: TokenStream, input: TokenStream) -&gt; TokenStream {
      modify_struct_and_generate_props_struct(input)
  }
  
  // Just as a placeholder attribute for the component attribute to work on.
  #[proc_macro_attribute]
  pub fn prop(_attribute: TokenStream, input: TokenStream) -&gt; TokenStream {
      input
  }
  </code></pre>
  
  <p>I could do it with a custom derive, but that is not what I want to achieve here because any struct annotated with <code>#[component]</code> would be modified to include additional fields. The <code>#[prop]</code> sub attribute is used to create a newer struct made up of only prop fields.</p>
  
  <p>The <code>proc_macro_attribute</code> does not support other sub-attributes used within its context and I tried to implement a separate attribute to mitigate that. This causes the compiler to error out with:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0658]: The attribute `prop` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
    --&gt; src/main.rs:33:1
     |
  33 | #[component]
     | ^^^^^^^^^^^^
     |
     = help: add #![feature(custom_attribute)] to the crate attributes to enable
  </code></pre>
  
  <p>Adding this feature conflicts with <code>#![feature(proc_macro)]</code>.</p>
  
  <p>I have defined the problem on <a href="https://github.com/csharad/proc_macro_attribute" rel="nofollow noreferrer">GitHub</a>. You could look it up to see what I am trying to accomplish.</p>
  
  <p>Is there no other possible way out?</p>
  
  <p>I have also filed an <a href="https://github.com/rust-lang/rust/issues/49411" rel="nofollow noreferrer">issue</a> with Rust if this was not the way it was meant to be.</p>