title: Is there a way to match the expression's syntactical type in a Rust macro?
body: <p>As opposed to <a href="https://stackoverflow.com/questions/34214136/how-do-i-match-the-type-of-an-expression-in-a-rust-macro">this question</a>, I'd like to match on the syntactic level. E.g. I'd like to do something such as:</p>
  <pre class="lang-rust prettyprint-override"><code>macro_rules! do_x {
      ($x:ident) =&gt; {
          $x.do().some().things();
      };
      ($x:ty) =&gt; {
          &lt;$x&gt;::singleton().do().some().things();
      };
  }
  </code></pre>
  <p>Clearly Rust already knows if the token is a type or not, because it errors out when I try to pass a non-type into a macro that's expecting a type. Is there a way to leverage this in the macro matching rules, instead of defining another macro that does the same exact thing as the first one?</p>