Fix borrow check warning
commita8c025eed587569b323df5b9b485738c61357018
authorWilfred Hughes <wilfred@fb.com>
Wed, 12 Jun 2019 10:08:38 +0000 (12 03:08 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Wed, 12 Jun 2019 10:11:51 +0000 (12 03:11 -0700)
tree851c2dbfef227d0c31d44f3016558281da83a63c
parent11f48fc515ab9b9c8297fc2008b291d07e32c6ec
Fix borrow check warning

Summary:
Previously we had the following warning:

```
warning: cannot borrow `*self` as mutable because it is also borrowed as immutable
    --> hphp/hack/src/parser/lexer.rs:1956:25
     |
1946 |             let original_text = self.current_text_as_str(); //
     |                                 ---- immutable borrow occurs here
...
1956 |                         self.with_error(Errors::uppercase_kw(original_text));
     |                         ^^^^ mutable borrow occurs here      ------------- immutable borrow later used here
     |
     = note: #[warn(mutable_borrow_reservation_conflict)] on by default
     = warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
     = note: for more information, see issue #59159 <https://github.com/rust-lang/rust/issues/59159>
```

Refactor the code so that the scope of `original_text` doesn't extend to `self.with_error`. This is consistent with the vector example given in [Rust issue #59159](https://github.com/rust-lang/rust/issues/59159).

Reviewed By: losvald

Differential Revision: D15759079

fbshipit-source-id: f5d067f32243abc75c7d2ac35709628ea34a48e9
hphp/hack/src/parser/lexer.rs