-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proc_macro: Implementation of Extend (parameterized over Group, Ident, Punct, and Literal) for TokenStream #242
Comments
Seconded. Please send PR. |
|
Development ProgressIt's my first contribution to the standard library so I might make some silly mistakes as I make it happen. In order to make the development of the PR more transparent, I'll document what I'm doing along the way. Steps takenFound Standard library developers Guide. Took a mental note of the Standard library developers Guide > 2. Building and debugging libraries,
From Rust Compiler Development Guide > Getting Started I learned about mentored issues. Q: What are the benefits? It looks like I could use some help. Followed Rust Compiler Development Guide > Building and debugging rustc > 1. How to build and run the compiler and shallow-cloned the repo, as suggested. Tried
Q: should the doc be updated to make it aware of Windows? Tried Installed Q: I guess I should report this bug later? Forked rust-lang/rust, thereby getting JohnScience/rust. Shallow-cloned and setup the fork. Started adding a new feature gate by following Rust Compiler Development Guide > Contributing to Rust > 15. Feature Gates: Q: I do need to add another feature gate, right?
Q: should the chapter on feature gates in Rust Compiler Development Guide be updated to add this info?
To resolve the error and pass the git hook used for the development of
// gate-test-ts_extend_w_tt_item
// compile-flags: --error-format human --edition 2018
// check-pass
// aux-build:feature-gate-ts_extend_w_tt_item.rs
extern crate feature_gate_ts_extend_w_tt_item;
fn main() {
// Add test code here that uses the feature gated by ts_extend_w_tt_item.
// Make sure the code compiles and runs correctly when the feature is enabled.
} Let's break down the contents of the file:
Save the file, commit your changes, and push them to your fork of
Q: I haven't found the list of the comments in the Rust Compiler Development Guide. Is it a thing that is yet to be documented?
Q: Can't git hook either propose changes or apply them automatically?
and after asking on official Discord server in
Implementation statusStatus: Postponed until the beginning of August Possible statusesActive - doing the work. |
That documentation is for compiler features. For library features, you don't need to touch any files in This specific feature however are trait implementations (for already stable types and trait), which unfortunately cannot be unstable. So your PR would need to add these implementations as stable right away (and requires team signoff through an FCP). |
@JohnScience this is extremely helpful, thank you ❤️ i don't have time right now but i plan to improve several of the issues you mentioned this weekend |
@jyn514 and I just agreed to spend some time working together to make sure the rustc and std dev guides cover these things better and refer to each other in the proper places. Stay tuned. :) Thanks for documenting your experience, @JohnScience. |
I've opened https://github.com/rust-lang/rustc-dev-guide/pull/1701/files?short_path=cdf7c1e#diff-cdf7c1e6d2d1ec81510204b0c3250cb2c90880843f005bb942bafb84996a90b0 to improve the docs here.
I made this error from tidy more helpful in https://github.com/rust-lang/rust/pull/113008/files#diff-31008ceb5198220e3ec8834cac868728b9db572697eb5a14e48b402edc9c2246.
I cannot replicate this bug. It looks like you're using cmd.exe, but when I run
We do not really support
This is documented at https://rustc-dev-guide.rust-lang.org/tests/headers.html#header-commands. I'm not sure how to make it easier to find.
Can you talk more about the error you ran into here? do you mean this?
it would be helpful if you could open an issue on rust-lang/rust asking for this to be |
…s, r=clubby789 Move some docs from the README to the dev-guide and as a drive-by cleanup, improve the error message for `x test tidy` when a feature gate is missing. This also improves the error message you get on Windows if python isn't installed. cc rust-lang/libs-team#242 (comment), rust-lang/rustc-dev-guide#1701
Proposal
Problem statement
At the moment of writing,
proc_macro::TokenStream
implements parametrizations ofcore::iter::Extend
overproc_macro::TokenStream
andproc_macro::TokenTree
, i.e.Extend<TokenStream>
andExtend<TokenTree>
. However, it is not implemented for parametrizations ofExtend
overproc_macro::Group
proc_macro::Ident
proc_macro::Punct
proc_macro::Literal
which all can can be stored in respective variants of
TokenTree
.I believe that this is a problem because it either
Group
,Ident
,Punct
, orLiteral
, is added to aTokenStream
, as will be demonstrated further; orExtend
that they would implement forTokenStream
, either manually or using a non-standard library.Such inconveniences could push developers use
quote
, which results in higher compile times, even in situations whereproc_macro
with the proposed changes would suffice.Also, it probably results in higher compile times in projects which extensively use procedural macros because these macros have to generate more Rust syntax.
Motivating examples or use cases
Before:
After:
Once (or when)
Extend::extend_one
stabilizes, the difference will be even more noticeable.Before:
After:
Solution sketch
Alternatives
Leave it as it is and delegate the implementation to a non-standard library via an extension trait that would be a twin of
Extend
. I dislike this approach because all these types belong to standard libraries and it would result in unnecessary complexity.Links and related work
proc_macro::TokenStream
should implement Extend<proc_macro::Group>, etc ".The text was updated successfully, but these errors were encountered: