crosvm/bin/clippy
Daniel Verkamp 15fadba6ea devices: replace .into_iter() on ref with .iter()
Fixes clippy warning:

  this `.into_iter()` call is equivalent to `.iter()` and will not
  consume the `slice`

https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref

BUG=None
TEST=bin/clippy

Change-Id: Id31c3f6252b86a7f453ab4e6e7dac0ed6654bc52
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885782
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-05-22 00:43:27 +00:00

97 lines
2.5 KiB
Bash
Executable file

#!/bin/bash
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Run `cargo clippy` on all Rust code in crosvm with a mindful set of lints
# suppressed.
set -eo pipefail
USE_CACHE=false
CLIPPY_ARGS=("$@")
# TODO: When we add more options, use a fancier parsing mechanism such as
# getopts. Also use the Rust convention of -- separating the arguments for this
# script itself from the ones for clippy.
if (("$#" > 0)) && [[ "$1" == "--use-cache" ]]; then
USE_CACHE=true
CLIPPY_ARGS=("${CLIPPY_ARGS[@]:1}")
fi
# Change into directory of script, which is crosvm/bin.
cd "$(dirname "${BASH_SOURCE[0]}")"
# Jump up to root directory of crosvm repo.
cd ..
SUPPRESS=(
# TODO(crbug/908640): To be resolved.
borrowed_box
collapsible_if
comparison_chain
extra_unused_lifetimes
for_kv_map
inefficient_to_string
let_unit_value
missing_safety_doc
needless_range_loop
needless_return
option_map_unit_fn
question_mark
range_plus_one
redundant_closure
single_match
slow_vector_initialization
unnecessary_filter_map
unnecessary_mut_passed
unneeded_field_pattern
useless_format
wrong_self_convention
# To be fixed in external libraries
upper_case_acronyms
from_over_into
# False positives affecting WlVfd @ `devices/src/virtio/wl.rs`.
# Bug: https://github.com/rust-lang/rust-clippy/issues/6312
field_reassign_with_default
# We don't care about these lints. Okay to remain suppressed globally.
cast_lossless
cognitive_complexity
enum_variant_names
identity_op
len_without_is_empty
len_zero
match_bool
match_wild_err_arm
module_inception
needless_bool
new_without_default
or_fun_call
should_implement_trait
single_char_pattern
too_many_arguments
transmute_ptr_to_ptr
trivially_copy_pass_by_ref
type_complexity
unreadable_literal
useless_let_if_seq
useless_transmute
new-ret-no-self
)
# Needed or else clippy won't re-run on code that has already compiled.
if [[ "${USE_CACHE}" == false ]]; then
cargo clean
fi
# Need to set pass --sysroot for cargo-clippy manually.
# cf. https://github.com/rust-lang/rust-clippy/issues/3523
RUST_SYSROOT=$(rustc --print sysroot)
RUSTFLAGS="${RUSTFLAGS:-}"
export RUSTFLAGS="$RUSTFLAGS --sysroot=$RUST_SYSROOT"
cargo clippy --all-features --all-targets -- ${SUPPRESS[@]/#/-Aclippy::} \
"${CLIPPY_ARGS[@]}" -D warnings