Skip to content

Conversation

jullanggit
Copy link
Contributor

@jullanggit jullanggit commented Aug 31, 2025

Disclaimer

This is my first PR to rust, so if I missed/could improve something about this PR, please excuse and tell me!

The improvement

The metavar_expr_concat feature currently does not seem to support nested repetitions, and throws an ICE without much explanation if the relevant code path is hit.
This PR adds a draft compiler error that attempts to explain the issue. I am not 100% sure what all the ways of triggering this error are, so the message is currently pretty generic, please do correct me if there's something wrong with it or it could be improved.

Thank you for you time!

Fixes #140479.

@rustbot
Copy link
Collaborator

rustbot commented Aug 31, 2025

r? @davidtwco

rustbot has assigned @davidtwco.
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

@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 Aug 31, 2025
@jullanggit
Copy link
Contributor Author

@rustbot label F-macro_metavar_expr_concat

@rustbot rustbot added the F-macro_metavar_expr_concat `#![feature(macro_metavar_expr_concat)]` label Aug 31, 2025
@rust-log-analyzer

This comment has been minimized.

@fmease
Copy link
Member

fmease commented Aug 31, 2025

Please add a regression test, squash your commits and make the error message start with a lower case letter (https://rustc-dev-guide.rust-lang.org/diagnostics.html?highlight=diagnostic#diagnostic-output-style-guide)

@rust-log-analyzer

This comment has been minimized.

@jullanggit
Copy link
Contributor Author

@fmease like this?

@jullanggit jullanggit force-pushed the patch-1 branch 2 times, most recently from 99dc5b4 to 22a770c Compare August 31, 2025 21:50
@rust-log-analyzer

This comment has been minimized.

@jullanggit
Copy link
Contributor Author

I seem to have fixed the crash from #140479, and already covered the issue in my regression test. Should I just remove the crash test?

Replace unimplemented()! with a more helpful compiler error.
@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@jullanggit
Copy link
Contributor Author

Is everything alright now?

@fmease
Copy link
Member

fmease commented Sep 1, 2025

Thanks, we're good!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 1, 2025

📌 Commit f6e7c81 has been approved by fmease

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 Sep 1, 2025
fmease added a commit to fmease/rust that referenced this pull request Sep 1, 2025
Add compiler error when trying to use concat metavar expr in repetitions

## Disclaimer
This is my first PR to rust, so if I missed/could improve something about this PR, please excuse and tell me!
## The improvement
The [metavar_expr_concat feature](rust-lang#124225) currently does not seem to support nested repetitions, and throws an ICE without much explanation if the relevant code path is hit.
This PR adds a draft compiler error that attempts to explain the issue. I am not 100% sure what all the ways of triggering this error are, so the message is currently pretty generic, please do correct me if there's something wrong with it or it could be improved.

Thank you for you time!

Fixes rust-lang#140479.
bors added a commit that referenced this pull request Sep 2, 2025
Rollup of 10 pull requests

Successful merges:

 - #144066 (stabilize c-style varargs for sysv64, win64, efiapi, aapcs)
 - #145783 (add span to struct pattern rest (..))
 - #145961 (resolve: Avoid a regression from splitting prelude into two scopes)
 - #145962 (Ensure we emit an allocator shim when only some crate types need one)
 - #146064 (Add compiler error when trying to use concat metavar expr in repetitions)
 - #146067 (alloc: make Cow From impls const)
 - #146070 (rustdoc-search: skip loading unneeded fnData)
 - #146089 (fix a constness ordering bug in rustfmt)
 - #146094 (Make `Parser::parse_for_head` public for rustfmt usage)
 - #146102 (Remove dead code stemming from an old effects desugaring)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 2, 2025
Add compiler error when trying to use concat metavar expr in repetitions

## Disclaimer
This is my first PR to rust, so if I missed/could improve something about this PR, please excuse and tell me!
## The improvement
The [metavar_expr_concat feature](rust-lang#124225) currently does not seem to support nested repetitions, and throws an ICE without much explanation if the relevant code path is hit.
This PR adds a draft compiler error that attempts to explain the issue. I am not 100% sure what all the ways of triggering this error are, so the message is currently pretty generic, please do correct me if there's something wrong with it or it could be improved.

Thank you for you time!

Fixes rust-lang#140479.
bors added a commit that referenced this pull request Sep 2, 2025
Rollup of 9 pull requests

Successful merges:

 - #145783 (add span to struct pattern rest (..))
 - #145961 (resolve: Avoid a regression from splitting prelude into two scopes)
 - #145962 (Ensure we emit an allocator shim when only some crate types need one)
 - #146064 (Add compiler error when trying to use concat metavar expr in repetitions)
 - #146067 (alloc: make Cow From impls const)
 - #146070 (rustdoc-search: skip loading unneeded fnData)
 - #146089 (fix a constness ordering bug in rustfmt)
 - #146094 (Make `Parser::parse_for_head` public for rustfmt usage)
 - #146102 (Remove dead code stemming from an old effects desugaring)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Sep 2, 2025
Rollup of 14 pull requests

Successful merges:

 - #144066 (stabilize c-style varargs for sysv64, win64, efiapi, aapcs)
 - #145783 (add span to struct pattern rest (..))
 - #146034 (Update target spec metadata of Arm64EC Windows and Trusty targets)
 - #146064 (Add compiler error when trying to use concat metavar expr in repetitions)
 - #146070 (rustdoc-search: skip loading unneeded fnData)
 - #146088 (constify impl Try for ControlFlow)
 - #146089 (fix a constness ordering bug in rustfmt)
 - #146091 (fix rustdoc `render_call_locations`  panicking because of default span `DUMMY_SP` pointing at non local-source file)
 - #146094 (Make `Parser::parse_for_head` public for rustfmt usage)
 - #146102 (Remove dead code stemming from an old effects desugaring)
 - #146115 (Add maintainer for VxWorks)
 - #146116 (Adjust issue-118306.rs test after LLVM change)
 - #146117 (Fix search index generation)
 - #146118 (improve process::abort rendering in Miri backtraces)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7b2bfa3 into rust-lang:master Sep 2, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 2, 2025
rust-timer added a commit that referenced this pull request Sep 2, 2025
Rollup merge of #146064 - jullanggit:patch-1, r=fmease

Add compiler error when trying to use concat metavar expr in repetitions

## Disclaimer
This is my first PR to rust, so if I missed/could improve something about this PR, please excuse and tell me!
## The improvement
The [metavar_expr_concat feature](#124225) currently does not seem to support nested repetitions, and throws an ICE without much explanation if the relevant code path is hit.
This PR adds a draft compiler error that attempts to explain the issue. I am not 100% sure what all the ways of triggering this error are, so the message is currently pretty generic, please do correct me if there's something wrong with it or it could be improved.

Thank you for you time!

Fixes #140479.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-macro_metavar_expr_concat `#![feature(macro_metavar_expr_concat)]` 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.

ICE: expand: unimplemented
6 participants