feat(ast): accept arrays for ArenaVec params of AST builder methods (#24621)

Builds on #24620.

Make generated and hand-written AST builder methods take `impl IntoIn<'a, ArenaVec<'a, T>>` instead of `ArenaVec<'a, T>` for their `Vec` params, so callers can pass an array literal (e.g. `[]` or `[a, b]`) in place of building an `ArenaVec` explicitly.

This enables shortening code in a lot of places - #24622 and following PRs.
This commit is contained in:
overlookmotel committed 2026-07-17 13:49:38 +00:00
1 parent f08b152b48
commit 77230c5c4d
3 files changed
+1564 -1044

No files matched your search

+6 -3
View File
@@ -183,12 +183,15 @@ impl<'a> ExportNamedDeclaration<'a> {
/// * `specifiers`
/// * `source`
#[inline]
pub fn boxed_plain<B: GetAstBuilder<'a>>(
pub fn boxed_plain<B: GetAstBuilder<'a>, T1>(
span: Span,
specifiers: ArenaVec<'a, ExportSpecifier<'a>>,
specifiers: T1,
source: Option<StringLiteral<'a>>,
builder: &B,
) -> ArenaBox<'a, Self> {
) -> ArenaBox<'a, Self>
where
T1: IntoIn<'a, ArenaVec<'a, ExportSpecifier<'a>>>,
{
ExportNamedDeclaration::boxed(
span,
None,
File diff suppressed because it is too large. Load diff
@@ -324,7 +324,7 @@ fn get_struct_params<'s>(
str_generic_count += 1;
Some((format_ident!("S{str_generic_count}"), GenericType::Into))
}
TypeDef::Box(_) => {
TypeDef::Box(_) | TypeDef::Vec(_) => {
generic_count += 1;
Some((format_ident!("T{generic_count}"), GenericType::IntoIn))
}