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

[macro_metavar_expr_concat] Allow concat in repetitions #127720

Merged
merged 1 commit into from
Jul 21, 2024

Conversation

c410-f3r
Copy link
Contributor

@c410-f3r c410-f3r commented Jul 14, 2024

cc #127723

@rustbot
Copy link
Collaborator

rustbot commented Jul 14, 2024

r? @cjgillot

rustbot has assigned @cjgillot.
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 Jul 14, 2024
@cjgillot cjgillot 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 Jul 14, 2024
@Noratrieb
Copy link
Member

I created a new issue for the problem and referenced that in your description, your previous "fixes" would have closed the tracking issue.

Copy link
Contributor Author

@c410-f3r c410-f3r left a comment

Choose a reason for hiding this comment

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

@rustbot review

compiler/rustc_expand/src/mbe/metavar_expr.rs Outdated Show resolved Hide resolved
compiler/rustc_expand/src/mbe/transcribe.rs Show resolved Hide resolved
compiler/rustc_expand/src/mbe/transcribe.rs Show resolved Hide resolved
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 15, 2024
@bors
Copy link
Contributor

bors commented Jul 18, 2024

☔ The latest upstream changes (presumably #127892) made this pull request unmergeable. Please resolve the merge conflicts.

@c410-f3r
Copy link
Contributor Author

@cjgillot If preferable, the dice of rustbot can be re-rolled

match *self {
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(ident),
MetaVarExpr::Concat { .. } | MetaVarExpr::Index(..) | MetaVarExpr::Len(..) => None,
pub(crate) fn metavars<A>(&self, mut aux: A, mut cb: impl FnMut(A, &Ident) -> A) -> A {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we get this signature?
This would make the logic a bit easier to read in consumer code.

Suggested change
pub(crate) fn metavars<A>(&self, mut aux: A, mut cb: impl FnMut(A, &Ident) -> A) -> A {
pub(crate) fn for_each_metavar(&self, mut cb: impl FnMut(&Ident)) {

Copy link
Contributor Author

@c410-f3r c410-f3r Jul 20, 2024

Choose a reason for hiding this comment

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

That was my first attempt. Unfortunately, LockstepIterSize::with takes ownership.

The name has been changed.

compiler/rustc_expand/src/mbe/transcribe.rs Show resolved Hide resolved
dcx: DiagCtxtHandle<'a>,
ident: Ident,
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
pnr: &ParseNtResult,
) -> PResult<'a, Symbol> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make all this a match?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored to use match but it is important to note that the only diff in this function is the removal of the outer most block.

@@ -752,39 +763,37 @@ fn transcribe_metavar_expr<'a>(
}

/// Extracts an metavariable symbol that can be an identifier, a token tree or a literal.
fn extract_var_symbol<'a>(
fn extract_symbol_from_pnr<'a>(
Copy link
Contributor

Choose a reason for hiding this comment

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

The jargon is getting a bit obscure. It took me a while to figure what a pnr is. "Parc Naturel Régional"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Non, ce n'est pas "Parc Naturel Régional" :)

pnr is in the function signature and extract_symbol_from_parse_nt_result would be too long IMO.

@@ -752,39 +763,37 @@ fn transcribe_metavar_expr<'a>(
}

/// Extracts an metavariable symbol that can be an identifier, a token tree or a literal.
fn extract_var_symbol<'a>(
fn extract_symbol_from_pnr<'a>(
dcx: DiagCtxtHandle<'a>,
ident: Ident,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we only pass the span? It may be interesting to document that it's meant for error reporting only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

@cjgillot cjgillot 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 Jul 19, 2024
@c410-f3r
Copy link
Contributor Author

@rustbot review

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

@bors r+

@bors
Copy link
Contributor

bors commented Jul 20, 2024

📌 Commit b8d4e4d has been approved by cjgillot

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 20, 2024
@c410-f3r
Copy link
Contributor Author

Thanks

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 20, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#127720 ([`macro_metavar_expr_concat`] Allow `concat` in repetitions)
 - rust-lang#127734 (Windows: move BSD socket shims to netc)
 - rust-lang#127752 (Ignore allocation bytes in one more mir-opt test)
 - rust-lang#127839 (Fix git safe-directory path for docker images)
 - rust-lang#127867 (Add `wasm32-wasip2` to `build-manifest` tool)
 - rust-lang#127958 (Cleanup rmake.rs setup in compiletest)
 - rust-lang#127975 (Fix trait bounds display)
 - rust-lang#128005 (Remove _tls_used hack)

r? `@ghost`
`@rustbot` modify labels: rollup
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jul 20, 2024
[`macro_metavar_expr_concat`] Allow `concat` in repetitions

cc rust-lang#127723
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 21, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#127720 ([`macro_metavar_expr_concat`] Allow `concat` in repetitions)
 - rust-lang#127734 (Windows: move BSD socket shims to netc)
 - rust-lang#127752 (Ignore allocation bytes in one more mir-opt test)
 - rust-lang#127839 (Fix git safe-directory path for docker images)
 - rust-lang#127867 (Add `wasm32-wasip2` to `build-manifest` tool)
 - rust-lang#127958 (Cleanup rmake.rs setup in compiletest)
 - rust-lang#127975 (Fix trait bounds display)
 - rust-lang#128005 (Remove _tls_used hack)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fba6e1e into rust-lang:master Jul 21, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 21, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 21, 2024
…mpiler-errors

Rollup of 7 pull requests

Successful merges:

 - rust-lang#126450 (Promote Mac Catalyst targets to Tier 2, and ship with rustup)
 - rust-lang#127177 (Distribute rustc_codegen_cranelift for arm64 macOS)
 - rust-lang#127510 (Rewrite `test-float-parse` in Rust)
 - rust-lang#127720 ([`macro_metavar_expr_concat`] Allow `concat` in repetitions)
 - rust-lang#127734 (Windows: move BSD socket shims to netc)
 - rust-lang#127839 (Fix git safe-directory path for docker images)
 - rust-lang#128005 (Remove _tls_used hack)

r? `@ghost`
`@rustbot` modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 21, 2024
Rollup merge of rust-lang#127720 - c410-f3r:concat-rep, r=cjgillot

[`macro_metavar_expr_concat`] Allow `concat` in repetitions

cc rust-lang#127723
@cuviper cuviper modified the milestones: 1.81.0, 1.82.0 Aug 15, 2024
@tgross35 tgross35 added the F-macro_metavar_expr_concat `#![feature(macro_metavar_expr_concat)]` label Aug 24, 2024
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.

7 participants