Skip to content

Commit 1c129f7

Browse files
committed
use vec![] macro to create Vector with first item inside instead of pushing to an empty vec![]
slightly reduces code bloat
1 parent 71a6c7c commit 1c129f7

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,8 +2189,7 @@ impl<'a> State<'a> {
21892189
Options(InlineAsmOptions),
21902190
}
21912191

2192-
let mut args = vec![];
2193-
args.push(AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template)));
2192+
let mut args = vec![AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template))];
21942193
args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
21952194
if !asm.options.is_empty() {
21962195
args.push(AsmArg::Options(asm.options));

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,8 +1356,8 @@ impl<'a> State<'a> {
13561356
Options(ast::InlineAsmOptions),
13571357
}
13581358

1359-
let mut args = vec![];
1360-
args.push(AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&asm.template)));
1359+
let mut args =
1360+
vec![AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&asm.template))];
13611361
args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
13621362
if !asm.options.is_empty() {
13631363
args.push(AsmArg::Options(asm.options));

compiler/rustc_mir/src/transform/coverage/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ impl TraverseCoverageGraphWithLoops {
526526
pub fn new(basic_coverage_blocks: &CoverageGraph) -> Self {
527527
let start_bcb = basic_coverage_blocks.start_node();
528528
let backedges = find_loop_backedges(basic_coverage_blocks);
529-
let mut context_stack = Vec::new();
530-
context_stack.push(TraversalContext { loop_backedges: None, worklist: vec![start_bcb] });
529+
let context_stack =
530+
vec![TraversalContext { loop_backedges: None, worklist: vec![start_bcb] }];
531531
// `context_stack` starts with a `TraversalContext` for the main function context (beginning
532532
// with the `start` BasicCoverageBlock of the function). New worklists are pushed to the top
533533
// of the stack as loops are entered, and popped off of the stack when a loop's worklist is

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
124124
self.impl_similar_to(trait_ref, obligation).unwrap_or_else(|| trait_ref.def_id());
125125
let trait_ref = trait_ref.skip_binder();
126126

127-
let mut flags = vec![];
128-
flags.push((
127+
let mut flags = vec![(
129128
sym::ItemContext,
130129
self.describe_enclosure(obligation.cause.body_id).map(|s| s.to_owned()),
131-
));
130+
)];
132131

133132
match obligation.cause.code {
134133
ObligationCauseCode::BuiltinDerivedObligation(..)

0 commit comments

Comments
 (0)