@@ -11,14 +11,13 @@ mod stmt;
11
11
mod ty;
12
12
13
13
use crate :: lexer:: UnmatchedDelim ;
14
- pub use attr_wrapper:: AttrWrapper ;
14
+ use attr_wrapper:: AttrWrapper ;
15
15
pub use diagnostics:: AttemptLocalParseRecovery ;
16
16
pub ( crate ) use expr:: ForbiddenLetReason ;
17
17
pub ( crate ) use item:: FnParseMode ;
18
18
pub use pat:: { CommaRecoveryMode , RecoverColon , RecoverComma } ;
19
- pub use path:: PathStyle ;
19
+ use path:: PathStyle ;
20
20
21
- use core:: fmt;
22
21
use rustc_ast:: ptr:: P ;
23
22
use rustc_ast:: token:: { self , Delimiter , IdentIsRaw , Nonterminal , Token , TokenKind } ;
24
23
use rustc_ast:: tokenstream:: { AttributesData , DelimSpacing , DelimSpan , Spacing } ;
@@ -37,7 +36,7 @@ use rustc_session::parse::ParseSess;
37
36
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
38
37
use rustc_span:: { Span , DUMMY_SP } ;
39
38
use std:: ops:: Range ;
40
- use std:: { mem, slice} ;
39
+ use std:: { fmt , mem, slice} ;
41
40
use thin_vec:: ThinVec ;
42
41
use tracing:: debug;
43
42
@@ -146,7 +145,7 @@ pub struct Parser<'a> {
146
145
/// The current token.
147
146
pub token : Token ,
148
147
/// The spacing for the current token.
149
- pub token_spacing : Spacing ,
148
+ token_spacing : Spacing ,
150
149
/// The previous token.
151
150
pub prev_token : Token ,
152
151
pub capture_cfg : bool ,
@@ -187,7 +186,7 @@ pub struct Parser<'a> {
187
186
current_closure : Option < ClosureSpans > ,
188
187
/// Whether the parser is allowed to do recovery.
189
188
/// This is disabled when parsing macro arguments, see #103534
190
- pub recovery : Recovery ,
189
+ recovery : Recovery ,
191
190
}
192
191
193
192
// This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure
@@ -197,10 +196,10 @@ rustc_data_structures::static_assert_size!(Parser<'_>, 264);
197
196
198
197
/// Stores span information about a closure.
199
198
#[ derive( Clone , Debug ) ]
200
- pub struct ClosureSpans {
201
- pub whole_closure : Span ,
202
- pub closing_pipe : Span ,
203
- pub body : Span ,
199
+ struct ClosureSpans {
200
+ whole_closure : Span ,
201
+ closing_pipe : Span ,
202
+ body : Span ,
204
203
}
205
204
206
205
/// Indicates a range of tokens that should be replaced by
@@ -220,13 +219,13 @@ pub struct ClosureSpans {
220
219
/// the first macro inner attribute to invoke a proc-macro).
221
220
/// When create a `TokenStream`, the inner attributes get inserted
222
221
/// into the proper place in the token stream.
223
- pub type ReplaceRange = ( Range < u32 > , Vec < ( FlatToken , Spacing ) > ) ;
222
+ type ReplaceRange = ( Range < u32 > , Vec < ( FlatToken , Spacing ) > ) ;
224
223
225
224
/// Controls how we capture tokens. Capturing can be expensive,
226
225
/// so we try to avoid performing capturing in cases where
227
226
/// we will never need an `AttrTokenStream`.
228
227
#[ derive( Copy , Clone , Debug ) ]
229
- pub enum Capturing {
228
+ enum Capturing {
230
229
/// We aren't performing any capturing - this is the default mode.
231
230
No ,
232
231
/// We are capturing tokens
@@ -374,21 +373,21 @@ pub enum FollowedByType {
374
373
}
375
374
376
375
#[ derive( Copy , Clone , Debug ) ]
377
- pub enum Trailing {
376
+ enum Trailing {
378
377
No ,
379
378
Yes ,
380
379
}
381
380
382
381
#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
383
- pub enum TokenDescription {
382
+ pub ( super ) enum TokenDescription {
384
383
ReservedIdentifier ,
385
384
Keyword ,
386
385
ReservedKeyword ,
387
386
DocComment ,
388
387
}
389
388
390
389
impl TokenDescription {
391
- pub fn from_token ( token : & Token ) -> Option < Self > {
390
+ pub ( super ) fn from_token ( token : & Token ) -> Option < Self > {
392
391
match token. kind {
393
392
_ if token. is_special_ident ( ) => Some ( TokenDescription :: ReservedIdentifier ) ,
394
393
_ if token. is_used_keyword ( ) => Some ( TokenDescription :: Keyword ) ,
@@ -502,7 +501,7 @@ impl<'a> Parser<'a> {
502
501
/// Expect next token to be edible or inedible token. If edible,
503
502
/// then consume it; if inedible, then return without consuming
504
503
/// anything. Signal a fatal error if next token is unexpected.
505
- pub fn expect_one_of (
504
+ fn expect_one_of (
506
505
& mut self ,
507
506
edible : & [ TokenKind ] ,
508
507
inedible : & [ TokenKind ] ,
@@ -572,7 +571,7 @@ impl<'a> Parser<'a> {
572
571
/// the main purpose of this function is to reduce the cluttering of the suggestions list
573
572
/// which using the normal eat method could introduce in some cases.
574
573
#[ inline]
575
- pub fn eat_noexpect ( & mut self , tok : & TokenKind ) -> bool {
574
+ fn eat_noexpect ( & mut self , tok : & TokenKind ) -> bool {
576
575
let is_present = self . check_noexpect ( tok) ;
577
576
if is_present {
578
577
self . bump ( )
@@ -1520,7 +1519,7 @@ impl<'a> Parser<'a> {
1520
1519
}
1521
1520
}
1522
1521
1523
- pub fn collect_tokens_no_attrs < R : HasAttrs + HasTokens > (
1522
+ fn collect_tokens_no_attrs < R : HasAttrs + HasTokens > (
1524
1523
& mut self ,
1525
1524
f : impl FnOnce ( & mut Self ) -> PResult < ' a , R > ,
1526
1525
) -> PResult < ' a , R > {
@@ -1541,8 +1540,10 @@ impl<'a> Parser<'a> {
1541
1540
} )
1542
1541
}
1543
1542
1544
- // debug view of the parser's token stream, up to `{lookahead}` tokens
1545
- pub fn debug_lookahead ( & self , lookahead : usize ) -> impl fmt:: Debug + ' _ {
1543
+ // Debug view of the parser's token stream, up to `{lookahead}` tokens.
1544
+ // Only used when debugging.
1545
+ #[ allow( unused) ]
1546
+ pub ( crate ) fn debug_lookahead ( & self , lookahead : usize ) -> impl fmt:: Debug + ' _ {
1546
1547
struct DebugParser < ' dbg > {
1547
1548
parser : & ' dbg Parser < ' dbg > ,
1548
1549
lookahead : usize ,
@@ -1618,7 +1619,7 @@ pub(crate) fn make_unclosed_delims_error(
1618
1619
/// is then 'parsed' to build up an `AttrTokenStream` with nested
1619
1620
/// `AttrTokenTree::Delimited` tokens.
1620
1621
#[ derive( Debug , Clone ) ]
1621
- pub enum FlatToken {
1622
+ enum FlatToken {
1622
1623
/// A token - this holds both delimiter (e.g. '{' and '}')
1623
1624
/// and non-delimiter tokens
1624
1625
Token ( Token ) ,
0 commit comments