title: What is the built-in `#[main]` attribute?
body: <p>I have been using the <code>#[tokio::main]</code> macro in one of my programs. After importing <code>main</code> and using it unqualified, I encountered an unexpected error.</p>
  <pre class="lang-rust prettyprint-override"><code>use tokio::main;
  
  #[main]
  async fn main() {}
  </code></pre>
  <pre><code>error[E0659]: `main` is ambiguous
   --&gt; src/main.rs:3:3
    |
  3 | #[main]
    |   ^^^^ ambiguous name
    |
    = note: ambiguous because of a name conflict with a builtin attribute
    = note: `main` could refer to a built-in attribute
  </code></pre>
  <p>I've been scouring the documentation but I haven't been able to find this built-in <code>#[main]</code> attribute described anywhere. <a href="https://doc.rust-lang.org/reference/attributes.html#built-in-attributes-index" rel="noreferrer">The Rust Reference contains an index of built-in attributes</a>. The index doesn't include <code>#[main]</code>, though it does include <a href="https://doc.rust-lang.org/reference/crates-and-source-files.html#the-no_main-attribute" rel="noreferrer">an attribute named <code>#[no_main]</code></a>.</p>
  <p>I did a search of the <code>rustlang/rust</code> repository, and found <a href="https://github.com/rust-lang/rust/blob/f52c31840df7ec9c9350baff51a8964b20b5e1ba/compiler/rustc_passes/src/entry.rs#L78" rel="noreferrer">some code that seems related</a>, but it seems to use a pair of macros named <code>#[start]</code> and <code>#[rustc_main]</code>, with no mention of <code>#[main]</code> itself. (Neither of those macros appears to be usable on stable, with <code>#[start]</code> emitting an error that it's unstable, and <code>#[rustc_main]</code> emitting an error that it's only meant for internal use by the compiler.)</p>
  <p>My guess from the name would have been that it's meant to mark a different function as an entry-point instead of <code>main</code>, but it also doesn't seem to do that:</p>
  <pre class="lang-rust prettyprint-override"><code>#[main]
  fn something_else() {
      println!(&quot;this does not run&quot;);
  }
  
  fn main() {
      println!(&quot;this runs&quot;);
  }
  </code></pre>
  <p>Rust Analyzer didn't have much to offer:</p>
  <blockquote>
  <img src="https://i.stack.imgur.com/HWMs6.png" height="92" alt="a screenshot showing Rust Analyzer's contextual help for the #[main] attribute, devoid of any details">
  </blockquote>
  <hr />
  <p>What does the built-in <code>#[main]</code> attribute do, aside from conflicting with my imports? </p>