Skip to content

Commit a8c025e

Browse files
Wilfredhhvm-bot
authored andcommitted
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 <rust-lang/rust#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](rust-lang/rust#59159). Reviewed By: losvald Differential Revision: D15759079 fbshipit-source-id: f5d067f32243abc75c7d2ac35709628ea34a48e9
1 parent 11f48fc commit a8c025e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: hphp/hack/src/parser/lexer.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,8 @@ impl<'a, Token: LexableToken> Lexer<'a, Token> {
19521952
Some(TokenKind::Let) if (!(self.is_experimental_mode())) => TokenKind::Name,
19531953
Some(keyword) => {
19541954
if self.lowercase_error(original_text, &text) {
1955-
self.with_error(Errors::uppercase_kw(original_text));
1955+
let err = Errors::uppercase_kw(original_text);
1956+
self.with_error(err);
19561957
}
19571958
keyword
19581959
}

0 commit comments

Comments
 (0)