Fix clippy warnings

clippy::{filter_next,single_char_pattern,unit_arg,identity_conversion,nonminimal_bool}
This commit is contained in:
Matthias Krüger 2020-04-15 15:15:31 +02:00
parent 835428c35d
commit 139c646251
6 changed files with 12 additions and 13 deletions

View File

@ -971,7 +971,7 @@ impl<T> Vec<T> {
}
let len = self.len();
if !(index < len) {
if index >= len {
assert_failed(index, len);
}
unsafe {
@ -1010,7 +1010,7 @@ impl<T> Vec<T> {
}
let len = self.len();
if !(index <= len) {
if index > len {
assert_failed(index, len);
}
@ -1058,7 +1058,7 @@ impl<T> Vec<T> {
}
let len = self.len();
if !(index < len) {
if index >= len {
assert_failed(index, len);
}
unsafe {
@ -1331,10 +1331,10 @@ impl<T> Vec<T> {
panic!("end drain index (is {}) should be <= len (is {})", end, len);
}
if !(start <= end) {
if start > end {
start_assert_failed(start, end);
}
if !(end <= len) {
if end > len {
end_assert_failed(end, len);
}
@ -1432,7 +1432,7 @@ impl<T> Vec<T> {
panic!("`at` split index (is {}) should be <= len (is {})", at, len);
}
if !(at <= self.len()) {
if at > self.len() {
assert_failed(at, self.len());
}

View File

@ -297,7 +297,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
self.collect_outlives_from_predicate_list(
move |ty| ty == identity_proj,
traits::elaborate_predicates(tcx, trait_predicates)
.into_iter()
.map(|o| o.predicate)
.collect::<Vec<_>>(),
)

View File

@ -495,7 +495,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// to store those. Otherwise, we'll pass in `None` to the
// functions below, which will trigger them to report errors
// eagerly.
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(|| vec![]);
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(Vec::new);
self.check_type_tests(infcx, body, outlives_requirements.as_mut(), &mut errors_buffer);

View File

@ -549,7 +549,7 @@ where
let n = base.len(self)?;
if n < u64::from(min_length) {
// This can only be reached in ConstProp and non-rustc-MIR.
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n.into() });
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
}
let index = if from_end {

View File

@ -1388,7 +1388,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
(self.tcx.sess.source_map().span_to_snippet(span), &obligation.cause.code)
{
let generics = self.tcx.generics_of(*def_id);
if generics.params.iter().filter(|p| p.name.as_str() != "Self").next().is_some()
if generics.params.iter().any(|p| p.name.as_str() != "Self")
&& !snippet.ends_with('>')
{
// FIXME: To avoid spurious suggestions in functions where type arguments
@ -1817,7 +1817,7 @@ pub fn suggest_constraining_type_param(
// Account for `fn foo<T>(t: T) where T: Foo,` so we don't suggest two trailing commas.
let mut trailing_comma = false;
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(where_clause_span) {
trailing_comma = snippet.ends_with(",");
trailing_comma = snippet.ends_with(',');
}
let where_clause_span = if trailing_comma {
let hi = where_clause_span.hi();

View File

@ -16,12 +16,12 @@ use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc;
macro_rules! try_err {
($e:expr, $file:expr) => {{
($e:expr, $file:expr) => {
match $e {
Ok(e) => e,
Err(e) => return Err(E::new(e, $file)),
}
}};
};
}
pub trait PathError {