syntax::parse::parser: convert unnecessary '&mut self's to '&self'.

This commit is contained in:
Mazdak Farrokhzad 2019-05-12 02:00:06 +02:00
parent 0535e42678
commit 9b4a630baa

View File

@ -1877,7 +1877,7 @@ impl<'a> Parser<'a> {
Ok(MutTy { ty: t, mutbl: mutbl })
}
fn is_named_argument(&mut self) -> bool {
fn is_named_argument(&self) -> bool {
let offset = match self.token {
token::Interpolated(ref nt) => match **nt {
token::NtPat(..) => return self.look_ahead(1, |t| t == &token::Colon),
@ -2471,27 +2471,27 @@ impl<'a> Parser<'a> {
})
}
fn mk_expr(&mut self, span: Span, node: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
fn mk_expr(&self, span: Span, node: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
P(Expr { node, span, attrs, id: ast::DUMMY_NODE_ID })
}
fn mk_unary(&mut self, unop: ast::UnOp, expr: P<Expr>) -> ast::ExprKind {
fn mk_unary(&self, unop: ast::UnOp, expr: P<Expr>) -> ast::ExprKind {
ExprKind::Unary(unop, expr)
}
fn mk_binary(&mut self, binop: ast::BinOp, lhs: P<Expr>, rhs: P<Expr>) -> ast::ExprKind {
fn mk_binary(&self, binop: ast::BinOp, lhs: P<Expr>, rhs: P<Expr>) -> ast::ExprKind {
ExprKind::Binary(binop, lhs, rhs)
}
fn mk_call(&mut self, f: P<Expr>, args: Vec<P<Expr>>) -> ast::ExprKind {
fn mk_call(&self, f: P<Expr>, args: Vec<P<Expr>>) -> ast::ExprKind {
ExprKind::Call(f, args)
}
fn mk_index(&mut self, expr: P<Expr>, idx: P<Expr>) -> ast::ExprKind {
fn mk_index(&self, expr: P<Expr>, idx: P<Expr>) -> ast::ExprKind {
ExprKind::Index(expr, idx)
}
fn mk_range(&mut self,
fn mk_range(&self,
start: Option<P<Expr>>,
end: Option<P<Expr>>,
limits: RangeLimits)
@ -2503,7 +2503,7 @@ impl<'a> Parser<'a> {
}
}
fn mk_assign_op(&mut self, binop: ast::BinOp,
fn mk_assign_op(&self, binop: ast::BinOp,
lhs: P<Expr>, rhs: P<Expr>) -> ast::ExprKind {
ExprKind::AssignOp(binop, lhs, rhs)
}
@ -3840,7 +3840,7 @@ impl<'a> Parser<'a> {
/// Produce an error if comparison operators are chained (RFC #558).
/// We only need to check lhs, not rhs, because all comparison ops
/// have same precedence and are left-associative
fn check_no_chained_comparison(&mut self, lhs: &Expr, outer_op: &AssocOp) {
fn check_no_chained_comparison(&self, lhs: &Expr, outer_op: &AssocOp) {
debug_assert!(outer_op.is_comparison(),
"check_no_chained_comparison: {:?} is not comparison",
outer_op);
@ -5137,7 +5137,7 @@ impl<'a> Parser<'a> {
})
}
fn is_async_block(&mut self) -> bool {
fn is_async_block(&self) -> bool {
self.token.is_keyword(keywords::Async) &&
(
( // `async move {`
@ -5149,19 +5149,19 @@ impl<'a> Parser<'a> {
)
}
fn is_async_fn(&mut self) -> bool {
fn is_async_fn(&self) -> bool {
self.token.is_keyword(keywords::Async) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Fn))
}
fn is_do_catch_block(&mut self) -> bool {
fn is_do_catch_block(&self) -> bool {
self.token.is_keyword(keywords::Do) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Catch)) &&
self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace)) &&
!self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL)
}
fn is_try_block(&mut self) -> bool {
fn is_try_block(&self) -> bool {
self.token.is_keyword(keywords::Try) &&
self.look_ahead(1, |t| *t == token::OpenDelim(token::Brace)) &&
self.span.rust_2018() &&
@ -5183,7 +5183,7 @@ impl<'a> Parser<'a> {
self.look_ahead(1, |t| t.is_keyword(keywords::Type))
}
fn is_auto_trait_item(&mut self) -> bool {
fn is_auto_trait_item(&self) -> bool {
// auto trait
(self.token.is_keyword(keywords::Auto)
&& self.look_ahead(1, |t| t.is_keyword(keywords::Trait)))
@ -5445,7 +5445,7 @@ impl<'a> Parser<'a> {
}
/// Checks if this expression is a successfully parsed statement.
fn expr_is_complete(&mut self, e: &Expr) -> bool {
fn expr_is_complete(&self, e: &Expr) -> bool {
self.restrictions.contains(Restrictions::STMT_EXPR) &&
!classify::expr_requires_semi_to_be_stmt(e)
}
@ -6517,7 +6517,7 @@ impl<'a> Parser<'a> {
Ok((id, generics))
}
fn mk_item(&mut self, span: Span, ident: Ident, node: ItemKind, vis: Visibility,
fn mk_item(&self, span: Span, ident: Ident, node: ItemKind, vis: Visibility,
attrs: Vec<Attribute>) -> P<Item> {
P(Item {
ident,
@ -6549,7 +6549,7 @@ impl<'a> Parser<'a> {
/// Returns `true` if we are looking at `const ID`
/// (returns `false` for things like `const fn`, etc.).
fn is_const_item(&mut self) -> bool {
fn is_const_item(&self) -> bool {
self.token.is_keyword(keywords::Const) &&
!self.look_ahead(1, |t| t.is_keyword(keywords::Fn)) &&
!self.look_ahead(1, |t| t.is_keyword(keywords::Unsafe))
@ -6657,7 +6657,7 @@ impl<'a> Parser<'a> {
})
}
fn complain_if_pub_macro(&mut self, vis: &VisibilityKind, sp: Span) {
fn complain_if_pub_macro(&self, vis: &VisibilityKind, sp: Span) {
match *vis {
VisibilityKind::Inherited => {}
_ => {
@ -6686,7 +6686,7 @@ impl<'a> Parser<'a> {
}
}
fn missing_assoc_item_kind_err(&mut self, item_type: &str, prev_span: Span)
fn missing_assoc_item_kind_err(&self, item_type: &str, prev_span: Span)
-> DiagnosticBuilder<'a>
{
let expected_kinds = if item_type == "extern" {