Skip to content

simplify ast_fragments!#155919

Open
cyrgani wants to merge 5 commits intorust-lang:mainfrom
cyrgani:ast-fragments
Open

simplify ast_fragments!#155919
cyrgani wants to merge 5 commits intorust-lang:mainfrom
cyrgani:ast-fragments

Conversation

@cyrgani
Copy link
Copy Markdown
Contributor

@cyrgani cyrgani commented Apr 28, 2026

The syntax and meaning of this macro are not very intuitive as its just a large dump of function names and has some special cases.
Each commit should be a small improvement that can be evaluated on its own.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 28, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

r? @folkertdev

rustbot has assigned @folkertdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 21 candidates

Comment thread compiler/rustc_expand/src/expand.rs Outdated
| AstFragment::Params(_)
| AstFragment::FieldDefs(_)
| AstFragment::Variants(_)
| AstFragment::WherePredicates(_) => unreachable!(),
Copy link
Copy Markdown
Contributor Author

@cyrgani cyrgani Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a small change in behavior: previously, if the contained SmallVecs were empty, using unreachable_to_string would not panic since there were no elements and it was never called. It now panics in all cases. Is this a problem? (I suppose not)

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this logic is only used in compiler\rustc_expand\src\stats.rs, and only for fragment in macro positions, so things like variants or where clauses should be safe.

Perhaps it would be better to move this function to stats.rs actually.

@folkertdev
Copy link
Copy Markdown
Contributor

r? petrochenkov

@rustbot rustbot assigned petrochenkov and unassigned folkertdev Apr 28, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

r=me after moving the fragment stringification to stats.rs, where its use should be limited to.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants