<p dir="auto">When trying to compile this code:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="pub fn write_to_log(line: String) {
    use std::fs::{File, OpenOptions};
    let resFile = OpenOptions::new().read(true).write(true)
            .append(true).open(&quot;log.log&quot;);
    let mut file = match resFile {
        Ok(f) =&gt; f,
        Err(e) =&gt; panic!(&quot;file error: {}&quot;, e),
    };
    let _ = writeln!(&amp;mut file, &quot;{}&quot;, line);
}

fn main() {
    write_to_log(&quot;Hello&quot;.to_string());
}"><pre class="notranslate"><span class="pl-k">pub</span> <span class="pl-k">fn</span> <span class="pl-en">write_to_log</span><span class="pl-kos">(</span><span class="pl-s1">line</span><span class="pl-kos">:</span> <span class="pl-smi">String</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">use</span> std<span class="pl-kos">::</span>fs<span class="pl-kos">::</span><span class="pl-kos">{</span><span class="pl-v">File</span><span class="pl-kos">,</span> <span class="pl-v">OpenOptions</span><span class="pl-kos">}</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> resFile = <span class="pl-smi">OpenOptions</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">read</span><span class="pl-kos">(</span><span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">write</span><span class="pl-kos">(</span><span class="pl-c1">true</span><span class="pl-kos">)</span>
            <span class="pl-kos">.</span><span class="pl-en">append</span><span class="pl-kos">(</span><span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">open</span><span class="pl-kos">(</span><span class="pl-s">"log.log"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> <span class="pl-k">mut</span> file = <span class="pl-k">match</span> resFile <span class="pl-kos">{</span>
        <span class="pl-v">Ok</span><span class="pl-kos">(</span>f<span class="pl-kos">)</span> =&gt; f<span class="pl-kos">,</span>
        <span class="pl-v">Err</span><span class="pl-kos">(</span>e<span class="pl-kos">)</span> =&gt; <span class="pl-en">panic</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"file error: {}"</span>, e<span class="pl-kos">)</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> _ = <span class="pl-en">writeln</span><span class="pl-en">!</span><span class="pl-kos">(</span>&amp;<span class="pl-k">mut</span> file, <span class="pl-s">"{}"</span>, line<span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-en">write_to_log</span><span class="pl-kos">(</span><span class="pl-s">"Hello"</span><span class="pl-kos">.</span><span class="pl-en">to_string</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">compiler prints this message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;std macros&gt;:2:20: 2:66 error: type `&amp;mut std::fs::File` does not implement any method in scope named `write_fmt`
&lt;std macros&gt;:2 ( &amp; mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&lt;std macros&gt;:2:66: 2:66 help: methods from traits can only be called if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
&lt;std macros&gt;:2:66: 2:66 help: candidate #1: use `std::io::Write`
error: aborting due to previous error"><pre class="notranslate"><code class="notranslate">&lt;std macros&gt;:2:20: 2:66 error: type `&amp;mut std::fs::File` does not implement any method in scope named `write_fmt`
&lt;std macros&gt;:2 ( &amp; mut * $ dst ) . write_fmt ( format_args ! ( $ ( $ arg ) * ) ) )
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&lt;std macros&gt;:2:66: 2:66 help: methods from traits can only be called if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
&lt;std macros&gt;:2:66: 2:66 help: candidate #1: use `std::io::Write`
error: aborting due to previous error
</code></pre></div>
<p dir="auto">I would expect it to point me to the fine and line where <code class="notranslate">writeln!</code> is used. Right now it very hard to find error location.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;std macros&gt;:4:19: 4:46 error: invalid reference to argument `1` (there is 1 argument)
&lt;std macros&gt;:4 write ! ( $ dst , concat ! ( $ fmt , &quot;\n&quot; ) , $ ( $ arg ) * ) ) ;
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~

&lt;std macros&gt;:3:11: 3:38 error: invalid reference to argument `2` (there are 2 arguments)
&lt;std macros&gt;:3 print ! ( concat ! ( $ fmt , &quot;\n&quot; ) , $ ( $ arg ) * ) ) ;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~"><pre class="notranslate"><code class="notranslate">&lt;std macros&gt;:4:19: 4:46 error: invalid reference to argument `1` (there is 1 argument)
&lt;std macros&gt;:4 write ! ( $ dst , concat ! ( $ fmt , "\n" ) , $ ( $ arg ) * ) ) ;
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~

&lt;std macros&gt;:3:11: 3:38 error: invalid reference to argument `2` (there are 2 arguments)
&lt;std macros&gt;:3 print ! ( concat ! ( $ fmt , "\n" ) , $ ( $ arg ) * ) ) ;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
</code></pre></div>
<p dir="auto">I’d expect it to at least emit an <code class="notranslate">in expansion of writeln!</code> and <code class="notranslate">in expansion of println!</code> hints which it doesn’t currently.</p>