Skip to content

Commit e7e8435

Browse files
authored
Rollup merge of rust-lang#68135 - calebcartwright:rustc-parse-visibilities, r=Centril
restore some rustc_parse visibilities for rustfmt In rust-lang@c189565 some visibilities were reduced on the parse mod (which now resides in the rustc_parse crate) as part of some refactoring and splitting up of libsyntax. However, rustfmt needs access to a few of those items that are no longer visible. This restores the visibility on those items rustfmt depends on. rust-lang/rustfmt#3903 (comment) rust-lang/rustfmt#4009 cc @topecongiro
2 parents 686f9ad + ed039e8 commit e7e8435

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/librustc_parse/parser/mod.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub mod attr;
22
mod expr;
33
mod item;
44
mod module;
5+
pub use module::{ModulePath, ModulePathSuccess};
56
mod pat;
67
mod path;
78
mod ty;
@@ -117,7 +118,8 @@ pub struct Parser<'a> {
117118
/// Used to determine the path to externally loaded source files.
118119
pub(super) directory: Directory<'a>,
119120
/// `true` to parse sub-modules in other files.
120-
pub(super) recurse_into_file_modules: bool,
121+
// Public for rustfmt usage.
122+
pub recurse_into_file_modules: bool,
121123
/// Name of the root module this parser originated from. If `None`, then the
122124
/// name is not known. This does not change while the parser is descending
123125
/// into modules, and sub-parsers have new values for this name.
@@ -126,7 +128,8 @@ pub struct Parser<'a> {
126128
token_cursor: TokenCursor,
127129
desugar_doc_comments: bool,
128130
/// `true` we should configure out of line modules as we parse.
129-
cfg_mods: bool,
131+
// Public for rustfmt usage.
132+
pub cfg_mods: bool,
130133
/// This field is used to keep track of how many left angle brackets we have seen. This is
131134
/// required in order to detect extra leading left angle brackets (`<` characters) and error
132135
/// appropriately.
@@ -483,7 +486,8 @@ impl<'a> Parser<'a> {
483486
}
484487
}
485488

486-
fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
489+
// Public for rustfmt usage.
490+
pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
487491
self.parse_ident_common(true)
488492
}
489493

@@ -540,7 +544,8 @@ impl<'a> Parser<'a> {
540544

541545
/// If the next token is the given keyword, eats it and returns `true`.
542546
/// Otherwise, returns `false`. An expectation is also added for diagnostics purposes.
543-
fn eat_keyword(&mut self, kw: Symbol) -> bool {
547+
// Public for rustfmt usage.
548+
pub fn eat_keyword(&mut self, kw: Symbol) -> bool {
544549
if self.check_keyword(kw) {
545550
self.bump();
546551
true

src/librustc_parse/parser/module.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ use syntax::token::{self, TokenKind};
1414
use std::path::{self, Path, PathBuf};
1515

1616
/// Information about the path to a module.
17-
pub(super) struct ModulePath {
17+
// Public for rustfmt usage.
18+
pub struct ModulePath {
1819
name: String,
1920
path_exists: bool,
2021
pub result: Result<ModulePathSuccess, Error>,
2122
}
2223

23-
pub(super) struct ModulePathSuccess {
24+
// Public for rustfmt usage.
25+
pub struct ModulePathSuccess {
2426
pub path: PathBuf,
2527
pub directory_ownership: DirectoryOwnership,
2628
}
@@ -177,7 +179,8 @@ impl<'a> Parser<'a> {
177179
}
178180
}
179181

180-
pub(super) fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option<PathBuf> {
182+
// Public for rustfmt usage.
183+
pub fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option<PathBuf> {
181184
if let Some(s) = attr::first_attr_value_str_by_name(attrs, sym::path) {
182185
let s = s.as_str();
183186

@@ -194,7 +197,8 @@ impl<'a> Parser<'a> {
194197
}
195198

196199
/// Returns a path to a module.
197-
pub(super) fn default_submod_path(
200+
// Public for rustfmt usage.
201+
pub fn default_submod_path(
198202
id: ast::Ident,
199203
relative: Option<ast::Ident>,
200204
dir_path: &Path,

0 commit comments

Comments
 (0)