Skip to content

Commit 21bfe52

Browse files
authored
Rollup merge of #75270 - matthiaskrgr:clippy_aug_1, r=Dylan-DPC
fix a couple of clippy findings
2 parents 81546de + a605e51 commit 21bfe52

File tree

27 files changed

+48
-53
lines changed

27 files changed

+48
-53
lines changed

library/test/src/helpers/concurrency.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::env;
44

55
#[allow(deprecated)]
66
pub fn get_concurrency() -> usize {
7-
return match env::var("RUST_TEST_THREADS") {
7+
match env::var("RUST_TEST_THREADS") {
88
Ok(s) => {
99
let opt_n: Option<usize> = s.parse().ok();
1010
match opt_n {
@@ -13,7 +13,7 @@ pub fn get_concurrency() -> usize {
1313
}
1414
}
1515
Err(..) => num_cpus(),
16-
};
16+
}
1717
}
1818

1919
cfg_if::cfg_if! {

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,15 +960,15 @@ fn pointer_type_metadata(
960960
fn param_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
961961
debug!("param_type_metadata: {:?}", t);
962962
let name = format!("{:?}", t);
963-
return unsafe {
963+
unsafe {
964964
llvm::LLVMRustDIBuilderCreateBasicType(
965965
DIB(cx),
966966
name.as_ptr().cast(),
967967
name.len(),
968968
Size::ZERO.bits(),
969969
DW_ATE_unsigned,
970970
)
971-
};
971+
}
972972
}
973973

974974
pub fn compile_unit_metadata(

src/librustc_codegen_ssa/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
490490
let _timer = sess.timer("copy_all_cgu_workproducts_to_incr_comp_cache_dir");
491491

492492
for module in compiled_modules.modules.iter().filter(|m| m.kind == ModuleKind::Regular) {
493-
let path = module.object.as_ref().map(|path| path.clone());
493+
let path = module.object.as_ref().cloned();
494494

495495
if let Some((id, product)) =
496496
copy_cgu_workproduct_to_incr_comp_cache_dir(sess, &module.name, &path)

src/librustc_infer/infer/error_reporting/nice_region_error/named_anon_conflict.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8585

8686
debug!("try_report_named_anon_conflict: ret ty {:?}", ty);
8787
if sub == &ty::ReStatic
88-
&& v.0
89-
.into_iter()
90-
.filter(|t| t.span.desugaring_kind().is_none())
91-
.next()
92-
.is_some()
88+
&& v.0.into_iter().find(|t| t.span.desugaring_kind().is_none()).is_some()
9389
{
9490
// If the failure is due to a `'static` requirement coming from a `dyn` or
9591
// `impl` Trait that *isn't* caused by `async fn` desugaring, handle this case

src/librustc_infer/infer/error_reporting/nice_region_error/static_impl_trait.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
257257
param.param_ty.to_string(),
258258
Applicability::MaybeIncorrect,
259259
);
260-
} else if let Some(_) = opaque
260+
} else if opaque
261261
.bounds
262262
.iter()
263263
.filter_map(|arg| match arg {
@@ -269,6 +269,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
269269
_ => None,
270270
})
271271
.next()
272+
.is_some()
272273
{
273274
} else {
274275
err.span_suggestion_verbose(

src/librustc_infer/infer/glb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
5050
ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b),
5151
ty::Covariant => self.relate(a, b),
5252
// FIXME(#41044) -- not correct, need test
53-
ty::Bivariant => Ok(a.clone()),
53+
ty::Bivariant => Ok(a),
5454
ty::Contravariant => self.fields.lub(self.a_is_expected).relate(a, b),
5555
}
5656
}
@@ -97,7 +97,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
9797
// very challenging, switch to invariance. This is obviously
9898
// overly conservative but works ok in practice.
9999
self.relate_with_variance(ty::Variance::Invariant, a, b)?;
100-
Ok(a.clone())
100+
Ok(a)
101101
}
102102
}
103103

src/librustc_infer/infer/nll_relate/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ where
719719
self.a_scopes.pop().unwrap();
720720
}
721721

722-
Ok(a.clone())
722+
Ok(a)
723723
}
724724
}
725725

src/librustc_infer/infer/region_constraints/leak_check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ impl<'me, 'tcx> LeakCheck<'me, 'tcx> {
288288
) -> TypeError<'tcx> {
289289
debug!("error: placeholder={:?}, other_region={:?}", placeholder, other_region);
290290
if self.overly_polymorphic {
291-
return TypeError::RegionsOverlyPolymorphic(placeholder.name, other_region);
291+
TypeError::RegionsOverlyPolymorphic(placeholder.name, other_region)
292292
} else {
293-
return TypeError::RegionsInsufficientlyPolymorphic(placeholder.name, other_region);
293+
TypeError::RegionsInsufficientlyPolymorphic(placeholder.name, other_region)
294294
}
295295
}
296296
}

src/librustc_infer/infer/sub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
6868
match variance {
6969
ty::Invariant => self.fields.equate(self.a_is_expected).relate(a, b),
7070
ty::Covariant => self.relate(a, b),
71-
ty::Bivariant => Ok(a.clone()),
71+
ty::Bivariant => Ok(a),
7272
ty::Contravariant => self.with_expected_switched(|this| this.relate(b, a)),
7373
}
7474
}

src/librustc_lint/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
10741074
}
10751075
// If `ty` is a `repr(transparent)` newtype, and the non-zero-sized type is a generic
10761076
// argument, which after substitution, is `()`, then this branch can be hit.
1077-
FfiResult::FfiUnsafe { ty, .. } if is_return_type && ty.is_unit() => return,
1077+
FfiResult::FfiUnsafe { ty, .. } if is_return_type && ty.is_unit() => {}
10781078
FfiResult::FfiUnsafe { ty, reason, help } => {
10791079
self.emit_ffi_unsafe_type_lint(ty, sp, &reason, help.as_deref());
10801080
}

0 commit comments

Comments
 (0)