Skip to content

Commit 6e6ba94

Browse files
Auto merge of #148789 - m-ou-se:new-fmt-args-alt, r=<try>
Experiment: New fmt::Arguments implementation (another one)
2 parents a7b3715 + 9f41692 commit 6e6ba94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+690
-934
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 13 additions & 31 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

@@ -924,7 +924,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
924924
arena_vec![self; new_unchecked, get_context],
925925
),
926926
};
927-
self.arena.alloc(self.expr_unsafe(call))
927+
self.arena.alloc(self.expr_unsafe(span, call))
928928
};
929929

930930
// `::std::task::Poll::Ready(result) => break result`
@@ -1826,7 +1826,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18261826
arena_vec![self; iter],
18271827
));
18281828
// `unsafe { ... }`
1829-
let iter = self.arena.alloc(self.expr_unsafe(iter));
1829+
let iter = self.arena.alloc(self.expr_unsafe(head_span, iter));
18301830
let kind = self.make_lowered_await(head_span, iter, FutureKind::AsyncIterator);
18311831
self.arena.alloc(hir::Expr { hir_id: self.next_id(), kind, span: head_span })
18321832
}
@@ -1881,7 +1881,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18811881
arena_vec![self; iter],
18821882
));
18831883
// `unsafe { ... }`
1884-
let iter = self.arena.alloc(self.expr_unsafe(iter));
1884+
let iter = self.arena.alloc(self.expr_unsafe(head_span, iter));
18851885
let inner_match_expr = self.arena.alloc(self.expr_match(
18861886
for_span,
18871887
iter,
@@ -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
}
@@ -2256,9 +2244,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
22562244
self.expr(span, expr_path)
22572245
}
22582246

2259-
fn expr_unsafe(&mut self, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
2247+
pub(super) fn expr_unsafe(
2248+
&mut self,
2249+
span: Span,
2250+
expr: &'hir hir::Expr<'hir>,
2251+
) -> hir::Expr<'hir> {
22602252
let hir_id = self.next_id();
2261-
let span = expr.span;
22622253
self.expr(
22632254
span,
22642255
hir::ExprKind::Block(
@@ -2296,15 +2287,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
22962287
self.arena.alloc(self.expr_block(b))
22972288
}
22982289

2299-
pub(super) fn expr_array_ref(
2300-
&mut self,
2301-
span: Span,
2302-
elements: &'hir [hir::Expr<'hir>],
2303-
) -> hir::Expr<'hir> {
2304-
let array = self.arena.alloc(self.expr(span, hir::ExprKind::Array(elements)));
2305-
self.expr_ref(span, array)
2306-
}
2307-
23082290
pub(super) fn expr_ref(&mut self, span: Span, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
23092291
self.expr(span, hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Not, expr))
23102292
}

0 commit comments

Comments
 (0)