Skip to content

Commit d66d15b

Browse files
committed
New format_args!()+fmt::Arguments implementation.
1 parent 756751b commit d66d15b

File tree

8 files changed

+363
-464
lines changed

8 files changed

+363
-464
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

@@ -2103,30 +2103,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
21032103
self.arena.alloc(self.expr(sp, hir::ExprKind::Tup(&[])))
21042104
}
21052105

2106-
fn expr_uint(&mut self, sp: Span, ty: ast::UintTy, value: u128) -> hir::Expr<'hir> {
2106+
pub(super) fn expr_str(&mut self, sp: Span, value: Symbol) -> hir::Expr<'hir> {
21072107
let lit = hir::Lit {
21082108
span: self.lower_span(sp),
2109-
node: ast::LitKind::Int(value.into(), ast::LitIntType::Unsigned(ty)),
2109+
node: ast::LitKind::Str(value, ast::StrStyle::Cooked),
21102110
};
21112111
self.expr(sp, hir::ExprKind::Lit(lit))
21122112
}
21132113

2114-
pub(super) fn expr_usize(&mut self, sp: Span, value: usize) -> hir::Expr<'hir> {
2115-
self.expr_uint(sp, ast::UintTy::Usize, value as u128)
2116-
}
2117-
2118-
pub(super) fn expr_u32(&mut self, sp: Span, value: u32) -> hir::Expr<'hir> {
2119-
self.expr_uint(sp, ast::UintTy::U32, value as u128)
2120-
}
2121-
2122-
pub(super) fn expr_u16(&mut self, sp: Span, value: u16) -> hir::Expr<'hir> {
2123-
self.expr_uint(sp, ast::UintTy::U16, value as u128)
2124-
}
2125-
2126-
pub(super) fn expr_str(&mut self, sp: Span, value: Symbol) -> hir::Expr<'hir> {
2114+
pub(super) fn expr_byte_str(&mut self, sp: Span, value: ByteSymbol) -> hir::Expr<'hir> {
21272115
let lit = hir::Lit {
21282116
span: self.lower_span(sp),
2129-
node: ast::LitKind::Str(value, ast::StrStyle::Cooked),
2117+
node: ast::LitKind::ByteStr(value, ast::StrStyle::Cooked),
21302118
};
21312119
self.expr(sp, hir::ExprKind::Lit(lit))
21322120
}
@@ -2305,15 +2293,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
23052293
self.arena.alloc(self.expr_block(b))
23062294
}
23072295

2308-
pub(super) fn expr_array_ref(
2309-
&mut self,
2310-
span: Span,
2311-
elements: &'hir [hir::Expr<'hir>],
2312-
) -> hir::Expr<'hir> {
2313-
let array = self.arena.alloc(self.expr(span, hir::ExprKind::Array(elements)));
2314-
self.expr_ref(span, array)
2315-
}
2316-
23172296
pub(super) fn expr_ref(&mut self, span: Span, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
23182297
self.expr(span, hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Not, expr))
23192298
}

0 commit comments

Comments
 (0)