Replace parse_[sth]_expr with parse_expr_[sth] function names
This resolves an inconsistency in naming style for functions on the parser, between functions parsing specific kinds of items and those for expressions, favoring the parse_item_[sth] style used by functions for items. There are multiple advantages of that style: * functions of both categories are collected in the same place in the rustdoc output. * it helps with autocompletion, as you can narrow down your search for a function to those about expressions. * it mirrors rust's path syntax where less specific things come first, then it gets more specific, i.e. std::collections::hash_map::Entry The disadvantage is that it doesn't "read like a sentence" any more, but I think the advantages weigh more greatly. This change was mostly application of this command: sed -i -E 's/(fn |\.)parse_([[:alnum:]_]+)_expr/\1parse_expr_\2/' compiler/rustc_parse/src/parser/*.rs Plus very minor fixes outside of rustc_parse, and an invocation of x fmt.
This commit is contained in:
parent
07c993eba8
commit
2850116636
7 changed files with 131 additions and 131 deletions
|
@ -146,14 +146,14 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
let expr = if this.eat(&token::OpenDelim(Delimiter::Brace)) {
|
||||
this.parse_struct_expr(None, path, true)?
|
||||
this.parse_expr_struct(None, path, true)?
|
||||
} else {
|
||||
let hi = this.prev_token.span;
|
||||
this.mk_expr(lo.to(hi), ExprKind::Path(None, path))
|
||||
};
|
||||
|
||||
let expr = this.with_res(Restrictions::STMT_EXPR, |this| {
|
||||
this.parse_dot_or_call_expr_with(expr, lo, attrs)
|
||||
this.parse_expr_dot_or_call_with(expr, lo, attrs)
|
||||
})?;
|
||||
// `DUMMY_SP` will get overwritten later in this function
|
||||
Ok((this.mk_stmt(rustc_span::DUMMY_SP, StmtKind::Expr(expr)), TrailingToken::None))
|
||||
|
@ -163,7 +163,7 @@ impl<'a> Parser<'a> {
|
|||
// Perform this outside of the `collect_tokens_trailing_token` closure,
|
||||
// since our outer attributes do not apply to this part of the expression
|
||||
let expr = self.with_res(Restrictions::STMT_EXPR, |this| {
|
||||
this.parse_assoc_expr_with(
|
||||
this.parse_expr_assoc_with(
|
||||
0,
|
||||
LhsExpr::AlreadyParsed { expr, starts_statement: true },
|
||||
)
|
||||
|
@ -199,8 +199,8 @@ impl<'a> Parser<'a> {
|
|||
// Since none of the above applied, this is an expression statement macro.
|
||||
let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac));
|
||||
let e = self.maybe_recover_from_bad_qpath(e)?;
|
||||
let e = self.parse_dot_or_call_expr_with(e, lo, attrs)?;
|
||||
let e = self.parse_assoc_expr_with(
|
||||
let e = self.parse_expr_dot_or_call_with(e, lo, attrs)?;
|
||||
let e = self.parse_expr_assoc_with(
|
||||
0,
|
||||
LhsExpr::AlreadyParsed { expr: e, starts_statement: false },
|
||||
)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue