Skip to content

Commit ccb9972

Browse files
committed
New format_args!()+fmt::Arguments implementation.
1 parent 565aec6 commit ccb9972

File tree

8 files changed

+343
-458
lines changed

8 files changed

+343
-458
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::span_bug;
1313
use rustc_middle::ty::TyCtxt;
1414
use rustc_session::errors::report_lit_error;
1515
use rustc_span::source_map::{Spanned, respan};
16-
use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
16+
use rustc_span::{ByteSymbol, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
1717
use thin_vec::{ThinVec, thin_vec};
1818
use visit::{Visitor, walk_expr};
1919

@@ -2097,30 +2097,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
20972097
self.arena.alloc(self.expr(sp, hir::ExprKind::Tup(&[])))
20982098
}
20992099

2100-
fn expr_uint(&mut self, sp: Span, ty: ast::UintTy, value: u128) -> hir::Expr<'hir> {
2100+
pub(super) fn expr_str(&mut self, sp: Span, value: Symbol) -> hir::Expr<'hir> {
21012101
let lit = hir::Lit {
21022102
span: self.lower_span(sp),
2103-
node: ast::LitKind::Int(value.into(), ast::LitIntType::Unsigned(ty)),
2103+
node: ast::LitKind::Str(value, ast::StrStyle::Cooked),
21042104
};
21052105
self.expr(sp, hir::ExprKind::Lit(lit))
21062106
}
21072107

2108-
pub(super) fn expr_usize(&mut self, sp: Span, value: usize) -> hir::Expr<'hir> {
2109-
self.expr_uint(sp, ast::UintTy::Usize, value as u128)
2110-
}
2111-
2112-
pub(super) fn expr_u32(&mut self, sp: Span, value: u32) -> hir::Expr<'hir> {
2113-
self.expr_uint(sp, ast::UintTy::U32, value as u128)
2114-
}
2115-
2116-
pub(super) fn expr_u16(&mut self, sp: Span, value: u16) -> hir::Expr<'hir> {
2117-
self.expr_uint(sp, ast::UintTy::U16, value as u128)
2118-
}
2119-
2120-
pub(super) fn expr_str(&mut self, sp: Span, value: Symbol) -> hir::Expr<'hir> {
2108+
pub(super) fn expr_byte_str(&mut self, sp: Span, value: ByteSymbol) -> hir::Expr<'hir> {
21212109
let lit = hir::Lit {
21222110
span: self.lower_span(sp),
2123-
node: ast::LitKind::Str(value, ast::StrStyle::Cooked),
2111+
node: ast::LitKind::ByteStr(value, ast::StrStyle::Cooked),
21242112
};
21252113
self.expr(sp, hir::ExprKind::Lit(lit))
21262114
}
@@ -2299,15 +2287,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
22992287
self.arena.alloc(self.expr_block(b))
23002288
}
23012289

2302-
pub(super) fn expr_array_ref(
2303-
&mut self,
2304-
span: Span,
2305-
elements: &'hir [hir::Expr<'hir>],
2306-
) -> hir::Expr<'hir> {
2307-
let array = self.arena.alloc(self.expr(span, hir::ExprKind::Array(elements)));
2308-
self.expr_ref(span, array)
2309-
}
2310-
23112290
pub(super) fn expr_ref(&mut self, span: Span, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
23122291
self.expr(span, hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Not, expr))
23132292
}

0 commit comments

Comments
 (0)