Rollup merge of #76115 - calebcartwright:parser-fn-visibility, r=matklad

Restore public visibility on some parsing functions for rustfmt

In #74826 the visibility of several parsing functions was reduced. However, rustfmt is an external consumer of some of these functions as well and needs the visibility to be public, similar to other elements in rustc_parse such as `parse_ident`

db534b3ac2/src/librustc_parse/parser/mod.rs (L433-L436)
This commit is contained in:
Aleksey Kladov 2020-08-31 15:22:43 +02:00 committed by GitHub
commit d8eb30127b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -1014,7 +1014,8 @@ impl<'a> Parser<'a> {
/// If the following element can't be a tuple (i.e., it's a function definition), then /// If the following element can't be a tuple (i.e., it's a function definition), then
/// it's not a tuple struct field), and the contents within the parentheses isn't valid, /// it's not a tuple struct field), and the contents within the parentheses isn't valid,
/// so emit a proper diagnostic. /// so emit a proper diagnostic.
pub(crate) fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> { // Public for rustfmt usage.
pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> {
maybe_whole!(self, NtVis, |x| x); maybe_whole!(self, NtVis, |x| x);
self.expected_tokens.push(TokenType::Keyword(kw::Crate)); self.expected_tokens.push(TokenType::Keyword(kw::Crate));

View File

@ -21,7 +21,8 @@ use std::mem;
impl<'a> Parser<'a> { impl<'a> Parser<'a> {
/// Parses a statement. This stops just before trailing semicolons on everything but items. /// Parses a statement. This stops just before trailing semicolons on everything but items.
/// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed. /// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed.
pub(super) fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> { // Public for rustfmt usage.
pub fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> {
Ok(self.parse_stmt_without_recovery().unwrap_or_else(|mut e| { Ok(self.parse_stmt_without_recovery().unwrap_or_else(|mut e| {
e.emit(); e.emit();
self.recover_stmt_(SemiColonMode::Break, BlockMode::Ignore); self.recover_stmt_(SemiColonMode::Break, BlockMode::Ignore);