diff --git a/CHANGELOG.md b/CHANGELOG.md index b28075d8eb31..098ec88e7186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5013,6 +5013,7 @@ Released 2018-09-13 [`explicit_deref_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_deref_methods [`explicit_into_iter_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_into_iter_loop [`explicit_iter_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop +[`explicit_reinitialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_reinitialization [`explicit_write`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_write [`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice [`extend_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_with_drain diff --git a/clippy_config/src/metadata.rs b/clippy_config/src/metadata.rs index 2451fbc91e89..6be76233ab2a 100644 --- a/clippy_config/src/metadata.rs +++ b/clippy_config/src/metadata.rs @@ -90,7 +90,7 @@ fn parse_config_field_doc(doc_comment: &str) -> Option<(Vec, String)> { && let Some(split_pos) = doc_comment.find('.') { let mut doc_comment = doc_comment.to_string(); - let mut documentation = doc_comment.split_off(split_pos); + let documentation = doc_comment.split_off(split_pos); // Extract lints doc_comment.make_ascii_lowercase(); @@ -102,7 +102,7 @@ fn parse_config_field_doc(doc_comment: &str) -> Option<(Vec, String)> { // Format documentation correctly // split off leading `.` from lint name list and indent for correct formatting - documentation = documentation.trim_start_matches('.').trim().replace("\n ", "\n "); + let documentation = documentation.trim_start_matches('.').trim().replace("\n ", "\n "); Some((lints, documentation)) } else { diff --git a/clippy_dev/src/update_lints.rs b/clippy_dev/src/update_lints.rs index 6b76a44debff..2ecb319eb74a 100644 --- a/clippy_dev/src/update_lints.rs +++ b/clippy_dev/src/update_lints.rs @@ -450,7 +450,7 @@ fn remove_lint_declaration(name: &str, path: &Path, lints: &mut Vec) -> io // Remove the module declaration (mod xyz;) let mod_decl = format!("\nmod {name};"); - content = content.replacen(&mod_decl, "", 1); + let mut content = content.replacen(&mod_decl, "", 1); remove_impl_lint_pass(&lint.name.to_uppercase(), &mut content); fs::write(path, content).unwrap_or_else(|_| panic!("failed to write to `{}`", path.to_string_lossy())); diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 8a3415133031..047fa9583d6b 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -167,6 +167,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::exhaustive_items::EXHAUSTIVE_ENUMS_INFO, crate::exhaustive_items::EXHAUSTIVE_STRUCTS_INFO, crate::exit::EXIT_INFO, + crate::explicit_reinitialization::EXPLICIT_REINITIALIZATION_INFO, crate::explicit_write::EXPLICIT_WRITE_INFO, crate::extra_unused_type_parameters::EXTRA_UNUSED_TYPE_PARAMETERS_INFO, crate::fallible_impl_from::FALLIBLE_IMPL_FROM_INFO, diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index ca4913ce1d1c..0382affc0d4d 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -801,11 +801,11 @@ impl TyCoercionStability { } fn for_mir_ty<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: Ty<'tcx>, for_return: bool) -> Self { - let ty::Ref(_, mut ty, _) = *ty.kind() else { + let ty::Ref(_, ty, _) = *ty.kind() else { return Self::None; }; - ty = tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty); + let mut ty = tcx.try_normalize_erasing_regions(param_env, ty).unwrap_or(ty); loop { break match *ty.kind() { ty::Ref(_, ref_ty, _) => { diff --git a/clippy_lints/src/explicit_reinitialization.rs b/clippy_lints/src/explicit_reinitialization.rs new file mode 100644 index 000000000000..d435d2d83d91 --- /dev/null +++ b/clippy_lints/src/explicit_reinitialization.rs @@ -0,0 +1,433 @@ +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::source::snippet_opt; +use clippy_utils::{fn_has_unsatisfiable_preds, is_from_proc_macro}; +use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::graph::dominators::Dominators; +use rustc_data_structures::graph::iterate::DepthFirstSearch; +use rustc_data_structures::graph::WithSuccessors; +use rustc_errors::Applicability; +use rustc_hir::def::Res; +use rustc_hir::def_id::LocalDefId; +use rustc_hir::{ + Closure, Expr, ExprKind, HirId, ImplItem, ImplItemKind, Item, ItemKind, Mutability, Node, Path, PathSegment, QPath, + StmtKind, TraitFn, TraitItem, TraitItemKind, +}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::lint::in_external_macro; +use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor}; +use rustc_middle::mir::{self, BasicBlock, Body, Local, Location, Place, Statement, Terminator}; +use rustc_session::{declare_lint_pass, declare_tool_lint, Session}; +use rustc_span::Span; + +declare_clippy_lint! { + /// ### What it does + /// If a reinitialization dominate all reachable usages, a fresh variable should be introduced + /// + /// ### Why is this bad? + /// Introduce unnecessary mut. + /// Not good in jumpping to definition in ide. + /// + /// ### Known Problems + /// 1. Known false positive and false negative: see test + /// 2. increase the peak memory usage + /// ``` + /// let mut x = vec![1, 2, 3]; + /// x = vec![4, 5, 6]; // x is dropped here + /// // let x = vec![4, 5, 6]; // x is no longer dropped here, but at the end of the scope + /// ``` + /// + /// ### Example + /// ```rust + /// let mut x = 1; + /// println!("{x}"); + /// x = 2; + /// println!("{x}"); + /// ``` + /// Use instead: + /// ```rust + /// let mut x = 1; + /// println!("{x}"); + /// let x = 2; + /// println!("{x}"); + /// ``` + #[clippy::version = "1.75.0"] + pub EXPLICIT_REINITIALIZATION, + style, + "introduce a fresh variable instead of reinitialization" +} + +declare_lint_pass!(ExplicitReinitialization => [EXPLICIT_REINITIALIZATION]); + +impl<'tcx> LateLintPass<'tcx> for ExplicitReinitialization { + fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx rustc_hir::Stmt<'tcx>) { + if stmt.span.from_expansion() || in_external_macro(cx.tcx.sess, stmt.span) { + return; + } + + for (parent_id, _) in cx.tcx.hir().parent_iter(stmt.hir_id) { + let span = cx.tcx.hir().span(parent_id); + if span.from_expansion() || in_external_macro(cx.tcx.sess, span) { + return; + } + } + + let StmtKind::Semi( + expr @ Expr { + kind: + ExprKind::Assign( + Expr { + kind: + ExprKind::Path(QPath::Resolved( + None, + Path { + segments: [PathSegment { args: None, .. }], + res: Res::Local(_), + .. + }, + )), + span: left_span, + .. + }, + right, + _, + ), + .. + }, + ) = stmt.kind + else { + return; + }; + if is_from_proc_macro(cx, expr) { + return; + } + let Some(snip) = snippet_opt(cx, stmt.span) else { + return; + }; + let Some(local_def_id) = associated_fn(cx, stmt.hir_id) else { + return; + }; + let def_id = local_def_id.to_def_id(); + + if fn_has_unsatisfiable_preds(cx, def_id) { + return; + } + + let mir = cx.tcx.optimized_mir(def_id); + let Some((_span, local, location)) = search_local(mir, *left_span, cx.tcx.sess) else { + return; + }; + let dominators = mir.basic_blocks.dominators(); + let Some((_span, reinit_location)) = search_mir_by_span(mir, right.span, dominators, cx.tcx.sess) else { + return; + }; + + assert!(reinit_location.dominates(location, dominators)); + + if let Some(mutability) = dominate_all_usage(mir, dominators, local, location) { + span_lint_and_sugg( + cx, + EXPLICIT_REINITIALIZATION, + stmt.span, + "create a fresh variable is more explicit", + "create a fresh variable instead of reinitialization", + format!("let {}{snip}", mutability.prefix_str()), + Applicability::MachineApplicable, + ); + } + } +} + +// based on associated_body() +fn associated_fn(cx: &LateContext<'_>, hir_id: HirId) -> Option { + for (_hir_id, node) in cx.tcx.hir().parent_iter(hir_id) { + match node { + Node::Item(Item { + owner_id, + kind: ItemKind::Fn(.., _body), + .. + }) + | Node::TraitItem(TraitItem { + owner_id, + kind: TraitItemKind::Const(_, Some(_body)) | TraitItemKind::Fn(_, TraitFn::Provided(_body)), + .. + }) + | Node::ImplItem(ImplItem { + owner_id, + kind: ImplItemKind::Const(_, _body) | ImplItemKind::Fn(_, _body), + .. + }) => { + return Some(owner_id.def_id); + }, + + Node::Item(Item { + kind: ItemKind::Impl(..), + .. + }) + | Node::Expr(Expr { + // abort if in any closure + kind: ExprKind::Closure(Closure { .. }), + .. + }) => { + return None; + }, + _ => {}, + } + } + None +} + +fn search_local(mir: &Body<'_>, left_span: Span, sess: &Session) -> Option<(Span, Local, Location)> { + struct SmallestSpanVisitor<'c, 'a> { + body: &'c Body<'a>, + debug_local: FxHashSet, + target_span: Span, + sess: &'c Session, + result: Option<(Span, Local, Location)>, + } + + impl<'a, 'c> SmallestSpanVisitor<'a, 'c> { + fn is_cleanup(&self, location: Location) -> bool { + self.body.basic_blocks[location.block].is_cleanup + } + + fn update(&mut self, span: Span, local: Local, location: Location) { + if span.from_expansion() || in_external_macro(self.sess, span) { + return; + } + if !span.contains(self.target_span) { + return; + } + if !self.debug_local.contains(&local) { + return; + } + if self.is_cleanup(location) { + return; + } + if span.ctxt() != self.target_span.ctxt() { + return; + } + match &self.result { + Some((span_a, _, prev_locaion)) => match cmp_span(*span_a, span) { + SpanCmp::Eq => unreachable!("{:?} {:?} {:?}", span_a, prev_locaion, location), + SpanCmp::AContainB => { + self.result = Some((span, local, location)); + }, + SpanCmp::BContainA => {}, + SpanCmp::Overlap | SpanCmp::NoOverLap => unreachable!(), + }, + None => { + self.result = Some((span, local, location)); + }, + } + } + } + + impl<'tcx, 'a, 'c> Visitor<'tcx> for SmallestSpanVisitor<'a, 'c> { + fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { + match &statement.kind { + mir::StatementKind::Assign(box (Place { local, .. }, _)) | mir::StatementKind::StorageLive(local) => { + self.update(statement.source_info.span, *local, location); + }, + _ => {}, + } + } + + fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { + if let mir::TerminatorKind::Call { destination, .. } = &terminator.kind { + self.update(terminator.source_info.span, destination.local, location); + } + } + } + + let debug_local: FxHashSet = mir + .var_debug_info + .iter() + .filter_map(|info| match &info.value { + mir::VarDebugInfoContents::Place(Place { local, .. }) => Some(*local), + mir::VarDebugInfoContents::Const(_) => None, + }) + .collect(); + + let mut accurate_visitor = SmallestSpanVisitor { + body: mir, + debug_local, + target_span: left_span, + sess, + result: None, + }; + accurate_visitor.visit_body(accurate_visitor.body); + accurate_visitor.result +} + +// must return Option bacause of expansion +fn search_mir_by_span( + mir: &mir::Body<'_>, + rvalue_span: Span, + dominators: &Dominators, + sess: &Session, +) -> Option<(Span, Location)> { + struct SmallestSpanVisitor<'b, 'a> { + body: &'b Body<'a>, + dominators: &'b Dominators, + target_span: Span, + sess: &'b Session, + result: Option<(Span, Location)>, + } + + impl<'a, 'b> SmallestSpanVisitor<'a, 'b> { + fn is_cleanup(&self, location: Location) -> bool { + self.body.basic_blocks[location.block].is_cleanup + } + + fn update(&mut self, span: Span, location: Location) { + if span.from_expansion() || in_external_macro(self.sess, span) { + return; + } + if !span.contains(self.target_span) { + return; + } + if self.is_cleanup(location) { + return; + } + if span.ctxt() != self.target_span.ctxt() { + return; + } + match &self.result { + Some((span_a, prev_location)) => match cmp_span(*span_a, span) { + SpanCmp::Eq => { + if prev_location.dominates(location, self.dominators) { + self.result = Some((span, location)); + } else if location.dominates(*prev_location, self.dominators) { + } else { + unreachable!() + } + }, + SpanCmp::AContainB => { + self.result = Some((span, location)); + }, + SpanCmp::BContainA => {}, + SpanCmp::Overlap | SpanCmp::NoOverLap => unreachable!(), + }, + None => { + self.result = Some((span, location)); + }, + } + } + } + + impl<'tcx, 'a, 'b> Visitor<'tcx> for SmallestSpanVisitor<'a, 'b> { + fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { + if let mir::StatementKind::Assign(_) = &statement.kind { + self.update(statement.source_info.span, location); + } + } + + fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { + if let mir::TerminatorKind::Call { .. } = &terminator.kind { + self.update(terminator.source_info.span, location); + } + } + } + + let mut accurate_visitor = SmallestSpanVisitor { + body: mir, + dominators, + target_span: rvalue_span, + sess, + result: None, + }; + accurate_visitor.visit_body(accurate_visitor.body); + accurate_visitor.result +} + +// None: doesn't dominate all usage +// Some(Mut): dominate all usage, and a mut usage found +// Some(Not); dominate all uagee, and no muge usage found +fn dominate_all_usage( + mir: &mir::Body<'_>, + dominators: &Dominators, + local: Local, + reinit_location: Location, +) -> Option { + let mut dfs = DepthFirstSearch::new(&mir.basic_blocks); + for successor in mir.basic_blocks.successors(reinit_location.block) { + dfs.push_start_node(successor); + } + let reachable_bb: FxHashSet = dfs.collect(); + + let mut res = Mutability::Not; + + for (location, mutability) in find_usage(mir, local) + .into_iter() + .filter(|(location, _)| !mir.basic_blocks[location.block].is_cleanup) + .filter(|(location, _)| { + reachable_bb.contains(&location.block) + || (location.block == reinit_location.block && location.statement_index > reinit_location.statement_index) + }) + { + if !reinit_location.dominates(location, dominators) { + return None; + } + if mutability == Mutability::Mut { + res = Mutability::Mut; + } + } + Some(res) +} + +// copy from https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_borrowck/diagnostics/find_all_local_uses.rs.html#1-29 +fn find_usage(body: &Body<'_>, local: Local) -> FxHashSet<(Location, Mutability)> { + struct AllLocalUsesVisitor { + for_local: Local, + uses: FxHashSet<(Location, Mutability)>, + } + + impl<'tcx> Visitor<'tcx> for AllLocalUsesVisitor { + fn visit_local(&mut self, local: Local, context: PlaceContext, location: Location) { + if local == self.for_local { + match context { + PlaceContext::NonMutatingUse(_) + | PlaceContext::NonUse(_) + | PlaceContext::MutatingUse(MutatingUseContext::Drop) => { + self.uses.insert((location, Mutability::Not)); + }, + PlaceContext::MutatingUse(_) => { + self.uses.insert((location, Mutability::Mut)); + }, + } + } + } + } + + let mut visitor = AllLocalUsesVisitor { + for_local: local, + uses: FxHashSet::default(), + }; + visitor.visit_body(body); + visitor.uses +} + +#[derive(Debug, Copy, Clone)] +enum SpanCmp { + Eq, + AContainB, + BContainA, + Overlap, + NoOverLap, +} + +fn cmp_span(a: Span, b: Span) -> SpanCmp { + if a == b { + return SpanCmp::Eq; + } + if a.contains(b) { + return SpanCmp::AContainB; + } + if b.contains(a) { + return SpanCmp::BContainA; + } + if a.overlaps(b) { + return SpanCmp::Overlap; + } + SpanCmp::NoOverLap +} diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index ab978a677c23..c760c077fd7c 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -125,6 +125,7 @@ mod excessive_bools; mod excessive_nesting; mod exhaustive_items; mod exit; +mod explicit_reinitialization; mod explicit_write; mod extra_unused_type_parameters; mod fallible_impl_from; @@ -1066,6 +1067,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: }); store.register_late_pass(move |_| Box::new(manual_hash_one::ManualHashOne::new(msrv()))); store.register_late_pass(|_| Box::new(iter_without_into_iter::IterWithoutIntoIter)); + store.register_late_pass(|_| Box::new(explicit_reinitialization::ExplicitReinitialization)); // add lints here, do not remove this comment, it's used in `new_lint` } diff --git a/clippy_lints/src/operators/arithmetic_side_effects.rs b/clippy_lints/src/operators/arithmetic_side_effects.rs index a10aa65e5948..3f1f811daf36 100644 --- a/clippy_lints/src/operators/arithmetic_side_effects.rs +++ b/clippy_lints/src/operators/arithmetic_side_effects.rs @@ -178,10 +178,10 @@ impl ArithmeticSideEffects { ) { return; }; - let (mut actual_lhs, lhs_ref_counter) = peel_hir_expr_refs(lhs); - let (mut actual_rhs, rhs_ref_counter) = peel_hir_expr_refs(rhs); - actual_lhs = expr_or_init(cx, actual_lhs); - actual_rhs = expr_or_init(cx, actual_rhs); + let (actual_lhs, lhs_ref_counter) = peel_hir_expr_refs(lhs); + let (actual_rhs, rhs_ref_counter) = peel_hir_expr_refs(rhs); + let actual_lhs = expr_or_init(cx, actual_lhs); + let actual_rhs = expr_or_init(cx, actual_rhs); let lhs_ty = cx.typeck_results().expr_ty(actual_lhs).peel_refs(); let rhs_ty = cx.typeck_results().expr_ty(actual_rhs).peel_refs(); if self.has_allowed_binary(lhs_ty, rhs_ty) { diff --git a/clippy_lints/src/suspicious_operation_groupings.rs b/clippy_lints/src/suspicious_operation_groupings.rs index 356156d699cc..0263e091ca56 100644 --- a/clippy_lints/src/suspicious_operation_groupings.rs +++ b/clippy_lints/src/suspicious_operation_groupings.rs @@ -617,7 +617,7 @@ fn ident_difference_expr_with_base_location( } let (new_difference, new_base) = ident_difference_via_ident_iter_with_base_location(left, right, base); - base = new_base; + let base = new_base; difference += new_difference; (difference, base) diff --git a/clippy_lints/src/unit_types/unit_arg.rs b/clippy_lints/src/unit_types/unit_arg.rs index 462b1aa8153e..f0625aef1799 100644 --- a/clippy_lints/src/unit_types/unit_arg.rs +++ b/clippy_lints/src/unit_types/unit_arg.rs @@ -185,7 +185,7 @@ fn fmt_stmts_and_call( .map(|it| it.as_ref().to_owned()) .collect::>(); stmts_and_call.push(call_snippet_with_replacements); - stmts_and_call = stmts_and_call + let stmts_and_call: Vec<_> = stmts_and_call .into_iter() .map(|v| reindent_multiline(v.into(), true, Some(call_expr_indent)).into_owned()) .collect(); diff --git a/tests/ui/arithmetic_side_effects.rs b/tests/ui/arithmetic_side_effects.rs index b454c29aef4d..d9d6a06b6cad 100644 --- a/tests/ui/arithmetic_side_effects.rs +++ b/tests/ui/arithmetic_side_effects.rs @@ -3,6 +3,7 @@ #![allow( clippy::assign_op_pattern, clippy::erasing_op, + clippy::explicit_reinitialization, clippy::identity_op, clippy::no_effect, clippy::op_ref, diff --git a/tests/ui/arithmetic_side_effects.stderr b/tests/ui/arithmetic_side_effects.stderr index 13729a6c5a33..885aa9b51f28 100644 --- a/tests/ui/arithmetic_side_effects.stderr +++ b/tests/ui/arithmetic_side_effects.stderr @@ -1,5 +1,5 @@ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:304:5 + --> $DIR/arithmetic_side_effects.rs:305:5 | LL | _n += 1; | ^^^^^^^ @@ -8,709 +8,709 @@ LL | _n += 1; = help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]` error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:305:5 + --> $DIR/arithmetic_side_effects.rs:306:5 | LL | _n += &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:306:5 + --> $DIR/arithmetic_side_effects.rs:307:5 | LL | _n -= 1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:307:5 + --> $DIR/arithmetic_side_effects.rs:308:5 | LL | _n -= &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:308:5 + --> $DIR/arithmetic_side_effects.rs:309:5 | LL | _n /= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:309:5 + --> $DIR/arithmetic_side_effects.rs:310:5 | LL | _n /= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:310:5 + --> $DIR/arithmetic_side_effects.rs:311:5 | LL | _n %= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:311:5 + --> $DIR/arithmetic_side_effects.rs:312:5 | LL | _n %= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:312:5 + --> $DIR/arithmetic_side_effects.rs:313:5 | LL | _n *= 2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:313:5 + --> $DIR/arithmetic_side_effects.rs:314:5 | LL | _n *= &2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:314:5 + --> $DIR/arithmetic_side_effects.rs:315:5 | LL | _n += -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:315:5 + --> $DIR/arithmetic_side_effects.rs:316:5 | LL | _n += &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:316:5 + --> $DIR/arithmetic_side_effects.rs:317:5 | LL | _n -= -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:317:5 + --> $DIR/arithmetic_side_effects.rs:318:5 | LL | _n -= &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:318:5 + --> $DIR/arithmetic_side_effects.rs:319:5 | LL | _n /= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:319:5 + --> $DIR/arithmetic_side_effects.rs:320:5 | LL | _n /= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:320:5 + --> $DIR/arithmetic_side_effects.rs:321:5 | LL | _n %= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:321:5 + --> $DIR/arithmetic_side_effects.rs:322:5 | LL | _n %= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:322:5 + --> $DIR/arithmetic_side_effects.rs:323:5 | LL | _n *= -2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:323:5 + --> $DIR/arithmetic_side_effects.rs:324:5 | LL | _n *= &-2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:324:5 + --> $DIR/arithmetic_side_effects.rs:325:5 | LL | _custom += Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:325:5 + --> $DIR/arithmetic_side_effects.rs:326:5 | LL | _custom += &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:326:5 + --> $DIR/arithmetic_side_effects.rs:327:5 | LL | _custom -= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:327:5 + --> $DIR/arithmetic_side_effects.rs:328:5 | LL | _custom -= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:328:5 + --> $DIR/arithmetic_side_effects.rs:329:5 | LL | _custom /= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:329:5 + --> $DIR/arithmetic_side_effects.rs:330:5 | LL | _custom /= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:330:5 + --> $DIR/arithmetic_side_effects.rs:331:5 | LL | _custom %= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:331:5 + --> $DIR/arithmetic_side_effects.rs:332:5 | LL | _custom %= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:332:5 + --> $DIR/arithmetic_side_effects.rs:333:5 | LL | _custom *= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:333:5 + --> $DIR/arithmetic_side_effects.rs:334:5 | LL | _custom *= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:334:5 + --> $DIR/arithmetic_side_effects.rs:335:5 | LL | _custom >>= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:335:5 + --> $DIR/arithmetic_side_effects.rs:336:5 | LL | _custom >>= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:336:5 + --> $DIR/arithmetic_side_effects.rs:337:5 | LL | _custom <<= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:337:5 + --> $DIR/arithmetic_side_effects.rs:338:5 | LL | _custom <<= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:338:5 + --> $DIR/arithmetic_side_effects.rs:339:5 | LL | _custom += -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:339:5 + --> $DIR/arithmetic_side_effects.rs:340:5 | LL | _custom += &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:340:5 + --> $DIR/arithmetic_side_effects.rs:341:5 | LL | _custom -= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:341:5 + --> $DIR/arithmetic_side_effects.rs:342:5 | LL | _custom -= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:342:5 + --> $DIR/arithmetic_side_effects.rs:343:5 | LL | _custom /= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:343:5 + --> $DIR/arithmetic_side_effects.rs:344:5 | LL | _custom /= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:344:5 + --> $DIR/arithmetic_side_effects.rs:345:5 | LL | _custom %= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:345:5 + --> $DIR/arithmetic_side_effects.rs:346:5 | LL | _custom %= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:346:5 + --> $DIR/arithmetic_side_effects.rs:347:5 | LL | _custom *= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:347:5 + --> $DIR/arithmetic_side_effects.rs:348:5 | LL | _custom *= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:348:5 + --> $DIR/arithmetic_side_effects.rs:349:5 | LL | _custom >>= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:349:5 + --> $DIR/arithmetic_side_effects.rs:350:5 | LL | _custom >>= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:350:5 + --> $DIR/arithmetic_side_effects.rs:351:5 | LL | _custom <<= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:351:5 + --> $DIR/arithmetic_side_effects.rs:352:5 | LL | _custom <<= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:354:10 + --> $DIR/arithmetic_side_effects.rs:355:10 | LL | _n = _n + 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:355:10 + --> $DIR/arithmetic_side_effects.rs:356:10 | LL | _n = _n + &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:356:10 + --> $DIR/arithmetic_side_effects.rs:357:10 | LL | _n = 1 + _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:357:10 + --> $DIR/arithmetic_side_effects.rs:358:10 | LL | _n = &1 + _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:358:10 + --> $DIR/arithmetic_side_effects.rs:359:10 | LL | _n = _n - 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:359:10 + --> $DIR/arithmetic_side_effects.rs:360:10 | LL | _n = _n - &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:360:10 + --> $DIR/arithmetic_side_effects.rs:361:10 | LL | _n = 1 - _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:361:10 + --> $DIR/arithmetic_side_effects.rs:362:10 | LL | _n = &1 - _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:362:10 + --> $DIR/arithmetic_side_effects.rs:363:10 | LL | _n = _n / 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:363:10 + --> $DIR/arithmetic_side_effects.rs:364:10 | LL | _n = _n / &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:364:10 + --> $DIR/arithmetic_side_effects.rs:365:10 | LL | _n = _n % 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:365:10 + --> $DIR/arithmetic_side_effects.rs:366:10 | LL | _n = _n % &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:366:10 + --> $DIR/arithmetic_side_effects.rs:367:10 | LL | _n = _n * 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:367:10 + --> $DIR/arithmetic_side_effects.rs:368:10 | LL | _n = _n * &2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:368:10 + --> $DIR/arithmetic_side_effects.rs:369:10 | LL | _n = 2 * _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:369:10 + --> $DIR/arithmetic_side_effects.rs:370:10 | LL | _n = &2 * _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:370:10 + --> $DIR/arithmetic_side_effects.rs:371:10 | LL | _n = 23 + &85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:371:10 + --> $DIR/arithmetic_side_effects.rs:372:10 | LL | _n = &23 + 85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:372:10 + --> $DIR/arithmetic_side_effects.rs:373:10 | LL | _n = &23 + &85; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:373:15 + --> $DIR/arithmetic_side_effects.rs:374:15 | LL | _custom = _custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:374:15 + --> $DIR/arithmetic_side_effects.rs:375:15 | LL | _custom = _custom + &_custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:375:15 + --> $DIR/arithmetic_side_effects.rs:376:15 | LL | _custom = Custom + _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:376:15 + --> $DIR/arithmetic_side_effects.rs:377:15 | LL | _custom = &Custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:377:15 + --> $DIR/arithmetic_side_effects.rs:378:15 | LL | _custom = _custom - Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:378:15 + --> $DIR/arithmetic_side_effects.rs:379:15 | LL | _custom = _custom - &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:379:15 + --> $DIR/arithmetic_side_effects.rs:380:15 | LL | _custom = Custom - _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:380:15 + --> $DIR/arithmetic_side_effects.rs:381:15 | LL | _custom = &Custom - _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:381:15 + --> $DIR/arithmetic_side_effects.rs:382:15 | LL | _custom = _custom / Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:382:15 + --> $DIR/arithmetic_side_effects.rs:383:15 | LL | _custom = _custom / &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:383:15 + --> $DIR/arithmetic_side_effects.rs:384:15 | LL | _custom = _custom % Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:384:15 + --> $DIR/arithmetic_side_effects.rs:385:15 | LL | _custom = _custom % &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:385:15 + --> $DIR/arithmetic_side_effects.rs:386:15 | LL | _custom = _custom * Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:386:15 + --> $DIR/arithmetic_side_effects.rs:387:15 | LL | _custom = _custom * &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:387:15 + --> $DIR/arithmetic_side_effects.rs:388:15 | LL | _custom = Custom * _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:388:15 + --> $DIR/arithmetic_side_effects.rs:389:15 | LL | _custom = &Custom * _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:389:15 + --> $DIR/arithmetic_side_effects.rs:390:15 | LL | _custom = Custom + &Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:390:15 + --> $DIR/arithmetic_side_effects.rs:391:15 | LL | _custom = &Custom + Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:391:15 + --> $DIR/arithmetic_side_effects.rs:392:15 | LL | _custom = &Custom + &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:392:15 + --> $DIR/arithmetic_side_effects.rs:393:15 | LL | _custom = _custom >> _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:393:15 + --> $DIR/arithmetic_side_effects.rs:394:15 | LL | _custom = _custom >> &_custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:394:15 + --> $DIR/arithmetic_side_effects.rs:395:15 | LL | _custom = Custom << _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:395:15 + --> $DIR/arithmetic_side_effects.rs:396:15 | LL | _custom = &Custom << _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:398:23 + --> $DIR/arithmetic_side_effects.rs:399:23 | LL | _n.saturating_div(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:399:21 + --> $DIR/arithmetic_side_effects.rs:400:21 | LL | _n.wrapping_div(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:400:21 + --> $DIR/arithmetic_side_effects.rs:401:21 | LL | _n.wrapping_rem(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:401:28 + --> $DIR/arithmetic_side_effects.rs:402:28 | LL | _n.wrapping_rem_euclid(0); | ^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:403:23 + --> $DIR/arithmetic_side_effects.rs:404:23 | LL | _n.saturating_div(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:404:21 + --> $DIR/arithmetic_side_effects.rs:405:21 | LL | _n.wrapping_div(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:405:21 + --> $DIR/arithmetic_side_effects.rs:406:21 | LL | _n.wrapping_rem(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:406:28 + --> $DIR/arithmetic_side_effects.rs:407:28 | LL | _n.wrapping_rem_euclid(_n); | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:409:10 + --> $DIR/arithmetic_side_effects.rs:410:10 | LL | _n = -_n; | ^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:410:10 + --> $DIR/arithmetic_side_effects.rs:411:10 | LL | _n = -&_n; | ^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:411:15 + --> $DIR/arithmetic_side_effects.rs:412:15 | LL | _custom = -_custom; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:412:15 + --> $DIR/arithmetic_side_effects.rs:413:15 | LL | _custom = -&_custom; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:421:5 + --> $DIR/arithmetic_side_effects.rs:422:5 | LL | 1 + i; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:422:5 + --> $DIR/arithmetic_side_effects.rs:423:5 | LL | i * 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:423:5 + --> $DIR/arithmetic_side_effects.rs:424:5 | LL | 1 % i / 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:424:5 + --> $DIR/arithmetic_side_effects.rs:425:5 | LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:425:5 + --> $DIR/arithmetic_side_effects.rs:426:5 | LL | -i; | ^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:436:5 + --> $DIR/arithmetic_side_effects.rs:437:5 | LL | i += 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:437:5 + --> $DIR/arithmetic_side_effects.rs:438:5 | LL | i -= 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:438:5 + --> $DIR/arithmetic_side_effects.rs:439:5 | LL | i *= 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:440:5 + --> $DIR/arithmetic_side_effects.rs:441:5 | LL | i /= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:442:5 + --> $DIR/arithmetic_side_effects.rs:443:5 | LL | i /= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:443:5 + --> $DIR/arithmetic_side_effects.rs:444:5 | LL | i /= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:445:5 + --> $DIR/arithmetic_side_effects.rs:446:5 | LL | i %= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:447:5 + --> $DIR/arithmetic_side_effects.rs:448:5 | LL | i %= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:448:5 + --> $DIR/arithmetic_side_effects.rs:449:5 | LL | i %= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:458:5 + --> $DIR/arithmetic_side_effects.rs:459:5 | LL | 10 / a | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:512:9 + --> $DIR/arithmetic_side_effects.rs:513:9 | LL | x / maybe_zero | ^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects - --> $DIR/arithmetic_side_effects.rs:516:9 + --> $DIR/arithmetic_side_effects.rs:517:9 | LL | x % maybe_zero | ^^^^^^^^^^^^^^ diff --git a/tests/ui/assign_ops.fixed b/tests/ui/assign_ops.fixed index 2bd0807f4262..558152e2063d 100644 --- a/tests/ui/assign_ops.fixed +++ b/tests/ui/assign_ops.fixed @@ -1,6 +1,11 @@ use core::num::Wrapping; -#[allow(dead_code, unused_assignments, clippy::useless_vec)] +#[allow( + dead_code, + unused_assignments, + clippy::useless_vec, + clippy::explicit_reinitialization +)] #[warn(clippy::assign_op_pattern)] fn main() { let mut a = 5; diff --git a/tests/ui/assign_ops.rs b/tests/ui/assign_ops.rs index be3491a44c7e..8e78e7dfb149 100644 --- a/tests/ui/assign_ops.rs +++ b/tests/ui/assign_ops.rs @@ -1,6 +1,11 @@ use core::num::Wrapping; -#[allow(dead_code, unused_assignments, clippy::useless_vec)] +#[allow( + dead_code, + unused_assignments, + clippy::useless_vec, + clippy::explicit_reinitialization +)] #[warn(clippy::assign_op_pattern)] fn main() { let mut a = 5; diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index e021e1bab4c4..fc87f0261fe2 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,5 +1,5 @@ error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:7:5 + --> $DIR/assign_ops.rs:12:5 | LL | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` @@ -8,61 +8,61 @@ LL | a = a + 1; = help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:8:5 + --> $DIR/assign_ops.rs:13:5 | LL | a = 1 + a; | ^^^^^^^^^ help: replace it with: `a += 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:9:5 + --> $DIR/assign_ops.rs:14:5 | LL | a = a - 1; | ^^^^^^^^^ help: replace it with: `a -= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:10:5 + --> $DIR/assign_ops.rs:15:5 | LL | a = a * 99; | ^^^^^^^^^^ help: replace it with: `a *= 99` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:11:5 + --> $DIR/assign_ops.rs:16:5 | LL | a = 42 * a; | ^^^^^^^^^^ help: replace it with: `a *= 42` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:12:5 + --> $DIR/assign_ops.rs:17:5 | LL | a = a / 2; | ^^^^^^^^^ help: replace it with: `a /= 2` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:13:5 + --> $DIR/assign_ops.rs:18:5 | LL | a = a % 5; | ^^^^^^^^^ help: replace it with: `a %= 5` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:14:5 + --> $DIR/assign_ops.rs:19:5 | LL | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:20:5 + --> $DIR/assign_ops.rs:25:5 | LL | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:24:5 + --> $DIR/assign_ops.rs:29:5 | LL | a = a + Wrapping(1u32); | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a += Wrapping(1u32)` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:26:5 + --> $DIR/assign_ops.rs:31:5 | LL | v[0] = v[0] + v[1]; | ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]` diff --git a/tests/ui/assign_ops2.rs b/tests/ui/assign_ops2.rs index a53556425849..0fbb3521b15c 100644 --- a/tests/ui/assign_ops2.rs +++ b/tests/ui/assign_ops2.rs @@ -1,5 +1,5 @@ //@no-rustfix: overlapping suggestions -#![allow(clippy::uninlined_format_args)] +#![allow(clippy::uninlined_format_args, clippy::explicit_reinitialization)] #[allow(unused_assignments)] #[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)] diff --git a/tests/ui/collection_is_never_read.rs b/tests/ui/collection_is_never_read.rs index bd281f7870ce..ff47033665a6 100644 --- a/tests/ui/collection_is_never_read.rs +++ b/tests/ui/collection_is_never_read.rs @@ -1,4 +1,4 @@ -#![allow(unused, clippy::useless_vec)] +#![allow(unused, clippy::useless_vec, clippy::explicit_reinitialization)] #![warn(clippy::collection_is_never_read)] use std::collections::{HashMap, HashSet}; diff --git a/tests/ui/crate_level_checks/no_std_swap.fixed b/tests/ui/crate_level_checks/no_std_swap.fixed index 32bccd3a0ffc..e4f01322730a 100644 --- a/tests/ui/crate_level_checks/no_std_swap.fixed +++ b/tests/ui/crate_level_checks/no_std_swap.fixed @@ -5,6 +5,7 @@ use core::panic::PanicInfo; #[warn(clippy::all)] +#[allow(clippy::explicit_reinitialization)] fn main() { let mut a = 42; let mut b = 1337; diff --git a/tests/ui/crate_level_checks/no_std_swap.rs b/tests/ui/crate_level_checks/no_std_swap.rs index 8ed45a334655..a3e567d52031 100644 --- a/tests/ui/crate_level_checks/no_std_swap.rs +++ b/tests/ui/crate_level_checks/no_std_swap.rs @@ -5,6 +5,7 @@ use core::panic::PanicInfo; #[warn(clippy::all)] +#[allow(clippy::explicit_reinitialization)] fn main() { let mut a = 42; let mut b = 1337; diff --git a/tests/ui/crate_level_checks/no_std_swap.stderr b/tests/ui/crate_level_checks/no_std_swap.stderr index 01033246dd90..e7b0bd2d41db 100644 --- a/tests/ui/crate_level_checks/no_std_swap.stderr +++ b/tests/ui/crate_level_checks/no_std_swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are trying to swap `a` and `b` - --> $DIR/no_std_swap.rs:12:5 + --> $DIR/no_std_swap.rs:13:5 | LL | / a = b; LL | | diff --git a/tests/ui/expect_tool_lint_rfc_2383.rs b/tests/ui/expect_tool_lint_rfc_2383.rs index 5fab9ceb6797..71a0994df581 100644 --- a/tests/ui/expect_tool_lint_rfc_2383.rs +++ b/tests/ui/expect_tool_lint_rfc_2383.rs @@ -11,7 +11,7 @@ //! This test can't cover every lint from Clippy, rustdoc and potentially other //! tools that will be developed. This therefore only tests a small subset of lints #![expect(rustdoc::missing_crate_level_docs)] -#![allow(clippy::needless_if)] +#![allow(clippy::needless_if, clippy::explicit_reinitialization)] mod rustc_ok { //! See diff --git a/tests/ui/explicit_counter_loop.rs b/tests/ui/explicit_counter_loop.rs index c25e79a36171..4607bf27c598 100644 --- a/tests/ui/explicit_counter_loop.rs +++ b/tests/ui/explicit_counter_loop.rs @@ -1,5 +1,9 @@ #![warn(clippy::explicit_counter_loop)] -#![allow(clippy::uninlined_format_args, clippy::useless_vec)] +#![allow( + clippy::uninlined_format_args, + clippy::useless_vec, + clippy::explicit_reinitialization +)] //@no-rustfix fn main() { let mut vec = vec![1, 2, 3, 4]; diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index aef979072525..1e3392f66db2 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -1,5 +1,5 @@ error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:7:5 + --> $DIR/explicit_counter_loop.rs:11:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` @@ -8,49 +8,49 @@ LL | for _v in &vec { = help: to override `-D warnings` add `#[allow(clippy::explicit_counter_loop)]` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:15:5 + --> $DIR/explicit_counter_loop.rs:19:5 | LL | for _v in &vec { | ^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter().enumerate()` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:21:5 + --> $DIR/explicit_counter_loop.rs:25:5 | LL | for _v in &mut vec { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.iter_mut().enumerate()` error: the variable `_index` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:27:5 + --> $DIR/explicit_counter_loop.rs:31:5 | LL | for _v in vec { | ^^^^^^^^^^^^^ help: consider using: `for (_index, _v) in vec.into_iter().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:115:9 + --> $DIR/explicit_counter_loop.rs:119:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:127:9 + --> $DIR/explicit_counter_loop.rs:131:9 | LL | for ch in text.chars() { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `for (count, ch) in text.chars().enumerate()` error: the variable `count` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:186:9 + --> $DIR/explicit_counter_loop.rs:190:9 | LL | for _i in 3..10 { | ^^^^^^^^^^^^^^^ help: consider using: `for (count, _i) in (3..10).enumerate()` error: the variable `idx_usize` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:227:9 + --> $DIR/explicit_counter_loop.rs:231:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_usize, _item) in slice.iter().enumerate()` error: the variable `idx_u32` is used as a loop counter - --> $DIR/explicit_counter_loop.rs:240:9 + --> $DIR/explicit_counter_loop.rs:244:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_u32, _item) in (0_u32..).zip(slice.iter())` diff --git a/tests/ui/explicit_reinitialization.fixed b/tests/ui/explicit_reinitialization.fixed new file mode 100644 index 000000000000..a5cf7c710d1e --- /dev/null +++ b/tests/ui/explicit_reinitialization.fixed @@ -0,0 +1,112 @@ +#![allow(dead_code)] +#![warn(clippy::explicit_reinitialization)] + +fn test_copy() { + let mut x = 1; + println!("{x}"); + let x = 2; + println!("{x}"); +} + +fn test_move() { + let mut x = String::new(); + println!("{x}"); + let x = String::new(); + println!("{x}"); +} + +#[allow(unused_assignments, clippy::misrefactored_assign_op)] +fn should_lint() { + let mut a = 1; + let a = a * a * a; +} + +#[allow(clippy::ptr_arg)] +fn should_lint_2() { + fn foo(_x: &mut String) {} + let mut s = String::new(); + let mut s = s.replacen('o', "a", 3); + foo(&mut s); + drop(s); +} + +// require liveness analysis +#[allow(clippy::ptr_arg, clippy::unnecessary_literal_unwrap, clippy::useless_format)] +fn should_lint_3() { + fn foo(_x: &mut String) {} + if true { + let mut s = Result::::Ok(String::new()).unwrap_or_else(|_| panic!()); + let mod_decl = format!("\nmod"); + let mut s = s.replacen(&mod_decl, "a", 3); + foo(&mut s); + } + println!("123"); +} + +fn should_not_lint_1() { + let mut x = 1; + loop { + println!("{x}"); + x = 2; + } +} + +fn should_not_lint_2() { + let mut x = String::new(); + loop { + println!("{x}"); + x = String::new(); + } +} + +fn should_not_lint_3() { + let mut x = String::new(); + if true { + x = String::new(); + } else { + x = x.trim().to_owned(); + } + drop(x) +} + +fn should_not_lint_4() { + let mut b = true; + loop { + b = !b; + } +} + +fn should_not_lint_5(mut v: Vec) -> Vec { + for _ in 0..10 { + if true { + v = Vec::new(); + continue; + } + v.push(String::new()); + } + v +} + +fn known_false_negative() { + let mut x = 1; + println!("{x}"); + { + let x = 2; + } + println!("{x}"); +} + +fn false_positive() { + let mut x = 1; + println!("{x}"); + + if true { + x = 2; + println!("{x}"); + } else { + x = 3; + println!("{x}"); + } +} + +fn main() {} diff --git a/tests/ui/explicit_reinitialization.rs b/tests/ui/explicit_reinitialization.rs new file mode 100644 index 000000000000..949f2d77c69e --- /dev/null +++ b/tests/ui/explicit_reinitialization.rs @@ -0,0 +1,112 @@ +#![allow(dead_code)] +#![warn(clippy::explicit_reinitialization)] + +fn test_copy() { + let mut x = 1; + println!("{x}"); + x = 2; + println!("{x}"); +} + +fn test_move() { + let mut x = String::new(); + println!("{x}"); + x = String::new(); + println!("{x}"); +} + +#[allow(unused_assignments, clippy::misrefactored_assign_op)] +fn should_lint() { + let mut a = 1; + a = a * a * a; +} + +#[allow(clippy::ptr_arg)] +fn should_lint_2() { + fn foo(_x: &mut String) {} + let mut s = String::new(); + s = s.replacen('o', "a", 3); + foo(&mut s); + drop(s); +} + +// require liveness analysis +#[allow(clippy::ptr_arg, clippy::unnecessary_literal_unwrap, clippy::useless_format)] +fn should_lint_3() { + fn foo(_x: &mut String) {} + if true { + let mut s = Result::::Ok(String::new()).unwrap_or_else(|_| panic!()); + let mod_decl = format!("\nmod"); + s = s.replacen(&mod_decl, "a", 3); + foo(&mut s); + } + println!("123"); +} + +fn should_not_lint_1() { + let mut x = 1; + loop { + println!("{x}"); + x = 2; + } +} + +fn should_not_lint_2() { + let mut x = String::new(); + loop { + println!("{x}"); + x = String::new(); + } +} + +fn should_not_lint_3() { + let mut x = String::new(); + if true { + x = String::new(); + } else { + x = x.trim().to_owned(); + } + drop(x) +} + +fn should_not_lint_4() { + let mut b = true; + loop { + b = !b; + } +} + +fn should_not_lint_5(mut v: Vec) -> Vec { + for _ in 0..10 { + if true { + v = Vec::new(); + continue; + } + v.push(String::new()); + } + v +} + +fn known_false_negative() { + let mut x = 1; + println!("{x}"); + { + x = 2; + } + println!("{x}"); +} + +fn false_positive() { + let mut x = 1; + println!("{x}"); + + if true { + x = 2; + println!("{x}"); + } else { + x = 3; + println!("{x}"); + } +} + +fn main() {} diff --git a/tests/ui/explicit_reinitialization.stderr b/tests/ui/explicit_reinitialization.stderr new file mode 100644 index 000000000000..cb2103d202a1 --- /dev/null +++ b/tests/ui/explicit_reinitialization.stderr @@ -0,0 +1,41 @@ +error: create a fresh variable is more explicit + --> $DIR/explicit_reinitialization.rs:7:5 + | +LL | x = 2; + | ^^^^^^ help: create a fresh variable instead of reinitialization: `let x = 2;` + | + = note: `-D clippy::explicit-reinitialization` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::explicit_reinitialization)]` + +error: create a fresh variable is more explicit + --> $DIR/explicit_reinitialization.rs:14:5 + | +LL | x = String::new(); + | ^^^^^^^^^^^^^^^^^^ help: create a fresh variable instead of reinitialization: `let x = String::new();` + +error: create a fresh variable is more explicit + --> $DIR/explicit_reinitialization.rs:21:5 + | +LL | a = a * a * a; + | ^^^^^^^^^^^^^^ help: create a fresh variable instead of reinitialization: `let a = a * a * a;` + +error: create a fresh variable is more explicit + --> $DIR/explicit_reinitialization.rs:28:5 + | +LL | s = s.replacen('o', "a", 3); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: create a fresh variable instead of reinitialization: `let mut s = s.replacen('o', "a", 3);` + +error: create a fresh variable is more explicit + --> $DIR/explicit_reinitialization.rs:40:9 + | +LL | s = s.replacen(&mod_decl, "a", 3); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: create a fresh variable instead of reinitialization: `let mut s = s.replacen(&mod_decl, "a", 3);` + +error: create a fresh variable is more explicit + --> $DIR/explicit_reinitialization.rs:94:9 + | +LL | x = 2; + | ^^^^^^ help: create a fresh variable instead of reinitialization: `let x = 2;` + +error: aborting due to 6 previous errors + diff --git a/tests/ui/field_reassign_with_default.rs b/tests/ui/field_reassign_with_default.rs index 2045b1eebcd7..44d88fcd80ae 100644 --- a/tests/ui/field_reassign_with_default.rs +++ b/tests/ui/field_reassign_with_default.rs @@ -1,6 +1,7 @@ //@aux-build:proc_macro_derive.rs //@aux-build:proc_macros.rs +#![allow(clippy::explicit_reinitialization)] #![warn(clippy::field_reassign_with_default)] #[macro_use] diff --git a/tests/ui/field_reassign_with_default.stderr b/tests/ui/field_reassign_with_default.stderr index a8cf84bd4114..48c827e29885 100644 --- a/tests/ui/field_reassign_with_default.stderr +++ b/tests/ui/field_reassign_with_default.stderr @@ -1,11 +1,11 @@ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:56:5 + --> $DIR/field_reassign_with_default.rs:57:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:55:5 + --> $DIR/field_reassign_with_default.rs:56:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,121 +13,121 @@ LL | let mut a: A = Default::default(); = help: to override `-D warnings` add `#[allow(clippy::field_reassign_with_default)]` error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:96:5 + --> $DIR/field_reassign_with_default.rs:97:5 | LL | a.j = 43; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { j: 43, i: 42 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:95:5 + --> $DIR/field_reassign_with_default.rs:96:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:101:5 + --> $DIR/field_reassign_with_default.rs:102:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, j: 44 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:100:5 + --> $DIR/field_reassign_with_default.rs:101:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:107:5 + --> $DIR/field_reassign_with_default.rs:108:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:106:5 + --> $DIR/field_reassign_with_default.rs:107:5 | LL | let mut a = A::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:117:5 + --> $DIR/field_reassign_with_default.rs:118:5 | LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `main::A { i: Default::default(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:116:5 + --> $DIR/field_reassign_with_default.rs:117:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:121:5 + --> $DIR/field_reassign_with_default.rs:122:5 | LL | a.i = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `main::A { i: Default::default(), j: 45 }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:120:5 + --> $DIR/field_reassign_with_default.rs:121:5 | LL | let mut a: A = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:143:5 + --> $DIR/field_reassign_with_default.rs:144:5 | LL | a.i = vec![1]; | ^^^^^^^^^^^^^^ | note: consider initializing the variable with `C { i: vec![1], ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:142:5 + --> $DIR/field_reassign_with_default.rs:143:5 | LL | let mut a: C = C::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:161:5 + --> $DIR/field_reassign_with_default.rs:162:5 | LL | a.i = true; | ^^^^^^^^^^^ | note: consider initializing the variable with `Wrapper:: { i: true }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:160:5 + --> $DIR/field_reassign_with_default.rs:161:5 | LL | let mut a: Wrapper = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:164:5 + --> $DIR/field_reassign_with_default.rs:165:5 | LL | a.i = 42; | ^^^^^^^^^ | note: consider initializing the variable with `WrapperMulti:: { i: 42, ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:163:5 + --> $DIR/field_reassign_with_default.rs:164:5 | LL | let mut a: WrapperMulti = Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:235:13 + --> $DIR/field_reassign_with_default.rs:236:13 | LL | f.name = name.len(); | ^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `issue6312::ImplDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:234:13 + --> $DIR/field_reassign_with_default.rs:235:13 | LL | let mut f = ImplDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: field assignment outside of initializer for an instance created with Default::default() - --> $DIR/field_reassign_with_default.rs:251:13 + --> $DIR/field_reassign_with_default.rs:252:13 | LL | f.name = name.len(); | ^^^^^^^^^^^^^^^^^^^^ | note: consider initializing the variable with `issue6312::NoDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments - --> $DIR/field_reassign_with_default.rs:250:13 + --> $DIR/field_reassign_with_default.rs:251:13 | LL | let mut f = NoDropAllCopy::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 312fa2aa40ad..859ea3456dd4 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -3,6 +3,7 @@ #![allow(unused_assignments)] #![allow(clippy::if_same_then_else)] #![allow(clippy::deref_addrof)] +#![allow(clippy::explicit_reinitialization)] #![allow(clippy::nonminimal_bool)] fn foo() -> bool { diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index d4eb8e511c8f..e917e2d8b0b0 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,5 +1,5 @@ error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:16:6 + --> $DIR/formatting.rs:17:6 | LL | a =- 35; | ^^^^ @@ -9,7 +9,7 @@ LL | a =- 35; = help: to override `-D warnings` add `#[allow(clippy::suspicious_assignment_formatting)]` error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - --> $DIR/formatting.rs:19:6 + --> $DIR/formatting.rs:20:6 | LL | a =* &191; | ^^^^ @@ -17,7 +17,7 @@ LL | a =* &191; = note: to remove this lint, use either `*=` or `= *` error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:24:6 + --> $DIR/formatting.rs:25:6 | LL | b =! false; | ^^^^ @@ -25,7 +25,7 @@ LL | b =! false; = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:35:19 + --> $DIR/formatting.rs:36:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -35,7 +35,7 @@ LL | -1, -2, -3 // <= no comma here = help: to override `-D warnings` add `#[allow(clippy::possible_missing_comma)]` error: possibly missing a comma here - --> $DIR/formatting.rs:41:19 + --> $DIR/formatting.rs:42:19 | LL | -1, -2, -3 // <= no comma here | ^ @@ -43,7 +43,7 @@ LL | -1, -2, -3 // <= no comma here = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:80:11 + --> $DIR/formatting.rs:81:11 | LL | -1 | ^ diff --git a/tests/ui/implicit_saturating_add.fixed b/tests/ui/implicit_saturating_add.fixed index 4cf8e3587b61..355f3b9a1b85 100644 --- a/tests/ui/implicit_saturating_add.fixed +++ b/tests/ui/implicit_saturating_add.fixed @@ -1,4 +1,4 @@ -#![allow(unused)] +#![allow(unused, clippy::explicit_reinitialization)] #![warn(clippy::implicit_saturating_add)] fn main() { diff --git a/tests/ui/implicit_saturating_add.rs b/tests/ui/implicit_saturating_add.rs index 94513f34c262..bb2848d9ed25 100644 --- a/tests/ui/implicit_saturating_add.rs +++ b/tests/ui/implicit_saturating_add.rs @@ -1,4 +1,4 @@ -#![allow(unused)] +#![allow(unused, clippy::explicit_reinitialization)] #![warn(clippy::implicit_saturating_add)] fn main() { diff --git a/tests/ui/implicit_saturating_sub.fixed b/tests/ui/implicit_saturating_sub.fixed index 27f679797dd9..eb362ac112b3 100644 --- a/tests/ui/implicit_saturating_sub.fixed +++ b/tests/ui/implicit_saturating_sub.fixed @@ -1,4 +1,9 @@ -#![allow(unused_assignments, unused_mut, clippy::assign_op_pattern)] +#![allow( + unused_assignments, + unused_mut, + clippy::assign_op_pattern, + clippy::explicit_reinitialization +)] #![warn(clippy::implicit_saturating_sub)] use std::cmp::PartialEq; diff --git a/tests/ui/implicit_saturating_sub.rs b/tests/ui/implicit_saturating_sub.rs index 5d7b95d2c652..54242d194b5a 100644 --- a/tests/ui/implicit_saturating_sub.rs +++ b/tests/ui/implicit_saturating_sub.rs @@ -1,4 +1,9 @@ -#![allow(unused_assignments, unused_mut, clippy::assign_op_pattern)] +#![allow( + unused_assignments, + unused_mut, + clippy::assign_op_pattern, + clippy::explicit_reinitialization +)] #![warn(clippy::implicit_saturating_sub)] use std::cmp::PartialEq; diff --git a/tests/ui/implicit_saturating_sub.stderr b/tests/ui/implicit_saturating_sub.stderr index 6e026d1a6987..6b56144dee06 100644 --- a/tests/ui/implicit_saturating_sub.stderr +++ b/tests/ui/implicit_saturating_sub.stderr @@ -1,5 +1,5 @@ error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:27:5 + --> $DIR/implicit_saturating_sub.rs:32:5 | LL | / if u_8 > 0 { LL | | u_8 = u_8 - 1; @@ -10,7 +10,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_sub)]` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:34:13 + --> $DIR/implicit_saturating_sub.rs:39:13 | LL | / if u_8 > 0 { LL | | u_8 -= 1; @@ -18,7 +18,7 @@ LL | | } | |_____________^ help: try: `u_8 = u_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:48:5 + --> $DIR/implicit_saturating_sub.rs:53:5 | LL | / if u_16 > 0 { LL | | u_16 -= 1; @@ -26,7 +26,7 @@ LL | | } | |_____^ help: try: `u_16 = u_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:58:5 + --> $DIR/implicit_saturating_sub.rs:63:5 | LL | / if u_32 != 0 { LL | | u_32 -= 1; @@ -34,7 +34,7 @@ LL | | } | |_____^ help: try: `u_32 = u_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:79:5 + --> $DIR/implicit_saturating_sub.rs:84:5 | LL | / if u_64 > 0 { LL | | u_64 -= 1; @@ -42,7 +42,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:84:5 + --> $DIR/implicit_saturating_sub.rs:89:5 | LL | / if 0 < u_64 { LL | | u_64 -= 1; @@ -50,7 +50,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:89:5 + --> $DIR/implicit_saturating_sub.rs:94:5 | LL | / if 0 != u_64 { LL | | u_64 -= 1; @@ -58,7 +58,7 @@ LL | | } | |_____^ help: try: `u_64 = u_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:110:5 + --> $DIR/implicit_saturating_sub.rs:115:5 | LL | / if u_usize > 0 { LL | | u_usize -= 1; @@ -66,7 +66,7 @@ LL | | } | |_____^ help: try: `u_usize = u_usize.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:122:5 + --> $DIR/implicit_saturating_sub.rs:127:5 | LL | / if i_8 > i8::MIN { LL | | i_8 -= 1; @@ -74,7 +74,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:127:5 + --> $DIR/implicit_saturating_sub.rs:132:5 | LL | / if i_8 > i8::MIN { LL | | i_8 -= 1; @@ -82,7 +82,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:132:5 + --> $DIR/implicit_saturating_sub.rs:137:5 | LL | / if i_8 != i8::MIN { LL | | i_8 -= 1; @@ -90,7 +90,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:137:5 + --> $DIR/implicit_saturating_sub.rs:142:5 | LL | / if i_8 != i8::MIN { LL | | i_8 -= 1; @@ -98,7 +98,7 @@ LL | | } | |_____^ help: try: `i_8 = i_8.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:147:5 + --> $DIR/implicit_saturating_sub.rs:152:5 | LL | / if i_16 > i16::MIN { LL | | i_16 -= 1; @@ -106,7 +106,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:152:5 + --> $DIR/implicit_saturating_sub.rs:157:5 | LL | / if i_16 > i16::MIN { LL | | i_16 -= 1; @@ -114,7 +114,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:157:5 + --> $DIR/implicit_saturating_sub.rs:162:5 | LL | / if i_16 != i16::MIN { LL | | i_16 -= 1; @@ -122,7 +122,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:162:5 + --> $DIR/implicit_saturating_sub.rs:167:5 | LL | / if i_16 != i16::MIN { LL | | i_16 -= 1; @@ -130,7 +130,7 @@ LL | | } | |_____^ help: try: `i_16 = i_16.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:172:5 + --> $DIR/implicit_saturating_sub.rs:177:5 | LL | / if i_32 > i32::MIN { LL | | i_32 -= 1; @@ -138,7 +138,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:177:5 + --> $DIR/implicit_saturating_sub.rs:182:5 | LL | / if i_32 > i32::MIN { LL | | i_32 -= 1; @@ -146,7 +146,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:182:5 + --> $DIR/implicit_saturating_sub.rs:187:5 | LL | / if i_32 != i32::MIN { LL | | i_32 -= 1; @@ -154,7 +154,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:187:5 + --> $DIR/implicit_saturating_sub.rs:192:5 | LL | / if i_32 != i32::MIN { LL | | i_32 -= 1; @@ -162,7 +162,7 @@ LL | | } | |_____^ help: try: `i_32 = i_32.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:197:5 + --> $DIR/implicit_saturating_sub.rs:202:5 | LL | / if i64::MIN < i_64 { LL | | i_64 -= 1; @@ -170,7 +170,7 @@ LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:202:5 + --> $DIR/implicit_saturating_sub.rs:207:5 | LL | / if i64::MIN != i_64 { LL | | i_64 -= 1; @@ -178,7 +178,7 @@ LL | | } | |_____^ help: try: `i_64 = i_64.saturating_sub(1);` error: implicitly performing saturating subtraction - --> $DIR/implicit_saturating_sub.rs:207:5 + --> $DIR/implicit_saturating_sub.rs:212:5 | LL | / if i64::MIN < i_64 { LL | | i_64 -= 1; diff --git a/tests/ui/let_if_seq.rs b/tests/ui/let_if_seq.rs index 9869d945299e..9693848b307a 100644 --- a/tests/ui/let_if_seq.rs +++ b/tests/ui/let_if_seq.rs @@ -1,10 +1,11 @@ #![allow( unused_variables, unused_assignments, - clippy::similar_names, - clippy::disallowed_names, clippy::branches_sharing_code, - clippy::needless_late_init + clippy::disallowed_names, + clippy::explicit_reinitialization, + clippy::needless_late_init, + clippy::similar_names )] #![warn(clippy::useless_let_if_seq)] //@no-rustfix diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index bfb4bb9d0d2f..92fc1c095fc0 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -1,5 +1,5 @@ error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:66:5 + --> $DIR/let_if_seq.rs:67:5 | LL | / let mut foo = 0; LL | | @@ -14,7 +14,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::useless_let_if_seq)]` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:73:5 + --> $DIR/let_if_seq.rs:74:5 | LL | / let mut bar = 0; LL | | @@ -28,7 +28,7 @@ LL | | } = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:83:5 + --> $DIR/let_if_seq.rs:84:5 | LL | / let quz; LL | | @@ -40,7 +40,7 @@ LL | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:113:5 + --> $DIR/let_if_seq.rs:114:5 | LL | / let mut baz = 0; LL | | diff --git a/tests/ui/let_unit.fixed b/tests/ui/let_unit.fixed index f98ce9d50a99..7549a4a3cfcc 100644 --- a/tests/ui/let_unit.fixed +++ b/tests/ui/let_unit.fixed @@ -1,6 +1,12 @@ #![feature(lint_reasons)] #![warn(clippy::let_unit_value)] -#![allow(unused, clippy::no_effect, clippy::needless_late_init, path_statements)] +#![allow( + unused, + clippy::no_effect, + clippy::needless_late_init, + path_statements, + clippy::explicit_reinitialization +)] macro_rules! let_and_return { ($n:expr) => {{ diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index 6d942ca8908c..11ef30478085 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -1,6 +1,12 @@ #![feature(lint_reasons)] #![warn(clippy::let_unit_value)] -#![allow(unused, clippy::no_effect, clippy::needless_late_init, path_statements)] +#![allow( + unused, + clippy::no_effect, + clippy::needless_late_init, + path_statements, + clippy::explicit_reinitialization +)] macro_rules! let_and_return { ($n:expr) => {{ diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index de106f50e0e7..31ad540883a0 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,5 +1,5 @@ error: this let-binding has unit value - --> $DIR/let_unit.rs:12:5 + --> $DIR/let_unit.rs:18:5 | LL | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `println!("x");` @@ -8,13 +8,13 @@ LL | let _x = println!("x"); = help: to override `-D warnings` add `#[allow(clippy::let_unit_value)]` error: this let-binding has unit value - --> $DIR/let_unit.rs:16:9 + --> $DIR/let_unit.rs:22:9 | LL | let _a = (); | ^^^^^^^^^^^^ help: omit the `let` binding: `();` error: this let-binding has unit value - --> $DIR/let_unit.rs:51:5 + --> $DIR/let_unit.rs:57:5 | LL | / let _ = v LL | | .into_iter() @@ -37,7 +37,7 @@ LL + .unwrap(); | error: this let-binding has unit value - --> $DIR/let_unit.rs:78:5 + --> $DIR/let_unit.rs:84:5 | LL | let x: () = f(); // Lint. | ^^^^-^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | let x: () = f(); // Lint. | help: use a wild (`_`) binding: `_` error: this let-binding has unit value - --> $DIR/let_unit.rs:81:5 + --> $DIR/let_unit.rs:87:5 | LL | let x: () = f2(0i32); // Lint. | ^^^^-^^^^^^^^^^^^^^^^ @@ -53,19 +53,19 @@ LL | let x: () = f2(0i32); // Lint. | help: use a wild (`_`) binding: `_` error: this let-binding has unit value - --> $DIR/let_unit.rs:83:5 + --> $DIR/let_unit.rs:89:5 | LL | let _: () = f3(()); // Lint | ^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `f3(());` error: this let-binding has unit value - --> $DIR/let_unit.rs:84:5 + --> $DIR/let_unit.rs:90:5 | LL | let x: () = f3(()); // Lint | ^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `f3(());` error: this let-binding has unit value - --> $DIR/let_unit.rs:100:5 + --> $DIR/let_unit.rs:106:5 | LL | let x: () = if true { f() } else { f2(0) }; // Lint | ^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let x: () = if true { f() } else { f2(0) }; // Lint | help: use a wild (`_`) binding: `_` error: this let-binding has unit value - --> $DIR/let_unit.rs:111:5 + --> $DIR/let_unit.rs:117:5 | LL | / let _: () = match Some(0) { LL | | None => f2(1), @@ -94,7 +94,7 @@ LL + }; | error: this let-binding has unit value - --> $DIR/let_unit.rs:158:13 + --> $DIR/let_unit.rs:164:13 | LL | let _: () = z; | ^^^^^^^^^^^^^^ help: omit the `let` binding: `z;` diff --git a/tests/ui/let_with_type_underscore.rs b/tests/ui/let_with_type_underscore.rs index ae1a480bcfc5..cdbb134bdaa3 100644 --- a/tests/ui/let_with_type_underscore.rs +++ b/tests/ui/let_with_type_underscore.rs @@ -1,7 +1,11 @@ //@aux-build: proc_macros.rs #![allow(unused)] #![warn(clippy::let_with_type_underscore)] -#![allow(clippy::let_unit_value, clippy::needless_late_init)] +#![allow( + clippy::let_unit_value, + clippy::needless_late_init, + clippy::explicit_reinitialization +)] extern crate proc_macros; @@ -35,7 +39,7 @@ fn main() { let x : _ = 1; let x : _ = 1; - let x : + let x : _; x = (); }; diff --git a/tests/ui/let_with_type_underscore.stderr b/tests/ui/let_with_type_underscore.stderr index d4c9ba19c39f..e2beab2ed726 100644 --- a/tests/ui/let_with_type_underscore.stderr +++ b/tests/ui/let_with_type_underscore.stderr @@ -1,11 +1,11 @@ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:15:5 + --> $DIR/let_with_type_underscore.rs:19:5 | LL | let x: _ = 1; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:15:10 + --> $DIR/let_with_type_underscore.rs:19:10 | LL | let x: _ = 1; | ^^^ @@ -13,49 +13,49 @@ LL | let x: _ = 1; = help: to override `-D warnings` add `#[allow(clippy::let_with_type_underscore)]` error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:16:5 + --> $DIR/let_with_type_underscore.rs:20:5 | LL | let _: _ = 2; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:16:10 + --> $DIR/let_with_type_underscore.rs:20:10 | LL | let _: _ = 2; | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:17:5 + --> $DIR/let_with_type_underscore.rs:21:5 | LL | let x: _ = func(); | ^^^^^^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:17:10 + --> $DIR/let_with_type_underscore.rs:21:10 | LL | let x: _ = func(); | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:18:5 + --> $DIR/let_with_type_underscore.rs:22:5 | LL | let x: _; | ^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:18:10 + --> $DIR/let_with_type_underscore.rs:22:10 | LL | let x: _; | ^^^ error: variable declared with type underscore - --> $DIR/let_with_type_underscore.rs:25:5 + --> $DIR/let_with_type_underscore.rs:29:5 | LL | let x : _ = 1; | ^^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration - --> $DIR/let_with_type_underscore.rs:25:10 + --> $DIR/let_with_type_underscore.rs:29:10 | LL | let x : _ = 1; | ^^^^ diff --git a/tests/ui/manual_clamp.fixed b/tests/ui/manual_clamp.fixed index c5355cce8e21..27c13af63d5f 100644 --- a/tests/ui/manual_clamp.fixed +++ b/tests/ui/manual_clamp.fixed @@ -4,7 +4,8 @@ dead_code, clippy::unnecessary_operation, clippy::no_effect, - clippy::if_same_then_else + clippy::if_same_then_else, + clippy::explicit_reinitialization )] use std::cmp::{max as cmp_max, min as cmp_min}; diff --git a/tests/ui/manual_clamp.rs b/tests/ui/manual_clamp.rs index cacb40ae027f..f6d0b1269905 100644 --- a/tests/ui/manual_clamp.rs +++ b/tests/ui/manual_clamp.rs @@ -4,7 +4,8 @@ dead_code, clippy::unnecessary_operation, clippy::no_effect, - clippy::if_same_then_else + clippy::if_same_then_else, + clippy::explicit_reinitialization )] use std::cmp::{max as cmp_max, min as cmp_min}; diff --git a/tests/ui/manual_clamp.stderr b/tests/ui/manual_clamp.stderr index 2fa68ede1261..ec0957e0f063 100644 --- a/tests/ui/manual_clamp.stderr +++ b/tests/ui/manual_clamp.stderr @@ -1,5 +1,5 @@ error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:94:5 + --> $DIR/manual_clamp.rs:95:5 | LL | / if x9 < min { LL | | @@ -15,7 +15,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_clamp)]` error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:113:5 + --> $DIR/manual_clamp.rs:114:5 | LL | / if x11 > max { LL | | @@ -29,7 +29,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:123:5 + --> $DIR/manual_clamp.rs:124:5 | LL | / if min > x12 { LL | | @@ -43,7 +43,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:133:5 + --> $DIR/manual_clamp.rs:134:5 | LL | / if max < x13 { LL | | @@ -57,7 +57,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:227:5 + --> $DIR/manual_clamp.rs:228:5 | LL | / if max < x33 { LL | | @@ -71,7 +71,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:21:14 + --> $DIR/manual_clamp.rs:22:14 | LL | let x0 = if max < input { | ______________^ @@ -86,7 +86,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:31:14 + --> $DIR/manual_clamp.rs:32:14 | LL | let x1 = if input > max { | ______________^ @@ -101,7 +101,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:41:14 + --> $DIR/manual_clamp.rs:42:14 | LL | let x2 = if input < min { | ______________^ @@ -116,7 +116,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:51:14 + --> $DIR/manual_clamp.rs:52:14 | LL | let x3 = if min > input { | ______________^ @@ -131,7 +131,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:61:14 + --> $DIR/manual_clamp.rs:62:14 | LL | let x4 = input.max(min).min(max); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)` @@ -139,7 +139,7 @@ LL | let x4 = input.max(min).min(max); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:65:14 + --> $DIR/manual_clamp.rs:66:14 | LL | let x5 = input.min(max).max(min); | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)` @@ -147,7 +147,7 @@ LL | let x5 = input.min(max).max(min); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:69:14 + --> $DIR/manual_clamp.rs:70:14 | LL | let x6 = match input { | ______________^ @@ -162,7 +162,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:77:14 + --> $DIR/manual_clamp.rs:78:14 | LL | let x7 = match input { | ______________^ @@ -177,7 +177,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:85:14 + --> $DIR/manual_clamp.rs:86:14 | LL | let x8 = match input { | ______________^ @@ -192,7 +192,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:103:15 + --> $DIR/manual_clamp.rs:104:15 | LL | let x10 = match input { | _______________^ @@ -207,7 +207,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:142:15 + --> $DIR/manual_clamp.rs:143:15 | LL | let x14 = if input > CONST_MAX { | _______________^ @@ -222,7 +222,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:153:19 + --> $DIR/manual_clamp.rs:154:19 | LL | let x15 = if input > max { | ___________________^ @@ -238,7 +238,7 @@ LL | | }; = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:166:19 + --> $DIR/manual_clamp.rs:167:19 | LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -246,7 +246,7 @@ LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:169:19 + --> $DIR/manual_clamp.rs:170:19 | LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -254,7 +254,7 @@ LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:172:19 + --> $DIR/manual_clamp.rs:173:19 | LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -262,7 +262,7 @@ LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:175:19 + --> $DIR/manual_clamp.rs:176:19 | LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -270,7 +270,7 @@ LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:178:19 + --> $DIR/manual_clamp.rs:179:19 | LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -278,7 +278,7 @@ LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:181:19 + --> $DIR/manual_clamp.rs:182:19 | LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -286,7 +286,7 @@ LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:184:19 + --> $DIR/manual_clamp.rs:185:19 | LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -294,7 +294,7 @@ LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:187:19 + --> $DIR/manual_clamp.rs:188:19 | LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -302,7 +302,7 @@ LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:191:19 + --> $DIR/manual_clamp.rs:192:19 | LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -311,7 +311,7 @@ LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:194:19 + --> $DIR/manual_clamp.rs:195:19 | LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -320,7 +320,7 @@ LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:197:19 + --> $DIR/manual_clamp.rs:198:19 | LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -329,7 +329,7 @@ LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:200:19 + --> $DIR/manual_clamp.rs:201:19 | LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -338,7 +338,7 @@ LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:203:19 + --> $DIR/manual_clamp.rs:204:19 | LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -347,7 +347,7 @@ LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:206:19 + --> $DIR/manual_clamp.rs:207:19 | LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -356,7 +356,7 @@ LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:209:19 + --> $DIR/manual_clamp.rs:210:19 | LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -365,7 +365,7 @@ LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:212:19 + --> $DIR/manual_clamp.rs:213:19 | LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)` @@ -374,7 +374,7 @@ LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:217:5 + --> $DIR/manual_clamp.rs:218:5 | LL | / if x32 < min { LL | | @@ -388,7 +388,7 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> $DIR/manual_clamp.rs:389:13 + --> $DIR/manual_clamp.rs:390:13 | LL | let _ = if input < min { | _____________^ diff --git a/tests/ui/manual_retain.fixed b/tests/ui/manual_retain.fixed index 4dea3e8bfe68..aa46f91e6111 100644 --- a/tests/ui/manual_retain.fixed +++ b/tests/ui/manual_retain.fixed @@ -1,5 +1,5 @@ #![warn(clippy::manual_retain)] -#![allow(unused, clippy::redundant_clone)] +#![allow(unused, clippy::redundant_clone, clippy::explicit_reinitialization)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; fn main() { diff --git a/tests/ui/manual_retain.rs b/tests/ui/manual_retain.rs index d839550f33a2..173a146cac33 100644 --- a/tests/ui/manual_retain.rs +++ b/tests/ui/manual_retain.rs @@ -1,5 +1,5 @@ #![warn(clippy::manual_retain)] -#![allow(unused, clippy::redundant_clone)] +#![allow(unused, clippy::redundant_clone, clippy::explicit_reinitialization)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; fn main() { diff --git a/tests/ui/manual_split_once.fixed b/tests/ui/manual_split_once.fixed index aaac6a048e1d..f63ee51c5859 100644 --- a/tests/ui/manual_split_once.fixed +++ b/tests/ui/manual_split_once.fixed @@ -1,5 +1,10 @@ #![warn(clippy::manual_split_once)] -#![allow(unused, clippy::iter_skip_next, clippy::iter_nth_zero)] +#![allow( + unused, + clippy::iter_skip_next, + clippy::iter_nth_zero, + clippy::explicit_reinitialization +)] extern crate itertools; diff --git a/tests/ui/manual_split_once.rs b/tests/ui/manual_split_once.rs index 113e1737c97d..c75bab588acf 100644 --- a/tests/ui/manual_split_once.rs +++ b/tests/ui/manual_split_once.rs @@ -1,5 +1,10 @@ #![warn(clippy::manual_split_once)] -#![allow(unused, clippy::iter_skip_next, clippy::iter_nth_zero)] +#![allow( + unused, + clippy::iter_skip_next, + clippy::iter_nth_zero, + clippy::explicit_reinitialization +)] extern crate itertools; diff --git a/tests/ui/manual_split_once.stderr b/tests/ui/manual_split_once.stderr index 494a035edc3a..618316c2a014 100644 --- a/tests/ui/manual_split_once.stderr +++ b/tests/ui/manual_split_once.stderr @@ -1,5 +1,5 @@ error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:11:13 + --> $DIR/manual_split_once.rs:16:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` @@ -8,79 +8,79 @@ LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::manual_split_once)]` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:12:13 + --> $DIR/manual_split_once.rs:17:13 | LL | let _ = "key=value".splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:13:18 + --> $DIR/manual_split_once.rs:18:18 | LL | let (_, _) = "key=value".splitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=')` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:16:13 + --> $DIR/manual_split_once.rs:21:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:19:13 + --> $DIR/manual_split_once.rs:24:13 | LL | let _ = s.splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:22:13 + --> $DIR/manual_split_once.rs:27:13 | LL | let _ = s.splitn(2, '=').skip(1).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:25:17 + --> $DIR/manual_split_once.rs:30:17 | LL | let _ = s.splitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:26:17 + --> $DIR/manual_split_once.rs:31:17 | LL | let _ = s.splitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.split_once('=')?.1` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:27:17 + --> $DIR/manual_split_once.rs:32:17 | LL | let _ = s.rsplitn(2, '=').nth(1)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:28:17 + --> $DIR/manual_split_once.rs:33:17 | LL | let _ = s.rsplitn(2, '=').skip(1).next()?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=')?.0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:36:13 + --> $DIR/manual_split_once.rs:41:13 | LL | let _ = "key=value".rsplitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').unwrap().0` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:37:18 + --> $DIR/manual_split_once.rs:42:18 | LL | let (_, _) = "key=value".rsplitn(2, '=').next_tuple().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".rsplit_once('=').map(|(x, y)| (y, x))` error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:38:13 + --> $DIR/manual_split_once.rs:43:13 | LL | let _ = s.rsplitn(2, '=').nth(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.rsplit_once('=').map(|x| x.0)` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:42:5 + --> $DIR/manual_split_once.rs:47:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL + | error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:46:5 + --> $DIR/manual_split_once.rs:51:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL + | error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:50:5 + --> $DIR/manual_split_once.rs:55:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -155,7 +155,7 @@ LL + | error: manual implementation of `rsplit_once` - --> $DIR/manual_split_once.rs:54:5 + --> $DIR/manual_split_once.rs:59:5 | LL | let mut iter = "a.b.c".rsplitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -180,13 +180,13 @@ LL + | error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:139:13 + --> $DIR/manual_split_once.rs:144:13 | LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"key=value".split_once('=').unwrap().1` error: manual implementation of `split_once` - --> $DIR/manual_split_once.rs:141:5 + --> $DIR/manual_split_once.rs:146:5 | LL | let mut iter = "a.b.c".splitn(2, '.'); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms.rs b/tests/ui/match_same_arms.rs index 2f4652dcf32b..584c7b37d0a4 100644 --- a/tests/ui/match_same_arms.rs +++ b/tests/ui/match_same_arms.rs @@ -1,5 +1,6 @@ //@no-rustfix: overlapping suggestions #![warn(clippy::match_same_arms)] +#![allow(clippy::explicit_reinitialization)] pub enum Abc { A, diff --git a/tests/ui/match_same_arms.stderr b/tests/ui/match_same_arms.stderr index 824dcfdce837..0aa0cc1a508a 100644 --- a/tests/ui/match_same_arms.stderr +++ b/tests/ui/match_same_arms.stderr @@ -1,12 +1,12 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms.rs:12:9 + --> $DIR/match_same_arms.rs:13:9 | LL | Abc::A => 0, | ^^^^^^^^^^^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms.rs:14:9 + --> $DIR/match_same_arms.rs:15:9 | LL | _ => 0, | ^^^^^^ @@ -14,7 +14,7 @@ LL | _ => 0, = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:18:9 + --> $DIR/match_same_arms.rs:19:9 | LL | (1, .., 3) => 42, | ----------^^^^^^ @@ -23,13 +23,13 @@ LL | (1, .., 3) => 42, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:19:9 + --> $DIR/match_same_arms.rs:20:9 | LL | (.., 3) => 42, | ^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:25:9 + --> $DIR/match_same_arms.rs:26:9 | LL | 51 => 1, | --^^^^^ @@ -38,13 +38,13 @@ LL | 51 => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:24:9 + --> $DIR/match_same_arms.rs:25:9 | LL | 42 => 1, | ^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:26:9 + --> $DIR/match_same_arms.rs:27:9 | LL | 41 => 2, | --^^^^^ @@ -53,13 +53,13 @@ LL | 41 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:27:9 + --> $DIR/match_same_arms.rs:28:9 | LL | 52 => 2, | ^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:33:9 + --> $DIR/match_same_arms.rs:34:9 | LL | 2 => 2, | -^^^^^ @@ -68,13 +68,13 @@ LL | 2 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:32:9 + --> $DIR/match_same_arms.rs:33:9 | LL | 1 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:35:9 + --> $DIR/match_same_arms.rs:36:9 | LL | 3 => 2, | -^^^^^ @@ -83,13 +83,13 @@ LL | 3 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:32:9 + --> $DIR/match_same_arms.rs:33:9 | LL | 1 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:33:9 + --> $DIR/match_same_arms.rs:34:9 | LL | 2 => 2, | -^^^^^ @@ -98,13 +98,13 @@ LL | 2 => 2, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:35:9 + --> $DIR/match_same_arms.rs:36:9 | LL | 3 => 2, | ^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms.rs:52:17 + --> $DIR/match_same_arms.rs:53:17 | LL | CommandInfo::External { name, .. } => name.to_string(), | ----------------------------------^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | CommandInfo::External { name, .. } => name.to_string(), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms.rs:51:17 + --> $DIR/match_same_arms.rs:52:17 | LL | CommandInfo::BuiltIn { name, .. } => name.to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms2.rs b/tests/ui/match_same_arms2.rs index 525a355f4035..7225fce632c0 100644 --- a/tests/ui/match_same_arms2.rs +++ b/tests/ui/match_same_arms2.rs @@ -2,7 +2,8 @@ #![allow( clippy::disallowed_names, clippy::diverging_sub_expression, - clippy::uninlined_format_args + clippy::uninlined_format_args, + clippy::explicit_reinitialization )] //@no-rustfix fn bar(_: T) {} diff --git a/tests/ui/match_same_arms2.stderr b/tests/ui/match_same_arms2.stderr index 40b20c7e16d2..559d6be9eee1 100644 --- a/tests/ui/match_same_arms2.stderr +++ b/tests/ui/match_same_arms2.stderr @@ -1,5 +1,5 @@ error: this match arm has an identical body to the `_` wildcard arm - --> $DIR/match_same_arms2.rs:15:9 + --> $DIR/match_same_arms2.rs:16:9 | LL | / 42 => { LL | | @@ -12,7 +12,7 @@ LL | | }, | = help: or try changing either arm body note: `_` wildcard arm here - --> $DIR/match_same_arms2.rs:25:9 + --> $DIR/match_same_arms2.rs:26:9 | LL | / _ => { LL | | foo(); @@ -26,7 +26,7 @@ LL | | }, = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:38:9 + --> $DIR/match_same_arms2.rs:39:9 | LL | 51 => foo(), | --^^^^^^^^^ @@ -35,13 +35,13 @@ LL | 51 => foo(), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:37:9 + --> $DIR/match_same_arms2.rs:38:9 | LL | 42 => foo(), | ^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:44:9 + --> $DIR/match_same_arms2.rs:45:9 | LL | None => 24, | ----^^^^^^ @@ -50,13 +50,13 @@ LL | None => 24, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:43:9 + --> $DIR/match_same_arms2.rs:44:9 | LL | Some(_) => 24, | ^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:66:9 + --> $DIR/match_same_arms2.rs:67:9 | LL | (None, Some(a)) => bar(a), | ---------------^^^^^^^^^^ @@ -65,13 +65,13 @@ LL | (None, Some(a)) => bar(a), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:65:9 + --> $DIR/match_same_arms2.rs:66:9 | LL | (Some(a), None) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:71:9 + --> $DIR/match_same_arms2.rs:72:9 | LL | (Some(a), ..) => bar(a), | -------------^^^^^^^^^^ @@ -80,13 +80,13 @@ LL | (Some(a), ..) => bar(a), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:72:9 + --> $DIR/match_same_arms2.rs:73:9 | LL | (.., Some(a)) => bar(a), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:105:9 + --> $DIR/match_same_arms2.rs:106:9 | LL | (Ok(x), Some(_)) => println!("ok {}", x), | ----------------^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,13 +95,13 @@ LL | (Ok(x), Some(_)) => println!("ok {}", x), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:106:9 + --> $DIR/match_same_arms2.rs:107:9 | LL | (Ok(_), Some(x)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:121:9 + --> $DIR/match_same_arms2.rs:122:9 | LL | Ok(_) => println!("ok"), | -----^^^^^^^^^^^^^^^^^^ @@ -110,13 +110,13 @@ LL | Ok(_) => println!("ok"), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:120:9 + --> $DIR/match_same_arms2.rs:121:9 | LL | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:148:9 + --> $DIR/match_same_arms2.rs:149:9 | LL | 1 => { | ^ help: try merging the arm patterns: `1 | 0` @@ -129,7 +129,7 @@ LL | | }, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:145:9 + --> $DIR/match_same_arms2.rs:146:9 | LL | / 0 => { LL | | empty!(0); @@ -137,7 +137,7 @@ LL | | }, | |_________^ error: match expression looks like `matches!` macro - --> $DIR/match_same_arms2.rs:167:16 + --> $DIR/match_same_arms2.rs:168:16 | LL | let _ans = match x { | ________________^ @@ -151,7 +151,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::match_like_matches_macro)]` error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:199:9 + --> $DIR/match_same_arms2.rs:200:9 | LL | Foo::X(0) => 1, | ---------^^^^^ @@ -160,13 +160,13 @@ LL | Foo::X(0) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:201:9 + --> $DIR/match_same_arms2.rs:202:9 | LL | Foo::Z(_) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:209:9 + --> $DIR/match_same_arms2.rs:210:9 | LL | Foo::Z(_) => 1, | ---------^^^^^ @@ -175,13 +175,13 @@ LL | Foo::Z(_) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:207:9 + --> $DIR/match_same_arms2.rs:208:9 | LL | Foo::X(0) => 1, | ^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:232:9 + --> $DIR/match_same_arms2.rs:233:9 | LL | Some(Bar { y: 0, x: 5, .. }) => 1, | ----------------------------^^^^^ @@ -190,13 +190,13 @@ LL | Some(Bar { y: 0, x: 5, .. }) => 1, | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:229:9 + --> $DIR/match_same_arms2.rs:230:9 | LL | Some(Bar { x: 0, y: 5, .. }) => 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm - --> $DIR/match_same_arms2.rs:246:9 + --> $DIR/match_same_arms2.rs:247:9 | LL | 1 => cfg!(not_enable), | -^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL | 1 => cfg!(not_enable), | = help: or try changing either arm body note: other arm here - --> $DIR/match_same_arms2.rs:245:9 + --> $DIR/match_same_arms2.rs:246:9 | LL | 0 => cfg!(not_enable), | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_single_binding.fixed b/tests/ui/match_single_binding.fixed index 3a3eee4c958b..ed8fe05e51d5 100644 --- a/tests/ui/match_single_binding.fixed +++ b/tests/ui/match_single_binding.fixed @@ -1,6 +1,7 @@ #![warn(clippy::match_single_binding)] #![allow( unused, + clippy::explicit_reinitialization, clippy::let_unit_value, clippy::no_effect, clippy::toplevel_ref_arg, diff --git a/tests/ui/match_single_binding.rs b/tests/ui/match_single_binding.rs index ff2f842ac39e..20c345141b2d 100644 --- a/tests/ui/match_single_binding.rs +++ b/tests/ui/match_single_binding.rs @@ -1,6 +1,7 @@ #![warn(clippy::match_single_binding)] #![allow( unused, + clippy::explicit_reinitialization, clippy::let_unit_value, clippy::no_effect, clippy::toplevel_ref_arg, diff --git a/tests/ui/match_single_binding.stderr b/tests/ui/match_single_binding.stderr index 81ec200dfc7a..0eb726e13b64 100644 --- a/tests/ui/match_single_binding.stderr +++ b/tests/ui/match_single_binding.stderr @@ -1,5 +1,5 @@ error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:33:5 + --> $DIR/match_single_binding.rs:34:5 | LL | / match (a, b, c) { LL | | (x, y, z) => { @@ -19,7 +19,7 @@ LL + } | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:39:5 + --> $DIR/match_single_binding.rs:40:5 | LL | / match (a, b, c) { LL | | (x, y, z) => println!("{} {} {}", x, y, z), @@ -33,7 +33,7 @@ LL + println!("{} {} {}", x, y, z); | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:56:5 + --> $DIR/match_single_binding.rs:57:5 | LL | / match a { LL | | _ => println!("whatever"), @@ -41,7 +41,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("whatever");` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:60:5 + --> $DIR/match_single_binding.rs:61:5 | LL | / match a { LL | | _ => { @@ -60,7 +60,7 @@ LL + } | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:67:5 + --> $DIR/match_single_binding.rs:68:5 | LL | / match a { LL | | _ => { @@ -82,7 +82,7 @@ LL + } | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:77:5 + --> $DIR/match_single_binding.rs:78:5 | LL | / match p { LL | | Point { x, y } => println!("Coords: ({}, {})", x, y), @@ -96,7 +96,7 @@ LL + println!("Coords: ({}, {})", x, y); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:81:5 + --> $DIR/match_single_binding.rs:82:5 | LL | / match p { LL | | Point { x: x1, y: y1 } => println!("Coords: ({}, {})", x1, y1), @@ -110,7 +110,7 @@ LL + println!("Coords: ({}, {})", x1, y1); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:86:5 + --> $DIR/match_single_binding.rs:87:5 | LL | / match x { LL | | ref r => println!("Got a reference to {}", r), @@ -124,7 +124,7 @@ LL + println!("Got a reference to {}", r); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:91:5 + --> $DIR/match_single_binding.rs:92:5 | LL | / match x { LL | | ref mut mr => println!("Got a mutable reference to {}", mr), @@ -138,7 +138,7 @@ LL + println!("Got a mutable reference to {}", mr); | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:95:5 + --> $DIR/match_single_binding.rs:96:5 | LL | / let product = match coords() { LL | | Point { x, y } => x * y, @@ -152,7 +152,7 @@ LL + let product = x * y; | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:103:18 + --> $DIR/match_single_binding.rs:104:18 | LL | .map(|i| match i.unwrap() { | __________________^ @@ -169,7 +169,7 @@ LL ~ }) | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:129:5 + --> $DIR/match_single_binding.rs:130:5 | LL | / match x { LL | | // => @@ -178,7 +178,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("Not an array index start")` error: this assignment could be simplified - --> $DIR/match_single_binding.rs:138:5 + --> $DIR/match_single_binding.rs:139:5 | LL | / val = match val.split_at(idx) { LL | | (pre, suf) => { @@ -198,7 +198,7 @@ LL ~ }; | error: this match could be replaced by its scrutinee and body - --> $DIR/match_single_binding.rs:151:16 + --> $DIR/match_single_binding.rs:152:16 | LL | let _ = || match side_effects() { | ________________^ @@ -215,7 +215,7 @@ LL ~ }; | error: this match could be written as a `let` statement - --> $DIR/match_single_binding.rs:157:5 + --> $DIR/match_single_binding.rs:158:5 | LL | / match r { LL | | x => match x { @@ -240,7 +240,7 @@ LL ~ }; | error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:170:5 + --> $DIR/match_single_binding.rs:171:5 | LL | / match 1 { LL | | _ => (), @@ -248,7 +248,7 @@ LL | | } | |_____^ help: consider using the match body instead: `();` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:174:13 + --> $DIR/match_single_binding.rs:175:13 | LL | let a = match 1 { | _____________^ @@ -257,7 +257,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:178:5 + --> $DIR/match_single_binding.rs:179:5 | LL | / match 1 { LL | | _ => side_effects(), @@ -265,7 +265,7 @@ LL | | } | |_____^ help: consider using the match body instead: `side_effects();` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:182:13 + --> $DIR/match_single_binding.rs:183:13 | LL | let b = match 1 { | _____________^ @@ -274,7 +274,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `side_effects()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:186:5 + --> $DIR/match_single_binding.rs:187:5 | LL | / match 1 { LL | | _ => println!("1"), @@ -282,7 +282,7 @@ LL | | } | |_____^ help: consider using the match body instead: `println!("1");` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:190:13 + --> $DIR/match_single_binding.rs:191:13 | LL | let c = match 1 { | _____________^ @@ -291,7 +291,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `println!("1")` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:195:9 + --> $DIR/match_single_binding.rs:196:9 | LL | / match 1 { LL | | _ => (), @@ -299,7 +299,7 @@ LL | | }, | |_________^ help: consider using the match body instead: `()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:198:9 + --> $DIR/match_single_binding.rs:199:9 | LL | / match 1 { LL | | _ => side_effects(), @@ -307,7 +307,7 @@ LL | | }, | |_________^ help: consider using the match body instead: `side_effects()` error: this match could be replaced by its body itself - --> $DIR/match_single_binding.rs:201:9 + --> $DIR/match_single_binding.rs:202:9 | LL | / match 1 { LL | | _ => println!("1"), diff --git a/tests/ui/mixed_read_write_in_expression.rs b/tests/ui/mixed_read_write_in_expression.rs index 241536abdfbd..b2018062501c 100644 --- a/tests/ui/mixed_read_write_in_expression.rs +++ b/tests/ui/mixed_read_write_in_expression.rs @@ -4,7 +4,8 @@ unused_variables, clippy::no_effect, dead_code, - clippy::disallowed_names + clippy::disallowed_names, + clippy::explicit_reinitialization )] fn main() { let mut x = 0; diff --git a/tests/ui/mixed_read_write_in_expression.stderr b/tests/ui/mixed_read_write_in_expression.stderr index 3dad98815c61..2af42f8fbce1 100644 --- a/tests/ui/mixed_read_write_in_expression.stderr +++ b/tests/ui/mixed_read_write_in_expression.stderr @@ -1,11 +1,11 @@ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:14:9 + --> $DIR/mixed_read_write_in_expression.rs:15:9 | LL | } + x; | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:12:9 + --> $DIR/mixed_read_write_in_expression.rs:13:9 | LL | x = 1; | ^^^^^ @@ -13,37 +13,37 @@ LL | x = 1; = help: to override `-D warnings` add `#[allow(clippy::mixed_read_write_in_expression)]` error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:18:5 + --> $DIR/mixed_read_write_in_expression.rs:19:5 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:20:9 + --> $DIR/mixed_read_write_in_expression.rs:21:9 | LL | x = 20; | ^^^^^^ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:32:12 + --> $DIR/mixed_read_write_in_expression.rs:33:12 | LL | a: x, | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:35:13 + --> $DIR/mixed_read_write_in_expression.rs:36:13 | LL | x = 6; | ^^^^^ error: unsequenced read of `x` - --> $DIR/mixed_read_write_in_expression.rs:42:9 + --> $DIR/mixed_read_write_in_expression.rs:43:9 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/mixed_read_write_in_expression.rs:44:13 + --> $DIR/mixed_read_write_in_expression.rs:45:13 | LL | x = 20; | ^^^^^^ diff --git a/tests/ui/multi_assignments.rs b/tests/ui/multi_assignments.rs index cdbf13b68889..726ab405559c 100644 --- a/tests/ui/multi_assignments.rs +++ b/tests/ui/multi_assignments.rs @@ -1,4 +1,6 @@ #![warn(clippy::multi_assignments)] +#![allow(clippy::explicit_reinitialization)] + fn main() { let (mut a, mut b, mut c, mut d) = ((), (), (), ()); a = b = c; diff --git a/tests/ui/multi_assignments.stderr b/tests/ui/multi_assignments.stderr index 9719b5e66847..1b158a002099 100644 --- a/tests/ui/multi_assignments.stderr +++ b/tests/ui/multi_assignments.stderr @@ -1,5 +1,5 @@ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:4:5 + --> $DIR/multi_assignments.rs:6:5 | LL | a = b = c; | ^^^^^^^^^ @@ -8,31 +8,31 @@ LL | a = b = c; = help: to override `-D warnings` add `#[allow(clippy::multi_assignments)]` error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:7:5 + --> $DIR/multi_assignments.rs:9:5 | LL | a = b = c = d; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:7:9 + --> $DIR/multi_assignments.rs:9:9 | LL | a = b = c = d; | ^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:10:5 + --> $DIR/multi_assignments.rs:12:5 | LL | a = b = { c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:12:5 + --> $DIR/multi_assignments.rs:14:5 | LL | a = { b = c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> $DIR/multi_assignments.rs:14:5 + --> $DIR/multi_assignments.rs:16:5 | LL | a = (b = c); | ^^^^^^^^^^^ diff --git a/tests/ui/needless_late_init.fixed b/tests/ui/needless_late_init.fixed index 9f45da04862c..0d3cd54a2f63 100644 --- a/tests/ui/needless_late_init.fixed +++ b/tests/ui/needless_late_init.fixed @@ -4,6 +4,7 @@ #![allow( clippy::assign_op_pattern, clippy::blocks_in_if_conditions, + clippy::explicit_reinitialization, clippy::let_and_return, clippy::let_unit_value, clippy::nonminimal_bool, diff --git a/tests/ui/needless_late_init.rs b/tests/ui/needless_late_init.rs index 0dab0faad561..90b18fac9544 100644 --- a/tests/ui/needless_late_init.rs +++ b/tests/ui/needless_late_init.rs @@ -4,6 +4,7 @@ #![allow( clippy::assign_op_pattern, clippy::blocks_in_if_conditions, + clippy::explicit_reinitialization, clippy::let_and_return, clippy::let_unit_value, clippy::nonminimal_bool, diff --git a/tests/ui/needless_late_init.stderr b/tests/ui/needless_late_init.stderr index 602b1a683e51..a5e0561ce8dc 100644 --- a/tests/ui/needless_late_init.stderr +++ b/tests/ui/needless_late_init.stderr @@ -1,5 +1,5 @@ error: unneeded late initialization - --> $DIR/needless_late_init.rs:27:5 + --> $DIR/needless_late_init.rs:28:5 | LL | let a; | ^^^^^^ created here @@ -14,7 +14,7 @@ LL | let a = "zero"; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:30:5 + --> $DIR/needless_late_init.rs:31:5 | LL | let b; | ^^^^^^ created here @@ -28,7 +28,7 @@ LL | let b = 1; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:31:5 + --> $DIR/needless_late_init.rs:32:5 | LL | let c; | ^^^^^^ created here @@ -42,7 +42,7 @@ LL | let c = 2; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:35:5 + --> $DIR/needless_late_init.rs:36:5 | LL | let d: usize; | ^^^^^^^^^^^^^ created here @@ -55,7 +55,7 @@ LL | let d: usize = 1; | ~~~~~~~~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:38:5 + --> $DIR/needless_late_init.rs:39:5 | LL | let e; | ^^^^^^ created here @@ -68,7 +68,7 @@ LL | let e = format!("{}", d); | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:43:5 + --> $DIR/needless_late_init.rs:44:5 | LL | let a; | ^^^^^^ @@ -89,7 +89,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:52:5 + --> $DIR/needless_late_init.rs:53:5 | LL | let b; | ^^^^^^ @@ -110,7 +110,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:59:5 + --> $DIR/needless_late_init.rs:60:5 | LL | let d; | ^^^^^^ @@ -131,7 +131,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:67:5 + --> $DIR/needless_late_init.rs:68:5 | LL | let e; | ^^^^^^ @@ -152,7 +152,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:74:5 + --> $DIR/needless_late_init.rs:75:5 | LL | let f; | ^^^^^^ @@ -168,7 +168,7 @@ LL + 1 => "three", | error: unneeded late initialization - --> $DIR/needless_late_init.rs:80:5 + --> $DIR/needless_late_init.rs:81:5 | LL | let g: usize; | ^^^^^^^^^^^^^ @@ -188,7 +188,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:88:5 + --> $DIR/needless_late_init.rs:89:5 | LL | let x; | ^^^^^^ created here @@ -202,7 +202,7 @@ LL | let x = 1; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:92:5 + --> $DIR/needless_late_init.rs:93:5 | LL | let x; | ^^^^^^ created here @@ -216,7 +216,7 @@ LL | let x = SignificantDrop; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:96:5 + --> $DIR/needless_late_init.rs:97:5 | LL | let x; | ^^^^^^ created here @@ -230,7 +230,7 @@ LL | let x = SignificantDrop; | ~~~~~ error: unneeded late initialization - --> $DIR/needless_late_init.rs:115:5 + --> $DIR/needless_late_init.rs:116:5 | LL | let a; | ^^^^^^ @@ -251,7 +251,7 @@ LL | }; | + error: unneeded late initialization - --> $DIR/needless_late_init.rs:132:5 + --> $DIR/needless_late_init.rs:133:5 | LL | let a; | ^^^^^^ diff --git a/tests/ui/option_if_let_else.fixed b/tests/ui/option_if_let_else.fixed index f0113ca696e1..a09fd0b02ad6 100644 --- a/tests/ui/option_if_let_else.fixed +++ b/tests/ui/option_if_let_else.fixed @@ -1,9 +1,10 @@ #![warn(clippy::option_if_let_else)] #![allow( unused_tuple_struct_fields, - clippy::ref_option_ref, clippy::equatable_if_let, + clippy::explicit_reinitialization, clippy::let_unit_value, + clippy::ref_option_ref, clippy::redundant_locals )] diff --git a/tests/ui/option_if_let_else.rs b/tests/ui/option_if_let_else.rs index 18b7af443925..334c7bef906a 100644 --- a/tests/ui/option_if_let_else.rs +++ b/tests/ui/option_if_let_else.rs @@ -1,9 +1,10 @@ #![warn(clippy::option_if_let_else)] #![allow( unused_tuple_struct_fields, - clippy::ref_option_ref, clippy::equatable_if_let, + clippy::explicit_reinitialization, clippy::let_unit_value, + clippy::ref_option_ref, clippy::redundant_locals )] diff --git a/tests/ui/option_if_let_else.stderr b/tests/ui/option_if_let_else.stderr index e36357bcb385..a145c4843a34 100644 --- a/tests/ui/option_if_let_else.stderr +++ b/tests/ui/option_if_let_else.stderr @@ -1,5 +1,5 @@ error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:11:5 + --> $DIR/option_if_let_else.rs:12:5 | LL | / if let Some(x) = string { LL | | (true, x) @@ -12,19 +12,19 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:29:13 + --> $DIR/option_if_let_else.rs:30:13 | LL | let _ = if let Some(s) = *string { s.len() } else { 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:30:13 + --> $DIR/option_if_let_else.rs:31:13 | LL | let _ = if let Some(s) = &num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:31:13 + --> $DIR/option_if_let_else.rs:32:13 | LL | let _ = if let Some(s) = &mut num { | _____________^ @@ -44,13 +44,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:37:13 + --> $DIR/option_if_let_else.rs:38:13 | LL | let _ = if let Some(ref s) = num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:38:13 + --> $DIR/option_if_let_else.rs:39:13 | LL | let _ = if let Some(mut s) = num { | _____________^ @@ -70,7 +70,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:44:13 + --> $DIR/option_if_let_else.rs:45:13 | LL | let _ = if let Some(ref mut s) = num { | _____________^ @@ -90,7 +90,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:53:5 + --> $DIR/option_if_let_else.rs:54:5 | LL | / if let Some(x) = arg { LL | | let y = x * x; @@ -109,7 +109,7 @@ LL + }) | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:66:13 + --> $DIR/option_if_let_else.rs:67:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -121,7 +121,7 @@ LL | | }; | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:75:13 + --> $DIR/option_if_let_else.rs:76:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x); | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:108:13 + --> $DIR/option_if_let_else.rs:109:13 | LL | / if let Some(idx) = s.find('.') { LL | | vec![s[..idx].to_string(), s[idx..].to_string()] @@ -154,7 +154,7 @@ LL | | } | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:119:5 + --> $DIR/option_if_let_else.rs:120:5 | LL | / if let Ok(binding) = variable { LL | | println!("Ok {binding}"); @@ -173,13 +173,13 @@ LL + }) | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:141:13 + --> $DIR/option_if_let_else.rs:142:13 | LL | let _ = if let Some(x) = optional { x + 2 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:151:13 + --> $DIR/option_if_let_else.rs:152:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -201,13 +201,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:179:13 + --> $DIR/option_if_let_else.rs:180:13 | LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:183:13 + --> $DIR/option_if_let_else.rs:184:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -227,7 +227,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:222:13 + --> $DIR/option_if_let_else.rs:223:13 | LL | let _ = match s { | _____________^ @@ -237,7 +237,7 @@ LL | | }; | |_____^ help: try: `s.map_or(1, |string| string.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:226:13 + --> $DIR/option_if_let_else.rs:227:13 | LL | let _ = match Some(10) { | _____________^ @@ -247,7 +247,7 @@ LL | | }; | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:232:13 + --> $DIR/option_if_let_else.rs:233:13 | LL | let _ = match res { | _____________^ @@ -257,7 +257,7 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:236:13 + --> $DIR/option_if_let_else.rs:237:13 | LL | let _ = match res { | _____________^ @@ -267,13 +267,13 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:240:13 + --> $DIR/option_if_let_else.rs:241:13 | LL | let _ = if let Ok(a) = res { a + 1 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:257:9 + --> $DIR/option_if_let_else.rs:258:9 | LL | / match initial { LL | | Some(value) => do_something(value), @@ -282,7 +282,7 @@ LL | | } | |_________^ help: try: `initial.as_ref().map_or({}, |value| do_something(value))` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:264:9 + --> $DIR/option_if_let_else.rs:265:9 | LL | / match initial { LL | | Some(value) => do_something2(value), @@ -291,7 +291,7 @@ LL | | } | |_________^ help: try: `initial.as_mut().map_or({}, |value| do_something2(value))` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:283:24 + --> $DIR/option_if_let_else.rs:284:24 | LL | let mut _hashmap = if let Some(hm) = &opt { | ________________________^ @@ -302,7 +302,7 @@ LL | | }; | |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:289:19 + --> $DIR/option_if_let_else.rs:290:19 | LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())` diff --git a/tests/ui/redundant_closure_call_early.rs b/tests/ui/redundant_closure_call_early.rs index 6f9c9fd52224..81b88f4ee98a 100644 --- a/tests/ui/redundant_closure_call_early.rs +++ b/tests/ui/redundant_closure_call_early.rs @@ -1,6 +1,7 @@ // non rustfixable, see redundant_closure_call_fixable.rs #![warn(clippy::redundant_closure_call)] +#![allow(clippy::explicit_reinitialization)] fn main() { let mut i = 1; diff --git a/tests/ui/redundant_closure_call_early.stderr b/tests/ui/redundant_closure_call_early.stderr index be7a981dc27b..98f6eeb4d9db 100644 --- a/tests/ui/redundant_closure_call_early.stderr +++ b/tests/ui/redundant_closure_call_early.stderr @@ -1,5 +1,5 @@ error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_early.rs:9:17 + --> $DIR/redundant_closure_call_early.rs:10:17 | LL | let mut k = (|m| m + 1)(i); | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let mut k = (|m| m + 1)(i); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: try not to call a closure in the expression where it is declared - --> $DIR/redundant_closure_call_early.rs:14:9 + --> $DIR/redundant_closure_call_early.rs:15:9 | LL | k = (|a, b| a * b)(1, 5); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_closure_call_late.rs b/tests/ui/redundant_closure_call_late.rs index dc369c3bc092..e18a46a1c15f 100644 --- a/tests/ui/redundant_closure_call_late.rs +++ b/tests/ui/redundant_closure_call_late.rs @@ -1,7 +1,7 @@ // non rustfixable, see redundant_closure_call_fixable.rs #![warn(clippy::redundant_closure_call)] -#![allow(clippy::needless_late_init)] +#![allow(clippy::needless_late_init, clippy::explicit_reinitialization)] fn main() { let mut i = 1; diff --git a/tests/ui/redundant_locals.rs b/tests/ui/redundant_locals.rs index 182d067a5e9f..c1eda791aec1 100644 --- a/tests/ui/redundant_locals.rs +++ b/tests/ui/redundant_locals.rs @@ -1,5 +1,10 @@ //@aux-build:proc_macros.rs -#![allow(unused, clippy::no_effect, clippy::needless_pass_by_ref_mut)] +#![allow( + unused, + clippy::no_effect, + clippy::needless_pass_by_ref_mut, + clippy::explicit_reinitialization +)] #![warn(clippy::redundant_locals)] extern crate proc_macros; diff --git a/tests/ui/redundant_locals.stderr b/tests/ui/redundant_locals.stderr index 30ab4aa2ea91..87b27de198c5 100644 --- a/tests/ui/redundant_locals.stderr +++ b/tests/ui/redundant_locals.stderr @@ -1,11 +1,11 @@ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:12:5 + --> $DIR/redundant_locals.rs:17:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:11:9 + --> $DIR/redundant_locals.rs:16:9 | LL | let x = 1; | ^ @@ -13,157 +13,157 @@ LL | let x = 1; = help: to override `-D warnings` add `#[allow(clippy::redundant_locals)]` error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:17:5 + --> $DIR/redundant_locals.rs:22:5 | LL | let mut x = x; | ^^^^^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:16:9 + --> $DIR/redundant_locals.rs:21:9 | LL | let mut x = 1; | ^^^^^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:47:5 + --> $DIR/redundant_locals.rs:52:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:46:14 + --> $DIR/redundant_locals.rs:51:14 | LL | fn parameter(x: i32) { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:52:5 + --> $DIR/redundant_locals.rs:57:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:51:9 + --> $DIR/redundant_locals.rs:56:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:53:5 + --> $DIR/redundant_locals.rs:58:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:52:9 + --> $DIR/redundant_locals.rs:57:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:54:5 + --> $DIR/redundant_locals.rs:59:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:53:9 + --> $DIR/redundant_locals.rs:58:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:55:5 + --> $DIR/redundant_locals.rs:60:5 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:54:9 + --> $DIR/redundant_locals.rs:59:9 | LL | let x = x; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:61:5 + --> $DIR/redundant_locals.rs:66:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:59:9 + --> $DIR/redundant_locals.rs:64:9 | LL | let a = 1; | ^ error: redundant redefinition of a binding `b` - --> $DIR/redundant_locals.rs:62:5 + --> $DIR/redundant_locals.rs:67:5 | LL | let b = b; | ^^^^^^^^^^ | help: `b` is initially defined here - --> $DIR/redundant_locals.rs:60:9 + --> $DIR/redundant_locals.rs:65:9 | LL | let b = 2; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:68:9 + --> $DIR/redundant_locals.rs:73:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:67:13 + --> $DIR/redundant_locals.rs:72:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:75:9 + --> $DIR/redundant_locals.rs:80:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:74:13 + --> $DIR/redundant_locals.rs:79:13 | LL | let x = 1; | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:78:9 + --> $DIR/redundant_locals.rs:83:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:77:6 + --> $DIR/redundant_locals.rs:82:6 | LL | |x: i32| { | ^ error: redundant redefinition of a binding `x` - --> $DIR/redundant_locals.rs:97:9 + --> $DIR/redundant_locals.rs:102:9 | LL | let x = x; | ^^^^^^^^^^ | help: `x` is initially defined here - --> $DIR/redundant_locals.rs:94:9 + --> $DIR/redundant_locals.rs:99:9 | LL | let x = 1; | ^ error: redundant redefinition of a binding `a` - --> $DIR/redundant_locals.rs:152:5 + --> $DIR/redundant_locals.rs:157:5 | LL | let a = a; | ^^^^^^^^^^ | help: `a` is initially defined here - --> $DIR/redundant_locals.rs:150:9 + --> $DIR/redundant_locals.rs:155:9 | LL | let a = WithoutDrop(1); | ^ diff --git a/tests/ui/reserve_after_initialization.fixed b/tests/ui/reserve_after_initialization.fixed index 0675277849ad..2bb03096e273 100644 --- a/tests/ui/reserve_after_initialization.fixed +++ b/tests/ui/reserve_after_initialization.fixed @@ -1,5 +1,6 @@ //@aux-build:proc_macros.rs #![warn(clippy::reserve_after_initialization)] +#![allow(clippy::explicit_reinitialization)] #![no_main] extern crate proc_macros; diff --git a/tests/ui/reserve_after_initialization.rs b/tests/ui/reserve_after_initialization.rs index b57a8e162c53..1e73057b88ee 100644 --- a/tests/ui/reserve_after_initialization.rs +++ b/tests/ui/reserve_after_initialization.rs @@ -1,5 +1,6 @@ //@aux-build:proc_macros.rs #![warn(clippy::reserve_after_initialization)] +#![allow(clippy::explicit_reinitialization)] #![no_main] extern crate proc_macros; diff --git a/tests/ui/reserve_after_initialization.stderr b/tests/ui/reserve_after_initialization.stderr index a91033890766..5222e24ff125 100644 --- a/tests/ui/reserve_after_initialization.stderr +++ b/tests/ui/reserve_after_initialization.stderr @@ -1,5 +1,5 @@ error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:10:5 + --> $DIR/reserve_after_initialization.rs:11:5 | LL | / let mut v1: Vec = vec![]; LL | | v1.reserve(10); @@ -9,14 +9,14 @@ LL | | v1.reserve(10); = help: to override `-D warnings` add `#[allow(clippy::reserve_after_initialization)]` error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:17:5 + --> $DIR/reserve_after_initialization.rs:18:5 | LL | / let mut v2: Vec = vec![]; LL | | v2.reserve(capacity); | |_________________________^ help: consider using `Vec::with_capacity(/* Space hint */)`: `let mut v2: Vec = Vec::with_capacity(capacity);` error: call to `reserve` immediately after creation - --> $DIR/reserve_after_initialization.rs:35:5 + --> $DIR/reserve_after_initialization.rs:36:5 | LL | / v5 = Vec::new(); LL | | v5.reserve(10); diff --git a/tests/ui/self_assignment.rs b/tests/ui/self_assignment.rs index 213bca6c4515..2980eec906b6 100644 --- a/tests/ui/self_assignment.rs +++ b/tests/ui/self_assignment.rs @@ -1,5 +1,9 @@ #![warn(clippy::self_assignment)] -#![allow(clippy::useless_vec, clippy::needless_pass_by_ref_mut)] +#![allow( + clippy::useless_vec, + clippy::needless_pass_by_ref_mut, + clippy::explicit_reinitialization +)] pub struct S<'a> { a: i32, diff --git a/tests/ui/self_assignment.stderr b/tests/ui/self_assignment.stderr index 4612f8f82448..27f443b125e1 100644 --- a/tests/ui/self_assignment.stderr +++ b/tests/ui/self_assignment.stderr @@ -1,5 +1,5 @@ error: self-assignment of `a` to `a` - --> $DIR/self_assignment.rs:13:5 + --> $DIR/self_assignment.rs:17:5 | LL | a = a; | ^^^^^ @@ -8,61 +8,61 @@ LL | a = a; = help: to override `-D warnings` add `#[allow(clippy::self_assignment)]` error: self-assignment of `*b` to `*b` - --> $DIR/self_assignment.rs:16:5 + --> $DIR/self_assignment.rs:20:5 | LL | *b = *b; | ^^^^^^^ error: self-assignment of `s` to `s` - --> $DIR/self_assignment.rs:18:5 + --> $DIR/self_assignment.rs:22:5 | LL | s = s; | ^^^^^ error: self-assignment of `s.a` to `s.a` - --> $DIR/self_assignment.rs:20:5 + --> $DIR/self_assignment.rs:24:5 | LL | s.a = s.a; | ^^^^^^^^^ error: self-assignment of `s.b[5 + 4]` to `s.b[9]` - --> $DIR/self_assignment.rs:22:5 + --> $DIR/self_assignment.rs:26:5 | LL | s.b[9] = s.b[5 + 4]; | ^^^^^^^^^^^^^^^^^^^ error: self-assignment of `s.c[0][1]` to `s.c[0][1]` - --> $DIR/self_assignment.rs:24:5 + --> $DIR/self_assignment.rs:28:5 | LL | s.c[0][1] = s.c[0][1]; | ^^^^^^^^^^^^^^^^^^^^^ error: self-assignment of `s.b[a]` to `s.b[a]` - --> $DIR/self_assignment.rs:26:5 + --> $DIR/self_assignment.rs:30:5 | LL | s.b[a] = s.b[a]; | ^^^^^^^^^^^^^^^ error: self-assignment of `*s.e` to `*s.e` - --> $DIR/self_assignment.rs:28:5 + --> $DIR/self_assignment.rs:32:5 | LL | *s.e = *s.e; | ^^^^^^^^^^^ error: self-assignment of `s.b[10 + a]` to `s.b[a + 10]` - --> $DIR/self_assignment.rs:30:5 + --> $DIR/self_assignment.rs:34:5 | LL | s.b[a + 10] = s.b[10 + a]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: self-assignment of `t.1` to `t.1` - --> $DIR/self_assignment.rs:34:5 + --> $DIR/self_assignment.rs:38:5 | LL | t.1 = t.1; | ^^^^^^^^^ error: self-assignment of `(t.0)` to `t.0` - --> $DIR/self_assignment.rs:36:5 + --> $DIR/self_assignment.rs:40:5 | LL | t.0 = (t.0); | ^^^^^^^^^^^ diff --git a/tests/ui/semicolon_if_nothing_returned.fixed b/tests/ui/semicolon_if_nothing_returned.fixed index bbcc0de27d11..911ba8c055b1 100644 --- a/tests/ui/semicolon_if_nothing_returned.fixed +++ b/tests/ui/semicolon_if_nothing_returned.fixed @@ -1,5 +1,10 @@ #![warn(clippy::semicolon_if_nothing_returned)] -#![allow(clippy::redundant_closure, clippy::uninlined_format_args, clippy::needless_late_init)] +#![allow( + clippy::redundant_closure, + clippy::uninlined_format_args, + clippy::needless_late_init, + clippy::explicit_reinitialization +)] fn get_unit() {} diff --git a/tests/ui/semicolon_if_nothing_returned.rs b/tests/ui/semicolon_if_nothing_returned.rs index fdc9c0c33f5a..ddc8165ef071 100644 --- a/tests/ui/semicolon_if_nothing_returned.rs +++ b/tests/ui/semicolon_if_nothing_returned.rs @@ -1,5 +1,10 @@ #![warn(clippy::semicolon_if_nothing_returned)] -#![allow(clippy::redundant_closure, clippy::uninlined_format_args, clippy::needless_late_init)] +#![allow( + clippy::redundant_closure, + clippy::uninlined_format_args, + clippy::needless_late_init, + clippy::explicit_reinitialization +)] fn get_unit() {} diff --git a/tests/ui/semicolon_if_nothing_returned.stderr b/tests/ui/semicolon_if_nothing_returned.stderr index 66373a13c569..09c4d12f216c 100644 --- a/tests/ui/semicolon_if_nothing_returned.stderr +++ b/tests/ui/semicolon_if_nothing_returned.stderr @@ -1,5 +1,5 @@ error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:8:5 + --> $DIR/semicolon_if_nothing_returned.rs:13:5 | LL | println!("Hello") | ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");` @@ -8,25 +8,25 @@ LL | println!("Hello") = help: to override `-D warnings` add `#[allow(clippy::semicolon_if_nothing_returned)]` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:12:5 + --> $DIR/semicolon_if_nothing_returned.rs:17:5 | LL | get_unit() | ^^^^^^^^^^ help: add a `;` here: `get_unit();` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:17:5 + --> $DIR/semicolon_if_nothing_returned.rs:22:5 | LL | y = x + 1 | ^^^^^^^^^ help: add a `;` here: `y = x + 1;` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:23:9 + --> $DIR/semicolon_if_nothing_returned.rs:28:9 | LL | hello() | ^^^^^^^ help: add a `;` here: `hello();` error: consider adding a `;` to the last statement for consistent formatting - --> $DIR/semicolon_if_nothing_returned.rs:34:9 + --> $DIR/semicolon_if_nothing_returned.rs:39:9 | LL | ptr::drop_in_place(s.as_mut_ptr()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());` diff --git a/tests/ui/slow_vector_initialization.rs b/tests/ui/slow_vector_initialization.rs index 16f81019574f..a9061b3cd0e8 100644 --- a/tests/ui/slow_vector_initialization.rs +++ b/tests/ui/slow_vector_initialization.rs @@ -1,4 +1,5 @@ //@no-rustfix +#![allow(clippy::explicit_reinitialization)] use std::iter::repeat; fn main() { resize_vector(); diff --git a/tests/ui/slow_vector_initialization.stderr b/tests/ui/slow_vector_initialization.stderr index 16a7057653c1..1c248b16a0cd 100644 --- a/tests/ui/slow_vector_initialization.stderr +++ b/tests/ui/slow_vector_initialization.stderr @@ -1,5 +1,5 @@ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:14:5 + --> $DIR/slow_vector_initialization.rs:15:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -10,7 +10,7 @@ LL | vec1.extend(repeat(0).take(len)); = help: to override `-D warnings` add `#[allow(clippy::slow_vector_initialization)]` error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:20:5 + --> $DIR/slow_vector_initialization.rs:21:5 | LL | let mut vec2 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replacing this with: `vec![0; len - 10]` @@ -18,7 +18,7 @@ LL | vec2.extend(repeat(0).take(len - 10)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:28:5 + --> $DIR/slow_vector_initialization.rs:29:5 | LL | let mut vec4 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -26,7 +26,7 @@ LL | vec4.extend(repeat(0).take(vec4.capacity())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:39:5 + --> $DIR/slow_vector_initialization.rs:40:5 | LL | let mut resized_vec = Vec::with_capacity(30); | ---------------------- help: consider replacing this with: `vec![0; 30]` @@ -34,7 +34,7 @@ LL | resized_vec.resize(30, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:43:5 + --> $DIR/slow_vector_initialization.rs:44:5 | LL | let mut extend_vec = Vec::with_capacity(30); | ---------------------- help: consider replacing this with: `vec![0; 30]` @@ -42,7 +42,7 @@ LL | extend_vec.extend(repeat(0).take(30)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:51:5 + --> $DIR/slow_vector_initialization.rs:52:5 | LL | let mut vec1 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -50,7 +50,7 @@ LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:60:5 + --> $DIR/slow_vector_initialization.rs:61:5 | LL | let mut vec3 = Vec::with_capacity(len - 10); | ---------------------------- help: consider replacing this with: `vec![0; len - 10]` @@ -58,7 +58,7 @@ LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:64:5 + --> $DIR/slow_vector_initialization.rs:65:5 | LL | let mut vec4 = Vec::with_capacity(len); | ----------------------- help: consider replacing this with: `vec![0; len]` @@ -66,7 +66,7 @@ LL | vec4.resize(vec4.capacity(), 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:69:5 + --> $DIR/slow_vector_initialization.rs:70:5 | LL | vec1 = Vec::with_capacity(10); | ---------------------- help: consider replacing this with: `vec![0; 10]` @@ -74,7 +74,7 @@ LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:77:5 + --> $DIR/slow_vector_initialization.rs:78:5 | LL | let mut vec1 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; len]` @@ -82,7 +82,7 @@ LL | vec1.resize(len, 0); | ^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:82:5 + --> $DIR/slow_vector_initialization.rs:83:5 | LL | let mut vec3 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; len - 10]` @@ -90,7 +90,7 @@ LL | vec3.resize(len - 10, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:87:5 + --> $DIR/slow_vector_initialization.rs:88:5 | LL | vec1 = Vec::new(); | ---------- help: consider replacing this with: `vec![0; 10]` @@ -98,7 +98,7 @@ LL | vec1.resize(10, 0); | ^^^^^^^^^^^^^^^^^^ error: slow zero-filling initialization - --> $DIR/slow_vector_initialization.rs:91:5 + --> $DIR/slow_vector_initialization.rs:92:5 | LL | vec1 = vec![]; | ------ help: consider replacing this with: `vec![0; 10]` diff --git a/tests/ui/string_add.rs b/tests/ui/string_add.rs index c535f2ebbfcb..3564f3a4f50e 100644 --- a/tests/ui/string_add.rs +++ b/tests/ui/string_add.rs @@ -4,7 +4,7 @@ extern crate proc_macros; use proc_macros::external; #[warn(clippy::string_add)] -#[allow(clippy::string_add_assign, unused)] +#[allow(clippy::string_add_assign, unused, clippy::explicit_reinitialization)] fn main() { // ignores assignment distinction let mut x = String::new(); diff --git a/tests/ui/string_add_assign.fixed b/tests/ui/string_add_assign.fixed index 31d84831d09a..92bd73e80b32 100644 --- a/tests/ui/string_add_assign.fixed +++ b/tests/ui/string_add_assign.fixed @@ -1,4 +1,4 @@ -#[allow(clippy::string_add, unused)] +#[allow(clippy::string_add, unused, clippy::explicit_reinitialization)] #[warn(clippy::string_add_assign)] fn main() { // ignores assignment distinction diff --git a/tests/ui/string_add_assign.rs b/tests/ui/string_add_assign.rs index cdea91573cc7..65eac16d4ef2 100644 --- a/tests/ui/string_add_assign.rs +++ b/tests/ui/string_add_assign.rs @@ -1,4 +1,4 @@ -#[allow(clippy::string_add, unused)] +#[allow(clippy::string_add, unused, clippy::explicit_reinitialization)] #[warn(clippy::string_add_assign)] fn main() { // ignores assignment distinction diff --git a/tests/ui/swap.fixed b/tests/ui/swap.fixed index 888665a17ad1..4a6df25f2ea8 100644 --- a/tests/ui/swap.fixed +++ b/tests/ui/swap.fixed @@ -11,7 +11,8 @@ unused_variables, clippy::let_and_return, clippy::useless_vec, - clippy::redundant_locals + clippy::redundant_locals, + clippy::explicit_reinitialization )] struct Foo(u32); diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index c9ad77629290..57a502ce44e1 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -11,7 +11,8 @@ unused_variables, clippy::let_and_return, clippy::useless_vec, - clippy::redundant_locals + clippy::redundant_locals, + clippy::explicit_reinitialization )] struct Foo(u32); diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index e69ad02b08fe..45d3820f57e5 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are swapping `bar.a` and `bar.b` manually - --> $DIR/swap.rs:28:5 + --> $DIR/swap.rs:29:5 | LL | / let temp = bar.a; LL | | bar.a = bar.b; @@ -11,7 +11,7 @@ LL | | bar.b = temp; = help: to override `-D warnings` add `#[allow(clippy::manual_swap)]` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:40:5 + --> $DIR/swap.rs:41:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -19,7 +19,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:49:5 + --> $DIR/swap.rs:50:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -27,7 +27,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:68:5 + --> $DIR/swap.rs:69:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -35,7 +35,7 @@ LL | | foo[1] = temp; | |__________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:79:5 + --> $DIR/swap.rs:80:5 | LL | / a ^= b; LL | | b ^= a; @@ -43,7 +43,7 @@ LL | | a ^= b; | |___________^ help: try: `std::mem::swap(&mut a, &mut b);` error: this looks like you are swapping `bar.a` and `bar.b` manually - --> $DIR/swap.rs:87:5 + --> $DIR/swap.rs:88:5 | LL | / bar.a ^= bar.b; LL | | bar.b ^= bar.a; @@ -51,7 +51,7 @@ LL | | bar.a ^= bar.b; | |___________________^ help: try: `std::mem::swap(&mut bar.a, &mut bar.b);` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:95:5 + --> $DIR/swap.rs:96:5 | LL | / foo[0] ^= foo[1]; LL | | foo[1] ^= foo[0]; @@ -59,7 +59,7 @@ LL | | foo[0] ^= foo[1]; | |_____________________^ help: try: `foo.swap(0, 1);` error: this looks like you are swapping `foo[0][1]` and `bar[1][0]` manually - --> $DIR/swap.rs:124:5 + --> $DIR/swap.rs:125:5 | LL | / let temp = foo[0][1]; LL | | foo[0][1] = bar[1][0]; @@ -69,7 +69,7 @@ LL | | bar[1][0] = temp; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:138:7 + --> $DIR/swap.rs:139:7 | LL | ; let t = a; | _______^ @@ -80,7 +80,7 @@ LL | | b = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:147:7 + --> $DIR/swap.rs:148:7 | LL | ; let t = c.0; | _______^ @@ -91,7 +91,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `b` and `a` manually - --> $DIR/swap.rs:173:5 + --> $DIR/swap.rs:174:5 | LL | / let t = b; LL | | b = a; @@ -101,7 +101,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:135:5 + --> $DIR/swap.rs:136:5 | LL | / a = b; LL | | b = a; @@ -112,7 +112,7 @@ LL | | b = a; = help: to override `-D warnings` add `#[allow(clippy::almost_swapped)]` error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:144:5 + --> $DIR/swap.rs:145:5 | LL | / c.0 = a; LL | | a = c.0; @@ -121,7 +121,7 @@ LL | | a = c.0; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:151:5 + --> $DIR/swap.rs:152:5 | LL | / let a = b; LL | | let b = a; @@ -130,7 +130,7 @@ LL | | let b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `d` and `c` - --> $DIR/swap.rs:156:5 + --> $DIR/swap.rs:157:5 | LL | / d = c; LL | | c = d; @@ -139,7 +139,7 @@ LL | | c = d; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:160:5 + --> $DIR/swap.rs:161:5 | LL | / let a = b; LL | | b = a; @@ -148,7 +148,7 @@ LL | | b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `s.0.x` and `s.0.y` manually - --> $DIR/swap.rs:208:5 + --> $DIR/swap.rs:209:5 | LL | / let t = s.0.x; LL | | s.0.x = s.0.y; diff --git a/tests/ui/unwrap_or_else_default.fixed b/tests/ui/unwrap_or_else_default.fixed index 8d5d34175c52..9f13a140afd5 100644 --- a/tests/ui/unwrap_or_else_default.fixed +++ b/tests/ui/unwrap_or_else_default.fixed @@ -1,6 +1,10 @@ #![warn(clippy::unwrap_or_default)] #![allow(dead_code)] -#![allow(clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)] +#![allow( + clippy::unnecessary_wraps, + clippy::unnecessary_literal_unwrap, + clippy::explicit_reinitialization +)] /// Checks implementation of the `UNWRAP_OR_DEFAULT` lint. fn unwrap_or_else_default() { diff --git a/tests/ui/unwrap_or_else_default.rs b/tests/ui/unwrap_or_else_default.rs index adbcb4b44659..2194b4833488 100644 --- a/tests/ui/unwrap_or_else_default.rs +++ b/tests/ui/unwrap_or_else_default.rs @@ -1,6 +1,10 @@ #![warn(clippy::unwrap_or_default)] #![allow(dead_code)] -#![allow(clippy::unnecessary_wraps, clippy::unnecessary_literal_unwrap)] +#![allow( + clippy::unnecessary_wraps, + clippy::unnecessary_literal_unwrap, + clippy::explicit_reinitialization +)] /// Checks implementation of the `UNWRAP_OR_DEFAULT` lint. fn unwrap_or_else_default() { diff --git a/tests/ui/unwrap_or_else_default.stderr b/tests/ui/unwrap_or_else_default.stderr index 3119aba19e8f..6ab9b087b6f8 100644 --- a/tests/ui/unwrap_or_else_default.stderr +++ b/tests/ui/unwrap_or_else_default.stderr @@ -1,5 +1,5 @@ error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:46:14 + --> $DIR/unwrap_or_else_default.rs:50:14 | LL | with_new.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` @@ -8,91 +8,91 @@ LL | with_new.unwrap_or_else(Vec::new); = help: to override `-D warnings` add `#[allow(clippy::unwrap_or_default)]` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:60:23 + --> $DIR/unwrap_or_else_default.rs:64:23 | LL | with_real_default.unwrap_or_else(::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:63:24 + --> $DIR/unwrap_or_else_default.rs:67:24 | LL | with_default_trait.unwrap_or_else(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:66:23 + --> $DIR/unwrap_or_else_default.rs:70:23 | LL | with_default_type.unwrap_or_else(u64::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:69:23 + --> $DIR/unwrap_or_else_default.rs:73:23 | LL | with_default_type.unwrap_or_else(Vec::new); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:72:18 + --> $DIR/unwrap_or_else_default.rs:76:18 | LL | empty_string.unwrap_or_else(|| "".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:76:12 + --> $DIR/unwrap_or_else_default.rs:80:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:79:12 + --> $DIR/unwrap_or_else_default.rs:83:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:82:12 + --> $DIR/unwrap_or_else_default.rs:86:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:85:12 + --> $DIR/unwrap_or_else_default.rs:89:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:88:12 + --> $DIR/unwrap_or_else_default.rs:92:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:91:12 + --> $DIR/unwrap_or_else_default.rs:95:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:94:12 + --> $DIR/unwrap_or_else_default.rs:98:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:97:12 + --> $DIR/unwrap_or_else_default.rs:101:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or_else` to construct default value - --> $DIR/unwrap_or_else_default.rs:113:12 + --> $DIR/unwrap_or_else_default.rs:117:12 | LL | option.unwrap_or_else(Vec::new).push(1); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `or_insert_with` to construct default value - --> $DIR/unwrap_or_else_default.rs:130:32 + --> $DIR/unwrap_or_else_default.rs:134:32 | LL | let _ = inner_map.entry(0).or_insert_with(Default::default); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` diff --git a/tests/ui/used_underscore_binding.rs b/tests/ui/used_underscore_binding.rs index a8f404b1400c..58334991e1b2 100644 --- a/tests/ui/used_underscore_binding.rs +++ b/tests/ui/used_underscore_binding.rs @@ -1,7 +1,12 @@ //@aux-build:proc_macro_derive.rs #![feature(rustc_private, lint_reasons)] #![warn(clippy::used_underscore_binding)] -#![allow(clippy::disallowed_names, clippy::eq_op, clippy::uninlined_format_args)] +#![allow( + clippy::disallowed_names, + clippy::eq_op, + clippy::uninlined_format_args, + clippy::explicit_reinitialization +)] #[macro_use] extern crate proc_macro_derive; diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 78d8279810c1..80a36676d3c2 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,11 +1,11 @@ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:23:5 + --> $DIR/used_underscore_binding.rs:28:5 | LL | _foo + 1 | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:22:22 + --> $DIR/used_underscore_binding.rs:27:22 | LL | fn prefix_underscore(_foo: u32) -> u32 { | ^^^^ @@ -13,61 +13,61 @@ LL | fn prefix_underscore(_foo: u32) -> u32 { = help: to override `-D warnings` add `#[allow(clippy::used_underscore_binding)]` error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:28:20 + --> $DIR/used_underscore_binding.rs:33:20 | LL | println!("{}", _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> $DIR/used_underscore_binding.rs:32:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:29:16 + --> $DIR/used_underscore_binding.rs:34:16 | LL | assert_eq!(_foo, _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> $DIR/used_underscore_binding.rs:32:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:29:22 + --> $DIR/used_underscore_binding.rs:34:22 | LL | assert_eq!(_foo, _foo); | ^^^^ | note: `_foo` is defined here - --> $DIR/used_underscore_binding.rs:27:24 + --> $DIR/used_underscore_binding.rs:32:24 | LL | fn in_macro_or_desugar(_foo: u32) { | ^^^^ error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:42:5 + --> $DIR/used_underscore_binding.rs:47:5 | LL | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ | note: `_underscore_field` is defined here - --> $DIR/used_underscore_binding.rs:36:5 + --> $DIR/used_underscore_binding.rs:41:5 | LL | _underscore_field: u32, | ^^^^^^^^^^^^^^^^^^^^^^ error: used binding `_i` which is prefixed with an underscore. A leading underscore signals that a binding will not be used - --> $DIR/used_underscore_binding.rs:103:16 + --> $DIR/used_underscore_binding.rs:108:16 | LL | uses_i(_i); | ^^ | note: `_i` is defined here - --> $DIR/used_underscore_binding.rs:102:13 + --> $DIR/used_underscore_binding.rs:107:13 | LL | let _i = 5; | ^^ diff --git a/tests/ui/vec_init_then_push.rs b/tests/ui/vec_init_then_push.rs index 1c60a75c56ae..844e1324ea1b 100644 --- a/tests/ui/vec_init_then_push.rs +++ b/tests/ui/vec_init_then_push.rs @@ -1,4 +1,4 @@ -#![allow(unused_variables)] +#![allow(unused_variables, clippy::explicit_reinitialization)] #![warn(clippy::vec_init_then_push)] //@no-rustfix fn main() { diff --git a/tests/ui/while_let_loop.rs b/tests/ui/while_let_loop.rs index fa5325bebffa..08dd84e617f9 100644 --- a/tests/ui/while_let_loop.rs +++ b/tests/ui/while_let_loop.rs @@ -1,5 +1,5 @@ #![warn(clippy::while_let_loop)] -#![allow(clippy::uninlined_format_args)] +#![allow(clippy::uninlined_format_args, clippy::explicit_reinitialization)] //@no-rustfix fn main() { let y = Some(true);