-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add stream_to_parser_with_base_dir #60995
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add stream_to_parser_with_base_dir #60995
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Thanks, @topecongiro! If you add an explanation of the rationale/use-case for the function to the doc comment, I'm fine with adding it. |
Thanks for the review, I added the doc comment in b07dbe1. |
@bors r+ |
📌 Commit b07dbe1 has been approved by |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Oops, sorry, forgot to run the tidy check... fixed it in 1f1a917. |
@bors r+ |
📌 Commit 1f1a917 has been approved by |
…base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from a token stream and a base directory. Context: I would like to parse `cfg_if!` macro and get a list of modules defined inside it from rustfmt so that rustfmt can format those modules (cc rust-lang/rustfmt#3253). To do so, I need to create a parser from `TokenStream` and set the directory of `Parser` to the same directory as the parent directory of a file which contains `cfg_if!` invocation. AFAIK there is no way to achieve this, and hence this PR. Alternatively, I could change the visibility of `Parser.directory` from `crate` to `pub` so that the value can be modified after initializing a parser. I don't have a preference over either approach (or others, as long as it works).
…base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from a token stream and a base directory. Context: I would like to parse `cfg_if!` macro and get a list of modules defined inside it from rustfmt so that rustfmt can format those modules (cc rust-lang/rustfmt#3253). To do so, I need to create a parser from `TokenStream` and set the directory of `Parser` to the same directory as the parent directory of a file which contains `cfg_if!` invocation. AFAIK there is no way to achieve this, and hence this PR. Alternatively, I could change the visibility of `Parser.directory` from `crate` to `pub` so that the value can be modified after initializing a parser. I don't have a preference over either approach (or others, as long as it works).
…base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from a token stream and a base directory. Context: I would like to parse `cfg_if!` macro and get a list of modules defined inside it from rustfmt so that rustfmt can format those modules (cc rust-lang/rustfmt#3253). To do so, I need to create a parser from `TokenStream` and set the directory of `Parser` to the same directory as the parent directory of a file which contains `cfg_if!` invocation. AFAIK there is no way to achieve this, and hence this PR. Alternatively, I could change the visibility of `Parser.directory` from `crate` to `pub` so that the value can be modified after initializing a parser. I don't have a preference over either approach (or others, as long as it works).
…base-dir, r=michaelwoerister Add stream_to_parser_with_base_dir This PR adds `stream_to_parser_with_base_dir`, which creates a parser from a token stream and a base directory. Context: I would like to parse `cfg_if!` macro and get a list of modules defined inside it from rustfmt so that rustfmt can format those modules (cc rust-lang/rustfmt#3253). To do so, I need to create a parser from `TokenStream` and set the directory of `Parser` to the same directory as the parent directory of a file which contains `cfg_if!` invocation. AFAIK there is no way to achieve this, and hence this PR. Alternatively, I could change the visibility of `Parser.directory` from `crate` to `pub` so that the value can be modified after initializing a parser. I don't have a preference over either approach (or others, as long as it works).
Rollup of 10 pull requests Successful merges: - #59742 (Move `edition` outside the hygiene lock and avoid accessing it) - #60581 (convert custom try macro to `?`) - #60963 (Update boxed::Box docs on memory layout) - #60973 (Avoid symbol interning in `file_metadata`.) - #60982 (Do not fail on child without DefId) - #60991 (LocalDecl push returns Local len) - #60995 (Add stream_to_parser_with_base_dir) - #60998 (static_assert: make use of anonymous constants) - #61003 (Remove impls for `InternedString`/string equality.) - #61006 (adjust deprecation date of mem::uninitialized) Failed merges: r? @ghost
This PR adds
stream_to_parser_with_base_dir
, which creates a parser from a token stream and a base directory.Context: I would like to parse
cfg_if!
macro and get a list of modules defined inside it from rustfmt so that rustfmt can format those modules (cc rust-lang/rustfmt#3253). To do so, I need to create a parser fromTokenStream
and set the directory ofParser
to the same directory as the parent directory of a file which containscfg_if!
invocation. AFAIK there is no way to achieve this, and hence this PR.Alternatively, I could change the visibility of
Parser.directory
fromcrate
topub
so that the value can be modified after initializing a parser. I don't have a preference over either approach (or others, as long as it works).