title: Lookup for all invocations of the particular `proc-macro` inside another crate
body: <p>I have a <a href="https://doc.rust-lang.org/cargo/reference/build-scripts.html" rel="nofollow noreferrer">build script</a> where I have access to <a href="https://docs.rs/cargo_metadata/0.11.3/cargo_metadata/struct.Package.html" rel="nofollow noreferrer">a lot of information</a> about another crate via <a href="https://crates.io/crates/cargo_metadata" rel="nofollow noreferrer">cargo_metadata</a>.</p>
  <p>Now I'm looking for the way to find all invocations of a specific <code>proc-macro</code> inside the another crate.</p>
  <p>Theoretically, I can parse another crate's sources by myself but I prefer to avoid it in any way possible for the well known reasons :-)</p>
  <p>Ideally, I'm looking for the crate which is used by the compiler already. Or at least the crate which somehow use compiler's output to collect that kind of information.</p>
  <p>But any solution will be helpful!</p>
  <p>There is how ideal solution may looks like from my code prospective:</p>
  <pre class="lang-rust prettyprint-override"><code>use proc_macro::TokenStream;
  
  use some_cool_crate::macros_lookup;
  use some_cool_crate::Macros;
  
  let path_to_another_crates_cargo_toml = &quot;/path/to/another_crate/Cargo.toml&quot;;
  let macros = Macros {
      name: &quot;my_macro&quot;,
      crate: &quot;macro_original_crate&quot;,
  };
  
  // The thing I'm looking for:
  macros_lookup(
      path_to_another_crates_cargo_toml, 
      &amp;macros, 
      |attr: TokenStream, input: TokenStream,| {
          // there I'll do some interesting stuff
      },
  );
  </code></pre>
  <p>P.S. Currently I obtain the information from custom section of <code>Cargo.toml</code>'s <code>[package.metadata]</code> but it requires me to keep <code>Cargo.toml</code> in sync with the sources.</p>
  <p>P.P.S. The reason I'm doing all that &quot;cool&quot; stuff is <a href="https://github.com/rust-lang/rfcs/issues/2771" rel="nofollow noreferrer">broken Re-exporting C symbols for cdylib</a></p>