Add an option to the parser to avoid parsing out of line modules#42071
Add an option to the parser to avoid parsing out of line modules#42071bors merged 1 commit intorust-lang:masterfrom
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
|
ping @nikomatsakis, pinging you on IRC too! |
nikomatsakis
left a comment
There was a problem hiding this comment.
Looks good. r=me with or without changing the order of the arguments to Parser::new
| where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, | ||
| { | ||
| let mut parser = Parser::new(sess, self.tokens.clone(), None, false); | ||
| let mut parser = Parser::new(sess, self.tokens.clone(), None, false, false); |
There was a problem hiding this comment.
Are you just using false here because we don't expect inline modules in attributes? In other words, we don't expect this option to matter here one way or the other, right?
| pub fn new(sess: &'a ParseSess, | ||
| tokens: TokenStream, | ||
| directory: Option<Directory>, | ||
| recurse_into_file_modules: bool, |
There was a problem hiding this comment.
I don't really care, but adding the new argument "next-to-last" seems a bit error-prone, as I imagine people may be inclined add the new argument at the end of the list. More generally, having a lot of booleans is a crappy API, it'd be sort of nice to make this a builder-style thing... but I guess that's for another PR.
There was a problem hiding this comment.
I put it here to be next to the directory option since they are related. My first attempt tried to combine the two into an enum, but it was really grotty. Builder would be best I guess, but yeah, later.
|
@bors: r=nikomatsakis |
|
📌 Commit a256630 has been approved by |
Add an option to the parser to avoid parsing out of line modules This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
Add an option to the parser to avoid parsing out of line modules This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
Add an option to the parser to avoid parsing out of line modules This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
Add an option to the parser to avoid parsing out of line modules This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
Add an option to the parser to avoid parsing out of line modules This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.