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

syntax: Unify macro and attribute arguments in AST #66935

Merged
merged 6 commits into from Dec 3, 2019

Conversation

@petrochenkov
Copy link
Contributor

petrochenkov commented Dec 1, 2019

The unified form (ast::MacArgs) represents parsed arguments instead of an unstructured token stream that was previously used for attributes.
It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions.

I've been talking about implementing this with @nnethercote in #65750 (comment).
The parsed representation is closer to MetaItem and requires less token juggling during conversions, so it potentially may be faster.

r? @Centril

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Dec 1, 2019

TODO (not in this PR):

  • Eliminate the use of outer_tokens from parse_in_attr (i.e. avoid reconstructing the token stream with delimiters just to re-parse it again immediately). @Centril, you touched this code last, perhaps you can do this? Otherwise I'll try to implement it next weekend.
  • MacArgs is large, for fn-like macros I had to keep it in a Box to keep static_assert_size!(Expr, 96) happy. Perhaps it needs to be boxed for attributes as well, need to measure.
@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Dec 1, 2019

Oh, this PR also basically implements "macro constants" in terms of representation (except they are still an error during parsing).

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Dec 1, 2019

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Dec 1, 2019

Awaiting bors try build completion

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 1, 2019

⌛️ Trying commit eadf48a with merge 6858a2a...

bors added a commit that referenced this pull request Dec 1, 2019
syntax: Unify macro and attribute arguments in AST

The unified form (`ast::MacArgs`) represents parsed arguments instead of an unstructured token stream that was previously used for attributes.
It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions.

I've been talking about implementing this with @nnethercote in #65750 (comment).
The parsed representation is closer to `MetaItem` and requires less token juggling during conversions, so it potentially may be faster.

r? @Centril
Copy link
Member

Centril left a comment

Looks good; some minor nits is all I have.

src/libsyntax/ast.rs Outdated Show resolved Hide resolved
src/libsyntax/ast.rs Show resolved Hide resolved
src/libsyntax/ast.rs Outdated Show resolved Hide resolved
src/libsyntax/ast.rs Outdated Show resolved Hide resolved
src/libsyntax/ast.rs Outdated Show resolved Hide resolved
src/librustc_parse/parser/mod.rs Outdated Show resolved Hide resolved
src/librustc_parse/parser/item.rs Show resolved Hide resolved
src/librustc_parse/lib.rs Show resolved Hide resolved
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 1, 2019

☀️ Try build successful - checks-azure
Build commit: 6858a2a (6858a2a7cb74e10251ba66cd547b555717bfaff2)

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Dec 1, 2019

Queued 6858a2a with parent 4007d4e, future comparison URL.

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Dec 2, 2019

Finished benchmarking try commit 6858a2a, comparison URL.

@nnethercote

This comment has been minimized.

Copy link
Contributor

nnethercote commented Dec 2, 2019

A very slight performance improvement.

@petrochenkov petrochenkov force-pushed the petrochenkov:attrtok2 branch from eadf48a to 498737c Dec 2, 2019
@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Dec 2, 2019

Updated.

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Dec 3, 2019

Thanks! @bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 3, 2019

📌 Commit 498737c has been approved by Centril

Centril added a commit to Centril/rust that referenced this pull request Dec 3, 2019
syntax: Unify macro and attribute arguments in AST

The unified form (`ast::MacArgs`) represents parsed arguments instead of an unstructured token stream that was previously used for attributes.
It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions.

I've been talking about implementing this with @nnethercote in rust-lang#65750 (comment).
The parsed representation is closer to `MetaItem` and requires less token juggling during conversions, so it potentially may be faster.

r? @Centril
bors added a commit that referenced this pull request Dec 3, 2019
Rollup of 9 pull requests

Successful merges:

 - #66405 (Tweak `ObligationForest` `NodeState`s)
 - #66651 (Add `enclosing scope` parameter to `rustc_on_unimplemented`)
 - #66730 (remove dependency from libhermit)
 - #66899 (Standard library support for riscv64gc-unknown-linux-gnu)
 - #66904 (Adding docs for keyword match, move)
 - #66927 (Miri core engine: use throw_ub instead of throw_panic)
 - #66935 (syntax: Unify macro and attribute arguments in AST)
 - #66941 (Remove `ord` lang item)
 - #66967 (Remove hack for top-level or-patterns in match checking)

Failed merges:

r? @ghost
bors added a commit that referenced this pull request Dec 3, 2019
Rollup of 9 pull requests

Successful merges:

 - #66405 (Tweak `ObligationForest` `NodeState`s)
 - #66651 (Add `enclosing scope` parameter to `rustc_on_unimplemented`)
 - #66730 (remove dependency from libhermit)
 - #66899 (Standard library support for riscv64gc-unknown-linux-gnu)
 - #66904 (Adding docs for keyword match, move)
 - #66927 (Miri core engine: use throw_ub instead of throw_panic)
 - #66935 (syntax: Unify macro and attribute arguments in AST)
 - #66941 (Remove `ord` lang item)
 - #66967 (Remove hack for top-level or-patterns in match checking)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Dec 3, 2019
syntax: Unify macro and attribute arguments in AST

The unified form (`ast::MacArgs`) represents parsed arguments instead of an unstructured token stream that was previously used for attributes.
It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions.

I've been talking about implementing this with @nnethercote in rust-lang#65750 (comment).
The parsed representation is closer to `MetaItem` and requires less token juggling during conversions, so it potentially may be faster.

r? @Centril
bors added a commit that referenced this pull request Dec 3, 2019
Rollup of 6 pull requests

Successful merges:

 - #66148 (Show the sign for signed ops on `exact_div`)
 - #66651 (Add `enclosing scope` parameter to `rustc_on_unimplemented`)
 - #66904 (Adding docs for keyword match, move)
 - #66935 (syntax: Unify macro and attribute arguments in AST)
 - #66941 (Remove `ord` lang item)
 - #66967 (Remove hack for top-level or-patterns in match checking)

Failed merges:

r? @ghost
@bors bors merged commit 498737c into rust-lang:master Dec 3, 2019
4 checks passed
4 checks passed
pr #20191202.49 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
flip1995 added a commit to flip1995/rust-clippy that referenced this pull request Dec 3, 2019
@flip1995 flip1995 mentioned this pull request Dec 3, 2019
flip1995 added a commit to flip1995/rust-clippy that referenced this pull request Dec 3, 2019
bors added a commit to rust-lang/rust-clippy that referenced this pull request Dec 3, 2019
Rustup

Included rustups:

- rust-lang/rust#66935 (syntax: Unify macro and attribute arguments in AST)
- rust-lang/rust#66941 (Remove `ord` lang item)

Fixes? #2597

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.