Fix clippy warnings
clippy::{filter_next,single_char_pattern,unit_arg,identity_conversion,nonminimal_bool}
This commit is contained in:
parent
835428c35d
commit
139c646251
6 changed files with 12 additions and 13 deletions
|
@ -971,7 +971,7 @@ impl<T> Vec<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let len = self.len();
|
let len = self.len();
|
||||||
if !(index < len) {
|
if index >= len {
|
||||||
assert_failed(index, len);
|
assert_failed(index, len);
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1010,7 +1010,7 @@ impl<T> Vec<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let len = self.len();
|
let len = self.len();
|
||||||
if !(index <= len) {
|
if index > len {
|
||||||
assert_failed(index, len);
|
assert_failed(index, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,7 +1058,7 @@ impl<T> Vec<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let len = self.len();
|
let len = self.len();
|
||||||
if !(index < len) {
|
if index >= len {
|
||||||
assert_failed(index, len);
|
assert_failed(index, len);
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1331,10 +1331,10 @@ impl<T> Vec<T> {
|
||||||
panic!("end drain index (is {}) should be <= len (is {})", end, len);
|
panic!("end drain index (is {}) should be <= len (is {})", end, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(start <= end) {
|
if start > end {
|
||||||
start_assert_failed(start, end);
|
start_assert_failed(start, end);
|
||||||
}
|
}
|
||||||
if !(end <= len) {
|
if end > len {
|
||||||
end_assert_failed(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);
|
panic!("`at` split index (is {}) should be <= len (is {})", at, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(at <= self.len()) {
|
if at > self.len() {
|
||||||
assert_failed(at, self.len());
|
assert_failed(at, self.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
||||||
self.collect_outlives_from_predicate_list(
|
self.collect_outlives_from_predicate_list(
|
||||||
move |ty| ty == identity_proj,
|
move |ty| ty == identity_proj,
|
||||||
traits::elaborate_predicates(tcx, trait_predicates)
|
traits::elaborate_predicates(tcx, trait_predicates)
|
||||||
.into_iter()
|
|
||||||
.map(|o| o.predicate)
|
.map(|o| o.predicate)
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -495,7 +495,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
// to store those. Otherwise, we'll pass in `None` to the
|
// to store those. Otherwise, we'll pass in `None` to the
|
||||||
// functions below, which will trigger them to report errors
|
// functions below, which will trigger them to report errors
|
||||||
// eagerly.
|
// 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);
|
self.check_type_tests(infcx, body, outlives_requirements.as_mut(), &mut errors_buffer);
|
||||||
|
|
||||||
|
|
|
@ -549,7 +549,7 @@ where
|
||||||
let n = base.len(self)?;
|
let n = base.len(self)?;
|
||||||
if n < u64::from(min_length) {
|
if n < u64::from(min_length) {
|
||||||
// This can only be reached in ConstProp and non-rustc-MIR.
|
// 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 {
|
let index = if from_end {
|
||||||
|
|
|
@ -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)
|
(self.tcx.sess.source_map().span_to_snippet(span), &obligation.cause.code)
|
||||||
{
|
{
|
||||||
let generics = self.tcx.generics_of(*def_id);
|
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('>')
|
&& !snippet.ends_with('>')
|
||||||
{
|
{
|
||||||
// FIXME: To avoid spurious suggestions in functions where type arguments
|
// 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.
|
// Account for `fn foo<T>(t: T) where T: Foo,` so we don't suggest two trailing commas.
|
||||||
let mut trailing_comma = false;
|
let mut trailing_comma = false;
|
||||||
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(where_clause_span) {
|
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 where_clause_span = if trailing_comma {
|
||||||
let hi = where_clause_span.hi();
|
let hi = where_clause_span.hi();
|
||||||
|
|
|
@ -16,12 +16,12 @@ use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
macro_rules! try_err {
|
macro_rules! try_err {
|
||||||
($e:expr, $file:expr) => {{
|
($e:expr, $file:expr) => {
|
||||||
match $e {
|
match $e {
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
Err(e) => return Err(E::new(e, $file)),
|
Err(e) => return Err(E::new(e, $file)),
|
||||||
}
|
}
|
||||||
}};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PathError {
|
pub trait PathError {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue