Skip to content

Commit

Permalink
Cleanup match expression
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Mar 29, 2020
1 parent 82b2989 commit bceab25
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/librustc_parse/parser/diagnostics.rs
Expand Up @@ -6,7 +6,7 @@ use rustc_ast::ast::{
};
use rustc_ast::ast::{AttrVec, ItemKind, Mutability, Pat, PatKind, PathSegment, QSelf, Ty, TyKind};
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Lit, LitKind, Token, TokenKind};
use rustc_ast::token::{self, Lit, LitKind, TokenKind};
use rustc_ast::util::parser::AssocOp;
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
Expand Down Expand Up @@ -287,14 +287,10 @@ impl<'a> Parser<'a> {
}

fn check_too_many_raw_str_terminators(&mut self, err: &mut DiagnosticBuilder<'_>) -> bool {
let prev_token_raw_str = match self.prev_token {
Token {
kind:
TokenKind::Literal(Lit {
kind: LitKind::StrRaw(n) | LitKind::ByteStrRaw(n), ..
}),
..
} => Some(n),
let prev_token_raw_str = match self.prev_token.kind {
TokenKind::Literal(Lit {
kind: LitKind::StrRaw(n) | LitKind::ByteStrRaw(n), ..
}) => Some(n),
_ => None,
};

Expand Down Expand Up @@ -523,7 +519,7 @@ impl<'a> Parser<'a> {
.unwrap_or_else(|_| pprust::expr_to_string(&e))
};
err.span_suggestion_verbose(
inner_op.span.shrink_to_hi(),
inner_op.span.shrink_to_hi(),
"split the comparison into two",
format!(" && {}", expr_to_str(&r1)),
Applicability::MaybeIncorrect,
Expand Down Expand Up @@ -1118,7 +1114,7 @@ impl<'a> Parser<'a> {
self.look_ahead(2, |t| t.is_ident())
|| self.look_ahead(1, |t| t == &token::ModSep)
&& (self.look_ahead(2, |t| t.is_ident()) || // `foo:bar::baz`
self.look_ahead(2, |t| t == &token::Lt)) // `foo:bar::<baz>`
self.look_ahead(2, |t| t == &token::Lt)) // `foo:bar::<baz>`
}

pub(super) fn recover_seq_parse_error(
Expand Down

0 comments on commit bceab25

Please sign in to comment.