<p dir="auto">I'm trying to use a constant at compile time to define the length of some vectors:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/* Gamma ramps */
const GLFW_GAMMA_RAMP_SIZE              : int = 256;

/* Gamma ramp */
struct GLFWgammaramp {
    red     : [c_ushort * GLFW_GAMMA_RAMP_SIZE],      // unsigned short red[GLFW_GAMMA_RAMP_SIZE];
    green   : [c_ushort * GLFW_GAMMA_RAMP_SIZE],      // unsigned short green[GLFW_GAMMA_RAMP_SIZE];
    blue    : [c_ushort * GLFW_GAMMA_RAMP_SIZE]       // unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
}"><pre class="notranslate"><code class="notranslate">/* Gamma ramps */
const GLFW_GAMMA_RAMP_SIZE              : int = 256;

/* Gamma ramp */
struct GLFWgammaramp {
    red     : [c_ushort * GLFW_GAMMA_RAMP_SIZE],      // unsigned short red[GLFW_GAMMA_RAMP_SIZE];
    green   : [c_ushort * GLFW_GAMMA_RAMP_SIZE],      // unsigned short green[GLFW_GAMMA_RAMP_SIZE];
    blue    : [c_ushort * GLFW_GAMMA_RAMP_SIZE]       // unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
}
</code></pre></div>
<p dir="auto">(code from <a href="https://github.com/bjz/glfw3-rs/blob/master/glfw3.rs#L389">glfw3-rs</a>)</p>
<p dir="auto">I get this error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" % rustc test.rs 
test.rs:6:26: 6:46 error: expected `]` but found `GLFW_GAMMA_RAMP_SIZE`
test.rs:6     red     : [c_ushort * GLFW_GAMMA_RAMP_SIZE],      // unsigned short red[GLFW_GAMMA_RAMP_SIZE];"><pre class="notranslate"><code class="notranslate"> % rustc test.rs 
test.rs:6:26: 6:46 error: expected `]` but found `GLFW_GAMMA_RAMP_SIZE`
test.rs:6     red     : [c_ushort * GLFW_GAMMA_RAMP_SIZE],      // unsigned short red[GLFW_GAMMA_RAMP_SIZE];
</code></pre></div>
<p dir="auto">Is this a bug or by design?</p>
<p dir="auto">The <code class="notranslate">format_args!</code> built-in macro currently generates structures located in <code class="notranslate">std::fmt</code>, which makes it difficult to use with libcore, even though libcore has the correct traits to read the generated structure.<br>
IMO it would be more logical to use core::fmt instead if possible.</p>
<p dir="auto">It gives the following errors:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="rust/main.rs:53:52: 53:55 error: failed to resolve. Maybe a missing `extern crate std`?
rust/main.rs:53     core::fmt::write(&amp;mut uart, format_args!(&quot;{}&quot;, 42u64));
                                                                   ^~~
note: in expansion of format_args!
rust/main.rs:53:33: 53:59 note: expansion site
rust/main.rs:53:52: 53:57 error: unresolved name `std::fmt::String::fmt`
rust/main.rs:53     core::fmt::write(&amp;mut uart, format_args!(&quot;{}&quot;, 42u64));
                                                                   ^~~~~
note: in expansion of format_args!
rust/main.rs:53:33: 53:59 note: expansion site
rust/main.rs:53:52: 53:55 error: failed to resolve. Maybe a missing `extern crate std`?
rust/main.rs:53     core::fmt::write(&amp;mut uart, format_args!(&quot;{}&quot;, 42u64));
                                                                   ^~~
note: in expansion of format_args!
rust/main.rs:53:33: 53:59 note: expansion site
rust/main.rs:53:52: 53:57 error: unresolved name `std::fmt::argument`
rust/main.rs:53     core::fmt::write(&amp;mut uart, format_args!(&quot;{}&quot;, 42u64));
                                                                   ^~~~~
note: in expansion of format_args!
rust/main.rs:53:33: 53:59 note: expansion site
rust/main.rs:53:46: 53:49 error: failed to resolve. Maybe a missing `extern crate std`?
rust/main.rs:53     core::fmt::write(&amp;mut uart, format_args!(&quot;{}&quot;, 42u64));
                                                             ^~~
note: in expansion of format_args!
rust/main.rs:53:33: 53:59 note: expansion site
rust/main.rs:53:46: 53:50 error: unresolved name `std::fmt::Arguments::new`
rust/main.rs:53     core::fmt::write(&amp;mut uart, format_args!(&quot;{}&quot;, 42u64));
                                                             ^~~~
note: in expansion of format_args!
rust/main.rs:53:33: 53:59 note: expansion site"><pre class="notranslate">rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">52</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">55</span> error<span class="pl-kos">:</span> failed to resolve<span class="pl-kos">.</span> <span class="pl-c1">Maybe</span> a missing `<span class="pl-k">extern</span> <span class="pl-k">crate</span> std`?
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span>     core<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> uart<span class="pl-kos">,</span> <span class="pl-en">format_args</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, <span class="pl-c1">42u64</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                                                                   ^~~
note<span class="pl-kos">:</span> <span class="pl-k">in</span> expansion of format_args!
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">33</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">59</span> note<span class="pl-kos">:</span> expansion site
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">52</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">57</span> error<span class="pl-kos">:</span> unresolved name `std<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-smi">String</span><span class="pl-kos">::</span><span class="pl-smi">fmt</span>`
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span>     core<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> uart<span class="pl-kos">,</span> <span class="pl-en">format_args</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, <span class="pl-c1">42u64</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                                                                   ^~~~~
note<span class="pl-kos">:</span> <span class="pl-k">in</span> expansion of format_args!
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">33</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">59</span> note<span class="pl-kos">:</span> expansion site
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">52</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">55</span> error<span class="pl-kos">:</span> failed to resolve<span class="pl-kos">.</span> <span class="pl-c1">Maybe</span> a missing `<span class="pl-k">extern</span> <span class="pl-k">crate</span> std`?
rust/main<span class="pl-kos">.</span>rs<span class="pl-kos">:</span><span class="pl-c1">53</span>     core<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> uart<span class="pl-kos">,</span> <span class="pl-en">format_args</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, <span class="pl-c1">42u64</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                                                                   ^~~
note<span class="pl-kos">:</span> <span class="pl-k">in</span> expansion of format_args!
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">33</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">59</span> note<span class="pl-kos">:</span> expansion site
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">52</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">57</span> error<span class="pl-kos">:</span> unresolved name `std<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-smi">argument</span>`
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span>     core<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> uart<span class="pl-kos">,</span> <span class="pl-en">format_args</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, <span class="pl-c1">42u64</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                                                                   ^~~~~
note<span class="pl-kos">:</span> <span class="pl-k">in</span> expansion of format_args!
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">33</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">59</span> note<span class="pl-kos">:</span> expansion site
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">46</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">49</span> error<span class="pl-kos">:</span> failed to resolve<span class="pl-kos">.</span> <span class="pl-c1">Maybe</span> a missing `<span class="pl-k">extern</span> <span class="pl-k">crate</span> std`?
rust/main<span class="pl-kos">.</span>rs<span class="pl-kos">:</span><span class="pl-c1">53</span>     core<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> uart<span class="pl-kos">,</span> <span class="pl-en">format_args</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, <span class="pl-c1">42u64</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                                                             ^~~
note<span class="pl-kos">:</span> <span class="pl-k">in</span> expansion of format_args!
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">33</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">59</span> note<span class="pl-kos">:</span> expansion site
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">46</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">50</span> error<span class="pl-kos">:</span> unresolved name `std<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-smi">Arguments</span><span class="pl-kos">::</span><span class="pl-smi">new</span>`
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span>     core<span class="pl-kos">::</span>fmt<span class="pl-kos">::</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> uart<span class="pl-kos">,</span> <span class="pl-en">format_args</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, <span class="pl-c1">42u64</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                                                             ^~~~
note<span class="pl-kos">:</span> <span class="pl-k">in</span> expansion of format_args!
rust/main<span class="pl-kos">.</span><span class="pl-c1">rs</span><span class="pl-kos">:</span><span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">33</span><span class="pl-kos">:</span> <span class="pl-c1">53</span><span class="pl-kos">:</span><span class="pl-c1">59</span> note<span class="pl-kos">:</span> expansion site</pre></div>
<p dir="auto">I currently have a workaround for this by putting a <code class="notranslate">extern crate "core" as std;</code> but it is really ugly ...</p>