Skip to content

Commit 139c646

Browse files
committed
Fix clippy warnings
clippy::{filter_next,single_char_pattern,unit_arg,identity_conversion,nonminimal_bool}
1 parent 835428c commit 139c646

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

src/liballoc/vec.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ impl<T> Vec<T> {
971971
}
972972

973973
let len = self.len();
974-
if !(index < len) {
974+
if index >= len {
975975
assert_failed(index, len);
976976
}
977977
unsafe {
@@ -1010,7 +1010,7 @@ impl<T> Vec<T> {
10101010
}
10111011

10121012
let len = self.len();
1013-
if !(index <= len) {
1013+
if index > len {
10141014
assert_failed(index, len);
10151015
}
10161016

@@ -1058,7 +1058,7 @@ impl<T> Vec<T> {
10581058
}
10591059

10601060
let len = self.len();
1061-
if !(index < len) {
1061+
if index >= len {
10621062
assert_failed(index, len);
10631063
}
10641064
unsafe {
@@ -1331,10 +1331,10 @@ impl<T> Vec<T> {
13311331
panic!("end drain index (is {}) should be <= len (is {})", end, len);
13321332
}
13331333

1334-
if !(start <= end) {
1334+
if start > end {
13351335
start_assert_failed(start, end);
13361336
}
1337-
if !(end <= len) {
1337+
if end > len {
13381338
end_assert_failed(end, len);
13391339
}
13401340

@@ -1432,7 +1432,7 @@ impl<T> Vec<T> {
14321432
panic!("`at` split index (is {}) should be <= len (is {})", at, len);
14331433
}
14341434

1435-
if !(at <= self.len()) {
1435+
if at > self.len() {
14361436
assert_failed(at, self.len());
14371437
}
14381438

src/librustc_infer/infer/outlives/verify.rs

-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
297297
self.collect_outlives_from_predicate_list(
298298
move |ty| ty == identity_proj,
299299
traits::elaborate_predicates(tcx, trait_predicates)
300-
.into_iter()
301300
.map(|o| o.predicate)
302301
.collect::<Vec<_>>(),
303302
)

src/librustc_mir/borrow_check/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
495495
// to store those. Otherwise, we'll pass in `None` to the
496496
// functions below, which will trigger them to report errors
497497
// eagerly.
498-
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(|| vec![]);
498+
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(Vec::new);
499499

500500
self.check_type_tests(infcx, body, outlives_requirements.as_mut(), &mut errors_buffer);
501501

src/librustc_mir/interpret/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ where
549549
let n = base.len(self)?;
550550
if n < u64::from(min_length) {
551551
// This can only be reached in ConstProp and non-rustc-MIR.
552-
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n.into() });
552+
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
553553
}
554554

555555
let index = if from_end {

src/librustc_trait_selection/traits/error_reporting/mod.rs

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

src/librustdoc/docfs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use std::sync::mpsc::{channel, Receiver, Sender};
1616
use std::sync::Arc;
1717

1818
macro_rules! try_err {
19-
($e:expr, $file:expr) => {{
19+
($e:expr, $file:expr) => {
2020
match $e {
2121
Ok(e) => e,
2222
Err(e) => return Err(E::new(e, $file)),
2323
}
24-
}};
24+
};
2525
}
2626

2727
pub trait PathError {

0 commit comments

Comments
 (0)