title: Why do return expressions use semicolons when they're unnecessary?
body: <p>I'm learning Rust and I've found something confusing with functions. According to <a href="https://doc.rust-lang.org/stable/reference/expressions/return-expr.html" rel="nofollow noreferrer">the official reference</a>, a return expression:</p>
  
  <blockquote>
    <p>.. [is] denoted with the keyword return. Evaluating a return expression moves its 
    argument into the output slot of the current function, destroys the current function activation 
    frame, and transfers control to the caller frame.</p>
  </blockquote>
  
  <p>So, this program works:</p>
  
  <pre><code>fn main() {
      let current_hour = 10;
      let message = get_message(current_hour);
  
      println!("Good {0}", message);
  }
  
  fn get_message(current_hour: i32) -&gt; &amp;'static str {
  
      if current_hour &lt; 11 {
          return "Morning"
      }
      else if current_hour &lt; 17 {
          return "Afternoon"
      }
      else {
          return "Evening"
      }
  
  }
  </code></pre>
  
  <p>And when I add semi-colons to the "return" expressions, it still works:</p>
  
  <pre><code>fn main() {
      let current_hour = 10;
      let message = get_message(current_hour);
  
      println!("Good {0}", message);
  }
  
  fn get_message(current_hour: i32) -&gt; &amp;'static str {
  
      if current_hour &lt; 11 {
          return "Morning";
      }
      else if current_hour &lt; 17 {
          return "Afternoon";
      }
      else {
          return "Evening";
      }
  
  }
  </code></pre>
  
  <p>My <a href="https://doc.rust-lang.org/stable/reference/statements.html#expression-statements" rel="nofollow noreferrer">understanding of expression statements (e.g. <code>expr;</code>)</a> is that it will evaluate the <code>expr</code> expression, and ignore the result (instead it will use <code>()</code>). In the case of using <code>return expr;</code>, there doesn't seem to be a <em>reason</em> for using <code>;</code> since <code>return expr</code> destroys the current function activation frame (and would then ignore the <code>;</code>).</p>
  
  <p>So, why does a lot of Rust code that I've seen use the semi-colon if it's not necessary (and in fact makes <a href="http://doc.rust-lang.org/book/functions.html" rel="nofollow noreferrer">learning about Rust's functions</a> very confusing... since it feels like it's contradictory). Is it just an idiom from other languages that has carried over?</p>