Skip to content

Commit c189565

Browse files
committed
syntax: reduce visibilities
1 parent 98017ca commit c189565

File tree

14 files changed

+101
-101
lines changed

14 files changed

+101
-101
lines changed

src/libsyntax/attr/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl Attribute {
280280
self.item.meta(self.span)
281281
}
282282

283-
pub fn parse<'a, T, F>(&self, sess: &'a ParseSess, mut f: F) -> PResult<'a, T>
283+
crate fn parse<'a, T, F>(&self, sess: &'a ParseSess, mut f: F) -> PResult<'a, T>
284284
where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
285285
{
286286
let mut parser = Parser::new(
@@ -298,14 +298,14 @@ impl Attribute {
298298
Ok(result)
299299
}
300300

301-
pub fn parse_derive_paths<'a>(&self, sess: &'a ParseSess) -> PResult<'a, Vec<Path>> {
301+
crate fn parse_derive_paths<'a>(&self, sess: &'a ParseSess) -> PResult<'a, Vec<Path>> {
302302
if self.tokens.is_empty() {
303303
return Ok(Vec::new());
304304
}
305305
self.parse(sess, |p| p.parse_derive_paths())
306306
}
307307

308-
pub fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> {
308+
crate fn parse_meta<'a>(&self, sess: &'a ParseSess) -> PResult<'a, MetaItem> {
309309
Ok(MetaItem {
310310
path: self.path.clone(),
311311
kind: self.parse(sess, |parser| parser.parse_meta_item_kind())?,

src/libsyntax/ext/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ impl<'a> Parser<'a> {
838838
self.this_token_to_string());
839839
// Avoid emitting backtrace info twice.
840840
let def_site_span = self.token.span.with_ctxt(SyntaxContext::root());
841-
let mut err = self.diagnostic().struct_span_err(def_site_span, &msg);
841+
let mut err = self.struct_span_err(def_site_span, &msg);
842842
err.span_label(span, "caused by the macro expansion here");
843843
let msg = format!(
844844
"the usage of `{}!` is likely invalid in {} context",

src/libsyntax/parse/literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl Lit {
212212
/// Attempts to recover an AST literal from semantic literal.
213213
/// This function is used when the original token doesn't exist (e.g. the literal is created
214214
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
215-
pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit {
215+
crate fn from_lit_kind(kind: LitKind, span: Span) -> Lit {
216216
Lit { token: kind.to_lit_token(), kind, span }
217217
}
218218

src/libsyntax/parse/parser.rs

+29-31
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ mod attr;
22
mod expr;
33
mod pat;
44
mod item;
5-
pub use item::AliasKind;
65
mod module;
7-
pub use module::{ModulePath, ModulePathSuccess};
86
mod ty;
97
mod path;
10-
pub use path::PathStyle;
8+
crate use path::PathStyle;
119
mod stmt;
1210
mod generics;
1311
mod diagnostics;
@@ -46,14 +44,14 @@ bitflags::bitflags! {
4644
}
4745

4846
#[derive(Clone, Copy, PartialEq, Debug)]
49-
crate enum SemiColonMode {
47+
enum SemiColonMode {
5048
Break,
5149
Ignore,
5250
Comma,
5351
}
5452

5553
#[derive(Clone, Copy, PartialEq, Debug)]
56-
crate enum BlockMode {
54+
enum BlockMode {
5755
Break,
5856
Ignore,
5957
}
@@ -126,33 +124,33 @@ pub struct Parser<'a> {
126124
prev_token_kind: PrevTokenKind,
127125
restrictions: Restrictions,
128126
/// Used to determine the path to externally loaded source files.
129-
crate directory: Directory<'a>,
127+
pub(super) directory: Directory<'a>,
130128
/// `true` to parse sub-modules in other files.
131-
pub recurse_into_file_modules: bool,
129+
pub(super) recurse_into_file_modules: bool,
132130
/// Name of the root module this parser originated from. If `None`, then the
133131
/// name is not known. This does not change while the parser is descending
134132
/// into modules, and sub-parsers have new values for this name.
135-
pub root_module_name: Option<String>,
136-
crate expected_tokens: Vec<TokenType>,
133+
crate root_module_name: Option<String>,
134+
expected_tokens: Vec<TokenType>,
137135
token_cursor: TokenCursor,
138136
desugar_doc_comments: bool,
139137
/// `true` we should configure out of line modules as we parse.
140-
pub cfg_mods: bool,
138+
cfg_mods: bool,
141139
/// This field is used to keep track of how many left angle brackets we have seen. This is
142140
/// required in order to detect extra leading left angle brackets (`<` characters) and error
143141
/// appropriately.
144142
///
145143
/// See the comments in the `parse_path_segment` function for more details.
146-
crate unmatched_angle_bracket_count: u32,
147-
crate max_angle_bracket_count: u32,
144+
unmatched_angle_bracket_count: u32,
145+
max_angle_bracket_count: u32,
148146
/// A list of all unclosed delimiters found by the lexer. If an entry is used for error recovery
149147
/// it gets removed from here. Every entry left at the end gets emitted as an independent
150148
/// error.
151-
crate unclosed_delims: Vec<UnmatchedBrace>,
152-
crate last_unexpected_token_span: Option<Span>,
149+
pub(super) unclosed_delims: Vec<UnmatchedBrace>,
150+
last_unexpected_token_span: Option<Span>,
153151
crate last_type_ascription: Option<(Span, bool /* likely path typo */)>,
154152
/// If present, this `Parser` is not parsing Rust code but rather a macro call.
155-
crate subparser_name: Option<&'static str>,
153+
subparser_name: Option<&'static str>,
156154
}
157155

158156
impl<'a> Drop for Parser<'a> {
@@ -196,7 +194,7 @@ struct TokenCursorFrame {
196194
/// You can find some more example usage of this in the `collect_tokens` method
197195
/// on the parser.
198196
#[derive(Clone)]
199-
crate enum LastToken {
197+
enum LastToken {
200198
Collecting(Vec<TreeAndJoint>),
201199
Was(Option<TreeAndJoint>),
202200
}
@@ -299,7 +297,7 @@ impl TokenCursor {
299297
}
300298

301299
#[derive(Clone, PartialEq)]
302-
crate enum TokenType {
300+
enum TokenType {
303301
Token(TokenKind),
304302
Keyword(Symbol),
305303
Operator,
@@ -311,7 +309,7 @@ crate enum TokenType {
311309
}
312310

313311
impl TokenType {
314-
crate fn to_string(&self) -> String {
312+
fn to_string(&self) -> String {
315313
match *self {
316314
TokenType::Token(ref t) => format!("`{}`", pprust::token_kind_to_string(t)),
317315
TokenType::Keyword(kw) => format!("`{}`", kw),
@@ -326,13 +324,13 @@ impl TokenType {
326324
}
327325

328326
#[derive(Copy, Clone, Debug)]
329-
crate enum TokenExpectType {
327+
enum TokenExpectType {
330328
Expect,
331329
NoExpect,
332330
}
333331

334332
impl<'a> Parser<'a> {
335-
pub fn new(
333+
crate fn new(
336334
sess: &'a ParseSess,
337335
tokens: TokenStream,
338336
directory: Option<Directory<'a>>,
@@ -407,7 +405,7 @@ impl<'a> Parser<'a> {
407405
pprust::token_to_string(&self.token)
408406
}
409407

410-
crate fn token_descr(&self) -> Option<&'static str> {
408+
fn token_descr(&self) -> Option<&'static str> {
411409
Some(match &self.token.kind {
412410
_ if self.token.is_special_ident() => "reserved identifier",
413411
_ if self.token.is_used_keyword() => "keyword",
@@ -417,7 +415,7 @@ impl<'a> Parser<'a> {
417415
})
418416
}
419417

420-
crate fn this_token_descr(&self) -> String {
418+
pub(super) fn this_token_descr(&self) -> String {
421419
if let Some(prefix) = self.token_descr() {
422420
format!("{} `{}`", prefix, self.this_token_to_string())
423421
} else {
@@ -467,7 +465,7 @@ impl<'a> Parser<'a> {
467465
}
468466
}
469467

470-
pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
468+
fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
471469
self.parse_ident_common(true)
472470
}
473471

@@ -500,7 +498,7 @@ impl<'a> Parser<'a> {
500498
///
501499
/// This method will automatically add `tok` to `expected_tokens` if `tok` is not
502500
/// encountered.
503-
crate fn check(&mut self, tok: &TokenKind) -> bool {
501+
fn check(&mut self, tok: &TokenKind) -> bool {
504502
let is_present = self.token == *tok;
505503
if !is_present { self.expected_tokens.push(TokenType::Token(tok.clone())); }
506504
is_present
@@ -522,7 +520,7 @@ impl<'a> Parser<'a> {
522520

523521
/// If the next token is the given keyword, eats it and returns `true`.
524522
/// Otherwise, returns `false`. An expectation is also added for diagnostics purposes.
525-
pub fn eat_keyword(&mut self, kw: Symbol) -> bool {
523+
fn eat_keyword(&mut self, kw: Symbol) -> bool {
526524
if self.check_keyword(kw) {
527525
self.bump();
528526
true
@@ -560,7 +558,7 @@ impl<'a> Parser<'a> {
560558
}
561559
}
562560

563-
crate fn check_ident(&mut self) -> bool {
561+
fn check_ident(&mut self) -> bool {
564562
self.check_or_expected(self.token.is_ident(), TokenType::Ident)
565563
}
566564

@@ -725,7 +723,7 @@ impl<'a> Parser<'a> {
725723
/// Parses a sequence, including the closing delimiter. The function
726724
/// `f` must consume tokens until reaching the next separator or
727725
/// closing bracket.
728-
pub fn parse_seq_to_end<T>(
726+
fn parse_seq_to_end<T>(
729727
&mut self,
730728
ket: &TokenKind,
731729
sep: SeqSep,
@@ -741,7 +739,7 @@ impl<'a> Parser<'a> {
741739
/// Parses a sequence, not including the closing delimiter. The function
742740
/// `f` must consume tokens until reaching the next separator or
743741
/// closing bracket.
744-
pub fn parse_seq_to_before_end<T>(
742+
fn parse_seq_to_before_end<T>(
745743
&mut self,
746744
ket: &TokenKind,
747745
sep: SeqSep,
@@ -759,7 +757,7 @@ impl<'a> Parser<'a> {
759757
})
760758
}
761759

762-
crate fn parse_seq_to_before_tokens<T>(
760+
fn parse_seq_to_before_tokens<T>(
763761
&mut self,
764762
kets: &[&TokenKind],
765763
sep: SeqSep,
@@ -1101,7 +1099,7 @@ impl<'a> Parser<'a> {
11011099
/// If the following element can't be a tuple (i.e., it's a function definition), then
11021100
/// it's not a tuple struct field), and the contents within the parentheses isn't valid,
11031101
/// so emit a proper diagnostic.
1104-
pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
1102+
crate fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
11051103
maybe_whole!(self, NtVis, |x| x);
11061104

11071105
self.expected_tokens.push(TokenType::Keyword(kw::Crate));
@@ -1325,7 +1323,7 @@ impl<'a> Parser<'a> {
13251323
*t == token::BinOp(token::Star))
13261324
}
13271325

1328-
pub fn parse_optional_str(&mut self) -> Option<(Symbol, ast::StrStyle, Option<ast::Name>)> {
1326+
fn parse_optional_str(&mut self) -> Option<(Symbol, ast::StrStyle, Option<ast::Name>)> {
13291327
let ret = match self.token.kind {
13301328
token::Literal(token::Lit { kind: token::Str, symbol, suffix }) =>
13311329
(symbol, ast::StrStyle::Cooked, suffix),

src/libsyntax/parse/parser/attr.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG: &str = "an inner attribute is not \
2020

2121
impl<'a> Parser<'a> {
2222
/// Parses attributes that appear before an item.
23-
crate fn parse_outer_attributes(&mut self) -> PResult<'a, Vec<ast::Attribute>> {
23+
pub(super) fn parse_outer_attributes(&mut self) -> PResult<'a, Vec<ast::Attribute>> {
2424
let mut attrs: Vec<ast::Attribute> = Vec::new();
2525
let mut just_parsed_doc_comment = false;
2626
loop {
@@ -66,7 +66,7 @@ impl<'a> Parser<'a> {
6666
///
6767
/// If `permit_inner` is `true`, then a leading `!` indicates an inner
6868
/// attribute.
69-
pub fn parse_attribute(&mut self, permit_inner: bool) -> PResult<'a, ast::Attribute> {
69+
fn parse_attribute(&mut self, permit_inner: bool) -> PResult<'a, ast::Attribute> {
7070
debug!("parse_attribute: permit_inner={:?} self.token={:?}",
7171
permit_inner,
7272
self.token);
@@ -84,9 +84,10 @@ impl<'a> Parser<'a> {
8484

8585
/// The same as `parse_attribute`, except it takes in an `InnerAttributeParsePolicy`
8686
/// that prescribes how to handle inner attributes.
87-
fn parse_attribute_with_inner_parse_policy(&mut self,
88-
inner_parse_policy: InnerAttributeParsePolicy<'_>)
89-
-> PResult<'a, ast::Attribute> {
87+
fn parse_attribute_with_inner_parse_policy(
88+
&mut self,
89+
inner_parse_policy: InnerAttributeParsePolicy<'_>
90+
) -> PResult<'a, ast::Attribute> {
9091
debug!("parse_attribute_with_inner_parse_policy: inner_parse_policy={:?} self.token={:?}",
9192
inner_parse_policy,
9293
self.token);

0 commit comments

Comments
 (0)