diff options
| author | Josh Stone <jistone@redhat.com> | 2024-01-17 15:40:30 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2024-01-19 20:10:39 -0800 |
| commit | 33e04228262cb7ac76023a94d3811e62518cfc42 (patch) | |
| tree | 060ca76f9a0219acd9f28cc8bf10ef254acb3f31 /compiler/rustc_ast_lowering/src | |
| parent | 167555f36a3b3e7f4a0a685c63d928bbd32f1157 (diff) | |
| download | rust-33e04228262cb7ac76023a94d3811e62518cfc42.tar.gz rust-33e04228262cb7ac76023a94d3811e62518cfc42.zip | |
Pack the u128 in LitKind::Int
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/expr.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 0920de48eb8..cc172b37657 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -1899,7 +1899,10 @@ impl<'hir> LoweringContext<'_, 'hir> { pub(super) fn expr_usize(&mut self, sp: Span, value: usize) -> hir::Expr<'hir> { let lit = self.arena.alloc(hir::Lit { span: sp, - node: ast::LitKind::Int(value as u128, ast::LitIntType::Unsigned(ast::UintTy::Usize)), + node: ast::LitKind::Int( + (value as u128).into(), + ast::LitIntType::Unsigned(ast::UintTy::Usize), + ), }); self.expr(sp, hir::ExprKind::Lit(lit)) } @@ -1907,7 +1910,10 @@ impl<'hir> LoweringContext<'_, 'hir> { pub(super) fn expr_u32(&mut self, sp: Span, value: u32) -> hir::Expr<'hir> { let lit = self.arena.alloc(hir::Lit { span: sp, - node: ast::LitKind::Int(value.into(), ast::LitIntType::Unsigned(ast::UintTy::U32)), + node: ast::LitKind::Int( + u128::from(value).into(), + ast::LitIntType::Unsigned(ast::UintTy::U32), + ), }); self.expr(sp, hir::ExprKind::Lit(lit)) } |
