@@ -11,14 +11,13 @@ mod stmt;
1111mod ty;
1212
1313use crate :: lexer:: UnmatchedDelim ;
14- pub use attr_wrapper:: AttrWrapper ;
14+ use attr_wrapper:: AttrWrapper ;
1515pub use diagnostics:: AttemptLocalParseRecovery ;
1616pub ( crate ) use expr:: ForbiddenLetReason ;
1717pub ( crate ) use item:: FnParseMode ;
1818pub use pat:: { CommaRecoveryMode , RecoverColon , RecoverComma } ;
19- pub use path:: PathStyle ;
19+ use path:: PathStyle ;
2020
21- use core:: fmt;
2221use rustc_ast:: ptr:: P ;
2322use rustc_ast:: token:: { self , Delimiter , IdentIsRaw , Nonterminal , Token , TokenKind } ;
2423use rustc_ast:: tokenstream:: { AttributesData , DelimSpacing , DelimSpan , Spacing } ;
@@ -37,7 +36,7 @@ use rustc_session::parse::ParseSess;
3736use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
3837use rustc_span:: { Span , DUMMY_SP } ;
3938use std:: ops:: Range ;
40- use std:: { mem, slice} ;
39+ use std:: { fmt , mem, slice} ;
4140use thin_vec:: ThinVec ;
4241use tracing:: debug;
4342
@@ -146,7 +145,7 @@ pub struct Parser<'a> {
146145 /// The current token.
147146 pub token : Token ,
148147 /// The spacing for the current token.
149- pub token_spacing : Spacing ,
148+ token_spacing : Spacing ,
150149 /// The previous token.
151150 pub prev_token : Token ,
152151 pub capture_cfg : bool ,
@@ -187,7 +186,7 @@ pub struct Parser<'a> {
187186 current_closure : Option < ClosureSpans > ,
188187 /// Whether the parser is allowed to do recovery.
189188 /// This is disabled when parsing macro arguments, see #103534
190- pub recovery : Recovery ,
189+ recovery : Recovery ,
191190}
192191
193192// 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);
197196
198197/// Stores span information about a closure.
199198#[ 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 ,
204203}
205204
206205/// Indicates a range of tokens that should be replaced by
@@ -220,13 +219,13 @@ pub struct ClosureSpans {
220219/// the first macro inner attribute to invoke a proc-macro).
221220/// When create a `TokenStream`, the inner attributes get inserted
222221/// 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 ) > ) ;
224223
225224/// Controls how we capture tokens. Capturing can be expensive,
226225/// so we try to avoid performing capturing in cases where
227226/// we will never need an `AttrTokenStream`.
228227#[ derive( Copy , Clone , Debug ) ]
229- pub enum Capturing {
228+ enum Capturing {
230229 /// We aren't performing any capturing - this is the default mode.
231230 No ,
232231 /// We are capturing tokens
@@ -374,21 +373,21 @@ pub enum FollowedByType {
374373}
375374
376375#[ derive( Copy , Clone , Debug ) ]
377- pub enum Trailing {
376+ enum Trailing {
378377 No ,
379378 Yes ,
380379}
381380
382381#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
383- pub enum TokenDescription {
382+ pub ( super ) enum TokenDescription {
384383 ReservedIdentifier ,
385384 Keyword ,
386385 ReservedKeyword ,
387386 DocComment ,
388387}
389388
390389impl TokenDescription {
391- pub fn from_token ( token : & Token ) -> Option < Self > {
390+ pub ( super ) fn from_token ( token : & Token ) -> Option < Self > {
392391 match token. kind {
393392 _ if token. is_special_ident ( ) => Some ( TokenDescription :: ReservedIdentifier ) ,
394393 _ if token. is_used_keyword ( ) => Some ( TokenDescription :: Keyword ) ,
@@ -502,7 +501,7 @@ impl<'a> Parser<'a> {
502501 /// Expect next token to be edible or inedible token. If edible,
503502 /// then consume it; if inedible, then return without consuming
504503 /// anything. Signal a fatal error if next token is unexpected.
505- pub fn expect_one_of (
504+ fn expect_one_of (
506505 & mut self ,
507506 edible : & [ TokenKind ] ,
508507 inedible : & [ TokenKind ] ,
@@ -572,7 +571,7 @@ impl<'a> Parser<'a> {
572571 /// the main purpose of this function is to reduce the cluttering of the suggestions list
573572 /// which using the normal eat method could introduce in some cases.
574573 #[ inline]
575- pub fn eat_noexpect ( & mut self , tok : & TokenKind ) -> bool {
574+ fn eat_noexpect ( & mut self , tok : & TokenKind ) -> bool {
576575 let is_present = self . check_noexpect ( tok) ;
577576 if is_present {
578577 self . bump ( )
@@ -1520,7 +1519,7 @@ impl<'a> Parser<'a> {
15201519 }
15211520 }
15221521
1523- pub fn collect_tokens_no_attrs < R : HasAttrs + HasTokens > (
1522+ fn collect_tokens_no_attrs < R : HasAttrs + HasTokens > (
15241523 & mut self ,
15251524 f : impl FnOnce ( & mut Self ) -> PResult < ' a , R > ,
15261525 ) -> PResult < ' a , R > {
@@ -1541,8 +1540,10 @@ impl<'a> Parser<'a> {
15411540 } )
15421541 }
15431542
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 + ' _ {
15461547 struct DebugParser < ' dbg > {
15471548 parser : & ' dbg Parser < ' dbg > ,
15481549 lookahead : usize ,
@@ -1618,7 +1619,7 @@ pub(crate) fn make_unclosed_delims_error(
16181619/// is then 'parsed' to build up an `AttrTokenStream` with nested
16191620/// `AttrTokenTree::Delimited` tokens.
16201621#[ derive( Debug , Clone ) ]
1621- pub enum FlatToken {
1622+ enum FlatToken {
16221623 /// A token - this holds both delimiter (e.g. '{' and '}')
16231624 /// and non-delimiter tokens
16241625 Token ( Token ) ,
0 commit comments