summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_builtin_macros/src/assert/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_builtin_macros/src/assert/context.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/assert/context.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_builtin_macros/src/assert/context.rs b/compiler/rustc_builtin_macros/src/assert/context.rs
index 93b07801e..b0b4dda16 100644
--- a/compiler/rustc_builtin_macros/src/assert/context.rs
+++ b/compiler/rustc_builtin_macros/src/assert/context.rs
@@ -12,7 +12,7 @@ use rustc_span::{
symbol::{sym, Ident, Symbol},
Span,
};
-use thin_vec::thin_vec;
+use thin_vec::{thin_vec, ThinVec};
pub(super) struct Context<'cx, 'a> {
// An optimization.
@@ -83,12 +83,12 @@ impl<'cx, 'a> Context<'cx, 'a> {
let Self { best_case_captures, capture_decls, cx, local_bind_decls, span, .. } = self;
- let mut assert_then_stmts = Vec::with_capacity(2);
+ let mut assert_then_stmts = ThinVec::with_capacity(2);
assert_then_stmts.extend(best_case_captures);
assert_then_stmts.push(self.cx.stmt_expr(panic));
let assert_then = self.cx.block(span, assert_then_stmts);
- let mut stmts = Vec::with_capacity(4);
+ let mut stmts = ThinVec::with_capacity(4);
stmts.push(initial_imports);
stmts.extend(capture_decls.into_iter().map(|c| c.decl));
stmts.extend(local_bind_decls);
@@ -120,7 +120,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
thin_vec![self.cx.attr_nested_word(sym::allow, sym::unused_imports, self.span)],
ItemKind::Use(UseTree {
prefix: self.cx.path(self.span, self.cx.std_path(&[sym::asserting])),
- kind: UseTreeKind::Nested(vec![
+ kind: UseTreeKind::Nested(thin_vec![
nested_tree(self, sym::TryCaptureGeneric),
nested_tree(self, sym::TryCapturePrintable),
]),
@@ -136,7 +136,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
self.cx.expr_call(
self.span,
self.cx.expr_path(self.cx.path(self.span, unlikely_path)),
- vec![self.cx.expr(self.span, ExprKind::Unary(UnOp::Not, cond_expr))],
+ thin_vec![self.cx.expr(self.span, ExprKind::Unary(UnOp::Not, cond_expr))],
)
}
@@ -297,6 +297,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
| ExprKind::Continue(_)
| ExprKind::Err
| ExprKind::Field(_, _)
+ | ExprKind::FormatArgs(_)
| ExprKind::ForLoop(_, _, _, _)
| ExprKind::If(_, _, _)
| ExprKind::IncludedBytes(..)
@@ -338,7 +339,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
let init = self.cx.expr_call(
self.span,
self.cx.expr_path(self.cx.path(self.span, init_std_path)),
- vec![],
+ ThinVec::new(),
);
let capture = Capture { decl: self.cx.stmt_let(self.span, true, ident, init), ident };
self.capture_decls.push(capture);
@@ -365,7 +366,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
self.cx.expr_path(
self.cx.path(self.span, self.cx.std_path(&[sym::asserting, sym::Wrapper])),
),
- vec![self.cx.expr_path(Path::from_ident(local_bind))],
+ thin_vec![self.cx.expr_path(Path::from_ident(local_bind))],
);
let try_capture_call = self
.cx
@@ -377,7 +378,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
ident: Ident::new(sym::try_capture, self.span),
},
expr_paren(self.cx, self.span, self.cx.expr_addr_of(self.span, wrapper)),
- vec![expr_addr_of_mut(
+ thin_vec![expr_addr_of_mut(
self.cx,
self.span,
self.cx.expr_path(Path::from_ident(capture)),
@@ -388,7 +389,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
let local_bind_path = self.cx.expr_path(Path::from_ident(local_bind));
let rslt = if self.is_consumed {
let ret = self.cx.stmt_expr(local_bind_path);
- self.cx.expr_block(self.cx.block(self.span, vec![try_capture_call, ret]))
+ self.cx.expr_block(self.cx.block(self.span, thin_vec![try_capture_call, ret]))
} else {
self.best_case_captures.push(try_capture_call);
local_bind_path
@@ -440,7 +441,7 @@ fn expr_method_call(
cx: &ExtCtxt<'_>,
seg: PathSegment,
receiver: P<Expr>,
- args: Vec<P<Expr>>,
+ args: ThinVec<P<Expr>>,
span: Span,
) -> P<Expr> {
cx.expr(span, ExprKind::MethodCall(Box::new(MethodCall { seg, receiver, args, span })))