Skip to content

Commit

Permalink
Refactor: Use borrowed types for arguments (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
2 people authored and tedinski committed Jun 29, 2021
1 parent 7e20534 commit 5e9ddf8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,10 @@ impl Expr {
expr!(IntConstant(i), typ)
}

pub fn typecheck_call(function: &Expr, arguments: &Vec<Expr>) -> bool {
pub fn typecheck_call(function: &Expr, arguments: &[Expr]) -> bool {
// For variadic functions, all named arguments must match the type of their formal param.
// Extra arguments (e.g the ... args) can have any type.
fn typecheck_named_args(parameters: &Vec<Parameter>, arguments: &Vec<Expr>) -> bool {
fn typecheck_named_args(parameters: &[Parameter], arguments: &[Expr]) -> bool {
parameters.iter().zip(arguments.iter()).all(|(p, a)| a.typ() == p.typ())
}

Expand Down Expand Up @@ -577,7 +577,7 @@ impl Expr {
/// ALL fields must be given, including padding
fn struct_expr_with_explicit_padding(
typ: Type,
fields: &Vec<DatatypeComponent>,
fields: &[DatatypeComponent],
values: Vec<Expr>,
) -> Self {
assert_eq!(fields.len(), values.len());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ impl Type {
StructTag(aggr_name(name))
}

pub fn components_are_unique(components: &Vec<DatatypeComponent>) -> bool {
pub fn components_are_unique(components: &[DatatypeComponent]) -> bool {
let mut names: Vec<_> = components.iter().map(|x| x.name()).collect();
names.sort();
names.dedup();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/gotoc/cbmc/irep/to_irep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait ToIrep {
}

/// Utility functions
fn arguments_irep(arguments: &Vec<Expr>, mm: &MachineModel) -> Irep {
fn arguments_irep(arguments: &[Expr], mm: &MachineModel) -> Irep {
Irep {
id: IrepId::Arguments,
sub: arguments.iter().map(|x| x.to_irep(mm)).collect(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl<'tcx> GotocCtx<'tcx> {
pub fn codegen_rvalue_aggregate(
&mut self,
k: &AggregateKind<'tcx>,
operands: &Vec<Operand<'tcx>>,
operands: &[Operand<'tcx>],
res_ty: Ty<'tcx>,
) -> Expr {
match *k {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/gotoc/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl<'tcx> GotocCtx<'tcx> {
fn codegen_funcall(
&mut self,
func: &Operand<'tcx>,
args: &Vec<Operand<'tcx>>,
args: &[Operand<'tcx>],
destination: &Option<(Place<'tcx>, BasicBlock)>,
span: Span,
) -> Stmt {
Expand Down

0 comments on commit 5e9ddf8

Please sign in to comment.