@@ -2,12 +2,10 @@ mod attr;
22mod expr;
33mod pat;
44mod item;
5- pub use item:: AliasKind ;
65mod module;
7- pub use module:: { ModulePath , ModulePathSuccess } ;
86mod ty;
97mod path;
10- pub use path:: PathStyle ;
8+ crate use path:: PathStyle ;
119mod stmt;
1210mod generics;
1311mod 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
158156impl < ' 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
313311impl 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
334332impl < ' 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) ,
0 commit comments