Skip to content

Commit 9dbe2e7

Browse files
committed
review comments
1 parent f5b2859 commit 9dbe2e7

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/libsyntax/parse/diagnostics.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ impl<'a> Parser<'a> {
327327
self.token.is_keyword(kw::Return) ||
328328
self.token.is_keyword(kw::While)
329329
);
330-
let cm = self.sess.source_map();
331-
match (cm.lookup_line(self.token.span.lo()), cm.lookup_line(sp.lo())) {
330+
let sm = self.sess.source_map();
331+
match (sm.lookup_line(self.token.span.lo()), sm.lookup_line(sp.lo())) {
332332
(Ok(ref a), Ok(ref b)) if a.line != b.line && is_semi_suggestable => {
333333
// The spans are in different lines, expected `;` and found `let` or `return`.
334334
// High likelihood that it is only a missing `;`.
@@ -376,9 +376,9 @@ impl<'a> Parser<'a> {
376376
maybe_expected_semicolon: bool,
377377
) {
378378
if let Some((sp, likely_path)) = self.last_type_ascription {
379-
let cm = self.sess.source_map();
380-
let next_pos = cm.lookup_char_pos(self.token.span.lo());
381-
let op_pos = cm.lookup_char_pos(sp.hi());
379+
let sm = self.sess.source_map();
380+
let next_pos = sm.lookup_char_pos(self.token.span.lo());
381+
let op_pos = sm.lookup_char_pos(sp.hi());
382382

383383
if likely_path {
384384
err.span_suggestion(
@@ -814,8 +814,8 @@ impl<'a> Parser<'a> {
814814
return Ok(recovered);
815815
}
816816
}
817-
let cm = self.sess.source_map();
818-
match (cm.lookup_line(prev_sp.lo()), cm.lookup_line(sp.lo())) {
817+
let sm = self.sess.source_map();
818+
match (sm.lookup_line(prev_sp.lo()), sm.lookup_line(sp.lo())) {
819819
(Ok(ref a), Ok(ref b)) if a.line == b.line => {
820820
// When the spans are in the same line, it means that the only content
821821
// between them is whitespace, point only at the found token.

src/libsyntax/parse/parser.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -2850,9 +2850,7 @@ impl<'a> Parser<'a> {
28502850

28512851
match (self.expr_is_complete(&lhs), AssocOp::from_token(&self.token)) {
28522852
(true, None) => {
2853-
if last_type_ascription_set {
2854-
self.last_type_ascription = None;
2855-
}
2853+
self.last_type_ascription = None;
28562854
// Semi-statement forms are odd. See https://github.com/rust-lang/rust/issues/29071
28572855
return Ok(lhs);
28582856
}
@@ -2867,18 +2865,14 @@ impl<'a> Parser<'a> {
28672865
// If the next token is a keyword, then the tokens above *are* unambiguously incorrect:
28682866
// `if x { a } else { b } && if y { c } else { d }`
28692867
if !self.look_ahead(1, |t| t.is_reserved_ident()) => {
2870-
if last_type_ascription_set {
2871-
self.last_type_ascription = None;
2872-
}
2868+
self.last_type_ascription = None;
28732869
// These cases are ambiguous and can't be identified in the parser alone
28742870
let sp = self.sess.source_map().start_point(self.token.span);
28752871
self.sess.ambiguous_block_expr_parse.borrow_mut().insert(sp, lhs.span);
28762872
return Ok(lhs);
28772873
}
28782874
(true, Some(ref op)) if !op.can_continue_expr_unambiguously() => {
2879-
if last_type_ascription_set {
2880-
self.last_type_ascription = None;
2881-
}
2875+
self.last_type_ascription = None;
28822876
return Ok(lhs);
28832877
}
28842878
(true, Some(_)) => {

0 commit comments

Comments
 (0)