title: Why does "move" in Rust not actually move?
body: <p>In the below example:</p>
  
  <pre><code>struct Foo {
      a: [u64; 100000],
  }
  
  fn foo(mut f: Foo) -&gt; Foo {
      f.a[0] = 99999;
      f.a[1] = 99999;
      println!("{:?}", &amp;mut f as *mut Foo);
  
      for i in 0..f.a[0] {
          f.a[i as usize] = 21444;
      }
  
      return f;
  }
  fn main(){
      let mut f = Foo {
          a:[0;100000]
      };
  
      println!("{:?}", &amp;mut f as *mut Foo);
      f = foo(f);
      println!("{:?}", &amp;mut f as *mut Foo);
  }
  </code></pre>
  
  <p>I find that before and after passing into the function <code>foo</code>, the address of <code>f</code> is different. Why does Rust copy such a big struct everywhere but not actually move it (or achieve this optimization)?</p>
  
  <p>I understand how stack memory works. But with the information provided by ownership in Rust, I think the copy can be avoided. The compiler unnecessarily copies the array twice. Can this be an optimization for the Rust compiler?</p>