Skip to content

Commit 294f9f3

Browse files
authored
Rollup merge of rust-lang#71179 - matthiaskrgr:cl6ppy, r=Dylan-DPC
fix more clippy warnings
2 parents 7da24a2 + 3837df2 commit 294f9f3

File tree

30 files changed

+111
-124
lines changed

30 files changed

+111
-124
lines changed

src/liballoc/vec.rs

Lines changed: 6 additions & 6 deletions
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_builtin_macros/deriving/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
6363
let span = cx.with_def_site_ctxt(span);
6464
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
6565
let builder = cx.ident_of("debug_trait_builder", span);
66-
let builder_expr = cx.expr_ident(span, builder.clone());
66+
let builder_expr = cx.expr_ident(span, builder);
6767

6868
let fmt = substr.nonself_args[0].clone();
6969

src/librustc_errors/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,7 @@ fn emit_to_destination(
20052005
let _buffer_lock = lock::acquire_global_lock("rustc_errors");
20062006
for (pos, line) in rendered_buffer.iter().enumerate() {
20072007
for part in line {
2008-
dst.apply_style(lvl.clone(), part.style)?;
2008+
dst.apply_style(*lvl, part.style)?;
20092009
write!(dst, "{}", part.text)?;
20102010
dst.reset()?;
20112011
}

src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
871871
return Some(());
872872
}
873873
if let &ty::Adt(def, _) = &ta.kind {
874-
let path_ = self.tcx.def_path_str(def.did.clone());
874+
let path_ = self.tcx.def_path_str(def.did);
875875
if path_ == other_path {
876876
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
877877
return Some(());
@@ -1091,8 +1091,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10911091
let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1);
10921092
let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2);
10931093
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
1094-
let path1 = self.tcx.def_path_str(def1.did.clone());
1095-
let path2 = self.tcx.def_path_str(def2.did.clone());
1094+
let path1 = self.tcx.def_path_str(def1.did);
1095+
let path2 = self.tcx.def_path_str(def2.did);
10961096
if def1.did == def2.did {
10971097
// Easy case. Replace same types with `_` to shorten the output and highlight
10981098
// the differing ones.

src/librustc_infer/infer/outlives/obligations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ where
452452
// even though a satisfactory solution exists.
453453
let generic = GenericKind::Projection(projection_ty);
454454
let verify_bound = self.verify_bound.generic_bound(generic);
455-
self.delegate.push_verify(origin, generic.clone(), region, verify_bound);
455+
self.delegate.push_verify(origin, generic, region, verify_bound);
456456
}
457457
}
458458

src/librustc_infer/infer/outlives/verify.rs

Lines changed: 0 additions & 1 deletion
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/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10561056
place: {:?}",
10571057
place_span.0
10581058
);
1059-
this.reservation_error_reported.insert(place_span.0.clone());
1059+
this.reservation_error_reported.insert(place_span.0);
10601060
}
10611061
Activation(_, activating) => {
10621062
debug!(

src/librustc_mir/borrow_check/region_infer/mod.rs

Lines changed: 1 addition & 1 deletion
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/dataflow/move_paths/builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
286286
// Box starts out uninitialized - need to create a separate
287287
// move-path for the interior so it will be separate from
288288
// the exterior.
289-
self.create_move_path(self.builder.tcx.mk_place_deref(place.clone()));
289+
self.create_move_path(self.builder.tcx.mk_place_deref(*place));
290290
self.gather_init(place.as_ref(), InitKind::Shallow);
291291
} else {
292292
self.gather_init(place.as_ref(), InitKind::Deep);
@@ -458,9 +458,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
458458
for offset in from..to {
459459
let elem =
460460
ProjectionElem::ConstantIndex { offset, min_length: len, from_end: false };
461-
let path = self.add_move_path(base_path, &elem, |tcx| {
462-
tcx.mk_place_elem(base_place.clone(), elem)
463-
});
461+
let path =
462+
self.add_move_path(base_path, &elem, |tcx| tcx.mk_place_elem(base_place, elem));
464463
self.record_move(place, path);
465464
}
466465
} else {

src/librustc_mir/interpret/place.rs

Lines changed: 1 addition & 1 deletion
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 {

0 commit comments

Comments
 (0)