1
Fork 0

Limit formatting width and precision to 16 bits.

This commit is contained in:
Mara Bos 2025-02-12 16:59:13 +01:00
parent 2c6a12ec44
commit fb9ce02976
10 changed files with 69 additions and 46 deletions

View file

@ -2152,6 +2152,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.expr(sp, hir::ExprKind::Lit(lit))
}
pub(super) fn expr_u16(&mut self, sp: Span, value: u16) -> hir::Expr<'hir> {
let lit = self.arena.alloc(hir::Lit {
span: sp,
node: ast::LitKind::Int(
u128::from(value).into(),
ast::LitIntType::Unsigned(ast::UintTy::U16),
),
});
self.expr(sp, hir::ExprKind::Lit(lit))
}
pub(super) fn expr_char(&mut self, sp: Span, value: char) -> hir::Expr<'hir> {
let lit = self.arena.alloc(hir::Lit { span: sp, node: ast::LitKind::Char(value) });
self.expr(sp, hir::ExprKind::Lit(lit))

View file

@ -292,7 +292,7 @@ fn make_count<'hir>(
hir::LangItem::FormatCount,
sym::Is,
));
let value = ctx.arena.alloc_from_iter([ctx.expr_usize(sp, *n)]);
let value = ctx.arena.alloc_from_iter([ctx.expr_u16(sp, *n)]);
ctx.expr_call_mut(sp, count_is, value)
}
Some(FormatCount::Argument(arg)) => {