title: Match statement using moved matched variable throwing compiler error
body: <p>I am attempting to iterate through a <code>Vec&lt;String&gt;</code> of file paths and read the content of the files. However, the <code>match</code> statement throws a compiler error regarding the variable in the pattern. The following is the code:</p>
  <pre><code>    //paths: Vec&lt;String&gt;
      //get counts in paths
      for path in paths.iter() {
          let mut path_result: Result&lt;std::fs::File, std::io::Error&gt;;
          let file: std::fs::File;
  
          if path != &quot;-&quot; {
              path_result = std::fs::File::open(&amp;path);
          }
  
          //match result with error
          match path_result {
              Ok(path_file) =&gt; { file = path_file },
              Err(e) =&gt; {
                  match e.kind() {
                      std::io::ErrorKind::NotFound =&gt; { println!(&quot;{}: No such file or directory&quot;, &amp;path) },
                      std::io::ErrorKind::PermissionDenied =&gt; { println!(&quot;{}: Permission denied&quot;, &amp;path) },
                      _ =&gt; {
                          println!(&quot;{}: Unknown error&quot;, &amp;path);
                          panic!(&quot;unknown error opening file&quot;);
                      }
                  }
                  continue;
              }
          };
          
          /*get content from file variable*/
      }
  </code></pre>
  <p>This is the compiler error I receive:</p>
  <pre><code>error[E0382]: use of moved value
    --&gt; src/main.rs:60:16
     |
  51 |         let mut path_result: Result&lt;std::fs::File, std::io::Error&gt;;
     |             --------------- move occurs because `path_result` has type `std::result::Result&lt;File, std::io::Error&gt;`, which does not implement the `Copy` trait
  ...
  60 |             Ok(path_file) =&gt; { file = path_file },
     |                ^^^^^^^^^ value used here after move
  ...
  75 |     }
     |     -
     |     |
     |     value moved here, in previous iteration of loop
     |     value moved here, in previous iteration of loop
  
  error: aborting due to previous error; 16 warnings emitted
  
  For more information about this error, try `rustc --explain E0382`.
  error: could not compile `test`
  
  To learn more, run the command again with --verbose.
  </code></pre>
  <p>The warnings are in regards to unused variables not included in this snippet.</p>
  <p>I have attempted borrowing the path_file variable's contents, but receive the same error. My understanding of the situation is that, because neither <code>path_file</code> nor <code>path_result</code> are used later in the <code>for</code> block and <code>path_result</code> is rebinded at the start, there should be no issue even if the ownership goes out of scope past the <code>match</code> statement. However, that seems to not be the case.</p>