Skip to content

Commit

Permalink
use vec![] macro to create Vector with first item inside instead of p…
Browse files Browse the repository at this point in the history
…ushing to an empty vec![]

slightly reduces code bloat
  • Loading branch information
matthiaskrgr committed Jul 25, 2021
1 parent 71a6c7c commit 1c129f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Expand Up @@ -2189,8 +2189,7 @@ impl<'a> State<'a> {
Options(InlineAsmOptions),
}

let mut args = vec![];
args.push(AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template)));
let mut args = vec![AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template))];
args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
if !asm.options.is_empty() {
args.push(AsmArg::Options(asm.options));
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_pretty/src/lib.rs
Expand Up @@ -1356,8 +1356,8 @@ impl<'a> State<'a> {
Options(ast::InlineAsmOptions),
}

let mut args = vec![];
args.push(AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&asm.template)));
let mut args =
vec![AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&asm.template))];
args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
if !asm.options.is_empty() {
args.push(AsmArg::Options(asm.options));
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/transform/coverage/graph.rs
Expand Up @@ -526,8 +526,8 @@ impl TraverseCoverageGraphWithLoops {
pub fn new(basic_coverage_blocks: &CoverageGraph) -> Self {
let start_bcb = basic_coverage_blocks.start_node();
let backedges = find_loop_backedges(basic_coverage_blocks);
let mut context_stack = Vec::new();
context_stack.push(TraversalContext { loop_backedges: None, worklist: vec![start_bcb] });
let context_stack =
vec![TraversalContext { loop_backedges: None, worklist: vec![start_bcb] }];
// `context_stack` starts with a `TraversalContext` for the main function context (beginning
// with the `start` BasicCoverageBlock of the function). New worklists are pushed to the top
// of the stack as loops are entered, and popped off of the stack when a loop's worklist is
Expand Down
Expand Up @@ -124,11 +124,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
self.impl_similar_to(trait_ref, obligation).unwrap_or_else(|| trait_ref.def_id());
let trait_ref = trait_ref.skip_binder();

let mut flags = vec![];
flags.push((
let mut flags = vec![(
sym::ItemContext,
self.describe_enclosure(obligation.cause.body_id).map(|s| s.to_owned()),
));
)];

match obligation.cause.code {
ObligationCauseCode::BuiltinDerivedObligation(..)
Expand Down

0 comments on commit 1c129f7

Please sign in to comment.