-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Split MacArgs
in two.
#104559
Split MacArgs
in two.
#104559
Conversation
Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
This shouldn't affect perf, but let's check. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit d12ca878a74b0a5115f6d2437aee163d8536ed3a with merge aeff0eacdd9049f2167cbec2bc220d77283e20f2... |
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d12ca87
to
539fe25
Compare
That's weird... the commit was fine when applied to the earlier revision I was working against, and only broke when applied to a new revision. I thought the tests would have run against the earlier revision? Huh. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 539fe25b517ed1a10b8a3f7e321bf5ec3678abf2 with merge 5c1b781397ab288bb9524bba03b0f8844b4b636c... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (5c1b781397ab288bb9524bba03b0f8844b4b636c): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
The regressions are small enough to be ignored. @rustbot label: +perf-regression-triaged |
From the description it looks similar to closed #96209, I'll check what are the differences. |
compiler/rustc_ast/src/attr/mod.rs
Outdated
use crate::ast::{ | ||
self, AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, DelimArgs, Lit, | ||
LitKind, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem, Path, PathSegment, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you keep the single-line style for imports, here and in other files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The great thing about rustfmt is that it mostly avoids the need to make arbitrary formatting decisions. But here:
use crate::ast::{AttrId, AttrItem, AttrKind, AttrStyle, Attribute};
use crate::ast::{Lit, LitKind};
use crate::ast::{MacArgs, MacArgsEq, MacDelimiter, MetaItem, MetaItemKind, NestedMetaItem};
I have multiple choices: add to the end of the first line, add to the start of the second line, or even combine the first and second line. And this is a relatively clean example where everything is in alphabetical order. We have lots of examples like this one:
use rustc_ast::{attr, BindingAnnotation, ByRef, Term};
use rustc_ast::{GenericArg, MacArgs, MacArgsEq};
use rustc_ast::{GenericBound, SelfKind, TraitBoundModifier};
where alphabetical order is not maintained across lines. Where should I insert an identifier like DelimArgs
here? It could be on any of the lines. That's exactly the kind of arbitrary choice I don't like having to make. The multi-line style avoids this, because rustfmt does it all for you. I think that's why it gets used for cases like this.
Having said that, I'll revert if it's necessary to get r+.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where should I insert an identifier like
DelimArgs
here?
Same as with multi-line imports, into its alphabetic order position.
I think that's why it gets used for cases like this.
For cases like that I'd personally use a glob import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single-line imports are easily greppable, and that's something I do quite regularly, that's why I keep this style in crates that I review and that already use this style.
539fe25
to
4f22a16
Compare
Thanks for being flexible. I still find the And I think this PR is better than #96209 because the |
☔ The latest upstream changes (presumably #104673) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me after fixing the last multi-line import and squashing commits. |
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
4f22a16
to
3e3a419
Compare
@bors r=petrochenkov rollup |
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#103396 (Pin::new_unchecked: discuss pinning closure captures) - rust-lang#104416 (Fix using `include_bytes` in pattern position) - rust-lang#104557 (Add a test case for async dyn* traits) - rust-lang#104559 (Split `MacArgs` in two.) - rust-lang#104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`) - rust-lang#104656 (Move tests) - rust-lang#104657 (Do not check transmute if has non region infer) - rust-lang#104663 (rustdoc: factor out common button CSS) - rust-lang#104666 (Migrate alias search result to CSS variables) - rust-lang#104674 (Make negative_impl and negative_impl_exists take the right types) - rust-lang#104692 (Update test's cfg-if dependency to 1.0) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#103396 (Pin::new_unchecked: discuss pinning closure captures) - rust-lang#104416 (Fix using `include_bytes` in pattern position) - rust-lang#104557 (Add a test case for async dyn* traits) - rust-lang#104559 (Split `MacArgs` in two.) - rust-lang#104597 (Probe + better error messsage for `need_migrate_deref_output_trait_object`) - rust-lang#104656 (Move tests) - rust-lang#104657 (Do not check transmute if has non region infer) - rust-lang#104663 (rustdoc: factor out common button CSS) - rust-lang#104666 (Migrate alias search result to CSS variables) - rust-lang#104674 (Make negative_impl and negative_impl_exists take the right types) - rust-lang#104692 (Update test's cfg-if dependency to 1.0) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
MacArgs
is an enum with three variants:Empty
,Delimited
, andEq
. It's used in two ways:AttrItem
), where all three variants are used.MacCall
andMacroDef
), where only theDelimited
variant is used.In other words,
MacArgs
is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally usingMacArgs::Empty
in aMacCall
).This commit splits
MacArgs
in two:DelimArgs
is a new struct just for the "delimited arguments" case. It is now used inMacCall
andMacroDef
.AttrArgs
is a renaming of the oldMacArgs
enum for the attribute macro case. ItsDelimited
variant now contains aDelimArgs
.Various other related things are renamed as well.
These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
r? @petrochenkov