-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
More attribute cleanups #127558
Merged
Merged
More attribute cleanups #127558
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In a `for` loop, instead of a `while` loop.
It makes for shorter code, and fewer allocations.
It's only needed for the `FlatToken::Token` variant. This makes things a little more concise.
The new condition is equivalent in practice, but it's much more obvious that it would result in an empty range, because the condition lines up with the contents of the iterator.
Returning `Vec<TokenTree>` works better for the call sites than returning `TokenStream`.
In various functions where the attribute being processed is known to be a `#[cfg_attr(...)]` attribute. I find this a helpful reminder.
This commit does the following. - Pulls the code out of `AttrTokenStream::to_token_trees` into a new function `attrs_and_tokens_to_token_trees`. - Simplifies `TokenStream::from_ast` by calling the new function. This is nicer than the old way, which created a temporary `AttrTokenStream` containing a single `AttrsTarget` (which required some cloning) just to call `to_token_trees` on it. (It is good to remove this use of `AttrsTarget` which isn't related to `cfg_attr` expansion.)
Explaining things that took me some time to work out.
rustbot
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Jul 10, 2024
@bors r+ |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Jul 13, 2024
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 13, 2024
… r=petrochenkov More attribute cleanups A follow-up to rust-lang#127308. r? `@petrochenkov`
💔 Test failed - checks-actions |
bors
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
and removed
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
labels
Jul 13, 2024
@bors retry |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Jul 13, 2024
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Jul 13, 2024
…s, r=petrochenkov More attribute cleanups A follow-up to rust-lang#127308. r? `@petrochenkov`
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Jul 13, 2024
…s, r=petrochenkov More attribute cleanups A follow-up to rust-lang#127308. r? ``@petrochenkov``
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 13, 2024
…kingjubilee Rollup of 8 pull requests Successful merges: - rust-lang#122300 (Add FileCheck annotations to mir-opt/dest-prop tests) - rust-lang#126967 (Promote the `wasm32-wasip2` target to Tier 2) - rust-lang#127370 (Windows: Add experimental support for linking std-required system DLLs using raw-dylib) - rust-lang#127434 (use "bootstrap" instead of "rustbuild" in comments and docs) - rust-lang#127477 (Clear `inner_attr_ranges` regularly.) - rust-lang#127558 (More attribute cleanups) - rust-lang#127659 (Use ManuallyDrop in BufWriter::into_parts) - rust-lang#127677 (using correct tool mode for `run-make-support` crate) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 14, 2024
…kingjubilee Rollup of 6 pull requests Successful merges: - rust-lang#122300 (Add FileCheck annotations to mir-opt/dest-prop tests) - rust-lang#127434 (use "bootstrap" instead of "rustbuild" in comments and docs) - rust-lang#127477 (Clear `inner_attr_ranges` regularly.) - rust-lang#127558 (More attribute cleanups) - rust-lang#127659 (Use ManuallyDrop in BufWriter::into_parts) - rust-lang#127671 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 8)) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 14, 2024
Rollup merge of rust-lang#127558 - nnethercote:more-Attribute-cleanups, r=petrochenkov More attribute cleanups A follow-up to rust-lang#127308. r? ```@petrochenkov```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A follow-up to #127308.
r? @petrochenkov