diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index ea9eb0cf2742b..a5a4de81f12f6 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1345,8 +1345,7 @@ impl<'hir> LoweringContext<'_, 'hir> { generics .params .iter() - .find(|p| def_id == self.resolver.local_def_id(p.id).to_def_id()) - .is_some() + .any(|p| def_id == self.resolver.local_def_id(p.id).to_def_id()) } // Either the `bounded_ty` is not a plain type parameter, or // it's not found in the generic type parameters list. diff --git a/compiler/rustc_borrowck/src/dataflow.rs b/compiler/rustc_borrowck/src/dataflow.rs index 1e660ece90868..7db8d4520d406 100644 --- a/compiler/rustc_borrowck/src/dataflow.rs +++ b/compiler/rustc_borrowck/src/dataflow.rs @@ -201,7 +201,7 @@ impl<'tcx> OutOfScopePrecomputer<'_, 'tcx> { let bb_data = &self.body[bb]; debug_assert!(hi == bb_data.statements.len()); for &succ_bb in bb_data.terminator().successors() { - if self.visited.insert(succ_bb) == false { + if !self.visited.insert(succ_bb) { if succ_bb == location.block && first_lo > 0 { // `succ_bb` has been seen before. If it wasn't // fully processed, add its first part to `stack` diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 7ca72cbed8de8..246d2e3208cf2 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -972,8 +972,7 @@ fn suggest_ampmut<'tcx>( if let Some(assignment_rhs_span) = opt_assignment_rhs_span { if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) { let is_mutbl = |ty: &str| -> bool { - if ty.starts_with("mut") { - let rest = &ty[3..]; + if let Some(rest) = ty.strip_prefix("mut") { match rest.chars().next() { // e.g. `&mut x` Some(c) if c.is_whitespace() => true, diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 0f88995846cc1..cd78c016caa4f 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -594,7 +594,7 @@ impl<'a> TraitDef<'a> { GenericParamKind::Const { ty, kw_span, .. } => { let const_nodefault_kind = GenericParamKind::Const { ty: ty.clone(), - kw_span: kw_span.clone(), + kw_span: *kw_span, // We can't have default values inside impl block default: None, diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs index 43aa8a6efcec4..0efe5a56436b5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs @@ -130,8 +130,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { .tcx() .sess .struct_span_err(span, &format!("`impl` associated type signature for `{}` doesn't match `trait` associated type signature", item_name)); - err.span_label(impl_sp, &format!("found")); - err.span_label(trait_sp, &format!("expected")); + err.span_label(impl_sp, "found"); + err.span_label(trait_sp, "expected"); err.emit(); } diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 103555a67524f..f2ad72f97eca7 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -230,8 +230,7 @@ fn check_panic_str<'tcx>( Err(_) => (None, None), }; - let mut fmt_parser = - Parser::new(fmt.as_ref(), style, snippet.clone(), false, ParseMode::Format); + let mut fmt_parser = Parser::new(fmt, style, snippet.clone(), false, ParseMode::Format); let n_arguments = (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count(); if n_arguments > 0 && fmt_parser.errors.is_empty() { diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 75b9e2ef62a88..5536cc42a2633 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -363,7 +363,7 @@ impl Collector<'tcx> { .collect::>(); if existing.is_empty() { // Add if not found - let new_name = passed_lib.new_name.as_ref().map(|s| &**s); // &Option -> Option<&str> + let new_name: Option<&str> = passed_lib.new_name.as_deref(); let lib = NativeLib { name: Some(Symbol::intern(new_name.unwrap_or(&passed_lib.name))), kind: passed_lib.kind, diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index fee13fd2e2eaf..0bdf70b3ec488 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -986,7 +986,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { let niche = if def.repr.hide_niche() { None } else { - Niche::from_scalar(dl, Size::ZERO, scalar.clone()) + Niche::from_scalar(dl, Size::ZERO, *scalar) }; if let Some(niche) = niche { match st.largest_niche { @@ -2273,7 +2273,7 @@ where ) -> TyMaybeWithLayout<'tcx> { let tcx = cx.tcx(); let tag_layout = |tag: Scalar| -> TyAndLayout<'tcx> { - let layout = Layout::scalar(cx, tag.clone()); + let layout = Layout::scalar(cx, tag); TyAndLayout { layout: tcx.intern_layout(layout), ty: tag.value.to_ty(tcx) } }; diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 1464ea58ad02c..9a86d465f98ca 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -130,7 +130,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { TerminatorKind::Call { func: exchange_malloc, args: vec![Operand::Move(size), Operand::Move(align)], - destination: Some((Place::from(storage), success)), + destination: Some((storage, success)), cleanup: None, from_hir_call: false, fn_span: expr_span, @@ -153,7 +153,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } // Transmute `*mut u8` to the box (thus far, uninitialized): - let box_ = Rvalue::ShallowInitBox(Operand::Move(Place::from(storage)), value.ty); + let box_ = Rvalue::ShallowInitBox(Operand::Move(storage), value.ty); this.cfg.push_assign(block, source_info, Place::from(result), box_); // initialize the box contents: diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index dfcbd0da3a6e1..9e961f7ba5dd0 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -1068,9 +1068,7 @@ impl<'tcx> SplitWildcard<'tcx> { Missing { nonexhaustive_enum_missing_real_variants: self .iter_missing(pcx) - .filter(|c| !c.is_non_exhaustive()) - .next() - .is_some(), + .any(|c| !c.is_non_exhaustive()), } } else { Missing { nonexhaustive_enum_missing_real_variants: false } diff --git a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs index d7f1ad7f69643..f191911a6c7c1 100644 --- a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs +++ b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs @@ -263,7 +263,7 @@ impl<'a, 'tcx> Helper<'a, 'tcx> { } // check that the value being matched on is the same. The - if this_bb_discr_info.targets_with_values.iter().find(|x| x.0 == value).is_none() { + if !this_bb_discr_info.targets_with_values.iter().any(|x| x.0 == value) { trace!("NO: values being matched on are not the same"); return None; } diff --git a/compiler/rustc_mir_transform/src/normalize_array_len.rs b/compiler/rustc_mir_transform/src/normalize_array_len.rs index 60e71130cd1db..76f0e83c8c3d5 100644 --- a/compiler/rustc_mir_transform/src/normalize_array_len.rs +++ b/compiler/rustc_mir_transform/src/normalize_array_len.rs @@ -111,8 +111,7 @@ impl<'a, 'tcx> Patcher<'a, 'tcx> { Operand::Copy(place) | Operand::Move(place) => { // create new local let ty = operand.ty(self.local_decls, self.tcx); - let local_decl = - LocalDecl::with_source_info(ty, statement.source_info.clone()); + let local_decl = LocalDecl::with_source_info(ty, statement.source_info); let local = self.local_decls.push(local_decl); // make it live let mut make_live_statement = statement.clone(); diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index e7b2a018680ad..ee111fb4e9a83 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1766,8 +1766,7 @@ impl CheckAttrVisitor<'tcx> { fn check_macro_export(&self, hir_id: HirId, attr: &Attribute, target: Target) { if target != Target::MacroDef { self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| { - lint.build(&format!("`#[macro_export]` only has an effect on macro definitions")) - .emit(); + lint.build("`#[macro_export]` only has an effect on macro definitions").emit(); }); } } diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 25ec9682d8407..1193d10d6a7d7 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -278,14 +278,14 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { fn visit_expr(&mut self, expr: &thir::Expr<'tcx>) { self.is_poly |= expr.ty.definitely_has_param_types_or_consts(self.tcx); - if self.is_poly == false { + if !self.is_poly { visit::walk_expr(self, expr) } } fn visit_pat(&mut self, pat: &thir::Pat<'tcx>) { self.is_poly |= pat.ty.definitely_has_param_types_or_consts(self.tcx); - if self.is_poly == false { + if !self.is_poly { visit::walk_pat(self, pat); } } @@ -298,7 +298,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { let mut is_poly_vis = IsThirPolymorphic { is_poly: false, thir: body, tcx }; visit::walk_expr(&mut is_poly_vis, &body[body_id]); debug!("AbstractConstBuilder: is_poly={}", is_poly_vis.is_poly); - if is_poly_vis.is_poly == false { + if !is_poly_vis.is_poly { return Ok(None); } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 1d4196e574782..e24f699adf6b3 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -892,7 +892,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> { match r { ty::ReLateBound(index, br) if *index == self.binder_index => match br.kind { ty::BoundRegionKind::BrNamed(def_id, _name) => { - if self.named_parameters.iter().find(|d| **d == def_id).is_none() { + if !self.named_parameters.iter().any(|d| *d == def_id) { self.named_parameters.push(def_id); } } diff --git a/compiler/rustc_typeck/src/check/callee.rs b/compiler/rustc_typeck/src/check/callee.rs index 4ffb061f7b48e..51bbcbebcdc0b 100644 --- a/compiler/rustc_typeck/src/check/callee.rs +++ b/compiler/rustc_typeck/src/check/callee.rs @@ -329,7 +329,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let obligation = Obligation::new( ObligationCause::dummy_with_span(callee_expr.span), self.param_env, - predicate.clone(), + *predicate, ); let result = self.infcx.evaluate_obligation(&obligation); self.tcx diff --git a/compiler/rustc_typeck/src/check/regionck.rs b/compiler/rustc_typeck/src/check/regionck.rs index 693246a3433e0..79443010fbb3d 100644 --- a/compiler/rustc_typeck/src/check/regionck.rs +++ b/compiler/rustc_typeck/src/check/regionck.rs @@ -413,7 +413,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> { } hir::ExprKind::Match(ref discr, arms, _) => { - self.link_match(discr, &arms[..]); + self.link_match(discr, arms); intravisit::walk_expr(self, expr); } diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 040a880ace947..4e19246314622 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -207,7 +207,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { debug!("Done with crate"); for primitive in Rc::clone(&self.cache).primitive_locations.values() { - self.get_impls(primitive.clone()); + self.get_impls(*primitive); } let mut index = (*self.index).clone().into_inner();