diff options
| author | cyrgani <ansgar.w.zielke@gmail.com> | 2025-09-07 21:26:24 +0200 |
|---|---|---|
| committer | cyrgani <ansgar.w.zielke@gmail.com> | 2025-09-07 22:09:37 +0200 |
| commit | 1cb749aa3b421db4f918e8befca569166e8ba6ab (patch) | |
| tree | b811b468d789d7dc34c51851db60cbcf339feddf /compiler/rustc_expand | |
| parent | fbd8f95118fff54a2402983d3f446cad9b2f30c5 (diff) | |
| download | rust-1cb749aa3b421db4f918e8befca569166e8ba6ab.tar.gz rust-1cb749aa3b421db4f918e8befca569166e8ba6ab.zip | |
support integer literals in `${concat()}`
Diffstat (limited to 'compiler/rustc_expand')
| -rw-r--r-- | compiler/rustc_expand/src/mbe/transcribe.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index e4e4866b64c..ed8aa71d59d 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -940,11 +940,27 @@ fn extract_symbol_from_pnr<'a>( { Ok(*symbol) } + ParseNtResult::Literal(expr) + if let ExprKind::Lit(lit @ Lit { kind: LitKind::Integer, symbol, suffix }) = + &expr.kind => + { + if lit.is_semantic_float() { + Err(dcx + .struct_err("floats are not supported as metavariables of `${concat(..)}`") + .with_span(span_err)) + } else if suffix.is_none() { + Ok(*symbol) + } else { + Err(dcx + .struct_err("integer metavariables of `${concat(..)}` must not be suffixed") + .with_span(span_err)) + } + } _ => Err(dcx .struct_err( "metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`", ) - .with_note("currently only string literals are supported") + .with_note("currently only string and integer literals are supported") .with_span(span_err)), } } |
