Skip to content
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 9 commits into from
Jul 14, 2024
Merged

Conversation

nnethercote
Copy link
Contributor

A follow-up to #127308.

r? @petrochenkov

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 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
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 13, 2024

📌 Commit 478ba59 has been approved by petrochenkov

It is now in the queue for this repository.

@bors 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`
@bors
Copy link
Contributor

bors commented Jul 13, 2024

⌛ Testing commit 478ba59 with merge 7aef878...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-ext failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Jul 13, 2024

💔 Test failed - checks-actions

@bors 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
@petrochenkov
Copy link
Contributor

@bors retry

@bors 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
@bors bors merged commit 125343e into rust-lang:master Jul 14, 2024
6 of 7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 14, 2024
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```
@nnethercote nnethercote deleted the more-Attribute-cleanups branch July 14, 2024 20:26
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants