<p dir="auto">I think there's an existing issue, but I can't find it. Currently borrowck treats nullary variants (like <code class="notranslate">None</code>) as static identifies. This doesn't make sense for generic enums and I don't think it matches up with trans. The reason it doesn't make sense for generic enums is that <code class="notranslate">None::&lt;Foo&gt;</code> and <code class="notranslate">None::&lt;Bar&gt;</code> have totally different sizes etc., so there couldn't possible be a single static constant to refer to. This is a relatively simple fix to the <code class="notranslate">mem_categorization</code> code, but it's worth investigating how trans handles enum variants and make sure that everything will be compatible.</p>
<p dir="auto">Nominating since it is a backwards compatibility thing.</p>
<p dir="auto">I asked stackoverflow about lifetime of variable. Original link is this : <a href="http://stackoverflow.com/questions/21226942/rust-lifetime-and-calling-member-function" rel="nofollow">http://stackoverflow.com/questions/21226942/rust-lifetime-and-calling-member-function</a></p>
<p dir="auto">** Question from link **</p>
<p dir="auto">I have a question about lifetime of varable in Rust programming language.</p>
<p dir="auto"><code class="notranslate">createTest</code> function creates and returns r-value reference. and when it returns a reference, <code class="notranslate">testValue</code> is destroyed. But test.print() doesn't lead to crash. Why?</p>
<p dir="auto">(Is Test::print function called as static function?)</p>
<p dir="auto"><strong>Code</strong></p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Test;                                                         
impl Drop for Test {                                                       
  fn drop (&amp;mut self) {                                                    
    println(&quot;Dropped.&quot;);                                                   
  }                                                                        
}                                                                          

impl Test {                                                                
  fn print(&amp;self) { println!(&quot;Print!&quot;); }                                  
}                                                                          

fn createTest() -&gt; &amp;Test {                                                 
  let testValue = &amp;Test;                                                   
  return testValue;                                                        
}                                                                          

fn main() {                                                                
  let test = createTest();                                             
  test.print();                                                            
  println(&quot;Test&quot;);                                                         
}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">Test</span><span class="pl-kos">;</span>                                                         
<span class="pl-k">impl</span> <span class="pl-smi">Drop</span> <span class="pl-k">for</span> <span class="pl-smi">Test</span> <span class="pl-kos">{</span>                                                       
  <span class="pl-k">fn</span> <span class="pl-en">drop</span> <span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> <span class="pl-smi">self</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>                                                    
    <span class="pl-en">println</span><span class="pl-kos">(</span><span class="pl-s">"Dropped."</span><span class="pl-kos">)</span><span class="pl-kos">;</span>                                                   
  <span class="pl-kos">}</span>                                                                        
<span class="pl-kos">}</span>                                                                          

<span class="pl-k">impl</span> <span class="pl-smi">Test</span> <span class="pl-kos">{</span>                                                                
  <span class="pl-k">fn</span> <span class="pl-en">print</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">self</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"Print!"</span><span class="pl-kos">)</span><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">createTest</span><span class="pl-kos">(</span><span class="pl-kos">)</span> -&gt; <span class="pl-c1">&amp;</span><span class="pl-smi">Test</span> <span class="pl-kos">{</span>                                                 
  <span class="pl-k">let</span> testValue = <span class="pl-c1">&amp;</span><span class="pl-v">Test</span><span class="pl-kos">;</span>                                                   
  <span class="pl-k">return</span> testValue<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-k">let</span> test = <span class="pl-en">createTest</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>                                             
  test<span class="pl-kos">.</span><span class="pl-en">print</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>                                                            
  <span class="pl-en">println</span><span class="pl-kos">(</span><span class="pl-s">"Test"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>                                                         
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><strong>Result</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Dropped.
Print!
Test"><pre class="notranslate"><code class="notranslate">Dropped.
Print!
Test
</code></pre></div>
<p dir="auto">It happened with empty struct only. Is it a really bug?</p>