-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
I created a new issue for the problem and referenced that in your description, your previous "fixes" would have closed the tracking issue. |
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.
@rustbot review
☔ The latest upstream changes (presumably #127892) made this pull request unmergeable. Please resolve the merge conflicts. |
@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 { |
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 we get this signature?
This would make the logic a bit easier to read in consumer code.
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)) { |
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.
That was my first attempt. Unfortunately, LockstepIterSize::with
takes ownership.
The name has been changed.
dcx: DiagCtxtHandle<'a>, | ||
ident: Ident, | ||
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>, | ||
pnr: &ParseNtResult, | ||
) -> PResult<'a, Symbol> { |
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 make all this a match
?
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.
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>( |
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 jargon is getting a bit obscure. It took me a while to figure what a pnr
is. "Parc Naturel Régional"?
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.
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, |
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.
Should we only pass the span? It may be interesting to document that it's meant for error reporting only.
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.
Changed
@rustbot review |
@bors r+ |
Thanks |
…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
[`macro_metavar_expr_concat`] Allow `concat` in repetitions cc rust-lang#127723
…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
…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
Rollup merge of rust-lang#127720 - c410-f3r:concat-rep, r=cjgillot [`macro_metavar_expr_concat`] Allow `concat` in repetitions cc rust-lang#127723
cc #127723