From 1f94d55a183c493ae2ca2754d9485f89e4ac76ae Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 12 Feb 2025 23:44:38 +0100 Subject: [PATCH] Fix new tests updates --- tests/ui/as_pointer_underscore.fixed | 2 - tests/ui/as_pointer_underscore.rs | 2 - tests/ui/as_pointer_underscore.stderr | 2 +- tests/ui/as_ptr_cast_mut.rs | 1 - tests/ui/as_ptr_cast_mut.stderr | 2 +- tests/ui/asm_syntax_x86.rs | 2 - tests/ui/asm_syntax_x86.stderr | 2 +- tests/ui/assertions_on_constants.rs | 6 - tests/ui/assertions_on_constants.stderr | 16 +- tests/ui/assign_ops2.rs | 3 - tests/ui/assign_ops2.stderr | 18 +- tests/ui/attrs.rs | 2 - tests/ui/attrs.stderr | 4 +- tests/ui/await_holding_refcell_ref.rs | 2 - tests/ui/await_holding_refcell_ref.stderr | 14 +- tests/ui/bind_instead_of_map_multipart.fixed | 2 +- tests/ui/bind_instead_of_map_multipart.rs | 2 +- tests/ui/bit_masks.rs | 9 - tests/ui/bit_masks.stderr | 30 +-- tests/ui/blanket_clippy_restriction_lints.rs | 3 - .../blanket_clippy_restriction_lints.stderr | 4 +- tests/ui/bool_comparison.fixed | 28 +-- tests/ui/bool_comparison.rs | 28 +-- tests/ui/bool_to_int_with_if.rs | 16 +- tests/ui/borrow_box.fixed | 6 - tests/ui/borrow_box.rs | 6 - tests/ui/borrow_box.stderr | 18 +- tests/ui/borrow_deref_ref_unfixable.rs | 2 - .../borrow_interior_mutable_const/others.rs | 56 ++--- .../others.stderr | 84 ++++---- .../borrow_interior_mutable_const/traits.rs | 68 +++--- .../traits.stderr | 102 ++++----- tests/ui/box_collection.rs | 9 - tests/ui/box_collection.stderr | 16 +- tests/ui/boxed_local.rs | 7 +- tests/ui/boxed_local.stderr | 6 +- .../branches_sharing_code/shared_at_bottom.rs | 10 +- .../shared_at_bottom.stderr | 31 ++- .../ui/branches_sharing_code/shared_at_top.rs | 15 +- .../shared_at_top.stderr | 14 +- .../shared_at_top_and_bottom.rs | 10 +- .../branches_sharing_code/valid_if_blocks.rs | 5 - .../valid_if_blocks.stderr | 16 +- tests/ui/builtin_type_shadow.rs | 2 +- tests/ui/bytecount.rs | 3 - tests/ui/bytecount.stderr | 4 +- tests/ui/cast.rs | 24 --- tests/ui/cast.stderr | 182 ++++++++-------- tests/ui/cast_alignment.rs | 3 - tests/ui/cast_alignment.stderr | 6 +- tests/ui/cast_enum_constructor.rs | 1 - tests/ui/cast_enum_constructor.stderr | 2 +- tests/ui/cast_lossless_integer.fixed | 13 -- tests/ui/cast_lossless_integer.rs | 13 -- tests/ui/cast_lossless_integer.stderr | 64 +++--- tests/ui/cast_nan_to_int.rs | 8 - tests/ui/cast_nan_to_int.stderr | 10 +- tests/ui/cast_slice_different_sizes.rs | 20 +- tests/ui/cast_slice_different_sizes.stderr | 28 +-- tests/ui/char_lit_as_u8.rs | 2 - .../ui/checked_unwrap/complex_conditionals.rs | 4 - .../complex_conditionals.stderr | 32 +-- .../ui/checked_unwrap/simple_conditionals.rs | 18 +- .../checked_unwrap/simple_conditionals.stderr | 46 ++-- tests/ui/cmp_null.fixed | 10 +- tests/ui/cmp_null.rs | 10 +- tests/ui/cmp_null.stderr | 8 +- tests/ui/cmp_owned/comparison_flip.fixed | 4 +- tests/ui/cmp_owned/comparison_flip.rs | 4 +- tests/ui/cmp_owned/without_suggestion.rs | 4 - tests/ui/cmp_owned/without_suggestion.stderr | 4 +- tests/ui/cognitive_complexity.rs | 37 ++-- tests/ui/cognitive_complexity.stderr | 32 +-- tests/ui/cognitive_complexity_attr_used.rs | 2 +- tests/ui/collapsible_match.rs | 32 ++- tests/ui/collapsible_match.stderr | 62 +++--- tests/ui/collapsible_match2.rs | 14 +- tests/ui/collapsible_match2.stderr | 28 ++- tests/ui/collection_is_never_read.rs | 1 - tests/ui/collection_is_never_read.stderr | 38 ++-- tests/ui/comparison_chain.rs | 16 +- tests/ui/comparison_to_empty.fixed | 2 +- tests/ui/comparison_to_empty.rs | 2 +- tests/ui/const_comparisons.rs | 30 --- tests/ui/const_comparisons.stderr | 60 +++--- tests/ui/const_is_empty.rs | 21 +- tests/ui/const_is_empty.stderr | 52 ++--- tests/ui/copy_iterator.rs | 3 +- tests/ui/copy_iterator.stderr | 3 + tests/ui/crashes/ice-11803.rs | 4 +- tests/ui/crashes/ice-2774.fixed | 3 +- tests/ui/crashes/ice-2774.rs | 3 +- tests/ui/crashes/ice-360.rs | 7 +- tests/ui/crashes/ice-360.stderr | 2 +- tests/ui/crashes/ice-3717.fixed | 2 +- tests/ui/crashes/ice-3717.rs | 2 +- tests/ui/crashes/ice-3969.rs | 8 +- tests/ui/crashes/ice-5872.fixed | 2 - tests/ui/crashes/ice-5872.rs | 2 - tests/ui/crashes/ice-6250.rs | 4 +- tests/ui/crashes/ice-6251.rs | 6 +- tests/ui/crashes/ice-7169.fixed | 2 - tests/ui/crashes/ice-7169.rs | 2 - tests/ui/crashes/ice-7869.rs | 3 +- tests/ui/crashes/ice-7869.stderr | 1 - tests/ui/crashes/ice-8250.fixed | 1 - tests/ui/crashes/ice-8250.rs | 1 - tests/ui/crashes/ice-9041.rs | 2 - .../needless_lifetimes_impl_trait.fixed | 2 +- .../crashes/needless_lifetimes_impl_trait.rs | 2 +- .../needless_pass_by_value-w-late-bound.fixed | 1 - .../needless_pass_by_value-w-late-bound.rs | 1 - tests/ui/crate_level_checks/no_std_swap.rs | 1 - .../crate_level_checks/std_main_recursion.rs | 1 - tests/ui/dbg_macro/dbg_macro.fixed | 12 +- tests/ui/dbg_macro/dbg_macro.rs | 12 +- tests/ui/dbg_macro/dbg_macro.stderr | 36 ++-- tests/ui/dbg_macro/dbg_macro_unfixable.rs | 1 - .../declare_interior_mutable_const/enums.rs | 39 ++-- .../enums.stderr | 53 +++-- .../declare_interior_mutable_const/others.rs | 2 - .../others.stderr | 4 +- .../declare_interior_mutable_const/traits.rs | 49 +++-- .../traits.stderr | 72 +++---- tests/ui/default_numeric_fallback_f64.fixed | 2 +- tests/ui/default_numeric_fallback_f64.rs | 2 +- tests/ui/default_numeric_fallback_i32.fixed | 2 +- tests/ui/default_numeric_fallback_i32.rs | 2 +- tests/ui/default_union_representation.rs | 12 +- tests/ui/default_union_representation.stderr | 10 +- tests/ui/deref_addrof_double_trigger.rs | 4 - tests/ui/deref_addrof_double_trigger.stderr | 4 +- tests/ui/derivable_impls.rs | 22 +- tests/ui/derive.rs | 10 +- tests/ui/derive_ord_xor_partial_ord.rs | 4 +- tests/ui/disallowed_names.rs | 10 +- tests/ui/disallowed_names.stderr | 26 +-- tests/ui/disallowed_script_idents.rs | 1 - tests/ui/diverging_sub_expression.rs | 2 - tests/ui/diverging_sub_expression.stderr | 20 +- tests/ui/doc/issue_12795.fixed | 4 - tests/ui/doc/issue_12795.rs | 4 - tests/ui/doc_errors.rs | 14 +- tests/ui/doc_errors.stderr | 12 +- tests/ui/doc_unsafe.rs | 10 +- tests/ui/double_comparison.fixed | 16 +- tests/ui/double_comparison.rs | 16 +- tests/ui/double_must_use.rs | 8 +- tests/ui/duplicate_underscore_argument.rs | 1 - tests/ui/else_if_without_else.rs | 8 +- tests/ui/empty_drop.rs | 4 +- tests/ui/empty_enum.rs | 1 - .../empty_enum_variants_with_brackets.fixed | 18 +- tests/ui/empty_enum_variants_with_brackets.rs | 18 +- .../empty_enum_variants_with_brackets.stderr | 24 +-- .../ui/empty_line_after/doc_comments.1.fixed | 11 +- .../ui/empty_line_after/doc_comments.2.fixed | 13 +- tests/ui/empty_line_after/doc_comments.rs | 11 +- tests/ui/empty_line_after/doc_comments.stderr | 32 +-- tests/ui/empty_loop_no_std.rs | 1 - tests/ui/entry.fixed | 18 +- tests/ui/entry.rs | 22 +- tests/ui/entry_btree.fixed | 2 +- tests/ui/entry_btree.rs | 2 +- tests/ui/entry_with_else.fixed | 14 +- tests/ui/entry_with_else.rs | 14 +- tests/ui/enum_clike_unportable_variant.rs | 10 - tests/ui/enum_clike_unportable_variant.stderr | 16 +- tests/ui/enum_variants.rs | 21 +- tests/ui/enum_variants.stderr | 19 +- tests/ui/eprint_with_newline.fixed | 8 +- tests/ui/eprint_with_newline.rs | 8 +- tests/ui/eprint_with_newline.stderr | 20 +- tests/ui/eq_op.rs | 13 -- tests/ui/eq_op.stderr | 56 ++--- tests/ui/equatable_if_let.fixed | 2 +- tests/ui/equatable_if_let.rs | 2 +- tests/ui/erasing_op.rs | 2 - tests/ui/erasing_op.stderr | 8 +- tests/ui/error_impl_error.rs | 6 +- tests/ui/error_impl_error.stderr | 12 +- tests/ui/exhaustive_items.fixed | 6 +- tests/ui/exhaustive_items.rs | 6 +- tests/ui/exit1.rs | 2 - tests/ui/exit2.rs | 2 - tests/ui/expect.rs | 2 - tests/ui/expect.stderr | 4 +- tests/ui/explicit_counter_loop.rs | 22 +- tests/ui/explicit_counter_loop.stderr | 18 +- tests/ui/explicit_deref_methods.fixed | 2 +- tests/ui/explicit_deref_methods.rs | 2 +- tests/ui/extra_unused_lifetimes.rs | 8 +- tests/ui/extra_unused_type_parameters.fixed | 16 +- tests/ui/extra_unused_type_parameters.rs | 16 +- .../extra_unused_type_parameters_unfixable.rs | 3 - ...ra_unused_type_parameters_unfixable.stderr | 4 +- tests/ui/fallible_impl_from.rs | 8 +- tests/ui/filetype_is_file.rs | 6 +- tests/ui/filter_map_bool_then.fixed | 6 +- tests/ui/filter_map_bool_then.rs | 6 +- tests/ui/filter_map_identity.fixed | 10 +- tests/ui/filter_map_identity.rs | 10 +- tests/ui/filter_map_identity.stderr | 34 +-- tests/ui/float_arithmetic.rs | 5 - tests/ui/float_arithmetic.stderr | 8 +- tests/ui/float_cmp.rs | 3 - tests/ui/float_cmp.stderr | 6 +- tests/ui/float_cmp_const.rs | 3 - tests/ui/float_cmp_const.stderr | 6 +- tests/ui/float_equality_without_abs.rs | 4 - tests/ui/float_equality_without_abs.stderr | 20 +- tests/ui/fn_to_numeric_cast_any.rs | 8 - tests/ui/fn_to_numeric_cast_any.stderr | 32 +-- tests/ui/for_kv_map.fixed | 13 +- tests/ui/for_kv_map.rs | 13 +- tests/ui/for_kv_map.stderr | 10 +- tests/ui/forget_non_drop.rs | 1 - tests/ui/forget_non_drop.stderr | 4 +- tests/ui/format.rs | 2 +- tests/ui/format_args.fixed | 4 +- tests/ui/format_args.rs | 4 +- tests/ui/format_args.stderr | 4 +- tests/ui/format_args_unfixable.rs | 8 +- tests/ui/format_args_unfixable.stderr | 34 ++- tests/ui/format_collect.rs | 4 +- tests/ui/format_collect.stderr | 16 +- tests/ui/format_push_string.rs | 8 +- tests/ui/format_push_string.stderr | 7 +- tests/ui/from_over_into.fixed | 14 +- tests/ui/from_over_into.rs | 14 +- tests/ui/from_over_into_unfixable.rs | 8 +- tests/ui/from_raw_with_void_ptr.rs | 5 - tests/ui/from_raw_with_void_ptr.stderr | 16 +- tests/ui/from_str_radix_10.fixed | 4 - tests/ui/from_str_radix_10.rs | 4 - tests/ui/from_str_radix_10.stderr | 14 +- tests/ui/functions.rs | 9 - tests/ui/functions.stderr | 30 +-- tests/ui/functions_maxlines.rs | 3 +- tests/ui/functions_maxlines.stderr | 3 + tests/ui/future_not_send.rs | 14 +- tests/ui/future_not_send.stderr | 17 +- tests/ui/get_first.fixed | 1 - tests/ui/get_first.rs | 1 - tests/ui/identity_op.fixed | 7 - tests/ui/identity_op.rs | 7 - tests/ui/identity_op.stderr | 42 ++-- tests/ui/if_not_else.fixed | 12 +- tests/ui/if_not_else.rs | 12 +- tests/ui/if_same_then_else.rs | 5 - tests/ui/if_same_then_else.stderr | 20 +- tests/ui/if_same_then_else2.rs | 6 - tests/ui/if_same_then_else2.stderr | 20 +- tests/ui/if_then_some_else_none.fixed | 2 - tests/ui/if_then_some_else_none.rs | 8 +- tests/ui/if_then_some_else_none.stderr | 6 +- tests/ui/ifs_same_cond.rs | 11 +- tests/ui/ifs_same_cond.stderr | 12 +- tests/ui/impl.rs | 7 +- tests/ui/impl_trait_in_params.rs | 9 +- tests/ui/impl_trait_in_params.stderr | 20 +- tests/ui/implicit_hasher.fixed | 10 +- tests/ui/implicit_hasher.rs | 10 +- tests/ui/implicit_saturating_add.rs | 48 ++--- tests/ui/implicit_saturating_sub.rs | 48 ++--- tests/ui/implied_bounds_in_impls.fixed | 10 +- tests/ui/implied_bounds_in_impls.rs | 10 +- tests/ui/incompatible_msrv.rs | 2 - tests/ui/incompatible_msrv.stderr | 2 +- .../ui/inconsistent_struct_constructor.fixed | 4 +- tests/ui/inconsistent_struct_constructor.rs | 4 +- .../if_let_slice_binding.fixed | 21 +- .../if_let_slice_binding.rs | 21 +- .../if_let_slice_binding.stderr | 12 +- tests/ui/ineffective_open_options.fixed | 6 +- tests/ui/ineffective_open_options.rs | 8 +- tests/ui/ineffective_open_options.stderr | 12 +- tests/ui/infallible_destructuring_match.rs | 8 +- tests/ui/infinite_iter.rs | 9 +- tests/ui/infinite_iter.stderr | 27 ++- tests/ui/infinite_loop.rs | 33 +-- tests/ui/infinite_loop.stderr | 20 +- tests/ui/infinite_loops.rs | 42 ++-- tests/ui/inherent_to_string.rs | 4 +- tests/ui/init_numbered_fields.rs | 4 +- tests/ui/inspect_for_each.rs | 2 +- tests/ui/into_iter_on_ref.fixed | 104 +++++----- tests/ui/into_iter_on_ref.rs | 104 +++++----- tests/ui/into_iter_on_ref.stderr | 156 +++++++------- tests/ui/into_iter_without_iter.rs | 12 +- tests/ui/invalid_upcast_comparisons.rs | 5 - tests/ui/invalid_upcast_comparisons.stderr | 52 ++--- tests/ui/issue-7447.rs | 2 - tests/ui/issue-7447.stderr | 2 +- tests/ui/issue_2356.fixed | 2 +- tests/ui/issue_2356.rs | 2 +- tests/ui/issue_4266.rs | 5 +- tests/ui/issue_4266.stderr | 4 +- tests/ui/items_after_statement.rs | 7 +- tests/ui/items_after_statement.stderr | 8 +- .../items_after_test_module/root_module.fixed | 2 +- .../ui/items_after_test_module/root_module.rs | 2 +- tests/ui/iter_filter_is_ok.fixed | 13 +- tests/ui/iter_filter_is_ok.rs | 13 +- tests/ui/iter_filter_is_ok.stderr | 18 +- tests/ui/iter_filter_is_some.fixed | 11 +- tests/ui/iter_filter_is_some.rs | 11 +- tests/ui/iter_filter_is_some.stderr | 14 +- tests/ui/iter_kv_map.fixed | 8 +- tests/ui/iter_kv_map.rs | 8 +- tests/ui/iter_kv_map.stderr | 14 +- tests/ui/iter_not_returning_iterator.rs | 6 +- tests/ui/iter_not_returning_iterator.stderr | 4 +- tests/ui/iter_on_empty_collections.fixed | 2 +- tests/ui/iter_on_empty_collections.rs | 2 +- tests/ui/iter_out_of_bounds.rs | 17 +- tests/ui/iter_out_of_bounds.stderr | 22 +- tests/ui/iter_over_hash_type.rs | 26 +-- tests/ui/iter_overeager_cloned.fixed | 2 +- tests/ui/iter_overeager_cloned.rs | 2 +- tests/ui/iter_skip_next_unfixable.rs | 2 - tests/ui/iter_skip_next_unfixable.stderr | 4 +- tests/ui/iter_without_into_iter.rs | 16 +- tests/ui/iterator_step_by_zero.rs | 5 - tests/ui/iterator_step_by_zero.stderr | 12 +- tests/ui/join_absolute_paths.rs | 4 - tests/ui/join_absolute_paths.stderr | 6 +- tests/ui/large_enum_variant.rs | 40 ++-- tests/ui/large_futures.fixed | 9 +- tests/ui/large_futures.rs | 9 +- tests/ui/large_futures.stderr | 14 +- tests/ui/large_stack_frames.rs | 6 +- tests/ui/large_types_passed_by_value.rs | 4 +- tests/ui/len_without_is_empty.rs | 34 ++- tests/ui/len_without_is_empty.stderr | 40 ++-- tests/ui/len_zero.fixed | 24 +-- tests/ui/len_zero.rs | 24 +-- tests/ui/let_and_return.edition2021.fixed | 11 - tests/ui/let_and_return.edition2021.stderr | 18 +- tests/ui/let_and_return.edition2024.fixed | 11 - tests/ui/let_and_return.edition2024.stderr | 28 +-- tests/ui/let_and_return.rs | 11 - tests/ui/let_if_seq.rs | 3 - tests/ui/let_if_seq.stderr | 17 +- tests/ui/let_underscore_future.rs | 2 - tests/ui/let_underscore_future.stderr | 2 +- tests/ui/let_underscore_must_use.rs | 7 - tests/ui/let_underscore_must_use.stderr | 18 +- tests/ui/let_unit.fixed | 4 +- tests/ui/let_unit.rs | 4 +- tests/ui/linkedlist.rs | 6 +- tests/ui/linkedlist.stderr | 14 +- tests/ui/literals.rs | 13 -- tests/ui/literals.stderr | 38 ++-- tests/ui/manual_arithmetic_check-2.rs | 2 - tests/ui/manual_arithmetic_check-2.stderr | 16 +- tests/ui/manual_arithmetic_check.fixed | 2 - tests/ui/manual_arithmetic_check.rs | 2 - tests/ui/manual_arithmetic_check.stderr | 4 +- tests/ui/manual_assert.rs | 20 +- tests/ui/manual_async_fn.rs | 18 +- tests/ui/manual_clamp.fixed | 21 -- tests/ui/manual_clamp.rs | 76 ++----- tests/ui/manual_clamp.stderr | 125 +++++++---- tests/ui/manual_div_ceil.fixed | 22 +- tests/ui/manual_div_ceil.rs | 22 +- tests/ui/manual_div_ceil.stderr | 30 +-- tests/ui/manual_filter.rs | 30 +-- tests/ui/manual_filter_map.rs | 2 +- tests/ui/manual_find.rs | 6 +- tests/ui/manual_find.stderr | 8 +- tests/ui/manual_find_fixable.rs | 22 +- tests/ui/manual_flatten.rs | 16 +- tests/ui/manual_ignore_case_cmp.fixed | 8 +- tests/ui/manual_ignore_case_cmp.rs | 8 +- tests/ui/manual_inspect.fixed | 26 +-- tests/ui/manual_inspect.rs | 26 +-- tests/ui/manual_let_else.rs | 50 ++--- tests/ui/manual_let_else.stderr | 61 +++--- tests/ui/manual_let_else_match.rs | 31 +-- tests/ui/manual_let_else_match.stderr | 30 +-- tests/ui/manual_let_else_question_mark.rs | 4 +- tests/ui/manual_map_option.rs | 38 ++-- tests/ui/manual_map_option_2.rs | 14 +- tests/ui/manual_memcpy/with_loop_counters.rs | 23 +- .../manual_memcpy/with_loop_counters.stderr | 24 ++- .../ui/manual_memcpy/without_loop_counters.rs | 37 ++-- .../without_loop_counters.stderr | 38 ++-- tests/ui/manual_non_exhaustive_enum.rs | 4 +- tests/ui/manual_ok_err.rs | 22 +- tests/ui/manual_ok_err.stderr | 20 +- tests/ui/manual_option_as_slice.fixed | 5 - tests/ui/manual_option_as_slice.rs | 10 +- tests/ui/manual_option_as_slice.stderr | 13 +- tests/ui/manual_retain.rs | 4 +- tests/ui/manual_saturating_arithmetic.rs | 10 +- tests/ui/manual_slice_fill.rs | 8 +- tests/ui/manual_strip.rs | 4 - tests/ui/manual_strip.stderr | 16 +- tests/ui/manual_try_fold.rs | 4 +- tests/ui/manual_unwrap_or.rs | 28 +-- tests/ui/manual_unwrap_or_default.rs | 21 +- tests/ui/manual_unwrap_or_default.stderr | 19 +- .../ui/manual_unwrap_or_default_unfixable.rs | 2 +- tests/ui/many_single_char_names.rs | 5 - tests/ui/many_single_char_names.stderr | 4 +- tests/ui/map_all_any_identity.fixed | 1 - tests/ui/map_all_any_identity.rs | 1 - tests/ui/map_clone.fixed | 12 -- tests/ui/map_clone.rs | 12 -- tests/ui/map_clone.stderr | 14 +- tests/ui/map_err.rs | 1 - tests/ui/map_flatten.rs | 1 - tests/ui/map_flatten_fixable.fixed | 2 +- tests/ui/map_flatten_fixable.rs | 2 +- tests/ui/map_identity.rs | 4 +- ...map_with_unused_argument_over_ranges.fixed | 2 +- .../map_with_unused_argument_over_ranges.rs | 2 +- tests/ui/match_as_ref.rs | 6 +- tests/ui/match_bool.rs | 39 ++-- tests/ui/match_bool.stderr | 50 ++--- tests/ui/match_on_vec_items.rs | 25 +-- tests/ui/match_on_vec_items.stderr | 14 +- tests/ui/match_overlapping_arm.rs | 8 - tests/ui/match_overlapping_arm.stderr | 30 +-- tests/ui/match_ref_pats.fixed | 10 +- tests/ui/match_ref_pats.rs | 10 +- tests/ui/match_result_ok.fixed | 2 +- tests/ui/match_result_ok.rs | 2 +- tests/ui/match_same_arms.rs | 28 ++- tests/ui/match_same_arms.stderr | 60 +++--- tests/ui/match_same_arms2.fixed | 33 ++- tests/ui/match_same_arms2.rs | 43 ++-- tests/ui/match_same_arms2.stderr | 86 ++++---- tests/ui/match_same_arms_non_exhaustive.fixed | 2 - tests/ui/match_same_arms_non_exhaustive.rs | 2 - .../ui/match_same_arms_non_exhaustive.stderr | 6 +- tests/ui/match_single_binding.rs | 48 ++--- tests/ui/match_single_binding2.fixed | 2 +- tests/ui/match_single_binding2.rs | 6 +- tests/ui/match_wild_err_arm.rs | 9 +- tests/ui/match_wild_err_arm.stderr | 6 +- tests/ui/mem_forget.rs | 8 - tests/ui/mem_forget.stderr | 6 +- tests/ui/mem_replace.stderr | 6 +- tests/ui/methods.rs | 2 +- tests/ui/methods_unfixable.rs | 1 - tests/ui/min_ident_chars.rs | 10 +- tests/ui/min_max.rs | 6 - tests/ui/min_max.stderr | 24 +-- tests/ui/min_rust_version_attr.rs | 6 - tests/ui/min_rust_version_attr.stderr | 10 +- tests/ui/mismatching_type_param_order.rs | 10 - tests/ui/mismatching_type_param_order.stderr | 16 +- tests/ui/misnamed_getters.fixed | 37 ++-- tests/ui/misnamed_getters.rs | 37 ++-- tests/ui/misnamed_getters.stderr | 37 ++-- tests/ui/missing_asserts_for_indexing.fixed | 5 - tests/ui/missing_asserts_for_indexing.rs | 5 - tests/ui/missing_asserts_for_indexing.stderr | 82 ++++---- .../missing_asserts_for_indexing_unfixable.rs | 3 - ...sing_asserts_for_indexing_unfixable.stderr | 44 ++-- .../missing_const_for_fn/could_be_const.fixed | 36 ++-- .../ui/missing_const_for_fn/could_be_const.rs | 36 ++-- tests/ui/missing_const_for_thread_local.fixed | 4 - tests/ui/missing_const_for_thread_local.rs | 4 - .../ui/missing_const_for_thread_local.stderr | 10 +- tests/ui/missing_doc.rs | 6 +- tests/ui/missing_doc_crate_missing.rs | 2 - tests/ui/missing_doc_impl.rs | 6 +- tests/ui/missing_fields_in_debug.rs | 6 +- tests/ui/missing_inline.rs | 3 - tests/ui/missing_inline.stderr | 10 +- tests/ui/missing_panics_doc.rs | 24 +-- tests/ui/missing_trait_methods.rs | 3 +- tests/ui/missing_trait_methods.stderr | 14 +- tests/ui/mixed_read_write_in_expression.rs | 6 +- .../ui/mixed_read_write_in_expression.stderr | 12 +- tests/ui/module_inception.rs | 9 +- tests/ui/module_inception.stderr | 10 +- tests/ui/module_name_repetitions.rs | 3 - tests/ui/module_name_repetitions.stderr | 10 +- tests/ui/modulo_arithmetic_float.rs | 21 -- tests/ui/modulo_arithmetic_float.stderr | 30 +-- tests/ui/modulo_arithmetic_integral.rs | 25 --- tests/ui/modulo_arithmetic_integral.stderr | 32 +-- tests/ui/modulo_arithmetic_integral_const.rs | 19 -- .../modulo_arithmetic_integral_const.stderr | 32 +-- tests/ui/modulo_one.rs | 1 - tests/ui/modulo_one.stderr | 10 +- tests/ui/multi_assignments.rs | 3 - tests/ui/multi_assignments.stderr | 10 +- tests/ui/multiple_bound_locations.rs | 6 - tests/ui/multiple_bound_locations.stderr | 10 +- tests/ui/multiple_unsafe_ops_per_block.rs | 14 +- tests/ui/must_use_candidates.fixed | 10 +- tests/ui/must_use_candidates.rs | 10 +- tests/ui/mut_from_ref.rs | 11 +- tests/ui/mut_from_ref.stderr | 16 +- tests/ui/mut_key.rs | 8 +- tests/ui/mut_key.stderr | 26 +-- tests/ui/mut_mut.rs | 2 +- tests/ui/mut_range_bound.rs | 10 - tests/ui/mut_range_bound.stderr | 12 +- tests/ui/mut_reference.rs | 3 - tests/ui/mut_reference.stderr | 4 +- tests/ui/mutex_atomic.rs | 3 - tests/ui/mutex_atomic.stderr | 20 +- tests/ui/needless_arbitrary_self_type.fixed | 12 +- tests/ui/needless_arbitrary_self_type.rs | 12 +- tests/ui/needless_as_bytes.fixed | 12 +- tests/ui/needless_as_bytes.rs | 12 +- tests/ui/needless_as_bytes.stderr | 12 +- tests/ui/needless_bitwise_bool.fixed | 2 +- tests/ui/needless_bitwise_bool.rs | 2 +- tests/ui/needless_borrow_pat.fixed | 16 +- tests/ui/needless_borrow_pat.rs | 16 +- tests/ui/needless_borrow_pat.stderr | 22 +- tests/ui/needless_borrowed_ref.fixed | 2 +- tests/ui/needless_borrowed_ref.rs | 2 +- tests/ui/needless_character_iteration.fixed | 3 - tests/ui/needless_character_iteration.rs | 7 +- tests/ui/needless_character_iteration.stderr | 10 +- tests/ui/needless_collect.fixed | 2 +- tests/ui/needless_collect.rs | 2 +- tests/ui/needless_continue.rs | 16 +- tests/ui/needless_continue.stderr | 24 +-- tests/ui/needless_for_each_fixable.fixed | 16 +- tests/ui/needless_for_each_fixable.rs | 16 +- tests/ui/needless_for_each_unfixable.rs | 3 +- tests/ui/needless_for_each_unfixable.stderr | 4 +- tests/ui/needless_if.fixed | 4 +- tests/ui/needless_if.rs | 4 +- tests/ui/needless_lifetimes.fixed | 76 +++---- tests/ui/needless_lifetimes.rs | 76 +++---- tests/ui/needless_match.rs | 22 +- tests/ui/needless_maybe_sized.fixed | 8 +- tests/ui/needless_maybe_sized.rs | 8 +- tests/ui/needless_option_take.fixed | 8 - tests/ui/needless_option_take.rs | 8 - tests/ui/needless_option_take.stderr | 16 +- tests/ui/needless_pass_by_ref_mut.rs | 46 ++-- tests/ui/needless_pass_by_ref_mut.stderr | 62 +++--- tests/ui/needless_pass_by_ref_mut2.fixed | 4 +- tests/ui/needless_pass_by_ref_mut2.rs | 4 +- tests/ui/needless_pass_by_value.rs | 45 ++-- tests/ui/needless_pass_by_value.stderr | 50 ++--- tests/ui/needless_range_loop.rs | 29 ++- tests/ui/needless_range_loop.stderr | 26 +-- tests/ui/needless_range_loop2.rs | 17 +- tests/ui/needless_range_loop2.stderr | 14 +- tests/ui/needless_update.rs | 2 - tests/ui/neg_cmp_op_on_partial_ord.rs | 5 - tests/ui/neg_cmp_op_on_partial_ord.stderr | 6 +- tests/ui/never_loop.rs | 33 ++- tests/ui/never_loop.stderr | 30 +-- tests/ui/new_ret_no_self.rs | 24 +-- tests/ui/new_ret_no_self.stderr | 28 +-- tests/ui/new_ret_no_self_overflow.rs | 2 +- tests/ui/new_without_default.fixed | 19 +- tests/ui/new_without_default.rs | 19 +- tests/ui/new_without_default.stderr | 20 +- tests/ui/no_effect.rs | 1 - tests/ui/no_effect.stderr | 6 +- tests/ui/no_effect_async_fn.rs | 4 - tests/ui/no_effect_async_fn.stderr | 6 +- tests/ui/no_effect_replace.rs | 3 - tests/ui/no_effect_replace.stderr | 14 +- tests/ui/no_effect_return.rs | 9 - tests/ui/no_effect_return.stderr | 16 +- tests/ui/no_mangle_with_rust_abi.rs | 2 +- tests/ui/no_mangle_with_rust_abi_2021.rs | 2 +- tests/ui/non_canonical_clone_impl.rs | 8 +- tests/ui/non_canonical_partial_ord_impl.fixed | 4 +- tests/ui/non_canonical_partial_ord_impl.rs | 4 +- ...n_canonical_partial_ord_impl_fully_qual.rs | 4 +- tests/ui/non_expressive_names.rs | 24 +-- tests/ui/non_expressive_names.stderr | 36 ++-- tests/ui/non_zero_suggestions.fixed | 6 - tests/ui/non_zero_suggestions.rs | 6 - tests/ui/non_zero_suggestions.stderr | 10 +- tests/ui/non_zero_suggestions_unfixable.rs | 2 - .../ui/non_zero_suggestions_unfixable.stderr | 4 +- tests/ui/nonminimal_bool.rs | 59 +++--- tests/ui/nonminimal_bool.stderr | 122 +++++------ tests/ui/nonminimal_bool_methods.fixed | 108 +++++----- tests/ui/nonminimal_bool_methods.rs | 108 +++++----- tests/ui/nonminimal_bool_methods.stderr | 168 +++++++-------- tests/ui/nonminimal_bool_methods_unfixable.rs | 6 +- .../nonminimal_bool_methods_unfixable.stderr | 12 +- tests/ui/obfuscated_if_else.fixed | 9 - tests/ui/obfuscated_if_else.rs | 9 - tests/ui/obfuscated_if_else.stderr | 24 +-- tests/ui/octal_escapes.rs | 30 ++- tests/ui/octal_escapes.stderr | 102 ++++----- tests/ui/ok_expect.rs | 1 - tests/ui/only_used_in_recursion.rs | 36 ++-- tests/ui/only_used_in_recursion.stderr | 56 ++--- tests/ui/only_used_in_recursion2.rs | 10 +- tests/ui/op_ref.fixed | 3 - tests/ui/op_ref.rs | 3 - tests/ui/op_ref.stderr | 6 +- tests/ui/open_options.rs | 5 - tests/ui/open_options.stderr | 14 +- tests/ui/open_options_fixable.fixed | 1 - tests/ui/open_options_fixable.rs | 1 - tests/ui/option_filter_map.fixed | 1 - tests/ui/option_filter_map.rs | 3 - tests/ui/option_filter_map.stderr | 12 +- tests/ui/option_if_let_else.fixed | 12 +- tests/ui/option_if_let_else.rs | 36 ++-- tests/ui/option_map_or_none.fixed | 2 +- tests/ui/option_map_or_none.rs | 2 +- tests/ui/or_fun_call.fixed | 3 +- tests/ui/or_fun_call.rs | 3 +- tests/ui/or_fun_call.stderr | 12 +- tests/ui/out_of_bounds_indexing/issue-3102.rs | 2 - .../out_of_bounds_indexing/issue-3102.stderr | 2 +- tests/ui/out_of_bounds_indexing/simple.rs | 2 - tests/ui/out_of_bounds_indexing/simple.stderr | 10 +- tests/ui/panic_in_result_fn.rs | 4 +- tests/ui/panic_in_result_fn.stderr | 18 +- tests/ui/panic_in_result_fn_assertions.rs | 3 - tests/ui/panic_in_result_fn_assertions.stderr | 22 +- tests/ui/panicking_macros.rs | 5 - tests/ui/panicking_macros.stderr | 30 +-- tests/ui/panicking_overflow_checks.rs | 24 +-- tests/ui/panicking_overflow_checks.stderr | 36 ++-- tests/ui/partial_pub_fields.rs | 4 - tests/ui/partial_pub_fields.stderr | 6 +- tests/ui/partialeq_ne_impl.rs | 3 +- tests/ui/partialeq_ne_impl.stderr | 4 +- tests/ui/partialeq_to_none.fixed | 2 +- tests/ui/partialeq_to_none.rs | 2 +- tests/ui/path_ends_with_ext.fixed | 2 - tests/ui/path_ends_with_ext.rs | 2 - tests/ui/path_ends_with_ext.stderr | 2 +- tests/ui/pathbuf_init_then_push.fixed | 8 +- tests/ui/pathbuf_init_then_push.rs | 16 +- tests/ui/pathbuf_init_then_push.stderr | 16 +- tests/ui/pattern_type_mismatch/mutability.rs | 2 - .../pattern_type_mismatch/mutability.stderr | 2 +- .../pattern_alternatives.rs | 1 - .../pattern_type_mismatch/pattern_structs.rs | 2 - .../pattern_structs.stderr | 10 +- .../pattern_type_mismatch/pattern_tuples.rs | 3 - .../pattern_tuples.stderr | 14 +- tests/ui/pattern_type_mismatch/syntax.rs | 9 +- tests/ui/pattern_type_mismatch/syntax.stderr | 16 +- tests/ui/patterns.fixed | 2 +- tests/ui/patterns.rs | 2 +- tests/ui/permissions_set_readonly_false.rs | 1 - tests/ui/pointers_in_nomem_asm_block.rs | 2 - tests/ui/pointers_in_nomem_asm_block.stderr | 2 +- tests/ui/print.rs | 9 - tests/ui/print.stderr | 14 +- tests/ui/print_in_format_impl.rs | 1 - tests/ui/print_in_format_impl.stderr | 12 +- tests/ui/print_literal.fixed | 4 - tests/ui/print_literal.rs | 4 - tests/ui/print_literal.stderr | 34 +-- tests/ui/print_stderr.rs | 1 - tests/ui/print_stderr.stderr | 2 +- tests/ui/print_with_newline.fixed | 8 +- tests/ui/print_with_newline.rs | 8 +- tests/ui/print_with_newline.stderr | 20 +- tests/ui/ptr_arg.rs | 51 +++-- tests/ui/ptr_arg.stderr | 52 ++--- tests/ui/pub_use.rs | 1 - tests/ui/question_mark.rs | 32 +-- tests/ui/rc_clone_in_vec_init/arc.rs | 4 - tests/ui/rc_clone_in_vec_init/arc.stderr | 6 +- tests/ui/rc_clone_in_vec_init/rc.rs | 4 - tests/ui/rc_clone_in_vec_init/rc.stderr | 6 +- tests/ui/rc_clone_in_vec_init/weak.rs | 9 - tests/ui/rc_clone_in_vec_init/weak.stderr | 14 +- tests/ui/rc_mutex.rs | 1 - tests/ui/read_line_without_trim.fixed | 4 +- tests/ui/read_line_without_trim.rs | 4 +- tests/ui/readonly_write_lock.fixed | 1 - tests/ui/readonly_write_lock.rs | 1 - tests/ui/readonly_write_lock.stderr | 2 +- tests/ui/recursive_format_impl.rs | 11 - tests/ui/recursive_format_impl.stderr | 18 +- tests/ui/redundant_allocation.rs | 49 +---- tests/ui/redundant_allocation.stderr | 38 ++-- tests/ui/redundant_clone.fixed | 2 +- tests/ui/redundant_clone.rs | 2 +- tests/ui/redundant_closure_call_early.rs | 3 - tests/ui/redundant_closure_call_early.stderr | 2 +- tests/ui/redundant_closure_call_fixable.fixed | 4 +- tests/ui/redundant_closure_call_fixable.rs | 4 +- tests/ui/redundant_closure_call_late.rs | 3 - tests/ui/redundant_closure_call_late.stderr | 4 +- tests/ui/redundant_else.fixed | 14 +- tests/ui/redundant_else.rs | 14 +- tests/ui/redundant_else.stderr | 14 +- tests/ui/redundant_field_names.fixed | 1 - tests/ui/redundant_field_names.rs | 1 - tests/ui/redundant_field_names.stderr | 14 +- tests/ui/redundant_guards.fixed | 2 +- tests/ui/redundant_guards.rs | 2 +- ...edundant_pattern_matching_drop_order.fixed | 6 +- .../redundant_pattern_matching_drop_order.rs | 6 +- ...dundant_pattern_matching_if_let_true.fixed | 4 +- .../redundant_pattern_matching_if_let_true.rs | 4 +- .../redundant_pattern_matching_ipaddr.fixed | 6 +- tests/ui/redundant_pattern_matching_ipaddr.rs | 18 +- .../redundant_pattern_matching_option.fixed | 8 +- tests/ui/redundant_pattern_matching_option.rs | 26 +-- .../ui/redundant_pattern_matching_poll.fixed | 6 +- tests/ui/redundant_pattern_matching_poll.rs | 16 +- .../redundant_pattern_matching_result.fixed | 4 +- tests/ui/redundant_pattern_matching_result.rs | 24 +-- tests/ui/redundant_pub_crate.fixed | 6 +- tests/ui/redundant_pub_crate.rs | 6 +- .../ui/redundant_static_lifetimes_multiple.rs | 11 - ...redundant_static_lifetimes_multiple.stderr | 16 +- tests/ui/redundant_type_annotations.rs | 16 -- tests/ui/redundant_type_annotations.stderr | 32 +-- tests/ui/ref_binding_to_reference.rs | 13 +- tests/ui/ref_binding_to_reference.stderr | 12 +- tests/ui/ref_option/ref_option.all.fixed | 10 +- tests/ui/ref_option/ref_option.private.fixed | 10 +- tests/ui/ref_option/ref_option.rs | 10 +- tests/ui/ref_option_ref.rs | 11 +- tests/ui/ref_option_ref.stderr | 20 +- tests/ui/ref_patterns.rs | 3 - tests/ui/ref_patterns.stderr | 4 +- tests/ui/repeat_vec_with_capacity.fixed | 3 - tests/ui/repeat_vec_with_capacity.rs | 3 - tests/ui/repeat_vec_with_capacity.stderr | 4 +- tests/ui/repl_uninit.rs | 1 - tests/ui/repl_uninit.stderr | 6 +- tests/ui/repr_packed_without_abi.rs | 4 +- tests/ui/rest_pat_in_fully_bound_structs.rs | 3 - .../ui/rest_pat_in_fully_bound_structs.stderr | 4 +- tests/ui/result_filter_map.rs | 4 - tests/ui/result_filter_map.stderr | 14 +- tests/ui/result_large_err.rs | 24 +-- tests/ui/result_map_or_into_option.fixed | 1 - tests/ui/result_map_or_into_option.rs | 1 - tests/ui/result_unit_error.rs | 9 +- tests/ui/result_unit_error.stderr | 6 +- tests/ui/result_unit_error_no_std.rs | 2 +- tests/ui/return_and_then.fixed | 8 +- tests/ui/return_and_then.rs | 4 +- tests/ui/return_and_then.stderr | 6 +- tests/ui/return_self_not_must_use.rs | 4 +- .../reversed_empty_ranges_loops_fixable.fixed | 12 +- .../ui/reversed_empty_ranges_loops_fixable.rs | 12 +- .../reversed_empty_ranges_loops_unfixable.rs | 5 +- ...versed_empty_ranges_loops_unfixable.stderr | 2 +- tests/ui/reversed_empty_ranges_unfixable.rs | 3 - .../ui/reversed_empty_ranges_unfixable.stderr | 4 +- tests/ui/same_functions_in_if_condition.rs | 18 +- .../ui/same_functions_in_if_condition.stderr | 20 +- tests/ui/same_item_push.rs | 6 - tests/ui/same_item_push.stderr | 10 +- tests/ui/same_name_method.rs | 6 - tests/ui/same_name_method.stderr | 22 +- tests/ui/search_is_some_fixable_none.fixed | 4 +- tests/ui/search_is_some_fixable_none.rs | 6 +- tests/ui/self_assignment.rs | 3 - tests/ui/self_assignment.stderr | 20 +- tests/ui/self_named_constructors.rs | 3 +- tests/ui/self_named_constructors.stderr | 4 +- tests/ui/set_contains_or_insert.rs | 28 +-- tests/ui/shadow.rs | 6 +- tests/ui/short_circuit_statement.fixed | 2 - tests/ui/short_circuit_statement.rs | 2 - tests/ui/short_circuit_statement.stderr | 4 +- tests/ui/should_impl_trait/method_list_1.rs | 30 +-- tests/ui/should_impl_trait/method_list_2.rs | 30 +-- tests/ui/significant_drop_in_scrutinee.rs | 62 +++--- tests/ui/similar_names.rs | 5 - tests/ui/similar_names.stderr | 16 +- tests/ui/single_call_fn.rs | 2 +- tests/ui/single_char_lifetime_names.rs | 9 +- tests/ui/single_char_lifetime_names.stderr | 6 +- ...gle_component_path_imports_nested_first.rs | 3 - ...component_path_imports_nested_first.stderr | 4 +- tests/ui/single_element_loop.fixed | 16 +- tests/ui/single_element_loop.rs | 16 +- tests/ui/single_option_map.rs | 6 +- .../size_of_in_element_count/expressions.rs | 4 - .../expressions.stderr | 6 +- .../ui/size_of_in_element_count/functions.rs | 7 - .../size_of_in_element_count/functions.stderr | 34 +-- tests/ui/size_of_ref.rs | 2 - tests/ui/size_of_ref.stderr | 2 +- tests/ui/slow_vector_initialization.rs | 1 - tests/ui/slow_vector_initialization.stderr | 24 +-- tests/ui/starts_ends_with.fixed | 12 +- tests/ui/starts_ends_with.rs | 12 +- tests/ui/str_to_string.fixed | 1 - tests/ui/str_to_string.rs | 1 - tests/ui/string_slice.rs | 2 - tests/ui/string_slice.stderr | 6 +- tests/ui/string_to_string.rs | 1 - tests/ui/struct_excessive_bools.rs | 6 +- tests/ui/struct_excessive_bools.stderr | 10 +- tests/ui/suspicious_arithmetic_impl.rs | 11 - tests/ui/suspicious_arithmetic_impl.stderr | 16 +- tests/ui/suspicious_command_arg_space.fixed | 2 - tests/ui/suspicious_command_arg_space.rs | 2 - tests/ui/suspicious_command_arg_space.stderr | 2 +- tests/ui/suspicious_doc_comments.fixed | 2 +- tests/ui/suspicious_doc_comments.rs | 2 +- tests/ui/suspicious_doc_comments.stderr | 2 - tests/ui/suspicious_doc_comments_unfixable.rs | 1 - .../suspicious_doc_comments_unfixable.stderr | 7 +- tests/ui/suspicious_map.rs | 2 - tests/ui/suspicious_map.stderr | 2 +- tests/ui/suspicious_operation_groupings.fixed | 2 +- tests/ui/suspicious_operation_groupings.rs | 2 +- tests/ui/suspicious_splitn.rs | 11 - tests/ui/suspicious_splitn.stderr | 16 +- tests/ui/suspicious_to_owned.rs | 3 - tests/ui/suspicious_to_owned.stderr | 10 +- tests/ui/suspicious_xor_used_as_pow.rs | 1 - tests/ui/suspicious_xor_used_as_pow.stderr | 10 +- tests/ui/swap_ptr_to_ref_unfixable.rs | 2 - tests/ui/swap_ptr_to_ref_unfixable.stderr | 4 +- .../non_expressive_names_error_recovery.fixed | 1 + .../non_expressive_names_error_recovery.rs | 1 + tests/ui/temporary_assignment.rs | 5 +- tests/ui/temporary_assignment.stderr | 10 +- tests/ui/test_attr_in_doctest.rs | 9 +- tests/ui/test_attr_in_doctest.stderr | 4 +- tests/ui/to_string_trait_impl.rs | 2 +- tests/ui/toplevel_ref_arg_non_rustfix.rs | 2 +- tests/ui/trailing_empty_array.rs | 29 +-- tests/ui/trailing_empty_array.stderr | 30 +-- tests/ui/trailing_zeros.fixed | 1 - tests/ui/trailing_zeros.rs | 1 - tests/ui/trailing_zeros.stderr | 2 +- tests/ui/trait_duplication_in_bounds.fixed | 17 +- tests/ui/trait_duplication_in_bounds.rs | 17 +- tests/ui/trait_duplication_in_bounds.stderr | 4 +- .../trait_duplication_in_bounds_unfixable.rs | 16 +- ...ait_duplication_in_bounds_unfixable.stderr | 12 +- tests/ui/transmute.rs | 32 --- tests/ui/transmute.stderr | 106 +++++----- tests/ui/transmute_64bit.rs | 3 - tests/ui/transmute_64bit.stderr | 2 +- tests/ui/transmute_collection.rs | 8 - tests/ui/transmute_collection.stderr | 34 +-- tests/ui/transmute_float_to_int.fixed | 7 - tests/ui/transmute_float_to_int.rs | 7 - tests/ui/transmute_float_to_int.stderr | 26 +-- tests/ui/transmute_int_to_char.fixed | 2 - tests/ui/transmute_int_to_char.rs | 2 - tests/ui/transmute_int_to_char.stderr | 2 +- tests/ui/transmute_int_to_char_no_std.fixed | 2 - tests/ui/transmute_int_to_char_no_std.rs | 2 - tests/ui/transmute_int_to_char_no_std.stderr | 2 +- tests/ui/transmute_int_to_non_zero.fixed | 3 - tests/ui/transmute_int_to_non_zero.rs | 3 - tests/ui/transmute_int_to_non_zero.stderr | 18 +- tests/ui/transmute_null_to_fn.rs | 2 - tests/ui/transmute_null_to_fn.stderr | 8 +- tests/ui/transmute_ptr_to_ptr.fixed | 2 - tests/ui/transmute_ptr_to_ptr.rs | 2 - tests/ui/transmute_ptr_to_ptr.stderr | 14 +- tests/ui/transmute_ref_to_ref.rs | 1 - tests/ui/transmute_ref_to_ref_no_std.rs | 1 - tests/ui/transmute_undefined_repr.rs | 17 -- tests/ui/transmute_undefined_repr.stderr | 22 +- tests/ui/transmuting_null.rs | 2 - tests/ui/transmuting_null.stderr | 4 +- tests/ui/type_complexity.rs | 12 +- tests/ui/type_complexity.stderr | 28 +-- tests/ui/type_id_on_box.fixed | 4 - tests/ui/type_id_on_box.rs | 4 - tests/ui/type_id_on_box.stderr | 6 +- tests/ui/type_id_on_box_unfixable.rs | 2 - tests/ui/type_id_on_box_unfixable.stderr | 2 +- tests/ui/unbuffered_bytes.rs | 4 + tests/ui/unbuffered_bytes.stderr | 6 +- tests/ui/unconditional_recursion.rs | 40 ++-- tests/ui/uninhabited_references.rs | 4 +- tests/ui/uninit.rs | 4 - tests/ui/uninit.stderr | 4 +- tests/ui/uninlined_format_args.fixed | 6 +- tests/ui/uninlined_format_args.rs | 6 +- tests/ui/unit_arg.rs | 10 +- tests/ui/unit_cmp.rs | 17 +- tests/ui/unit_cmp.stderr | 27 ++- tests/ui/unit_hash.fixed | 6 - tests/ui/unit_hash.rs | 6 - tests/ui/unit_hash.stderr | 4 +- tests/ui/unit_return_expecting_ord.rs | 7 +- tests/ui/unnecessary_box_returns.rs | 7 +- tests/ui/unnecessary_box_returns.stderr | 6 +- tests/ui/unnecessary_cast_unfixable.rs | 3 - tests/ui/unnecessary_cast_unfixable.stderr | 2 +- tests/ui/unnecessary_clippy_cfg.rs | 7 - tests/ui/unnecessary_clippy_cfg.stderr | 26 +-- tests/ui/unnecessary_clone.rs | 6 - tests/ui/unnecessary_clone.stderr | 16 +- .../ui/unnecessary_fallible_conversions.fixed | 10 - tests/ui/unnecessary_fallible_conversions.rs | 10 - .../unnecessary_fallible_conversions.stderr | 18 +- tests/ui/unnecessary_filter_map.rs | 7 +- tests/ui/unnecessary_filter_map.stderr | 15 +- tests/ui/unnecessary_find_map.rs | 7 +- tests/ui/unnecessary_find_map.stderr | 9 +- tests/ui/unnecessary_fold.fixed | 2 +- tests/ui/unnecessary_fold.rs | 2 +- tests/ui/unnecessary_get_then_check.fixed | 40 ++-- tests/ui/unnecessary_get_then_check.rs | 40 ++-- tests/ui/unnecessary_get_then_check.stderr | 80 +++---- tests/ui/unnecessary_iter_cloned.fixed | 14 +- tests/ui/unnecessary_iter_cloned.rs | 14 +- tests/ui/unnecessary_iter_cloned.stderr | 4 +- tests/ui/unnecessary_lazy_eval_unfixable.rs | 2 - .../ui/unnecessary_lazy_eval_unfixable.stderr | 6 +- tests/ui/unnecessary_literal_bound.fixed | 6 +- tests/ui/unnecessary_literal_bound.rs | 6 +- .../unnecessary_literal_unwrap_unfixable.rs | 16 -- ...nnecessary_literal_unwrap_unfixable.stderr | 196 +++++++++--------- tests/ui/unnecessary_map_or.fixed | 2 +- tests/ui/unnecessary_map_or.rs | 4 +- tests/ui/unnecessary_operation.fixed | 1 - tests/ui/unnecessary_operation.rs | 5 +- tests/ui/unnecessary_result_map_or_else.fixed | 12 +- tests/ui/unnecessary_result_map_or_else.rs | 15 +- .../ui/unnecessary_result_map_or_else.stderr | 20 +- tests/ui/unnecessary_safety_comment.rs | 4 - tests/ui/unnecessary_safety_comment.stderr | 16 +- .../unnecessary_semicolon.edition2021.fixed | 2 - .../unnecessary_semicolon.edition2021.stderr | 4 +- .../unnecessary_semicolon.edition2024.fixed | 2 - .../unnecessary_semicolon.edition2024.stderr | 6 +- tests/ui/unnecessary_semicolon.rs | 2 - tests/ui/unnecessary_struct_initialization.rs | 4 +- tests/ui/unnecessary_to_owned.fixed | 22 +- tests/ui/unnecessary_to_owned.rs | 22 +- tests/ui/unnecessary_to_owned.stderr | 30 +-- tests/ui/unnecessary_to_owned_on_split.fixed | 2 - tests/ui/unnecessary_to_owned_on_split.rs | 2 - tests/ui/unnecessary_to_owned_on_split.stderr | 8 +- tests/ui/unnecessary_unsafety_doc.rs | 12 +- tests/ui/unnecessary_wraps.rs | 15 +- tests/ui/unnecessary_wraps.stderr | 15 +- tests/ui/unneeded_field_pattern.rs | 1 - tests/ui/unneeded_field_pattern.stderr | 2 +- tests/ui/unneeded_struct_pattern.fixed | 20 +- tests/ui/unneeded_struct_pattern.rs | 26 ++- tests/ui/unneeded_struct_pattern.stderr | 4 +- tests/ui/unsafe_removed_from_name.rs | 6 - tests/ui/unsafe_removed_from_name.stderr | 8 +- tests/ui/unused_async.rs | 7 +- tests/ui/unused_async.stderr | 4 +- tests/ui/unused_enumerate_index.fixed | 4 +- tests/ui/unused_enumerate_index.rs | 4 +- tests/ui/unused_format_specs.1.fixed | 7 - tests/ui/unused_format_specs.2.fixed | 7 - tests/ui/unused_format_specs.rs | 7 - tests/ui/unused_format_specs.stderr | 14 +- tests/ui/unused_io_amount.rs | 16 +- tests/ui/unused_peekable.rs | 5 - tests/ui/unused_peekable.stderr | 14 +- tests/ui/unused_self.rs | 4 +- tests/ui/unwrap.rs | 2 - tests/ui/unwrap.stderr | 4 +- tests/ui/unwrap_expect_used.rs | 1 - tests/ui/unwrap_expect_used.stderr | 8 +- tests/ui/unwrap_in_result.rs | 6 +- tests/ui/unwrap_or.fixed | 3 - tests/ui/unwrap_or.rs | 3 - tests/ui/unwrap_or.stderr | 2 +- tests/ui/upper_case_acronyms.fixed | 15 +- tests/ui/upper_case_acronyms.rs | 15 +- tests/ui/upper_case_acronyms.stderr | 22 +- tests/ui/use_self.fixed | 22 +- tests/ui/use_self.rs | 22 +- tests/ui/use_self_trait.fixed | 20 +- tests/ui/use_self_trait.rs | 20 +- tests/ui/useless_asref.fixed | 3 - tests/ui/useless_asref.rs | 3 - tests/ui/useless_asref.stderr | 8 +- tests/ui/useless_conversion.fixed | 9 - tests/ui/useless_conversion.rs | 9 - tests/ui/useless_conversion.stderr | 28 +-- tests/ui/useless_conversion_try.rs | 4 +- tests/ui/useless_conversion_try.stderr | 14 +- tests/ui/useless_nonzero_new_unchecked.fixed | 5 - tests/ui/useless_nonzero_new_unchecked.rs | 5 - tests/ui/useless_nonzero_new_unchecked.stderr | 8 +- tests/ui/useless_vec.rs | 3 +- tests/ui/useless_vec.stderr | 1 - tests/ui/vec.fixed | 10 +- tests/ui/vec.rs | 10 +- tests/ui/vec.stderr | 6 +- tests/ui/vec_box_sized.rs | 8 +- tests/ui/vec_init_then_push.rs | 1 - tests/ui/vec_init_then_push.stderr | 14 +- tests/ui/vec_resize_to_zero.fixed | 1 - tests/ui/vec_resize_to_zero.rs | 1 - tests/ui/while_float.rs | 4 +- tests/ui/while_let_loop.rs | 11 +- tests/ui/while_let_loop.stderr | 11 +- tests/ui/while_let_on_iterator.fixed | 50 ++--- tests/ui/while_let_on_iterator.rs | 50 ++--- tests/ui/wild_in_or_pats.rs | 12 +- tests/ui/write_literal.fixed | 5 - tests/ui/write_literal.rs | 5 - tests/ui/write_literal.stderr | 26 +-- tests/ui/write_literal_2.rs | 8 +- tests/ui/write_literal_2.stderr | 20 +- tests/ui/write_with_newline.fixed | 8 +- tests/ui/write_with_newline.rs | 8 +- tests/ui/write_with_newline.stderr | 20 +- tests/ui/wrong_self_convention.rs | 7 +- tests/ui/wrong_self_convention.stderr | 46 ++-- tests/ui/wrong_self_convention2.rs | 3 +- tests/ui/wrong_self_conventions_mut.rs | 4 +- tests/ui/zero_offset.rs | 3 - tests/ui/zero_offset.stderr | 14 +- tests/ui/zero_sized_btreemap_values.rs | 16 +- tests/ui/zero_sized_btreemap_values.stderr | 24 +-- tests/ui/zero_sized_hashmap_values.rs | 16 +- tests/ui/zero_sized_hashmap_values.stderr | 24 +-- 1025 files changed, 5989 insertions(+), 7822 deletions(-) diff --git a/tests/ui/as_pointer_underscore.fixed b/tests/ui/as_pointer_underscore.fixed index 374c8a7f611ad..93daae6bc668f 100644 --- a/tests/ui/as_pointer_underscore.fixed +++ b/tests/ui/as_pointer_underscore.fixed @@ -7,11 +7,9 @@ struct S; fn f(s: &S) -> usize { &s as *const &S as usize //~^ as_pointer_underscore - } fn g(s: &mut S) -> usize { s as *mut S as usize //~^ as_pointer_underscore - } diff --git a/tests/ui/as_pointer_underscore.rs b/tests/ui/as_pointer_underscore.rs index b194b3f473e26..56f1a89352557 100644 --- a/tests/ui/as_pointer_underscore.rs +++ b/tests/ui/as_pointer_underscore.rs @@ -7,11 +7,9 @@ struct S; fn f(s: &S) -> usize { &s as *const _ as usize //~^ as_pointer_underscore - } fn g(s: &mut S) -> usize { s as *mut _ as usize //~^ as_pointer_underscore - } diff --git a/tests/ui/as_pointer_underscore.stderr b/tests/ui/as_pointer_underscore.stderr index fd9f061322b5d..270056f36454e 100644 --- a/tests/ui/as_pointer_underscore.stderr +++ b/tests/ui/as_pointer_underscore.stderr @@ -8,7 +8,7 @@ LL | &s as *const _ as usize = help: to override `-D warnings` add `#[allow(clippy::as_pointer_underscore)]` error: using inferred pointer cast - --> tests/ui/as_pointer_underscore.rs:14:10 + --> tests/ui/as_pointer_underscore.rs:13:10 | LL | s as *mut _ as usize | ^^^^^^ help: use explicit type: `*mut S` diff --git a/tests/ui/as_ptr_cast_mut.rs b/tests/ui/as_ptr_cast_mut.rs index 751e4a70b0fad..baf7279adc4a4 100644 --- a/tests/ui/as_ptr_cast_mut.rs +++ b/tests/ui/as_ptr_cast_mut.rs @@ -22,7 +22,6 @@ fn main() { let _ = string.as_ptr() as *mut u8; //~^ as_ptr_cast_mut - let _: *mut i8 = string.as_ptr() as *mut _; //~^ as_ptr_cast_mut diff --git a/tests/ui/as_ptr_cast_mut.stderr b/tests/ui/as_ptr_cast_mut.stderr index 67dd7ddb8291e..b3fc223ccdba1 100644 --- a/tests/ui/as_ptr_cast_mut.stderr +++ b/tests/ui/as_ptr_cast_mut.stderr @@ -8,7 +8,7 @@ LL | let _ = string.as_ptr() as *mut u8; = help: to override `-D warnings` add `#[allow(clippy::as_ptr_cast_mut)]` error: casting the result of `as_ptr` to *mut i8 - --> tests/ui/as_ptr_cast_mut.rs:26:22 + --> tests/ui/as_ptr_cast_mut.rs:25:22 | LL | let _: *mut i8 = string.as_ptr() as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` diff --git a/tests/ui/asm_syntax_x86.rs b/tests/ui/asm_syntax_x86.rs index 0d30b95dcf5e6..4e91f27cd3189 100644 --- a/tests/ui/asm_syntax_x86.rs +++ b/tests/ui/asm_syntax_x86.rs @@ -40,14 +40,12 @@ mod warn_att { asm!("", options(nostack, att_syntax)); //~^ inline_asm_x86_att_syntax - } global_asm!(""); global_asm!("", options()); global_asm!("", options(att_syntax)); //~^ inline_asm_x86_att_syntax - } fn main() { diff --git a/tests/ui/asm_syntax_x86.stderr b/tests/ui/asm_syntax_x86.stderr index 8e1992b66bca3..2dcd955f03479 100644 --- a/tests/ui/asm_syntax_x86.stderr +++ b/tests/ui/asm_syntax_x86.stderr @@ -59,7 +59,7 @@ LL | asm!("", options(nostack, att_syntax)); = help: use Intel x86 assembly syntax error: AT&T x86 assembly syntax used - --> tests/ui/asm_syntax_x86.rs:48:5 + --> tests/ui/asm_syntax_x86.rs:47:5 | LL | global_asm!("", options(att_syntax)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/assertions_on_constants.rs b/tests/ui/assertions_on_constants.rs index 96b9c16d4303f..c2516c5414753 100644 --- a/tests/ui/assertions_on_constants.rs +++ b/tests/ui/assertions_on_constants.rs @@ -19,17 +19,14 @@ fn main() { assert!(false, "false message"); //~^ assertions_on_constants - let msg = "panic message"; assert!(false, "{}", msg.to_uppercase()); //~^ assertions_on_constants - const B: bool = true; assert!(B); //~^ assertions_on_constants - const C: bool = false; assert!(C); //~^ assertions_on_constants @@ -37,7 +34,6 @@ fn main() { assert!(C, "C message"); //~^ assertions_on_constants - debug_assert!(true); //~^ assertions_on_constants @@ -58,11 +54,9 @@ fn main() { const _: () = assert!(true); //~^ assertions_on_constants - assert!(8 == (7 + 1)); //~^ assertions_on_constants - // Don't lint if the value is dependent on a defined constant: const N: usize = 1024; const _: () = assert!(N.is_power_of_two()); diff --git a/tests/ui/assertions_on_constants.stderr b/tests/ui/assertions_on_constants.stderr index b0e6496982f99..8b7440ec4832c 100644 --- a/tests/ui/assertions_on_constants.stderr +++ b/tests/ui/assertions_on_constants.stderr @@ -33,7 +33,7 @@ LL | assert!(false, "false message"); = help: use `panic!(..)` or `unreachable!(..)` error: `assert!(false, ..)` should probably be replaced - --> tests/ui/assertions_on_constants.rs:24:5 + --> tests/ui/assertions_on_constants.rs:23:5 | LL | assert!(false, "{}", msg.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | assert!(false, "{}", msg.to_uppercase()); = help: use `panic!(..)` or `unreachable!(..)` error: `assert!(true)` will be optimized out by the compiler - --> tests/ui/assertions_on_constants.rs:29:5 + --> tests/ui/assertions_on_constants.rs:27:5 | LL | assert!(B); | ^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | assert!(B); = help: remove it error: `assert!(false)` should probably be replaced - --> tests/ui/assertions_on_constants.rs:34:5 + --> tests/ui/assertions_on_constants.rs:31:5 | LL | assert!(C); | ^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | assert!(C); = help: use `panic!()` or `unreachable!()` error: `assert!(false, ..)` should probably be replaced - --> tests/ui/assertions_on_constants.rs:37:5 + --> tests/ui/assertions_on_constants.rs:34:5 | LL | assert!(C, "C message"); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | assert!(C, "C message"); = help: use `panic!(..)` or `unreachable!(..)` error: `debug_assert!(true)` will be optimized out by the compiler - --> tests/ui/assertions_on_constants.rs:41:5 + --> tests/ui/assertions_on_constants.rs:37:5 | LL | debug_assert!(true); | ^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | debug_assert!(true); = help: remove it error: `assert!(true)` will be optimized out by the compiler - --> tests/ui/assertions_on_constants.rs:58:19 + --> tests/ui/assertions_on_constants.rs:54:19 | LL | const _: () = assert!(true); | ^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | const _: () = assert!(true); = help: remove it error: `assert!(true)` will be optimized out by the compiler - --> tests/ui/assertions_on_constants.rs:62:5 + --> tests/ui/assertions_on_constants.rs:57:5 | LL | assert!(8 == (7 + 1)); | ^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | assert!(8 == (7 + 1)); = help: remove it error: `assert!(true)` will be optimized out by the compiler - --> tests/ui/assertions_on_constants.rs:72:5 + --> tests/ui/assertions_on_constants.rs:66:5 | LL | assert!(true); | ^^^^^^^^^^^^^ diff --git a/tests/ui/assign_ops2.rs b/tests/ui/assign_ops2.rs index 7cac9f51ea4e3..51867fa6962cf 100644 --- a/tests/ui/assign_ops2.rs +++ b/tests/ui/assign_ops2.rs @@ -8,7 +8,6 @@ fn main() { a += a + 1; //~^ misrefactored_assign_op - a += 1 + a; //~^ misrefactored_assign_op @@ -72,8 +71,6 @@ fn cow_add_assign() { buf = buf + cows.clone(); //~^ assign_op_pattern - - // this should not as cow Add is not commutative buf = cows + buf; println!("{}", buf); diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 56b5219dd6469..19deebe178502 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -16,7 +16,7 @@ LL | a = a + a + 1; | ~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:12:5 + --> tests/ui/assign_ops2.rs:11:5 | LL | a += 1 + a; | ^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | a = a + 1 + a; | ~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:15:5 + --> tests/ui/assign_ops2.rs:14:5 | LL | a -= a - 1; | ^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | a = a - (a - 1); | ~~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:18:5 + --> tests/ui/assign_ops2.rs:17:5 | LL | a *= a * 99; | ^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | a = a * a * 99; | ~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:21:5 + --> tests/ui/assign_ops2.rs:20:5 | LL | a *= 42 * a; | ^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | a = a * 42 * a; | ~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:24:5 + --> tests/ui/assign_ops2.rs:23:5 | LL | a /= a / 2; | ^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | a = a / (a / 2); | ~~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:27:5 + --> tests/ui/assign_ops2.rs:26:5 | LL | a %= a % 5; | ^^^^^^^^^^ @@ -106,7 +106,7 @@ LL | a = a % (a % 5); | ~~~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:30:5 + --> tests/ui/assign_ops2.rs:29:5 | LL | a &= a & 1; | ^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | a = a & a & 1; | ~~~~~~~~~~~~~ error: variable appears on both sides of an assignment operation - --> tests/ui/assign_ops2.rs:33:5 + --> tests/ui/assign_ops2.rs:32:5 | LL | a *= a * a; | ^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | a = a * a * a; | ~~~~~~~~~~~~~ error: manual implementation of an assign operation - --> tests/ui/assign_ops2.rs:72:5 + --> tests/ui/assign_ops2.rs:71:5 | LL | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` diff --git a/tests/ui/attrs.rs b/tests/ui/attrs.rs index 32e4053e74b01..583a0ada437d2 100644 --- a/tests/ui/attrs.rs +++ b/tests/ui/attrs.rs @@ -5,7 +5,6 @@ #[inline(always)] //~^ inline_always - fn test_attr_lint() { assert!(true) } @@ -28,7 +27,6 @@ fn empty_and_false_positive_stmt() { #[deprecated(since = "forever")] //~^ deprecated_semver - pub const SOME_CONST: u8 = 42; #[deprecated(since = "1")] diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index f4803380cc41f..a7fdceaba6f39 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,5 +1,5 @@ error: the since field must contain a semver-compliant version - --> tests/ui/attrs.rs:28:14 + --> tests/ui/attrs.rs:27:14 | LL | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #[deprecated(since = "forever")] = help: to override `-D warnings` add `#[allow(clippy::deprecated_semver)]` error: the since field must contain a semver-compliant version - --> tests/ui/attrs.rs:34:14 + --> tests/ui/attrs.rs:32:14 | LL | #[deprecated(since = "1")] | ^^^^^^^^^^^ diff --git a/tests/ui/await_holding_refcell_ref.rs b/tests/ui/await_holding_refcell_ref.rs index 258e16c07e04f..e1db2e387497e 100644 --- a/tests/ui/await_holding_refcell_ref.rs +++ b/tests/ui/await_holding_refcell_ref.rs @@ -36,7 +36,6 @@ async fn also_bad(x: &RefCell) -> u32 { let b = x.borrow_mut(); //~^ await_holding_refcell_ref - let second = baz().await; let third = baz().await; @@ -50,7 +49,6 @@ async fn less_bad(x: &RefCell) -> u32 { let b = x.borrow_mut(); //~^ await_holding_refcell_ref - let second = baz().await; drop(b); diff --git a/tests/ui/await_holding_refcell_ref.stderr b/tests/ui/await_holding_refcell_ref.stderr index ce7c71ae8fec9..ed8aa747bd076 100644 --- a/tests/ui/await_holding_refcell_ref.stderr +++ b/tests/ui/await_holding_refcell_ref.stderr @@ -34,7 +34,7 @@ LL | let b = x.borrow_mut(); | = help: ensure the reference is dropped before calling `await` note: these are all the await points this reference is held through - --> tests/ui/await_holding_refcell_ref.rs:40:24 + --> tests/ui/await_holding_refcell_ref.rs:39:24 | LL | let second = baz().await; | ^^^^^ @@ -43,40 +43,40 @@ LL | let third = baz().await; | ^^^^^ error: this `RefCell` reference is held across an await point - --> tests/ui/await_holding_refcell_ref.rs:50:9 + --> tests/ui/await_holding_refcell_ref.rs:49:9 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the await points this reference is held through - --> tests/ui/await_holding_refcell_ref.rs:54:24 + --> tests/ui/await_holding_refcell_ref.rs:52:24 | LL | let second = baz().await; | ^^^^^ error: this `RefCell` reference is held across an await point - --> tests/ui/await_holding_refcell_ref.rs:67:13 + --> tests/ui/await_holding_refcell_ref.rs:65:13 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the await points this reference is held through - --> tests/ui/await_holding_refcell_ref.rs:70:15 + --> tests/ui/await_holding_refcell_ref.rs:68:15 | LL | baz().await | ^^^^^ error: this `RefCell` reference is held across an await point - --> tests/ui/await_holding_refcell_ref.rs:81:13 + --> tests/ui/await_holding_refcell_ref.rs:79:13 | LL | let b = x.borrow_mut(); | ^ | = help: ensure the reference is dropped before calling `await` note: these are all the await points this reference is held through - --> tests/ui/await_holding_refcell_ref.rs:84:15 + --> tests/ui/await_holding_refcell_ref.rs:82:15 | LL | baz().await | ^^^^^ diff --git a/tests/ui/bind_instead_of_map_multipart.fixed b/tests/ui/bind_instead_of_map_multipart.fixed index a1da2cfc9fc6f..b61ce97fe8e63 100644 --- a/tests/ui/bind_instead_of_map_multipart.fixed +++ b/tests/ui/bind_instead_of_map_multipart.fixed @@ -20,7 +20,7 @@ pub fn main() { fn hard_example() { Some("42").map(|s| { - //~^ bind_instead_of_map + //~^ bind_instead_of_map if { if s == "43" { return 43; diff --git a/tests/ui/bind_instead_of_map_multipart.rs b/tests/ui/bind_instead_of_map_multipart.rs index 5710254ddf6e6..37f406def1972 100644 --- a/tests/ui/bind_instead_of_map_multipart.rs +++ b/tests/ui/bind_instead_of_map_multipart.rs @@ -20,7 +20,7 @@ pub fn main() { fn hard_example() { Some("42").and_then(|s| { - //~^ bind_instead_of_map + //~^ bind_instead_of_map if { if s == "43" { return Some(43); diff --git a/tests/ui/bit_masks.rs b/tests/ui/bit_masks.rs index b38523a039606..87dcdb3084d00 100644 --- a/tests/ui/bit_masks.rs +++ b/tests/ui/bit_masks.rs @@ -15,9 +15,6 @@ fn main() { //~^ bad_bit_mask //~| erasing_op - - - x & 1 == 1; //ok, distinguishes bit 0 x & 1 == 0; //ok, compared with zero x & 2 == 1; @@ -29,7 +26,6 @@ fn main() { x | 3 == 2; //~^ bad_bit_mask - x & 1 > 1; //~^ bad_bit_mask @@ -51,12 +47,10 @@ fn main() { x | EVEN_MORE_REDIRECTION < 7; //~^ bad_bit_mask - 0 & x == 0; //~^ bad_bit_mask //~| erasing_op - 1 | x > 1; // and should now also match uncommon usage @@ -69,7 +63,6 @@ fn main() { 1 == x & 2; //~^ bad_bit_mask - x | 1 > 2; // no error, because we allowed ineffective bit masks ineffective(); } @@ -82,7 +75,6 @@ fn ineffective() { x | 1 > 3; //~^ ineffective_bit_mask - x | 1 < 4; //~^ ineffective_bit_mask @@ -92,7 +84,6 @@ fn ineffective() { x | 1 >= 8; //~^ ineffective_bit_mask - x | 1 > 2; // not an error (yet), better written as x >= 2 x | 1 >= 7; // not an error (yet), better written as x >= 6 x | 3 > 4; // not an error (yet), better written as x >= 4 diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index 300c93df9250b..666ad671edee6 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -16,73 +16,73 @@ LL | x & 0 == 0; = note: `#[deny(clippy::erasing_op)]` on by default error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> tests/ui/bit_masks.rs:23:5 + --> tests/ui/bit_masks.rs:20:5 | LL | x & 2 == 1; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> tests/ui/bit_masks.rs:29:5 + --> tests/ui/bit_masks.rs:26:5 | LL | x | 3 == 2; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 1` will never be higher than `1` - --> tests/ui/bit_masks.rs:33:5 + --> tests/ui/bit_masks.rs:29:5 | LL | x & 1 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> tests/ui/bit_masks.rs:39:5 + --> tests/ui/bit_masks.rs:35:5 | LL | x | 2 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ & 7` can never be equal to `8` - --> tests/ui/bit_masks.rs:48:5 + --> tests/ui/bit_masks.rs:44:5 | LL | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ error: incompatible bit mask: `_ | 7` will never be lower than `7` - --> tests/ui/bit_masks.rs:51:5 + --> tests/ui/bit_masks.rs:47:5 | LL | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: &-masking with zero - --> tests/ui/bit_masks.rs:55:5 + --> tests/ui/bit_masks.rs:50:5 | LL | 0 & x == 0; | ^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> tests/ui/bit_masks.rs:55:5 + --> tests/ui/bit_masks.rs:50:5 | LL | 0 & x == 0; | ^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> tests/ui/bit_masks.rs:63:5 + --> tests/ui/bit_masks.rs:57:5 | LL | 1 < 2 | x; | ^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> tests/ui/bit_masks.rs:66:5 + --> tests/ui/bit_masks.rs:60:5 | LL | 2 == 3 | x; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> tests/ui/bit_masks.rs:69:5 + --> tests/ui/bit_masks.rs:63:5 | LL | 1 == x & 2; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> tests/ui/bit_masks.rs:82:5 + --> tests/ui/bit_masks.rs:75:5 | LL | x | 1 > 3; | ^^^^^^^^^ @@ -91,19 +91,19 @@ LL | x | 1 > 3; = help: to override `-D warnings` add `#[allow(clippy::ineffective_bit_mask)]` error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly - --> tests/ui/bit_masks.rs:86:5 + --> tests/ui/bit_masks.rs:78:5 | LL | x | 1 < 4; | ^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> tests/ui/bit_masks.rs:89:5 + --> tests/ui/bit_masks.rs:81:5 | LL | x | 1 <= 3; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly - --> tests/ui/bit_masks.rs:92:5 + --> tests/ui/bit_masks.rs:84:5 | LL | x | 1 >= 8; | ^^^^^^^^^^ diff --git a/tests/ui/blanket_clippy_restriction_lints.rs b/tests/ui/blanket_clippy_restriction_lints.rs index 16e2e62c523db..de699309b16d1 100644 --- a/tests/ui/blanket_clippy_restriction_lints.rs +++ b/tests/ui/blanket_clippy_restriction_lints.rs @@ -6,12 +6,9 @@ //! Test that the whole restriction group is not enabled #![warn(clippy::restriction)] //~^ blanket_clippy_restriction_lints - #![deny(clippy::restriction)] //~^ blanket_clippy_restriction_lints - #![forbid(clippy::restriction)] //~^ blanket_clippy_restriction_lints - fn main() {} diff --git a/tests/ui/blanket_clippy_restriction_lints.stderr b/tests/ui/blanket_clippy_restriction_lints.stderr index 5bfd7d2083075..ff3a7cfc3931b 100644 --- a/tests/ui/blanket_clippy_restriction_lints.stderr +++ b/tests/ui/blanket_clippy_restriction_lints.stderr @@ -14,7 +14,7 @@ LL | #![warn(clippy::restriction)] = help: enable the restriction lints you need individually error: `clippy::restriction` is not meant to be enabled as a group - --> tests/ui/blanket_clippy_restriction_lints.rs:10:9 + --> tests/ui/blanket_clippy_restriction_lints.rs:9:9 | LL | #![deny(clippy::restriction)] | ^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | #![deny(clippy::restriction)] = help: enable the restriction lints you need individually error: `clippy::restriction` is not meant to be enabled as a group - --> tests/ui/blanket_clippy_restriction_lints.rs:13:11 + --> tests/ui/blanket_clippy_restriction_lints.rs:11:11 | LL | #![forbid(clippy::restriction)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/bool_comparison.fixed b/tests/ui/bool_comparison.fixed index 724bf9253d33d..166abbe549c3d 100644 --- a/tests/ui/bool_comparison.fixed +++ b/tests/ui/bool_comparison.fixed @@ -5,86 +5,86 @@ fn main() { let x = true; if x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if !x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if !x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if !x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if !x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if !x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if !x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; let y = true; if !x & y { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x & !y { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index 6d11f9efe5690..7265c2b4c5a6f 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -5,86 +5,86 @@ fn main() { let x = true; if x == true { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x == false { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if true == x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if false == x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x != true { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x != false { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if true != x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if false != x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x < true { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if false < x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x > false { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if true > x { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; let y = true; if x < y { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" }; if x > y { - //~^ bool_comparison + //~^ bool_comparison "yes" } else { "no" diff --git a/tests/ui/bool_to_int_with_if.rs b/tests/ui/bool_to_int_with_if.rs index d12b0af5312ee..72c7e2c71c560 100644 --- a/tests/ui/bool_to_int_with_if.rs +++ b/tests/ui/bool_to_int_with_if.rs @@ -12,37 +12,37 @@ fn main() { // Should lint // precedence if a { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 1 } else { 0 }; if a { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 0 } else { 1 }; if !a { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 1 } else { 0 }; if a || b { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 1 } else { 0 }; if cond(a, b) { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 1 } else { 0 }; if x + y < 4 { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 1 } else { 0 @@ -52,7 +52,7 @@ fn main() { if a { 123 } else if b { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 1 } else { 0 @@ -62,7 +62,7 @@ fn main() { if a { 123 } else if b { - //~^ bool_to_int_with_if + //~^ bool_to_int_with_if 0 } else { 1 diff --git a/tests/ui/borrow_box.fixed b/tests/ui/borrow_box.fixed index 4529138c0edc8..e6e7f74af7cf6 100644 --- a/tests/ui/borrow_box.fixed +++ b/tests/ui/borrow_box.fixed @@ -24,19 +24,16 @@ pub fn test1(foo: &mut Box) { pub fn test2() { let foo: &bool; //~^ borrowed_box - } struct Test3<'a> { foo: &'a bool, //~^ borrowed_box - } trait Test4 { fn test4(a: &bool); //~^ borrowed_box - } use std::any::Any; @@ -105,7 +102,6 @@ pub fn test15(_display: &(dyn Display + Send)) {} pub fn test16<'a>(_display: &'a (dyn Display + 'a)) {} //~^ borrowed_box - pub fn test17(_display: &impl Display) {} //~^ borrowed_box @@ -115,14 +111,12 @@ pub fn test18(_display: &(impl Display + Send)) {} pub fn test19<'a>(_display: &'a (impl Display + 'a)) {} //~^ borrowed_box - // This exists only to check what happens when parentheses are already present. // Even though the current implementation doesn't put extra parentheses, // it's fine that unnecessary parentheses appear in the future for some reason. pub fn test20(_display: &(dyn Display + Send)) {} //~^ borrowed_box - #[allow(clippy::borrowed_box)] trait Trait { fn f(b: &Box); diff --git a/tests/ui/borrow_box.rs b/tests/ui/borrow_box.rs index 3f2a0168ef42d..43cf809306b30 100644 --- a/tests/ui/borrow_box.rs +++ b/tests/ui/borrow_box.rs @@ -24,19 +24,16 @@ pub fn test1(foo: &mut Box) { pub fn test2() { let foo: &Box; //~^ borrowed_box - } struct Test3<'a> { foo: &'a Box, //~^ borrowed_box - } trait Test4 { fn test4(a: &Box); //~^ borrowed_box - } use std::any::Any; @@ -105,7 +102,6 @@ pub fn test15(_display: &Box) {} pub fn test16<'a>(_display: &'a Box) {} //~^ borrowed_box - pub fn test17(_display: &Box) {} //~^ borrowed_box @@ -115,14 +111,12 @@ pub fn test18(_display: &Box) {} pub fn test19<'a>(_display: &'a Box) {} //~^ borrowed_box - // This exists only to check what happens when parentheses are already present. // Even though the current implementation doesn't put extra parentheses, // it's fine that unnecessary parentheses appear in the future for some reason. pub fn test20(_display: &Box<(dyn Display + Send)>) {} //~^ borrowed_box - #[allow(clippy::borrowed_box)] trait Trait { fn f(b: &Box); diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index e23e49f1c88b4..dbe3757dd4357 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)] | ^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:31:10 + --> tests/ui/borrow_box.rs:30:10 | LL | foo: &'a Box, | ^^^^^^^^^^^^^ help: try: `&'a bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:37:17 + --> tests/ui/borrow_box.rs:35:17 | LL | fn test4(a: &Box); | ^^^^^^^^^^ help: try: `&bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:99:25 + --> tests/ui/borrow_box.rs:96:25 | LL | pub fn test14(_display: &Box) {} | ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:102:25 + --> tests/ui/borrow_box.rs:99:25 | LL | pub fn test15(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:105:29 + --> tests/ui/borrow_box.rs:102:29 | LL | pub fn test16<'a>(_display: &'a Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:109:25 + --> tests/ui/borrow_box.rs:105:25 | LL | pub fn test17(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:112:25 + --> tests/ui/borrow_box.rs:108:25 | LL | pub fn test18(_display: &Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:115:29 + --> tests/ui/borrow_box.rs:111:29 | LL | pub fn test19<'a>(_display: &'a Box) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> tests/ui/borrow_box.rs:122:25 + --> tests/ui/borrow_box.rs:117:25 | LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` diff --git a/tests/ui/borrow_deref_ref_unfixable.rs b/tests/ui/borrow_deref_ref_unfixable.rs index e51d9912b3088..f05a90d2c1fa8 100644 --- a/tests/ui/borrow_deref_ref_unfixable.rs +++ b/tests/ui/borrow_deref_ref_unfixable.rs @@ -8,7 +8,5 @@ mod should_lint { let s = &String::new(); let x: &str = &*s; //~^ borrow_deref_ref - - } } diff --git a/tests/ui/borrow_interior_mutable_const/others.rs b/tests/ui/borrow_interior_mutable_const/others.rs index eaf90ce6a8dd9..fa729b62d7f51 100644 --- a/tests/ui/borrow_interior_mutable_const/others.rs +++ b/tests/ui/borrow_interior_mutable_const/others.rs @@ -62,20 +62,20 @@ mod issue12979 { const CELL_REF: StaticRef<(UnsafeCell,)> = unsafe { StaticRef::new(std::ptr::null()) }; fn main() { -ATOMIC.store(1, Ordering::SeqCst); -//~^ borrow_interior_mutable_const -assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); -//~^ borrow_interior_mutable_const + ATOMIC.store(1, Ordering::SeqCst); + //~^ borrow_interior_mutable_const + assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); + //~^ borrow_interior_mutable_const let _once = ONCE_INIT; -let _once_ref = &ONCE_INIT; -//~^ borrow_interior_mutable_const -let _once_ref_2 = &&ONCE_INIT; -//~^ borrow_interior_mutable_const -let _once_ref_4 = &&&&ONCE_INIT; -//~^ borrow_interior_mutable_const -let _once_mut = &mut ONCE_INIT; -//~^ borrow_interior_mutable_const + let _once_ref = &ONCE_INIT; + //~^ borrow_interior_mutable_const + let _once_ref_2 = &&ONCE_INIT; + //~^ borrow_interior_mutable_const + let _once_ref_4 = &&&&ONCE_INIT; + //~^ borrow_interior_mutable_const + let _once_mut = &mut ONCE_INIT; + //~^ borrow_interior_mutable_const let _atomic_into_inner = ATOMIC.into_inner(); // these should be all fine. let _twice = (ONCE_INIT, ONCE_INIT); @@ -86,30 +86,30 @@ let _once_mut = &mut ONCE_INIT; let _ref_array_once = &[ONCE_INIT, ONCE_INIT][0]; // referencing projection is still bad. -let _ = &ATOMIC_TUPLE; -//~^ borrow_interior_mutable_const -let _ = &ATOMIC_TUPLE.0; -//~^ borrow_interior_mutable_const -let _ = &(&&&&ATOMIC_TUPLE).0; -//~^ borrow_interior_mutable_const -let _ = &ATOMIC_TUPLE.0[0]; -//~^ borrow_interior_mutable_const -let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); -//~^ borrow_interior_mutable_const + let _ = &ATOMIC_TUPLE; + //~^ borrow_interior_mutable_const + let _ = &ATOMIC_TUPLE.0; + //~^ borrow_interior_mutable_const + let _ = &(&&&&ATOMIC_TUPLE).0; + //~^ borrow_interior_mutable_const + let _ = &ATOMIC_TUPLE.0[0]; + //~^ borrow_interior_mutable_const + let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); + //~^ borrow_interior_mutable_const let _ = &ATOMIC_TUPLE.2; let _ = (&&&&ATOMIC_TUPLE).0; let _ = (&&&&ATOMIC_TUPLE).2; let _ = ATOMIC_TUPLE.0; -let _ = ATOMIC_TUPLE.0[0]; -//~^ borrow_interior_mutable_const + let _ = ATOMIC_TUPLE.0[0]; + //~^ borrow_interior_mutable_const let _ = ATOMIC_TUPLE.1.into_iter(); let _ = ATOMIC_TUPLE.2; let _ = &{ ATOMIC_TUPLE }; -CELL.set(2); -//~^ borrow_interior_mutable_const -assert_eq!(CELL.get(), 6); -//~^ borrow_interior_mutable_const + CELL.set(2); + //~^ borrow_interior_mutable_const + assert_eq!(CELL.get(), 6); + //~^ borrow_interior_mutable_const assert_eq!(INTEGER, 8); assert!(STRING.is_empty()); diff --git a/tests/ui/borrow_interior_mutable_const/others.stderr b/tests/ui/borrow_interior_mutable_const/others.stderr index f156640301516..decea153f7173 100644 --- a/tests/ui/borrow_interior_mutable_const/others.stderr +++ b/tests/ui/borrow_interior_mutable_const/others.stderr @@ -1,8 +1,8 @@ error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:65:1 + --> tests/ui/borrow_interior_mutable_const/others.rs:65:5 | -LL | ATOMIC.store(1, Ordering::SeqCst); - | ^^^^^^ +LL | ATOMIC.store(1, Ordering::SeqCst); + | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here @@ -12,106 +12,106 @@ LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:67:12 + --> tests/ui/borrow_interior_mutable_const/others.rs:67:16 | -LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); - | ^^^^^^ +LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); + | ^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:71:18 + --> tests/ui/borrow_interior_mutable_const/others.rs:71:22 | -LL | let _once_ref = &ONCE_INIT; - | ^^^^^^^^^ +LL | let _once_ref = &ONCE_INIT; + | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:73:21 + --> tests/ui/borrow_interior_mutable_const/others.rs:73:25 | -LL | let _once_ref_2 = &&ONCE_INIT; - | ^^^^^^^^^ +LL | let _once_ref_2 = &&ONCE_INIT; + | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:75:23 + --> tests/ui/borrow_interior_mutable_const/others.rs:75:27 | -LL | let _once_ref_4 = &&&&ONCE_INIT; - | ^^^^^^^^^ +LL | let _once_ref_4 = &&&&ONCE_INIT; + | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:77:22 + --> tests/ui/borrow_interior_mutable_const/others.rs:77:26 | -LL | let _once_mut = &mut ONCE_INIT; - | ^^^^^^^^^ +LL | let _once_mut = &mut ONCE_INIT; + | ^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:89:10 + --> tests/ui/borrow_interior_mutable_const/others.rs:89:14 | -LL | let _ = &ATOMIC_TUPLE; - | ^^^^^^^^^^^^ +LL | let _ = &ATOMIC_TUPLE; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:91:10 + --> tests/ui/borrow_interior_mutable_const/others.rs:91:14 | -LL | let _ = &ATOMIC_TUPLE.0; - | ^^^^^^^^^^^^ +LL | let _ = &ATOMIC_TUPLE.0; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:93:15 + --> tests/ui/borrow_interior_mutable_const/others.rs:93:19 | -LL | let _ = &(&&&&ATOMIC_TUPLE).0; - | ^^^^^^^^^^^^ +LL | let _ = &(&&&&ATOMIC_TUPLE).0; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:95:10 + --> tests/ui/borrow_interior_mutable_const/others.rs:95:14 | -LL | let _ = &ATOMIC_TUPLE.0[0]; - | ^^^^^^^^^^^^ +LL | let _ = &ATOMIC_TUPLE.0[0]; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:97:9 + --> tests/ui/borrow_interior_mutable_const/others.rs:97:13 | -LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); - | ^^^^^^^^^^^^ +LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:103:9 + --> tests/ui/borrow_interior_mutable_const/others.rs:103:13 | -LL | let _ = ATOMIC_TUPLE.0[0]; - | ^^^^^^^^^^^^ +LL | let _ = ATOMIC_TUPLE.0[0]; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:109:1 + --> tests/ui/borrow_interior_mutable_const/others.rs:109:5 | -LL | CELL.set(2); - | ^^^^ +LL | CELL.set(2); + | ^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/others.rs:111:12 + --> tests/ui/borrow_interior_mutable_const/others.rs:111:16 | -LL | assert_eq!(CELL.get(), 6); - | ^^^^ +LL | assert_eq!(CELL.get(), 6); + | ^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/borrow_interior_mutable_const/traits.rs b/tests/ui/borrow_interior_mutable_const/traits.rs index 8e2b7ffd554fe..c4878dbe57b29 100644 --- a/tests/ui/borrow_interior_mutable_const/traits.rs +++ b/tests/ui/borrow_interior_mutable_const/traits.rs @@ -12,8 +12,8 @@ trait ConcreteTypes { const STRING: String; fn function() { -let _ = &Self::ATOMIC; -//~^ borrow_interior_mutable_const + let _ = &Self::ATOMIC; + //~^ borrow_interior_mutable_const let _ = &Self::STRING; } } @@ -24,8 +24,8 @@ impl ConcreteTypes for u64 { fn function() { // Lint this again since implementers can choose not to borrow it. -let _ = &Self::ATOMIC; -//~^ borrow_interior_mutable_const + let _ = &Self::ATOMIC; + //~^ borrow_interior_mutable_const let _ = &Self::STRING; } } @@ -50,8 +50,8 @@ impl GenericTypes for Vec { fn function() { let _ = &Self::TO_REMAIN_GENERIC; -let _ = &Self::TO_BE_CONCRETE; -//~^ borrow_interior_mutable_const + let _ = &Self::TO_BE_CONCRETE; + //~^ borrow_interior_mutable_const } } @@ -86,10 +86,10 @@ impl AssocTypes for Vec { fn function() { let _ = &Self::TO_BE_FROZEN; -let _ = &Self::TO_BE_UNFROZEN; -//~^ borrow_interior_mutable_const -let _ = &Self::WRAPPED_TO_BE_UNFROZEN; -//~^ borrow_interior_mutable_const + let _ = &Self::TO_BE_UNFROZEN; + //~^ borrow_interior_mutable_const + let _ = &Self::WRAPPED_TO_BE_UNFROZEN; + //~^ borrow_interior_mutable_const let _ = &Self::WRAPPED_TO_BE_GENERIC_PARAM; } } @@ -111,8 +111,8 @@ where fn function() { let _ = &Self::NOT_BOUNDED; -let _ = &Self::BOUNDED; -//~^ borrow_interior_mutable_const + let _ = &Self::BOUNDED; + //~^ borrow_interior_mutable_const } } @@ -125,8 +125,8 @@ where fn function() { let _ = &Self::NOT_BOUNDED; -let _ = &Self::BOUNDED; -//~^ borrow_interior_mutable_const + let _ = &Self::BOUNDED; + //~^ borrow_interior_mutable_const } } @@ -155,10 +155,10 @@ impl SelfType for AtomicUsize { const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); fn function() { -let _ = &Self::SELF; -//~^ borrow_interior_mutable_const -let _ = &Self::WRAPPED_SELF; -//~^ borrow_interior_mutable_const + let _ = &Self::SELF; + //~^ borrow_interior_mutable_const + let _ = &Self::WRAPPED_SELF; + //~^ borrow_interior_mutable_const } } @@ -167,10 +167,10 @@ trait BothOfCellAndGeneric { const INDIRECT: Cell<*const T>; fn function() { -let _ = &Self::DIRECT; -//~^ borrow_interior_mutable_const -let _ = &Self::INDIRECT; -//~^ borrow_interior_mutable_const + let _ = &Self::DIRECT; + //~^ borrow_interior_mutable_const + let _ = &Self::INDIRECT; + //~^ borrow_interior_mutable_const } } @@ -179,10 +179,10 @@ impl BothOfCellAndGeneric for Vec { const INDIRECT: Cell<*const T> = Cell::new(std::ptr::null()); fn function() { -let _ = &Self::DIRECT; -//~^ borrow_interior_mutable_const -let _ = &Self::INDIRECT; -//~^ borrow_interior_mutable_const + let _ = &Self::DIRECT; + //~^ borrow_interior_mutable_const + let _ = &Self::INDIRECT; + //~^ borrow_interior_mutable_const } } @@ -201,19 +201,19 @@ where const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); fn function() { -let _ = &Self::ATOMIC; -//~^ borrow_interior_mutable_const + let _ = &Self::ATOMIC; + //~^ borrow_interior_mutable_const let _ = &Self::COW; let _ = &Self::GENERIC_TYPE; let _ = &Self::ASSOC_TYPE; -let _ = &Self::BOUNDED_ASSOC_TYPE; -//~^ borrow_interior_mutable_const + let _ = &Self::BOUNDED_ASSOC_TYPE; + //~^ borrow_interior_mutable_const } } fn main() { -u64::ATOMIC.store(5, Ordering::SeqCst); -//~^ borrow_interior_mutable_const -assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); -//~^ borrow_interior_mutable_const + u64::ATOMIC.store(5, Ordering::SeqCst); + //~^ borrow_interior_mutable_const + assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); + //~^ borrow_interior_mutable_const } diff --git a/tests/ui/borrow_interior_mutable_const/traits.stderr b/tests/ui/borrow_interior_mutable_const/traits.stderr index 6998ba6fc0906..cad68ca9260cb 100644 --- a/tests/ui/borrow_interior_mutable_const/traits.stderr +++ b/tests/ui/borrow_interior_mutable_const/traits.stderr @@ -1,8 +1,8 @@ error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:15:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:15:18 | -LL | let _ = &Self::ATOMIC; - | ^^^^^^^^^^^^ +LL | let _ = &Self::ATOMIC; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here note: the lint level is defined here @@ -12,130 +12,130 @@ LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:27:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:27:18 | -LL | let _ = &Self::ATOMIC; - | ^^^^^^^^^^^^ +LL | let _ = &Self::ATOMIC; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:53:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:53:18 | -LL | let _ = &Self::TO_BE_CONCRETE; - | ^^^^^^^^^^^^^^^^^^^^ +LL | let _ = &Self::TO_BE_CONCRETE; + | ^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:89:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:89:18 | -LL | let _ = &Self::TO_BE_UNFROZEN; - | ^^^^^^^^^^^^^^^^^^^^ +LL | let _ = &Self::TO_BE_UNFROZEN; + | ^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:91:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:91:18 | -LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:114:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:114:18 | -LL | let _ = &Self::BOUNDED; - | ^^^^^^^^^^^^^ +LL | let _ = &Self::BOUNDED; + | ^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:128:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:128:18 | -LL | let _ = &Self::BOUNDED; - | ^^^^^^^^^^^^^ +LL | let _ = &Self::BOUNDED; + | ^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:158:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:158:18 | -LL | let _ = &Self::SELF; - | ^^^^^^^^^^ +LL | let _ = &Self::SELF; + | ^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:160:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:160:18 | -LL | let _ = &Self::WRAPPED_SELF; - | ^^^^^^^^^^^^^^^^^^ +LL | let _ = &Self::WRAPPED_SELF; + | ^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:170:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:170:18 | -LL | let _ = &Self::DIRECT; - | ^^^^^^^^^^^^ +LL | let _ = &Self::DIRECT; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:172:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:172:18 | -LL | let _ = &Self::INDIRECT; - | ^^^^^^^^^^^^^^ +LL | let _ = &Self::INDIRECT; + | ^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:182:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:182:18 | -LL | let _ = &Self::DIRECT; - | ^^^^^^^^^^^^ +LL | let _ = &Self::DIRECT; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:184:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:184:18 | -LL | let _ = &Self::INDIRECT; - | ^^^^^^^^^^^^^^ +LL | let _ = &Self::INDIRECT; + | ^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:204:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:204:18 | -LL | let _ = &Self::ATOMIC; - | ^^^^^^^^^^^^ +LL | let _ = &Self::ATOMIC; + | ^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:209:10 + --> tests/ui/borrow_interior_mutable_const/traits.rs:209:18 | -LL | let _ = &Self::BOUNDED_ASSOC_TYPE; - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _ = &Self::BOUNDED_ASSOC_TYPE; + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:215:1 + --> tests/ui/borrow_interior_mutable_const/traits.rs:215:5 | -LL | u64::ATOMIC.store(5, Ordering::SeqCst); - | ^^^^^^^^^^^ +LL | u64::ATOMIC.store(5, Ordering::SeqCst); + | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here error: a `const` item with interior mutability should not be borrowed - --> tests/ui/borrow_interior_mutable_const/traits.rs:217:12 + --> tests/ui/borrow_interior_mutable_const/traits.rs:217:16 | -LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); - | ^^^^^^^^^^^ +LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); + | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/box_collection.rs b/tests/ui/box_collection.rs index 61117412016ac..0f7d3c74ddd07 100644 --- a/tests/ui/box_collection.rs +++ b/tests/ui/box_collection.rs @@ -21,7 +21,6 @@ fn test_macro() { fn test1(foo: Box>) {} //~^ box_collection - fn test2(foo: Box)>) { // pass if #31 is fixed foo(vec![1, 2, 3]) @@ -30,35 +29,27 @@ fn test2(foo: Box)>) { fn test3(foo: Box) {} //~^ box_collection - fn test4(foo: Box>) {} //~^ box_collection - fn test5(foo: Box>) {} //~^ box_collection - fn test6(foo: Box>) {} //~^ box_collection - fn test7(foo: Box>) {} //~^ box_collection - fn test8(foo: Box>) {} //~^ box_collection - fn test9(foo: Box>) {} //~^ box_collection - fn test10(foo: Box>) {} //~^ box_collection - fn test_local_not_linted() { let _: Box>; } diff --git a/tests/ui/box_collection.stderr b/tests/ui/box_collection.stderr index 644556edd572a..ebbc3d92b57f7 100644 --- a/tests/ui/box_collection.stderr +++ b/tests/ui/box_collection.stderr @@ -9,7 +9,7 @@ LL | fn test1(foo: Box>) {} = help: to override `-D warnings` add `#[allow(clippy::box_collection)]` error: you seem to be trying to use `Box`. Consider using just `String` - --> tests/ui/box_collection.rs:30:15 + --> tests/ui/box_collection.rs:29:15 | LL | fn test3(foo: Box) {} | ^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn test3(foo: Box) {} = help: `String` is already on the heap, `Box` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `HashMap<..>` - --> tests/ui/box_collection.rs:34:15 + --> tests/ui/box_collection.rs:32:15 | LL | fn test4(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn test4(foo: Box>) {} = help: `HashMap<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `HashSet<..>` - --> tests/ui/box_collection.rs:38:15 + --> tests/ui/box_collection.rs:35:15 | LL | fn test5(foo: Box>) {} | ^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | fn test5(foo: Box>) {} = help: `HashSet<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `VecDeque<..>` - --> tests/ui/box_collection.rs:42:15 + --> tests/ui/box_collection.rs:38:15 | LL | fn test6(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | fn test6(foo: Box>) {} = help: `VecDeque<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `LinkedList<..>` - --> tests/ui/box_collection.rs:46:15 + --> tests/ui/box_collection.rs:41:15 | LL | fn test7(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn test7(foo: Box>) {} = help: `LinkedList<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `BTreeMap<..>` - --> tests/ui/box_collection.rs:50:15 + --> tests/ui/box_collection.rs:44:15 | LL | fn test8(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn test8(foo: Box>) {} = help: `BTreeMap<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `BTreeSet<..>` - --> tests/ui/box_collection.rs:54:15 + --> tests/ui/box_collection.rs:47:15 | LL | fn test9(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn test9(foo: Box>) {} = help: `BTreeSet<..>` is already on the heap, `Box>` makes an extra allocation error: you seem to be trying to use `Box>`. Consider using just `BinaryHeap<..>` - --> tests/ui/box_collection.rs:58:16 + --> tests/ui/box_collection.rs:50:16 | LL | fn test10(foo: Box>) {} | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/boxed_local.rs b/tests/ui/boxed_local.rs index fa234dce1a99b..3fb685aa36c11 100644 --- a/tests/ui/boxed_local.rs +++ b/tests/ui/boxed_local.rs @@ -38,8 +38,7 @@ fn warn_call() { } fn warn_arg(x: Box) { -//~^ boxed_local - + //~^ boxed_local x.foo(); } @@ -124,7 +123,6 @@ pub struct PeekableSeekable { pub fn new(_needs_name: Box>) -> () {} //~^ boxed_local - /// Regression for #916, #1123 /// /// This shouldn't warn for `boxed_local`as the implementation of a trait @@ -189,7 +187,7 @@ mod issue4804 { // warn on `x: Box` fn default_impl_x(self: Box, x: Box) -> u32 { - //~^ boxed_local + //~^ boxed_local 4 } @@ -199,7 +197,6 @@ mod issue4804 { // warn on `x: Box` fn foo(x: Box) {} //~^ boxed_local - } } diff --git a/tests/ui/boxed_local.stderr b/tests/ui/boxed_local.stderr index 5ce2c8083f15d..81ebc4fde4985 100644 --- a/tests/ui/boxed_local.stderr +++ b/tests/ui/boxed_local.stderr @@ -8,19 +8,19 @@ LL | fn warn_arg(x: Box) { = help: to override `-D warnings` add `#[allow(clippy::boxed_local)]` error: local variable doesn't need to be boxed here - --> tests/ui/boxed_local.rs:124:12 + --> tests/ui/boxed_local.rs:123:12 | LL | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ error: local variable doesn't need to be boxed here - --> tests/ui/boxed_local.rs:191:44 + --> tests/ui/boxed_local.rs:189:44 | LL | fn default_impl_x(self: Box, x: Box) -> u32 { | ^ error: local variable doesn't need to be boxed here - --> tests/ui/boxed_local.rs:200:16 + --> tests/ui/boxed_local.rs:198:16 | LL | fn foo(x: Box) {} | ^ diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.rs b/tests/ui/branches_sharing_code/shared_at_bottom.rs index 050c8c0d53f21..06472a4f5d572 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.rs +++ b/tests/ui/branches_sharing_code/shared_at_bottom.rs @@ -35,7 +35,6 @@ fn simple_examples() { let result = false; //~^ branches_sharing_code - println!("Block end!"); result }; @@ -55,7 +54,6 @@ fn simple_examples() { println!("This is also eq with the else block"); println!("Same end of block"); //~^ branches_sharing_code - } // Use of outer scope value @@ -73,8 +71,7 @@ fn simple_examples() { println!("I'm a local because I use the value `z`: `{}`", z); println!( - //~^ branches_sharing_code - + //~^ branches_sharing_code "I'm moveable because I know: `outer_scope_value`: '{}'", outer_scope_value ); @@ -88,7 +85,6 @@ fn simple_examples() { } else { println!("Hello World"); //~^ branches_sharing_code - } } } @@ -188,8 +184,6 @@ fn added_note_for_expression_use() -> u32 { let _ = 6; x << 2 //~^ branches_sharing_code - - }; if x == 9 { @@ -198,8 +192,6 @@ fn added_note_for_expression_use() -> u32 { let _ = 17; x * 4 //~^ branches_sharing_code - - } } diff --git a/tests/ui/branches_sharing_code/shared_at_bottom.stderr b/tests/ui/branches_sharing_code/shared_at_bottom.stderr index b7bb077752415..648a99c65ed22 100644 --- a/tests/ui/branches_sharing_code/shared_at_bottom.stderr +++ b/tests/ui/branches_sharing_code/shared_at_bottom.stderr @@ -2,7 +2,9 @@ error: all if blocks contain the same code at the end --> tests/ui/branches_sharing_code/shared_at_bottom.rs:35:5 | LL | / let result = false; -... | +LL | | +LL | | +LL | | println!("Block end!"); LL | | result LL | | }; | |_____^ @@ -19,16 +21,15 @@ LL ~ } LL + let result = false; LL + LL + -LL + LL + println!("Block end!"); LL ~ result; | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:56:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:55:5 | LL | / println!("Same end of block"); -... | +LL | | LL | | } | |_____^ | @@ -39,11 +40,10 @@ LL + println!("Same end of block"); | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:75:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:73:5 | LL | / println!( LL | | -LL | | LL | | "I'm moveable because I know: `outer_scope_value`: '{}'", LL | | outer_scope_value LL | | ); @@ -55,17 +55,16 @@ help: consider moving these statements after the if LL ~ } LL + println!( LL + -LL + LL + "I'm moveable because I know: `outer_scope_value`: '{}'", LL + outer_scope_value LL + ); | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:89:9 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:86:9 | LL | / println!("Hello World"); -... | +LL | | LL | | } | |_________^ | @@ -76,7 +75,7 @@ LL + println!("Hello World"); | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:107:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:103:5 | LL | / let later_used_value = "A string value"; LL | | @@ -97,7 +96,7 @@ LL + println!("{}", later_used_value); | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:122:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:118:5 | LL | / let simple_examples = "I now identify as a &str :)"; LL | | @@ -117,10 +116,10 @@ LL + println!("This is the new simple_example: {}", simple_examples); | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:189:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:185:5 | LL | / x << 2 -... | +LL | | LL | | }; | |_____^ | @@ -132,10 +131,10 @@ LL ~ x << 2; | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:199:5 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:193:5 | LL | / x * 4 -... | +LL | | LL | | } | |_____^ | @@ -147,7 +146,7 @@ LL + x * 4 | error: all if blocks contain the same code at the end - --> tests/ui/branches_sharing_code/shared_at_bottom.rs:214:44 + --> tests/ui/branches_sharing_code/shared_at_bottom.rs:206:44 | LL | if x == 17 { b = 1; a = 0x99; } else { a = 0x99; } | ^^^^^^^^^^^ diff --git a/tests/ui/branches_sharing_code/shared_at_top.rs b/tests/ui/branches_sharing_code/shared_at_top.rs index a6f8ce8a3816e..694c67d4c85b3 100644 --- a/tests/ui/branches_sharing_code/shared_at_top.rs +++ b/tests/ui/branches_sharing_code/shared_at_top.rs @@ -9,7 +9,7 @@ fn simple_examples() { // Simple if true { - //~^ branches_sharing_code + //~^ branches_sharing_code println!("Hello World!"); println!("I'm branch nr: 1"); } else { @@ -17,10 +17,9 @@ fn simple_examples() { println!("I'm branch nr: 2"); } - // Else if if x == 0 { - //~^ branches_sharing_code + //~^ branches_sharing_code let y = 9; println!("The value y was set to: `{}`", y); let _z = y; @@ -40,10 +39,9 @@ fn simple_examples() { println!("Ha, Pascal allows you to start the array where you want") } - // Return a value let _ = if x == 7 { - //~^ branches_sharing_code + //~^ branches_sharing_code let y = 16; println!("What can I say except: \"you're welcome?\""); @@ -63,7 +61,7 @@ fn simple_but_suggestion_is_invalid() { // Can't be automatically moved because used_value_name is getting used again let used_value_name = 19; if x == 10 { - //~^ branches_sharing_code + //~^ branches_sharing_code let used_value_name = "Different type"; println!("Str: {}", used_value_name); let _ = 1; @@ -79,7 +77,7 @@ fn simple_but_suggestion_is_invalid() { let can_be_overridden = 8; let _ = can_be_overridden; if x == 11 { - //~^ branches_sharing_code + //~^ branches_sharing_code let can_be_overridden = "Move me"; println!("I'm also moveable"); @@ -97,7 +95,7 @@ fn check_if_same_than_else_mask() { #[allow(clippy::if_same_then_else)] if x == 2020 { - //~^ branches_sharing_code + //~^ branches_sharing_code println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint."); println!("Because `IF_SAME_THEN_ELSE` is allowed here"); @@ -112,7 +110,6 @@ fn check_if_same_than_else_mask() { println!("This should trigger `IS_SAME_THAN_ELSE` as usual"); } //~^^^^^ if_same_then_else - } #[allow(clippy::vec_init_then_push)] diff --git a/tests/ui/branches_sharing_code/shared_at_top.stderr b/tests/ui/branches_sharing_code/shared_at_top.stderr index 5b0422d5df189..d28e9c7af2967 100644 --- a/tests/ui/branches_sharing_code/shared_at_top.stderr +++ b/tests/ui/branches_sharing_code/shared_at_top.stderr @@ -18,7 +18,7 @@ LL + if true { | error: all if blocks contain the same code at the start - --> tests/ui/branches_sharing_code/shared_at_top.rs:22:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:21:5 | LL | / if x == 0 { LL | | @@ -37,7 +37,7 @@ LL + if x == 0 { | error: all if blocks contain the same code at the start - --> tests/ui/branches_sharing_code/shared_at_top.rs:45:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:43:5 | LL | / let _ = if x == 7 { ... | @@ -51,7 +51,7 @@ LL + let _ = if x == 7 { | error: all if blocks contain the same code at the start - --> tests/ui/branches_sharing_code/shared_at_top.rs:65:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:63:5 | LL | / if x == 10 { LL | | @@ -68,7 +68,7 @@ LL + if x == 10 { | error: all if blocks contain the same code at the start - --> tests/ui/branches_sharing_code/shared_at_top.rs:81:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:79:5 | LL | / if x == 11 { LL | | @@ -86,7 +86,7 @@ LL + if x == 11 { | error: all if blocks contain the same code at the start - --> tests/ui/branches_sharing_code/shared_at_top.rs:99:5 + --> tests/ui/branches_sharing_code/shared_at_top.rs:97:5 | LL | / if x == 2020 { LL | | @@ -103,7 +103,7 @@ LL + if x == 2020 { | error: this `if` has identical blocks - --> tests/ui/branches_sharing_code/shared_at_top.rs:109:18 + --> tests/ui/branches_sharing_code/shared_at_top.rs:107:18 | LL | if x == 2019 { | __________________^ @@ -112,7 +112,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/branches_sharing_code/shared_at_top.rs:111:12 + --> tests/ui/branches_sharing_code/shared_at_top.rs:109:12 | LL | } else { | ____________^ diff --git a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs index 799f58d284306..75334f70f1f62 100644 --- a/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs +++ b/tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs @@ -15,7 +15,7 @@ fn overlapping_eq_regions() { // Overlap with separator if x == 7 { - //~^ branches_sharing_code + //~^ branches_sharing_code let t = 7; let _overlap_start = t * 2; @@ -33,7 +33,7 @@ fn overlapping_eq_regions() { // Overlap with separator if x == 99 { - //~^ branches_sharing_code + //~^ branches_sharing_code let r = 7; let _overlap_start = r; @@ -64,7 +64,7 @@ fn complexer_example() { let x = 8; let y = 9; if (x > 7 && y < 13) || (x + y) % 2 == 1 { - //~^ branches_sharing_code + //~^ branches_sharing_code let a = 0xcafe; let b = 0xffff00ff; @@ -99,7 +99,7 @@ fn added_note_for_expression_use() -> u32 { let x = 9; let _ = if x == 7 { - //~^ branches_sharing_code + //~^ branches_sharing_code let _ = 19; @@ -113,7 +113,7 @@ fn added_note_for_expression_use() -> u32 { }; if x == 9 { - //~^ branches_sharing_code + //~^ branches_sharing_code let _ = 17; diff --git a/tests/ui/branches_sharing_code/valid_if_blocks.rs b/tests/ui/branches_sharing_code/valid_if_blocks.rs index 23ea86c88f540..d72c5eef87adc 100644 --- a/tests/ui/branches_sharing_code/valid_if_blocks.rs +++ b/tests/ui/branches_sharing_code/valid_if_blocks.rs @@ -110,7 +110,6 @@ fn valid_examples() { } else { } //~^^^ if_same_then_else - } /// This makes sure that the `if_same_then_else` masks the `shared_code_in_if_blocks` lint @@ -130,12 +129,10 @@ fn trigger_other_lint() { } //~^^^^^^^^^ if_same_then_else - // Only same expression let _ = if x == 6 { 7 } else { 7 }; //~^ if_same_then_else - // Same in else if block let _ = if x == 67 { println!("Well I'm the most important block"); @@ -151,7 +148,6 @@ fn trigger_other_lint() { }; //~^^^^^^^^^ if_same_then_else - if x == 0 { println!("I'm single"); } else if x == 68 { @@ -160,7 +156,6 @@ fn trigger_other_lint() { println!("I'm a doppelgänger"); } //~^^^^^ if_same_then_else - } fn main() {} diff --git a/tests/ui/branches_sharing_code/valid_if_blocks.stderr b/tests/ui/branches_sharing_code/valid_if_blocks.stderr index a0c4dd24d6b40..4c7e4141b629c 100644 --- a/tests/ui/branches_sharing_code/valid_if_blocks.stderr +++ b/tests/ui/branches_sharing_code/valid_if_blocks.stderr @@ -20,7 +20,7 @@ LL | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has identical blocks - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:122:15 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:121:15 | LL | if x == 0 { | _______________^ @@ -31,7 +31,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:126:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:125:12 | LL | } else { | ____________^ @@ -42,19 +42,19 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:135:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:133:23 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ | note: same as this - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:135:34 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:133:34 | LL | let _ = if x == 6 { 7 } else { 7 }; | ^^^^^ error: this `if` has identical blocks - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:143:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:140:23 | LL | } else if x == 68 { | _______________________^ @@ -65,7 +65,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:147:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:144:12 | LL | } else { | ____________^ @@ -76,7 +76,7 @@ LL | | }; | |_____^ error: this `if` has identical blocks - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:157:23 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:153:23 | LL | } else if x == 68 { | _______________________^ @@ -85,7 +85,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/branches_sharing_code/valid_if_blocks.rs:159:12 + --> tests/ui/branches_sharing_code/valid_if_blocks.rs:155:12 | LL | } else { | ____________^ diff --git a/tests/ui/builtin_type_shadow.rs b/tests/ui/builtin_type_shadow.rs index 31df0c21b67ea..eda22b7c38efe 100644 --- a/tests/ui/builtin_type_shadow.rs +++ b/tests/ui/builtin_type_shadow.rs @@ -2,7 +2,7 @@ #![allow(non_camel_case_types)] fn foo(a: u32) -> u32 { -//~^ builtin_type_shadow + //~^ builtin_type_shadow 42 //~ ERROR: mismatched type } diff --git a/tests/ui/bytecount.rs b/tests/ui/bytecount.rs index bad39fcf8f660..f03f99177d54e 100644 --- a/tests/ui/bytecount.rs +++ b/tests/ui/bytecount.rs @@ -10,12 +10,10 @@ fn main() { let _ = x.iter().filter(|&&a| a == 0).count(); //~^ naive_bytecount - // naive byte count let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); //~^ naive_bytecount - // not an equality count, OK. let _ = x.iter().filter(|a| **a > 0).count(); @@ -34,7 +32,6 @@ fn main() { let _ = x.iter().filter(|a| b + 1 == **a).count(); //~^ naive_bytecount - let y = vec![0_u16; 3]; // naive count, but not bytes diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index 9a0986f56478a..d1a73fe983584 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -11,13 +11,13 @@ LL | #[deny(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: you appear to be counting bytes the naive way - --> tests/ui/bytecount.rs:15:13 + --> tests/ui/bytecount.rs:14:13 | LL | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count((&x[..]), 0)` error: you appear to be counting bytes the naive way - --> tests/ui/bytecount.rs:34:13 + --> tests/ui/bytecount.rs:32:13 | LL | let _ = x.iter().filter(|a| b + 1 == **a).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the bytecount crate: `bytecount::count(x, b + 1)` diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index b2e92d36f4020..56e4326cdc1d9 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -25,7 +25,6 @@ fn main() { x0 as f32; //~^ cast_precision_loss - let x1 = 1i64; x1 as f32; //~^ cast_precision_loss @@ -52,8 +51,6 @@ fn main() { //~^ cast_possible_truncation //~| cast_sign_loss - - 1f64 as f32; //~^ cast_possible_truncation @@ -70,14 +67,11 @@ fn main() { //~^ cast_possible_truncation //~| cast_sign_loss - 1f32 as u32 as u16; //~^ cast_possible_truncation //~| cast_possible_truncation //~| cast_sign_loss - - { let _x: i8 = 1i32 as _; //~^ cast_possible_truncation @@ -91,14 +85,11 @@ fn main() { 1f32 as u8; //~^ cast_possible_truncation //~| cast_sign_loss - - } // Test clippy::cast_possible_wrap 1u8 as i8; //~^ cast_possible_wrap - 1u16 as i16; //~^ cast_possible_wrap @@ -120,14 +111,11 @@ fn main() { //~^ cast_possible_truncation //~| cast_possible_wrap - - // wraps on 32 bit ptr size 1usize as i32; //~^ cast_possible_truncation //~| cast_possible_wrap - // wraps on 64 bit ptr size 1usize as i64; //~^ cast_possible_wrap @@ -138,7 +126,6 @@ fn main() { 1u16 as isize; //~^ cast_possible_wrap - // wraps on 32 bit ptr size 1u32 as isize; //~^ cast_possible_wrap @@ -148,7 +135,6 @@ fn main() { //~^ cast_possible_truncation //~| cast_possible_wrap - // Test clippy::cast_sign_loss 1i32 as u32; -1i32 as u32; @@ -253,7 +239,6 @@ fn main() { (-99999999999i64).min(1) as i8; //~^ cast_possible_truncation - // Test for various operations that remove enough bits for the result to fit (999999u64 & 1) as u8; (999999u64 % 15) as u8; @@ -268,7 +253,6 @@ fn main() { 999999u64.clamp(0, 256) as u8; //~^ cast_possible_truncation - #[derive(Clone, Copy)] enum E1 { A, @@ -295,7 +279,6 @@ fn main() { let _ = Self::B as u8; //~^ cast_enum_truncation - // Don't lint. `255..=256` fits in i16 let _ = self as i16; // Don't lint. @@ -468,7 +451,6 @@ fn issue11642() { (-2_i32).pow(3) as u32; //~^ cast_sign_loss - (3_i32 % 2) as u32; (3_i32 % -2) as u32; (-5_i32 % 2) as u32; @@ -481,14 +463,12 @@ fn issue11642() { (-2_i32 >> 1) as u32; //~^ cast_sign_loss - let x: i32 = 10; (x * x) as u32; //~^ cast_sign_loss (x * x * x) as u32; //~^ cast_sign_loss - let y: i16 = -2; (y * y * y * y * -2) as u16; //~^ cast_sign_loss @@ -502,14 +482,12 @@ fn issue11642() { //~^ cast_sign_loss //~| eq_op - (y + y + y + -2) as u16; //~^ cast_sign_loss (y + y + y + 2) as u16; //~^ cast_sign_loss - let z: i16 = 2; (z + -2) as u16; //~^ cast_sign_loss @@ -547,7 +525,6 @@ fn issue11642() { (a.abs() * b.pow(2) / c.abs()) as u32 //~^ cast_sign_loss - } } @@ -590,5 +567,4 @@ fn issue12721() { (255 % 999999u64) as u8; //~^ cast_possible_truncation - } diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index daabb8192141c..484be7905d422 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -8,37 +8,37 @@ LL | x0 as f32; = help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]` error: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> tests/ui/cast.rs:30:5 + --> tests/ui/cast.rs:29:5 | LL | x1 as f32; | ^^^^^^^^^ error: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> tests/ui/cast.rs:33:5 + --> tests/ui/cast.rs:32:5 | LL | x1 as f64; | ^^^^^^^^^ error: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> tests/ui/cast.rs:37:5 + --> tests/ui/cast.rs:36:5 | LL | x2 as f32; | ^^^^^^^^^ error: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide) - --> tests/ui/cast.rs:41:5 + --> tests/ui/cast.rs:40:5 | LL | x3 as f32; | ^^^^^^^^^ error: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide) - --> tests/ui/cast.rs:44:5 + --> tests/ui/cast.rs:43:5 | LL | x3 as f64; | ^^^^^^^^^ error: casting `f32` to `i32` may truncate the value - --> tests/ui/cast.rs:48:5 + --> tests/ui/cast.rs:47:5 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | 1f32 as i32; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]` error: casting `f32` to `u32` may truncate the value - --> tests/ui/cast.rs:51:5 + --> tests/ui/cast.rs:50:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | 1f32 as u32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:51:5 + --> tests/ui/cast.rs:50:5 | LL | 1f32 as u32; | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | 1f32 as u32; = help: to override `-D warnings` add `#[allow(clippy::cast_sign_loss)]` error: casting `f64` to `f32` may truncate the value - --> tests/ui/cast.rs:57:5 + --> tests/ui/cast.rs:54:5 | LL | 1f64 as f32; | ^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | 1f64 as f32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `i32` to `i8` may truncate the value - --> tests/ui/cast.rs:60:5 + --> tests/ui/cast.rs:57:5 | LL | 1i32 as i8; | ^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | i8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u8` may truncate the value - --> tests/ui/cast.rs:63:5 + --> tests/ui/cast.rs:60:5 | LL | 1i32 as u8; | ^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | u8::try_from(1i32); | ~~~~~~~~~~~~~~~~~~ error: casting `f64` to `isize` may truncate the value - --> tests/ui/cast.rs:66:5 + --> tests/ui/cast.rs:63:5 | LL | 1f64 as isize; | ^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | 1f64 as isize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may truncate the value - --> tests/ui/cast.rs:69:5 + --> tests/ui/cast.rs:66:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ @@ -113,13 +113,13 @@ LL | 1f64 as usize; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `usize` may lose the sign of the value - --> tests/ui/cast.rs:69:5 + --> tests/ui/cast.rs:66:5 | LL | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting `u32` to `u16` may truncate the value - --> tests/ui/cast.rs:74:5 + --> tests/ui/cast.rs:70:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^^^^^^^^ @@ -131,7 +131,7 @@ LL | u16::try_from(1f32 as u32); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `f32` to `u32` may truncate the value - --> tests/ui/cast.rs:74:5 + --> tests/ui/cast.rs:70:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ @@ -139,13 +139,13 @@ LL | 1f32 as u32 as u16; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:74:5 + --> tests/ui/cast.rs:70:5 | LL | 1f32 as u32 as u16; | ^^^^^^^^^^^ error: casting `i32` to `i8` may truncate the value - --> tests/ui/cast.rs:82:22 + --> tests/ui/cast.rs:76:22 | LL | let _x: i8 = 1i32 as _; | ^^^^^^^^^ @@ -157,7 +157,7 @@ LL | let _x: i8 = 1i32.try_into(); | ~~~~~~~~~~~~~~~ error: casting `f32` to `i32` may truncate the value - --> tests/ui/cast.rs:85:9 + --> tests/ui/cast.rs:79:9 | LL | 1f32 as i32; | ^^^^^^^^^^^ @@ -165,7 +165,7 @@ LL | 1f32 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f64` to `i32` may truncate the value - --> tests/ui/cast.rs:88:9 + --> tests/ui/cast.rs:82:9 | LL | 1f64 as i32; | ^^^^^^^^^^^ @@ -173,7 +173,7 @@ LL | 1f64 as i32; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may truncate the value - --> tests/ui/cast.rs:91:9 + --> tests/ui/cast.rs:85:9 | LL | 1f32 as u8; | ^^^^^^^^^^ @@ -181,13 +181,13 @@ LL | 1f32 as u8; = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ... error: casting `f32` to `u8` may lose the sign of the value - --> tests/ui/cast.rs:91:9 + --> tests/ui/cast.rs:85:9 | LL | 1f32 as u8; | ^^^^^^^^^^ error: casting `u8` to `i8` may wrap around the value - --> tests/ui/cast.rs:98:5 + --> tests/ui/cast.rs:90:5 | LL | 1u8 as i8; | ^^^^^^^^^ @@ -196,31 +196,31 @@ LL | 1u8 as i8; = help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]` error: casting `u16` to `i16` may wrap around the value - --> tests/ui/cast.rs:102:5 + --> tests/ui/cast.rs:93:5 | LL | 1u16 as i16; | ^^^^^^^^^^^ error: casting `u32` to `i32` may wrap around the value - --> tests/ui/cast.rs:105:5 + --> tests/ui/cast.rs:96:5 | LL | 1u32 as i32; | ^^^^^^^^^^^ error: casting `u64` to `i64` may wrap around the value - --> tests/ui/cast.rs:108:5 + --> tests/ui/cast.rs:99:5 | LL | 1u64 as i64; | ^^^^^^^^^^^ error: casting `usize` to `isize` may wrap around the value - --> tests/ui/cast.rs:111:5 + --> tests/ui/cast.rs:102:5 | LL | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting `usize` to `i8` may truncate the value - --> tests/ui/cast.rs:115:5 + --> tests/ui/cast.rs:106:5 | LL | 1usize as i8; | ^^^^^^^^^^^^ @@ -232,7 +232,7 @@ LL | i8::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may truncate the value - --> tests/ui/cast.rs:119:5 + --> tests/ui/cast.rs:110:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -244,7 +244,7 @@ LL | i16::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i16` may wrap around the value on targets with 16-bit wide pointers - --> tests/ui/cast.rs:119:5 + --> tests/ui/cast.rs:110:5 | LL | 1usize as i16; | ^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | 1usize as i16; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers - --> tests/ui/cast.rs:126:5 + --> tests/ui/cast.rs:115:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ @@ -265,19 +265,19 @@ LL | i32::try_from(1usize); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:126:5 + --> tests/ui/cast.rs:115:5 | LL | 1usize as i32; | ^^^^^^^^^^^^^ error: casting `usize` to `i64` may wrap around the value on targets with 64-bit wide pointers - --> tests/ui/cast.rs:132:5 + --> tests/ui/cast.rs:120:5 | LL | 1usize as i64; | ^^^^^^^^^^^^^ error: casting `u16` to `isize` may wrap around the value on targets with 16-bit wide pointers - --> tests/ui/cast.rs:138:5 + --> tests/ui/cast.rs:126:5 | LL | 1u16 as isize; | ^^^^^^^^^^^^^ @@ -286,13 +286,13 @@ LL | 1u16 as isize; = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:143:5 + --> tests/ui/cast.rs:130:5 | LL | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:147:5 + --> tests/ui/cast.rs:134:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ @@ -304,55 +304,55 @@ LL | isize::try_from(1u64); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers - --> tests/ui/cast.rs:147:5 + --> tests/ui/cast.rs:134:5 | LL | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:154:5 + --> tests/ui/cast.rs:140:5 | LL | -1i32 as u32; | ^^^^^^^^^^^^ error: casting `isize` to `usize` may lose the sign of the value - --> tests/ui/cast.rs:158:5 + --> tests/ui/cast.rs:144:5 | LL | -1isize as usize; | ^^^^^^^^^^^^^^^^ error: casting `i8` to `u8` may lose the sign of the value - --> tests/ui/cast.rs:170:5 + --> tests/ui/cast.rs:156:5 | LL | (i8::MIN).abs() as u8; | ^^^^^^^^^^^^^^^^^^^^^ error: casting `i64` to `u64` may lose the sign of the value - --> tests/ui/cast.rs:175:5 + --> tests/ui/cast.rs:161:5 | LL | (-1i64).abs() as u64; | ^^^^^^^^^^^^^^^^^^^^ error: casting `isize` to `usize` may lose the sign of the value - --> tests/ui/cast.rs:177:5 + --> tests/ui/cast.rs:163:5 | LL | (-1isize).abs() as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i64` to `u64` may lose the sign of the value - --> tests/ui/cast.rs:185:5 + --> tests/ui/cast.rs:171:5 | LL | (unsafe { (-1i64).checked_abs().unwrap_unchecked() }) as u64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i64` to `u64` may lose the sign of the value - --> tests/ui/cast.rs:201:5 + --> tests/ui/cast.rs:187:5 | LL | (unsafe { (-1i64).checked_isqrt().unwrap_unchecked() }) as u64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i64` to `i8` may truncate the value - --> tests/ui/cast.rs:253:5 + --> tests/ui/cast.rs:239:5 | LL | (-99999999999i64).min(1) as i8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -364,7 +364,7 @@ LL | i8::try_from((-99999999999i64).min(1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `u8` may truncate the value - --> tests/ui/cast.rs:268:5 + --> tests/ui/cast.rs:253:5 | LL | 999999u64.clamp(0, 256) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -376,7 +376,7 @@ LL | u8::try_from(999999u64.clamp(0, 256)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E2` to `u8` may truncate the value - --> tests/ui/cast.rs:292:21 + --> tests/ui/cast.rs:276:21 | LL | let _ = self as u8; | ^^^^^^^^^^ @@ -388,7 +388,7 @@ LL | let _ = u8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E2::B` to `u8` will truncate the value - --> tests/ui/cast.rs:295:21 + --> tests/ui/cast.rs:279:21 | LL | let _ = Self::B as u8; | ^^^^^^^^^^^^^ @@ -397,7 +397,7 @@ LL | let _ = Self::B as u8; = help: to override `-D warnings` add `#[allow(clippy::cast_enum_truncation)]` error: casting `main::E5` to `i8` may truncate the value - --> tests/ui/cast.rs:338:21 + --> tests/ui/cast.rs:321:21 | LL | let _ = self as i8; | ^^^^^^^^^^ @@ -409,13 +409,13 @@ LL | let _ = i8::try_from(self); | ~~~~~~~~~~~~~~~~~~ error: casting `main::E5::A` to `i8` will truncate the value - --> tests/ui/cast.rs:341:21 + --> tests/ui/cast.rs:324:21 | LL | let _ = Self::A as i8; | ^^^^^^^^^^^^^ error: casting `main::E6` to `i16` may truncate the value - --> tests/ui/cast.rs:359:21 + --> tests/ui/cast.rs:342:21 | LL | let _ = self as i16; | ^^^^^^^^^^^ @@ -427,7 +427,7 @@ LL | let _ = i16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `main::E7` to `usize` may truncate the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:379:21 + --> tests/ui/cast.rs:362:21 | LL | let _ = self as usize; | ^^^^^^^^^^^^^ @@ -439,7 +439,7 @@ LL | let _ = usize::try_from(self); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `main::E10` to `u16` may truncate the value - --> tests/ui/cast.rs:427:21 + --> tests/ui/cast.rs:410:21 | LL | let _ = self as u16; | ^^^^^^^^^^^ @@ -451,7 +451,7 @@ LL | let _ = u16::try_from(self); | ~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> tests/ui/cast.rs:439:13 + --> tests/ui/cast.rs:422:13 | LL | let c = (q >> 16) as u8; | ^^^^^^^^^^^^^^^ @@ -463,7 +463,7 @@ LL | let c = u8::try_from(q >> 16); | ~~~~~~~~~~~~~~~~~~~~~ error: casting `u32` to `u8` may truncate the value - --> tests/ui/cast.rs:444:13 + --> tests/ui/cast.rs:427:13 | LL | let c = (q / 1000) as u8; | ^^^^^^^^^^^^^^^^ @@ -475,85 +475,85 @@ LL | let c = u8::try_from(q / 1000); | ~~~~~~~~~~~~~~~~~~~~~~ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:457:9 + --> tests/ui/cast.rs:440:9 | LL | (x * x) as u32; | ^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:463:32 + --> tests/ui/cast.rs:446:32 | LL | let _a = |x: i32| -> u32 { (x * x * x * x) as u32 }; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:466:5 + --> tests/ui/cast.rs:449:5 | LL | (2_i32).checked_pow(3).unwrap() as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:468:5 + --> tests/ui/cast.rs:451:5 | LL | (-2_i32).pow(3) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:474:5 + --> tests/ui/cast.rs:456:5 | LL | (-5_i32 % 2) as u32; | ^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:477:5 + --> tests/ui/cast.rs:459:5 | LL | (-5_i32 % -2) as u32; | ^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:481:5 + --> tests/ui/cast.rs:463:5 | LL | (-2_i32 >> 1) as u32; | ^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:486:5 + --> tests/ui/cast.rs:467:5 | LL | (x * x) as u32; | ^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:488:5 + --> tests/ui/cast.rs:469:5 | LL | (x * x * x) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:493:5 + --> tests/ui/cast.rs:473:5 | LL | (y * y * y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:496:5 + --> tests/ui/cast.rs:476:5 | LL | (y * y * y / y * 2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:498:5 + --> tests/ui/cast.rs:478:5 | LL | (y * y / y * 2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:501:5 + --> tests/ui/cast.rs:481:5 | LL | (y / y * y * -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `/` - --> tests/ui/cast.rs:501:6 + --> tests/ui/cast.rs:481:6 | LL | (y / y * y * -2) as u16; | ^^^^^ @@ -561,97 +561,97 @@ LL | (y / y * y * -2) as u16; = note: `#[deny(clippy::eq_op)]` on by default error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:506:5 + --> tests/ui/cast.rs:485:5 | LL | (y + y + y + -2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:509:5 + --> tests/ui/cast.rs:488:5 | LL | (y + y + y + 2) as u16; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:514:5 + --> tests/ui/cast.rs:492:5 | LL | (z + -2) as u16; | ^^^^^^^^^^^^^^^ error: casting `i16` to `u16` may lose the sign of the value - --> tests/ui/cast.rs:517:5 + --> tests/ui/cast.rs:495:5 | LL | (z + z + 2) as u16; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:521:9 + --> tests/ui/cast.rs:499:9 | LL | (a * a * b * b * c * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:523:9 + --> tests/ui/cast.rs:501:9 | LL | (a * b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:526:9 + --> tests/ui/cast.rs:504:9 | LL | (a * -b * c) as u32; | ^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:529:9 + --> tests/ui/cast.rs:507:9 | LL | (a * b * c * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:531:9 + --> tests/ui/cast.rs:509:9 | LL | (a * -2) as u32; | ^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:534:9 + --> tests/ui/cast.rs:512:9 | LL | (a * b * c * -2) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:537:9 + --> tests/ui/cast.rs:515:9 | LL | (a / b) as u32; | ^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:539:9 + --> tests/ui/cast.rs:517:9 | LL | (a / b * c) as u32; | ^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:542:9 + --> tests/ui/cast.rs:520:9 | LL | (a / b + b * c) as u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:545:9 + --> tests/ui/cast.rs:523:9 | LL | a.saturating_pow(3) as u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:548:9 + --> tests/ui/cast.rs:526:9 | LL | (a.abs() * b.pow(2) / c.abs()) as u32 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `i32` to `u32` may lose the sign of the value - --> tests/ui/cast.rs:557:21 + --> tests/ui/cast.rs:534:21 | LL | let _ = i32::MIN as u32; // cast_sign_loss | ^^^^^^^^^^^^^^^ @@ -662,7 +662,7 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error: casting `u32` to `u8` may truncate the value - --> tests/ui/cast.rs:559:21 + --> tests/ui/cast.rs:536:21 | LL | let _ = u32::MAX as u8; // cast_possible_truncation | ^^^^^^^^^^^^^^ @@ -678,7 +678,7 @@ LL | let _ = u8::try_from(u32::MAX); // cast_possible_truncation | ~~~~~~~~~~~~~~~~~~~~~~ error: casting `f64` to `f32` may truncate the value - --> tests/ui/cast.rs:561:21 + --> tests/ui/cast.rs:538:21 | LL | let _ = std::f64::consts::PI as f32; // cast_possible_truncation | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -690,7 +690,7 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers - --> tests/ui/cast.rs:571:5 + --> tests/ui/cast.rs:548:5 | LL | bar.unwrap().unwrap() as usize | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -702,13 +702,13 @@ LL | usize::try_from(bar.unwrap().unwrap()) | error: casting `i64` to `usize` may lose the sign of the value - --> tests/ui/cast.rs:571:5 + --> tests/ui/cast.rs:548:5 | LL | bar.unwrap().unwrap() as usize | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting `u64` to `u8` may truncate the value - --> tests/ui/cast.rs:588:5 + --> tests/ui/cast.rs:565:5 | LL | (256 & 999999u64) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -720,7 +720,7 @@ LL | u8::try_from(256 & 999999u64); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting `u64` to `u8` may truncate the value - --> tests/ui/cast.rs:591:5 + --> tests/ui/cast.rs:568:5 | LL | (255 % 999999u64) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_alignment.rs b/tests/ui/cast_alignment.rs index 1f14cb8a84526..5773ffddb9176 100644 --- a/tests/ui/cast_alignment.rs +++ b/tests/ui/cast_alignment.rs @@ -19,11 +19,9 @@ fn main() { (&1u8 as *const u8) as *const u16; //~^ cast_ptr_alignment - (&mut 1u8 as *mut u8) as *mut u16; //~^ cast_ptr_alignment - // cast to more-strictly-aligned type, but with the `pointer::cast` function. (&1u8 as *const u8).cast::(); //~^ cast_ptr_alignment @@ -31,7 +29,6 @@ fn main() { (&mut 1u8 as *mut u8).cast::(); //~^ cast_ptr_alignment - /* These should be ok */ // not a pointer type diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index a1598eb1b6b41..6d9a81f0ecfd4 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -8,19 +8,19 @@ LL | (&1u8 as *const u8) as *const u16; = help: to override `-D warnings` add `#[allow(clippy::cast_ptr_alignment)]` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) - --> tests/ui/cast_alignment.rs:23:5 + --> tests/ui/cast_alignment.rs:22:5 | LL | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes) - --> tests/ui/cast_alignment.rs:28:5 + --> tests/ui/cast_alignment.rs:26:5 | LL | (&1u8 as *const u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes) - --> tests/ui/cast_alignment.rs:31:5 + --> tests/ui/cast_alignment.rs:29:5 | LL | (&mut 1u8 as *mut u8).cast::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_enum_constructor.rs b/tests/ui/cast_enum_constructor.rs index 9de5b40955560..eecf56f71a334 100644 --- a/tests/ui/cast_enum_constructor.rs +++ b/tests/ui/cast_enum_constructor.rs @@ -13,7 +13,6 @@ fn main() { let _ = Foo::Y as usize; //~^ cast_enum_constructor - let _ = Foo::Y as isize; //~^ cast_enum_constructor diff --git a/tests/ui/cast_enum_constructor.stderr b/tests/ui/cast_enum_constructor.stderr index 890d88cacdf29..67cca68073152 100644 --- a/tests/ui/cast_enum_constructor.stderr +++ b/tests/ui/cast_enum_constructor.stderr @@ -8,7 +8,7 @@ LL | let _ = Foo::Y as usize; = help: to override `-D warnings` add `#[allow(clippy::cast_enum_constructor)]` error: cast of an enum tuple constructor to an integer - --> tests/ui/cast_enum_constructor.rs:17:13 + --> tests/ui/cast_enum_constructor.rs:16:13 | LL | let _ = Foo::Y as isize; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_lossless_integer.fixed b/tests/ui/cast_lossless_integer.fixed index cd689801702aa..2af2dbd1282df 100644 --- a/tests/ui/cast_lossless_integer.fixed +++ b/tests/ui/cast_lossless_integer.fixed @@ -29,7 +29,6 @@ fn main() { i128::from(0u8); //~^ cast_lossless - u32::from(0u16); //~^ cast_lossless @@ -48,7 +47,6 @@ fn main() { i128::from(0u16); //~^ cast_lossless - u64::from(0u32); //~^ cast_lossless @@ -61,14 +59,12 @@ fn main() { i128::from(0u32); //~^ cast_lossless - u128::from(0u64); //~^ cast_lossless i128::from(0u64); //~^ cast_lossless - i16::from(0i8); //~^ cast_lossless @@ -81,7 +77,6 @@ fn main() { i128::from(0i8); //~^ cast_lossless - i32::from(0i16); //~^ cast_lossless @@ -91,27 +86,22 @@ fn main() { i128::from(0i16); //~^ cast_lossless - i64::from(0i32); //~^ cast_lossless i128::from(0i32); //~^ cast_lossless - i128::from(0i64); //~^ cast_lossless - // Test with an expression wrapped in parens let _ = u16::from(1u8 + 1u8); //~^ cast_lossless - let _ = I64Alias::from(1i8); //~^ cast_lossless - let _: u16 = 0u8.into(); //~^ cast_lossless @@ -123,7 +113,6 @@ fn main() { let _: u32 = (1i8 as u16).into(); //~^ cast_lossless - } // The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const, @@ -162,7 +151,6 @@ fn issue11458() { let _ = i32::from(sign_cast!(x, u8, i8) + 1); //~^ cast_lossless - } fn issue12695() { @@ -170,7 +158,6 @@ fn issue12695() { () => { u32::from(1u8) //~^ cast_lossless - }; } diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs index 03c1a77c34ad1..c65b725bb7298 100644 --- a/tests/ui/cast_lossless_integer.rs +++ b/tests/ui/cast_lossless_integer.rs @@ -29,7 +29,6 @@ fn main() { 0u8 as i128; //~^ cast_lossless - 0u16 as u32; //~^ cast_lossless @@ -48,7 +47,6 @@ fn main() { 0u16 as i128; //~^ cast_lossless - 0u32 as u64; //~^ cast_lossless @@ -61,14 +59,12 @@ fn main() { 0u32 as i128; //~^ cast_lossless - 0u64 as u128; //~^ cast_lossless 0u64 as i128; //~^ cast_lossless - 0i8 as i16; //~^ cast_lossless @@ -81,7 +77,6 @@ fn main() { 0i8 as i128; //~^ cast_lossless - 0i16 as i32; //~^ cast_lossless @@ -91,27 +86,22 @@ fn main() { 0i16 as i128; //~^ cast_lossless - 0i32 as i64; //~^ cast_lossless 0i32 as i128; //~^ cast_lossless - 0i64 as i128; //~^ cast_lossless - // Test with an expression wrapped in parens let _ = (1u8 + 1u8) as u16; //~^ cast_lossless - let _ = 1i8 as I64Alias; //~^ cast_lossless - let _: u16 = 0u8 as _; //~^ cast_lossless @@ -123,7 +113,6 @@ fn main() { let _: u32 = 1i8 as u16 as _; //~^ cast_lossless - } // The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const, @@ -162,7 +151,6 @@ fn issue11458() { let _ = (sign_cast!(x, u8, i8) + 1) as i32; //~^ cast_lossless - } fn issue12695() { @@ -170,7 +158,6 @@ fn issue12695() { () => { 1u8 as u32 //~^ cast_lossless - }; } diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index 3bec773ff8613..393c20f682942 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -97,7 +97,7 @@ LL | i128::from(0u8); | ~~~~~~~~~~~~~~~ error: casts from `u16` to `u32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:33:5 + --> tests/ui/cast_lossless_integer.rs:32:5 | LL | 0u16 as u32; | ^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | u32::from(0u16); | ~~~~~~~~~~~~~~~ error: casts from `u16` to `i32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:36:5 + --> tests/ui/cast_lossless_integer.rs:35:5 | LL | 0u16 as i32; | ^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | i32::from(0u16); | ~~~~~~~~~~~~~~~ error: casts from `u16` to `u64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:39:5 + --> tests/ui/cast_lossless_integer.rs:38:5 | LL | 0u16 as u64; | ^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | u64::from(0u16); | ~~~~~~~~~~~~~~~ error: casts from `u16` to `i64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:42:5 + --> tests/ui/cast_lossless_integer.rs:41:5 | LL | 0u16 as i64; | ^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | i64::from(0u16); | ~~~~~~~~~~~~~~~ error: casts from `u16` to `u128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:45:5 + --> tests/ui/cast_lossless_integer.rs:44:5 | LL | 0u16 as u128; | ^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | u128::from(0u16); | ~~~~~~~~~~~~~~~~ error: casts from `u16` to `i128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:48:5 + --> tests/ui/cast_lossless_integer.rs:47:5 | LL | 0u16 as i128; | ^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL | i128::from(0u16); | ~~~~~~~~~~~~~~~~ error: casts from `u32` to `u64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:52:5 + --> tests/ui/cast_lossless_integer.rs:50:5 | LL | 0u32 as u64; | ^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL | u64::from(0u32); | ~~~~~~~~~~~~~~~ error: casts from `u32` to `i64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:55:5 + --> tests/ui/cast_lossless_integer.rs:53:5 | LL | 0u32 as i64; | ^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | i64::from(0u32); | ~~~~~~~~~~~~~~~ error: casts from `u32` to `u128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:58:5 + --> tests/ui/cast_lossless_integer.rs:56:5 | LL | 0u32 as u128; | ^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL | u128::from(0u32); | ~~~~~~~~~~~~~~~~ error: casts from `u32` to `i128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:61:5 + --> tests/ui/cast_lossless_integer.rs:59:5 | LL | 0u32 as i128; | ^^^^^^^^^^^^ @@ -217,7 +217,7 @@ LL | i128::from(0u32); | ~~~~~~~~~~~~~~~~ error: casts from `u64` to `u128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:65:5 + --> tests/ui/cast_lossless_integer.rs:62:5 | LL | 0u64 as u128; | ^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL | u128::from(0u64); | ~~~~~~~~~~~~~~~~ error: casts from `u64` to `i128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:68:5 + --> tests/ui/cast_lossless_integer.rs:65:5 | LL | 0u64 as i128; | ^^^^^^^^^^^^ @@ -241,7 +241,7 @@ LL | i128::from(0u64); | ~~~~~~~~~~~~~~~~ error: casts from `i8` to `i16` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:72:5 + --> tests/ui/cast_lossless_integer.rs:68:5 | LL | 0i8 as i16; | ^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | i16::from(0i8); | ~~~~~~~~~~~~~~ error: casts from `i8` to `i32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:75:5 + --> tests/ui/cast_lossless_integer.rs:71:5 | LL | 0i8 as i32; | ^^^^^^^^^^ @@ -265,7 +265,7 @@ LL | i32::from(0i8); | ~~~~~~~~~~~~~~ error: casts from `i8` to `i64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:78:5 + --> tests/ui/cast_lossless_integer.rs:74:5 | LL | 0i8 as i64; | ^^^^^^^^^^ @@ -277,7 +277,7 @@ LL | i64::from(0i8); | ~~~~~~~~~~~~~~ error: casts from `i8` to `i128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:81:5 + --> tests/ui/cast_lossless_integer.rs:77:5 | LL | 0i8 as i128; | ^^^^^^^^^^^ @@ -289,7 +289,7 @@ LL | i128::from(0i8); | ~~~~~~~~~~~~~~~ error: casts from `i16` to `i32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:85:5 + --> tests/ui/cast_lossless_integer.rs:80:5 | LL | 0i16 as i32; | ^^^^^^^^^^^ @@ -301,7 +301,7 @@ LL | i32::from(0i16); | ~~~~~~~~~~~~~~~ error: casts from `i16` to `i64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:88:5 + --> tests/ui/cast_lossless_integer.rs:83:5 | LL | 0i16 as i64; | ^^^^^^^^^^^ @@ -313,7 +313,7 @@ LL | i64::from(0i16); | ~~~~~~~~~~~~~~~ error: casts from `i16` to `i128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:91:5 + --> tests/ui/cast_lossless_integer.rs:86:5 | LL | 0i16 as i128; | ^^^^^^^^^^^^ @@ -325,7 +325,7 @@ LL | i128::from(0i16); | ~~~~~~~~~~~~~~~~ error: casts from `i32` to `i64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:95:5 + --> tests/ui/cast_lossless_integer.rs:89:5 | LL | 0i32 as i64; | ^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL | i64::from(0i32); | ~~~~~~~~~~~~~~~ error: casts from `i32` to `i128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:98:5 + --> tests/ui/cast_lossless_integer.rs:92:5 | LL | 0i32 as i128; | ^^^^^^^^^^^^ @@ -349,7 +349,7 @@ LL | i128::from(0i32); | ~~~~~~~~~~~~~~~~ error: casts from `i64` to `i128` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:102:5 + --> tests/ui/cast_lossless_integer.rs:95:5 | LL | 0i64 as i128; | ^^^^^^^^^^^^ @@ -361,7 +361,7 @@ LL | i128::from(0i64); | ~~~~~~~~~~~~~~~~ error: casts from `u8` to `u16` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:107:13 + --> tests/ui/cast_lossless_integer.rs:99:13 | LL | let _ = (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ @@ -373,7 +373,7 @@ LL | let _ = u16::from(1u8 + 1u8); | ~~~~~~~~~~~~~~~~~~~~ error: casts from `i8` to `i64` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:111:13 + --> tests/ui/cast_lossless_integer.rs:102:13 | LL | let _ = 1i8 as I64Alias; | ^^^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL | let _ = I64Alias::from(1i8); | ~~~~~~~~~~~~~~~~~~~ error: casts from `u8` to `u16` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:115:18 + --> tests/ui/cast_lossless_integer.rs:105:18 | LL | let _: u16 = 0u8 as _; | ^^^^^^^^ @@ -397,7 +397,7 @@ LL | let _: u16 = 0u8.into(); | ~~~~~~~~~~ error: casts from `i8` to `i16` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:118:18 + --> tests/ui/cast_lossless_integer.rs:108:18 | LL | let _: i16 = -1i8 as _; | ^^^^^^^^^ @@ -409,7 +409,7 @@ LL | let _: i16 = (-1i8).into(); | ~~~~~~~~~~~~~ error: casts from `u8` to `u16` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:121:18 + --> tests/ui/cast_lossless_integer.rs:111:18 | LL | let _: u16 = (1u8 + 2) as _; | ^^^^^^^^^^^^^^ @@ -421,7 +421,7 @@ LL | let _: u16 = (1u8 + 2).into(); | ~~~~~~~~~~~~~~~~ error: casts from `u16` to `u32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:124:18 + --> tests/ui/cast_lossless_integer.rs:114:18 | LL | let _: u32 = 1i8 as u16 as _; | ^^^^^^^^^^^^^^^ @@ -433,7 +433,7 @@ LL | let _: u32 = (1i8 as u16).into(); | ~~~~~~~~~~~~~~~~~~~ error: casts from `i8` to `i32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:160:13 + --> tests/ui/cast_lossless_integer.rs:149:13 | LL | let _ = sign_cast!(x, u8, i8) as i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -445,7 +445,7 @@ LL | let _ = i32::from(sign_cast!(x, u8, i8)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casts from `i8` to `i32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:163:13 + --> tests/ui/cast_lossless_integer.rs:152:13 | LL | let _ = (sign_cast!(x, u8, i8) + 1) as i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -457,7 +457,7 @@ LL | let _ = i32::from(sign_cast!(x, u8, i8) + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casts from `u8` to `u32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:171:13 + --> tests/ui/cast_lossless_integer.rs:159:13 | LL | 1u8 as u32 | ^^^^^^^^^^ @@ -473,7 +473,7 @@ LL | u32::from(1u8) | error: casts from `u8` to `u32` can be expressed infallibly using `From` - --> tests/ui/cast_lossless_integer.rs:187:13 + --> tests/ui/cast_lossless_integer.rs:174:13 | LL | let _ = 0u8 as ty!(); | ^^^^^^^^^^^^ diff --git a/tests/ui/cast_nan_to_int.rs b/tests/ui/cast_nan_to_int.rs index 227dae3b1c4b3..72e61b3542e20 100644 --- a/tests/ui/cast_nan_to_int.rs +++ b/tests/ui/cast_nan_to_int.rs @@ -7,29 +7,21 @@ fn main() { let _ = (0.0_f32 / -0.0) as usize; //~^ cast_nan_to_int - let _ = (f64::INFINITY * -0.0) as usize; //~^ cast_nan_to_int - let _ = (0.0 * f32::INFINITY) as usize; //~^ cast_nan_to_int - - let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; //~^ cast_nan_to_int - let _ = (f32::INFINITY - f32::INFINITY) as usize; //~^ cast_nan_to_int - let _ = (f32::INFINITY / f32::NEG_INFINITY) as usize; //~^ cast_nan_to_int - - // those won't be linted: let _ = (1.0_f32 / 0.0) as usize; let _ = (f32::INFINITY * f32::NEG_INFINITY) as usize; diff --git a/tests/ui/cast_nan_to_int.stderr b/tests/ui/cast_nan_to_int.stderr index 0f9b3565485f4..15ca3876ea18f 100644 --- a/tests/ui/cast_nan_to_int.stderr +++ b/tests/ui/cast_nan_to_int.stderr @@ -9,7 +9,7 @@ LL | let _ = (0.0_f32 / -0.0) as usize; = help: to override `-D warnings` add `#[allow(clippy::cast_nan_to_int)]` error: casting a known NaN to usize - --> tests/ui/cast_nan_to_int.rs:11:13 + --> tests/ui/cast_nan_to_int.rs:10:13 | LL | let _ = (f64::INFINITY * -0.0) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = (f64::INFINITY * -0.0) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> tests/ui/cast_nan_to_int.rs:15:13 + --> tests/ui/cast_nan_to_int.rs:13:13 | LL | let _ = (0.0 * f32::INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = (0.0 * f32::INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> tests/ui/cast_nan_to_int.rs:20:13 + --> tests/ui/cast_nan_to_int.rs:16:13 | LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = (f64::INFINITY + f64::NEG_INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> tests/ui/cast_nan_to_int.rs:24:13 + --> tests/ui/cast_nan_to_int.rs:19:13 | LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = (f32::INFINITY - f32::INFINITY) as usize; = note: this always evaluates to 0 error: casting a known NaN to usize - --> tests/ui/cast_nan_to_int.rs:28:13 + --> tests/ui/cast_nan_to_int.rs:22:13 | LL | let _ = (f32::INFINITY / f32::NEG_INFINITY) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cast_slice_different_sizes.rs b/tests/ui/cast_slice_different_sizes.rs index 2db14d4f2515b..518ed77ab2200 100644 --- a/tests/ui/cast_slice_different_sizes.rs +++ b/tests/ui/cast_slice_different_sizes.rs @@ -10,16 +10,13 @@ fn main() { let b = a as *const [u8]; //~^ cast_slice_different_sizes - let c = b as *const [u32]; //~^ cast_slice_different_sizes - // loses data let loss = r_x as *const [i32] as *const [u8]; //~^ cast_slice_different_sizes - // Cast back to same size but different type loses no data, just type conversion // This is weird code but there's no reason for this lint specifically to fire *twice* on it let restore = r_x as *const [i32] as *const [u8] as *const [u32]; @@ -29,7 +26,7 @@ fn main() { //~^ cast_slice_different_sizes let loss_block_2 = { - //~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes let _ = (); r_x as *const [i32] @@ -65,48 +62,47 @@ fn foo2(x: *mut [u8]) -> *mut [u8] { // Test that casts as part of function returns work fn bar(x: *mut [u16]) -> *mut [u8] { -//~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes x as *mut [u8] } fn uwu(x: *mut [u16]) -> *mut [u8] { -//~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes x as *mut _ } fn bar2(x: *mut [u16]) -> *mut [u8] { -//~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes x as _ } // constify fn bar3(x: *mut [u16]) -> *const [u8] { -//~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes x as _ } // unconstify fn bar4(x: *const [u16]) -> *mut [u8] { -//~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes x as _ } // function returns plus blocks fn blocks(x: *mut [u16]) -> *mut [u8] { -//~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes ({ x }) as _ } fn more_blocks(x: *mut [u16]) -> *mut [u8] { -//~^ cast_slice_different_sizes + //~^ cast_slice_different_sizes { ({ x }) as _ } //~^ cast_slice_different_sizes - } diff --git a/tests/ui/cast_slice_different_sizes.stderr b/tests/ui/cast_slice_different_sizes.stderr index e028e13db6169..307d37ac2ea8a 100644 --- a/tests/ui/cast_slice_different_sizes.stderr +++ b/tests/ui/cast_slice_different_sizes.stderr @@ -7,25 +7,25 @@ LL | let b = a as *const [u8]; = note: `#[deny(clippy::cast_slice_different_sizes)]` on by default error: casting between raw pointers to `[u8]` (element size 1) and `[u32]` (element size 4) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:14:13 + --> tests/ui/cast_slice_different_sizes.rs:13:13 | LL | let c = b as *const [u32]; | ^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(b as *const u32, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:19:16 + --> tests/ui/cast_slice_different_sizes.rs:17:16 | LL | let loss = r_x as *const [i32] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:28:24 + --> tests/ui/cast_slice_different_sizes.rs:25:24 | LL | let loss_block_1 = { r_x as *const [i32] } as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts({ r_x as *const [i32] } as *const u8, ..)` error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:31:24 + --> tests/ui/cast_slice_different_sizes.rs:28:24 | LL | let loss_block_2 = { | ________________________^ @@ -47,13 +47,13 @@ LL ~ } as *const u8, ..); | error: casting between raw pointers to `[i32]` (element size 4) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:50:27 + --> tests/ui/cast_slice_different_sizes.rs:47:27 | LL | let long_chain_loss = r_x as *const [i32] as *const [u32] as *const [u16] as *const [i8] as *const [u8]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(r_x as *const [i32] as *const u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:67:36 + --> tests/ui/cast_slice_different_sizes.rs:64:36 | LL | fn bar(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -64,7 +64,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:73:36 + --> tests/ui/cast_slice_different_sizes.rs:70:36 | LL | fn uwu(x: *mut [u16]) -> *mut [u8] { | ____________________________________^ @@ -75,7 +75,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:79:37 + --> tests/ui/cast_slice_different_sizes.rs:76:37 | LL | fn bar2(x: *mut [u16]) -> *mut [u8] { | _____________________________________^ @@ -86,7 +86,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:86:39 + --> tests/ui/cast_slice_different_sizes.rs:83:39 | LL | fn bar3(x: *mut [u16]) -> *const [u8] { | _______________________________________^ @@ -97,7 +97,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts`: `core::ptr::slice_from_raw_parts(x as *const u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:93:39 + --> tests/ui/cast_slice_different_sizes.rs:90:39 | LL | fn bar4(x: *const [u16]) -> *mut [u8] { | _______________________________________^ @@ -108,7 +108,7 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(x as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:100:39 + --> tests/ui/cast_slice_different_sizes.rs:97:39 | LL | fn blocks(x: *mut [u16]) -> *mut [u8] { | _______________________________________^ @@ -119,19 +119,19 @@ LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:106:44 + --> tests/ui/cast_slice_different_sizes.rs:103:44 | LL | fn more_blocks(x: *mut [u16]) -> *mut [u8] { | ____________________________________________^ LL | | LL | | LL | | { ({ x }) as _ } -... | +LL | | LL | | } | |_^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` error: casting between raw pointers to `[u16]` (element size 2) and `[u8]` (element size 1) does not adjust the count - --> tests/ui/cast_slice_different_sizes.rs:109:5 + --> tests/ui/cast_slice_different_sizes.rs:106:5 | LL | { ({ x }) as _ } | ^^^^^^^^^^^^^^^^ help: replace with `ptr::slice_from_raw_parts_mut`: `core::ptr::slice_from_raw_parts_mut(({ x }) as *mut u8, ..)` diff --git a/tests/ui/char_lit_as_u8.rs b/tests/ui/char_lit_as_u8.rs index 41e3c5e545cb7..c8774c7f30916 100644 --- a/tests/ui/char_lit_as_u8.rs +++ b/tests/ui/char_lit_as_u8.rs @@ -4,6 +4,4 @@ fn main() { // no suggestion, since a byte literal won't work. let _ = '❤' as u8; //~^ char_lit_as_u8 - - } diff --git a/tests/ui/checked_unwrap/complex_conditionals.rs b/tests/ui/checked_unwrap/complex_conditionals.rs index 3eedb659ebf65..7d0bcc547a42b 100644 --- a/tests/ui/checked_unwrap/complex_conditionals.rs +++ b/tests/ui/checked_unwrap/complex_conditionals.rs @@ -24,7 +24,6 @@ fn test_complex_conditions() { // unnecessary y.unwrap_err(); //~^ unnecessary_unwrap - } else { // not statically determinable whether any of the following will always succeed or always fail: x.unwrap(); @@ -53,7 +52,6 @@ fn test_complex_conditions() { // unnecessary y.unwrap_err(); //~^ unnecessary_unwrap - } let z: Result<(), ()> = Ok(()); if x.is_ok() && !(y.is_ok() || z.is_err()) { @@ -80,7 +78,6 @@ fn test_complex_conditions() { // will panic z.unwrap_err(); //~^ panicking_unwrap - } if x.is_ok() || !(y.is_ok() && z.is_err()) { // not statically determinable whether any of the following will always succeed or always fail: @@ -111,7 +108,6 @@ fn test_complex_conditions() { // unnecessary z.unwrap_err(); //~^ unnecessary_unwrap - } } diff --git a/tests/ui/checked_unwrap/complex_conditionals.stderr b/tests/ui/checked_unwrap/complex_conditionals.stderr index 02118affe731d..d3905850c9702 100644 --- a/tests/ui/checked_unwrap/complex_conditionals.stderr +++ b/tests/ui/checked_unwrap/complex_conditionals.stderr @@ -50,7 +50,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:42:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:41:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -59,7 +59,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/complex_conditionals.rs:46:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:45:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -70,7 +70,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:50:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:49:9 | LL | if x.is_ok() || y.is_ok() { | --------- because of this check @@ -79,7 +79,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/complex_conditionals.rs:54:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:53:9 | LL | if x.is_ok() || y.is_ok() { | --------- the check is happening here @@ -90,7 +90,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `x` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/complex_conditionals.rs:61:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:59:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -101,7 +101,7 @@ LL | x.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:65:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:63:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -110,7 +110,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:69:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:67:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check @@ -119,7 +119,7 @@ LL | y.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `y` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/complex_conditionals.rs:73:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:71:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here @@ -130,7 +130,7 @@ LL | y.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `z` after checking its variant with `is_err` - --> tests/ui/checked_unwrap/complex_conditionals.rs:77:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:75:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here @@ -141,7 +141,7 @@ LL | z.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:81:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:79:9 | LL | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check @@ -150,7 +150,7 @@ LL | z.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:92:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:89:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -159,7 +159,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/complex_conditionals.rs:96:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:93:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -170,7 +170,7 @@ LL | x.unwrap_err(); = help: try using `if let` or `match` error: called `unwrap` on `y` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/complex_conditionals.rs:100:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:97:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here @@ -181,7 +181,7 @@ LL | y.unwrap(); = help: try using `if let` or `match` error: this call to `unwrap_err()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:104:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:101:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check @@ -190,7 +190,7 @@ LL | y.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/complex_conditionals.rs:108:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:105:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check @@ -199,7 +199,7 @@ LL | z.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `z` after checking its variant with `is_err` - --> tests/ui/checked_unwrap/complex_conditionals.rs:112:9 + --> tests/ui/checked_unwrap/complex_conditionals.rs:109:9 | LL | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- the check is happening here diff --git a/tests/ui/checked_unwrap/simple_conditionals.rs b/tests/ui/checked_unwrap/simple_conditionals.rs index 7736643d894c5..4101897d38004 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.rs +++ b/tests/ui/checked_unwrap/simple_conditionals.rs @@ -50,7 +50,6 @@ fn main() { // unnecessary x.expect("an error message"); //~^ unnecessary_unwrap - } else { // will panic x.unwrap(); @@ -59,18 +58,15 @@ fn main() { // will panic x.expect("an error message"); //~^ panicking_unwrap - } if x.is_none() { // will panic x.unwrap(); //~^ panicking_unwrap - } else { // unnecessary x.unwrap(); //~^ unnecessary_unwrap - } m!(x); // ok @@ -92,7 +88,6 @@ fn main() { // will panic x.unwrap_err(); //~^ panicking_unwrap - } else { // will panic x.unwrap(); @@ -105,7 +100,6 @@ fn main() { // unnecessary x.unwrap_err(); //~^ unnecessary_unwrap - } if x.is_err() { // will panic @@ -115,7 +109,6 @@ fn main() { // unnecessary x.unwrap_err(); //~^ unnecessary_unwrap - } else { // unnecessary x.unwrap(); @@ -124,7 +117,6 @@ fn main() { // will panic x.unwrap_err(); //~^ panicking_unwrap - } if x.is_ok() { x = Err(()); @@ -150,11 +142,9 @@ fn issue11371() { if option.is_some() { option.as_ref().unwrap(); //~^ unnecessary_unwrap - } else { option.as_ref().unwrap(); //~^ panicking_unwrap - } let result = Ok::<(), ()>(()); @@ -162,33 +152,27 @@ fn issue11371() { if result.is_ok() { result.as_ref().unwrap(); //~^ unnecessary_unwrap - } else { result.as_ref().unwrap(); //~^ panicking_unwrap - } let mut option = Some(()); if option.is_some() { option.as_mut().unwrap(); //~^ unnecessary_unwrap - } else { option.as_mut().unwrap(); //~^ panicking_unwrap - } let mut result = Ok::<(), ()>(()); if result.is_ok() { result.as_mut().unwrap(); //~^ unnecessary_unwrap - } else { result.as_mut().unwrap(); //~^ panicking_unwrap - } // This should not lint. Statics are, at the time of writing, not linted on anyway, @@ -197,7 +181,7 @@ fn issue11371() { static mut X: Option = Some(123); unsafe { if X.is_some() { - //~^ ERROR: creating a shared reference + //~^ ERROR: creating a shared reference X = None; X.unwrap(); } diff --git a/tests/ui/checked_unwrap/simple_conditionals.stderr b/tests/ui/checked_unwrap/simple_conditionals.stderr index 789a4a8f92bc0..c17eaef2326b3 100644 --- a/tests/ui/checked_unwrap/simple_conditionals.stderr +++ b/tests/ui/checked_unwrap/simple_conditionals.stderr @@ -23,7 +23,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:56:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:55:9 | LL | if x.is_some() { | ----------- because of this check @@ -38,7 +38,7 @@ LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `expect()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:60:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:59:9 | LL | if x.is_some() { | ----------- because of this check @@ -47,7 +47,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:66:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:64:9 | LL | if x.is_none() { | ----------- because of this check @@ -56,7 +56,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_none` - --> tests/ui/checked_unwrap/simple_conditionals.rs:71:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:68:9 | LL | if x.is_none() { | -------------- help: try: `if let Some() = x` @@ -79,7 +79,7 @@ LL | m!(x); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error: called `unwrap` on `x` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:81:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok() = x` @@ -88,7 +88,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `expect` on `x` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:85:9 | LL | if x.is_ok() { | ------------ help: try: `if let Ok() = x` @@ -97,7 +97,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:93:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:89:9 | LL | if x.is_ok() { | --------- because of this check @@ -106,7 +106,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:98:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:93:9 | LL | if x.is_ok() { | --------- because of this check @@ -115,7 +115,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `expect()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:102:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:97:9 | LL | if x.is_ok() { | --------- because of this check @@ -124,7 +124,7 @@ LL | x.expect("an error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/simple_conditionals.rs:106:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:101:9 | LL | if x.is_ok() { | ------------ help: try: `if let Err() = x` @@ -133,7 +133,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:112:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:106:9 | LL | if x.is_err() { | ---------- because of this check @@ -142,7 +142,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: called `unwrap_err` on `x` after checking its variant with `is_err` - --> tests/ui/checked_unwrap/simple_conditionals.rs:116:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:110:9 | LL | if x.is_err() { | ------------- help: try: `if let Err() = x` @@ -151,7 +151,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `x` after checking its variant with `is_err` - --> tests/ui/checked_unwrap/simple_conditionals.rs:121:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:114:9 | LL | if x.is_err() { | ------------- help: try: `if let Ok() = x` @@ -160,7 +160,7 @@ LL | x.unwrap(); | ^^^^^^^^^^ error: this call to `unwrap_err()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:125:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:118:9 | LL | if x.is_err() { | ---------- because of this check @@ -169,7 +169,7 @@ LL | x.unwrap_err(); | ^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> tests/ui/checked_unwrap/simple_conditionals.rs:151:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:143:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some() = &option` @@ -177,7 +177,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:155:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:146:9 | LL | if option.is_some() { | ---------------- because of this check @@ -186,7 +186,7 @@ LL | option.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/simple_conditionals.rs:163:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:153:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok() = &result` @@ -194,7 +194,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:167:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:156:9 | LL | if result.is_ok() { | -------------- because of this check @@ -203,7 +203,7 @@ LL | result.as_ref().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `option` after checking its variant with `is_some` - --> tests/ui/checked_unwrap/simple_conditionals.rs:174:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:162:9 | LL | if option.is_some() { | ------------------- help: try: `if let Some() = &mut option` @@ -211,7 +211,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:178:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:165:9 | LL | if option.is_some() { | ---------------- because of this check @@ -220,7 +220,7 @@ LL | option.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `unwrap` on `result` after checking its variant with `is_ok` - --> tests/ui/checked_unwrap/simple_conditionals.rs:185:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:171:9 | LL | if result.is_ok() { | ----------------- help: try: `if let Ok() = &mut result` @@ -228,7 +228,7 @@ LL | result.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this call to `unwrap()` will always panic - --> tests/ui/checked_unwrap/simple_conditionals.rs:189:9 + --> tests/ui/checked_unwrap/simple_conditionals.rs:174:9 | LL | if result.is_ok() { | -------------- because of this check @@ -237,7 +237,7 @@ LL | result.as_mut().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: creating a shared reference to mutable static is discouraged - --> tests/ui/checked_unwrap/simple_conditionals.rs:199:12 + --> tests/ui/checked_unwrap/simple_conditionals.rs:183:12 | LL | if X.is_some() { | ^^^^^^^^^^^ shared reference to mutable static diff --git a/tests/ui/cmp_null.fixed b/tests/ui/cmp_null.fixed index 27b831950dc7c..140ddb10aeb86 100644 --- a/tests/ui/cmp_null.fixed +++ b/tests/ui/cmp_null.fixed @@ -7,13 +7,12 @@ fn main() { let x = 0; let p: *const usize = &x; if p.is_null() { - //~^ cmp_null - + //~^ cmp_null println!("This is surprising!"); } if p.is_null() { - //~^ cmp_null + //~^ cmp_null println!("This is surprising!"); } @@ -21,17 +20,16 @@ fn main() { let mut y = 0; let mut m: *mut usize = &mut y; if m.is_null() { - //~^ cmp_null + //~^ cmp_null println!("This is surprising, too!"); } if m.is_null() { - //~^ cmp_null + //~^ cmp_null println!("This is surprising, too!"); } let _ = (x as *const ()).is_null(); //~^ cmp_null - } diff --git a/tests/ui/cmp_null.rs b/tests/ui/cmp_null.rs index ac1bf83e094cb..16ed17765dace 100644 --- a/tests/ui/cmp_null.rs +++ b/tests/ui/cmp_null.rs @@ -7,13 +7,12 @@ fn main() { let x = 0; let p: *const usize = &x; if p == ptr::null() { - //~^ cmp_null - + //~^ cmp_null println!("This is surprising!"); } if ptr::null() == p { - //~^ cmp_null + //~^ cmp_null println!("This is surprising!"); } @@ -21,17 +20,16 @@ fn main() { let mut y = 0; let mut m: *mut usize = &mut y; if m == ptr::null_mut() { - //~^ cmp_null + //~^ cmp_null println!("This is surprising, too!"); } if ptr::null_mut() == m { - //~^ cmp_null + //~^ cmp_null println!("This is surprising, too!"); } let _ = x as *const () == ptr::null(); //~^ cmp_null - } diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index a44dd80676136..6821846d0466d 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -8,25 +8,25 @@ LL | if p == ptr::null() { = help: to override `-D warnings` add `#[allow(clippy::cmp_null)]` error: comparing with null is better expressed by the `.is_null()` method - --> tests/ui/cmp_null.rs:15:8 + --> tests/ui/cmp_null.rs:14:8 | LL | if ptr::null() == p { | ^^^^^^^^^^^^^^^^ help: try: `p.is_null()` error: comparing with null is better expressed by the `.is_null()` method - --> tests/ui/cmp_null.rs:23:8 + --> tests/ui/cmp_null.rs:22:8 | LL | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ help: try: `m.is_null()` error: comparing with null is better expressed by the `.is_null()` method - --> tests/ui/cmp_null.rs:28:8 + --> tests/ui/cmp_null.rs:27:8 | LL | if ptr::null_mut() == m { | ^^^^^^^^^^^^^^^^^^^^ help: try: `m.is_null()` error: comparing with null is better expressed by the `.is_null()` method - --> tests/ui/cmp_null.rs:34:13 + --> tests/ui/cmp_null.rs:33:13 | LL | let _ = x as *const () == ptr::null(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(x as *const ()).is_null()` diff --git a/tests/ui/cmp_owned/comparison_flip.fixed b/tests/ui/cmp_owned/comparison_flip.fixed index a926857c78a10..711fbca1c8d28 100644 --- a/tests/ui/cmp_owned/comparison_flip.fixed +++ b/tests/ui/cmp_owned/comparison_flip.fixed @@ -4,12 +4,12 @@ fn main() { let a = Foo; if a != "bar" { - //~^ cmp_owned + //~^ cmp_owned println!("foo"); } if a != "bar" { - //~^ cmp_owned + //~^ cmp_owned println!("foo"); } } diff --git a/tests/ui/cmp_owned/comparison_flip.rs b/tests/ui/cmp_owned/comparison_flip.rs index 169d472203c58..ce86bb3f7b5c8 100644 --- a/tests/ui/cmp_owned/comparison_flip.rs +++ b/tests/ui/cmp_owned/comparison_flip.rs @@ -4,12 +4,12 @@ fn main() { let a = Foo; if a.to_string() != "bar" { - //~^ cmp_owned + //~^ cmp_owned println!("foo"); } if "bar" != a.to_string() { - //~^ cmp_owned + //~^ cmp_owned println!("foo"); } } diff --git a/tests/ui/cmp_owned/without_suggestion.rs b/tests/ui/cmp_owned/without_suggestion.rs index 71bcac44ed7c0..4e14c3054d9f7 100644 --- a/tests/ui/cmp_owned/without_suggestion.rs +++ b/tests/ui/cmp_owned/without_suggestion.rs @@ -7,14 +7,11 @@ fn main() { y.to_owned() == *x; //~^ cmp_owned - - let x = &&Baz; let y = &Baz; y.to_owned() == **x; //~^ cmp_owned - let x = 0u32; let y = U32Wrapper(x); let _ = U32Wrapper::from(x) == y; @@ -26,7 +23,6 @@ impl PartialEq for Foo { fn eq(&self, other: &Self) -> bool { self.to_owned() == *other //~^ cmp_owned - } } diff --git a/tests/ui/cmp_owned/without_suggestion.stderr b/tests/ui/cmp_owned/without_suggestion.stderr index 6efaf9688e207..c8e2efab4915c 100644 --- a/tests/ui/cmp_owned/without_suggestion.stderr +++ b/tests/ui/cmp_owned/without_suggestion.stderr @@ -8,13 +8,13 @@ LL | y.to_owned() == *x; = help: to override `-D warnings` add `#[allow(clippy::cmp_owned)]` error: this creates an owned instance just for comparison - --> tests/ui/cmp_owned/without_suggestion.rs:14:5 + --> tests/ui/cmp_owned/without_suggestion.rs:12:5 | LL | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> tests/ui/cmp_owned/without_suggestion.rs:27:9 + --> tests/ui/cmp_owned/without_suggestion.rs:24:9 | LL | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating diff --git a/tests/ui/cognitive_complexity.rs b/tests/ui/cognitive_complexity.rs index d750202d00ec2..2dbec955f63fe 100644 --- a/tests/ui/cognitive_complexity.rs +++ b/tests/ui/cognitive_complexity.rs @@ -91,7 +91,7 @@ fn main() { #[clippy::cognitive_complexity = "1"] fn kaboom() { -//~^ cognitive_complexity + //~^ cognitive_complexity let n = 0; 'a: for i in 0..20 { @@ -151,11 +151,10 @@ fn lots_of_short_circuits2() -> bool { #[clippy::cognitive_complexity = "1"] fn baa() { -//~^ cognitive_complexity - - let x = || match 99 { //~^ cognitive_complexity + let x = || match 99 { + //~^ cognitive_complexity 0 => 0, 1 => 1, 2 => 2, @@ -173,7 +172,7 @@ fn baa() { #[clippy::cognitive_complexity = "1"] fn bar() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -186,7 +185,7 @@ fn bar() { /// Tests are usually complex but simple at the same time. `clippy::cognitive_complexity` used to /// give lots of false-positives in tests. fn dont_warn_on_tests() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -196,7 +195,7 @@ fn dont_warn_on_tests() { #[clippy::cognitive_complexity = "1"] fn barr() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -208,7 +207,7 @@ fn barr() { #[clippy::cognitive_complexity = "1"] fn barr2() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -226,7 +225,7 @@ fn barr2() { #[clippy::cognitive_complexity = "1"] fn barrr() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -238,7 +237,7 @@ fn barrr() { #[clippy::cognitive_complexity = "1"] fn barrr2() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -256,7 +255,7 @@ fn barrr2() { #[clippy::cognitive_complexity = "1"] fn barrrr() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -268,7 +267,7 @@ fn barrrr() { #[clippy::cognitive_complexity = "1"] fn barrrr2() { -//~^ cognitive_complexity + //~^ cognitive_complexity match 99 { 0 => println!("hi"), @@ -286,7 +285,7 @@ fn barrrr2() { #[clippy::cognitive_complexity = "1"] fn cake() { -//~^ cognitive_complexity + //~^ cognitive_complexity if 4 == 5 { println!("yea"); @@ -298,7 +297,7 @@ fn cake() { #[clippy::cognitive_complexity = "1"] pub fn read_file(input_path: &str) -> String { -//~^ cognitive_complexity + //~^ cognitive_complexity use std::fs::File; use std::io::{Read, Write}; @@ -331,7 +330,7 @@ enum Void {} #[clippy::cognitive_complexity = "1"] fn void(void: Void) { -//~^ cognitive_complexity + //~^ cognitive_complexity if true { match void {} @@ -407,7 +406,7 @@ fn early_ret() -> i32 { #[clippy::cognitive_complexity = "1"] fn closures() { let x = |a: i32, b: i32| -> i32 { - //~^ cognitive_complexity + //~^ cognitive_complexity if true { println!("moo"); @@ -422,7 +421,7 @@ struct Moo; #[clippy::cognitive_complexity = "1"] impl Moo { fn moo(&self) { - //~^ cognitive_complexity + //~^ cognitive_complexity if true { println!("moo"); @@ -433,7 +432,7 @@ impl Moo { #[clippy::cognitive_complexity = "1"] mod issue9300 { async fn a() { - //~^ cognitive_complexity + //~^ cognitive_complexity let a = 0; if a == 0 {} @@ -442,7 +441,7 @@ mod issue9300 { pub struct S; impl S { pub async fn async_method() { - //~^ cognitive_complexity + //~^ cognitive_complexity let a = 0; if a == 0 {} diff --git a/tests/ui/cognitive_complexity.stderr b/tests/ui/cognitive_complexity.stderr index 60a834765a6be..52607b87c60ef 100644 --- a/tests/ui/cognitive_complexity.stderr +++ b/tests/ui/cognitive_complexity.stderr @@ -33,7 +33,7 @@ LL | let x = || match 99 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:175:4 + --> tests/ui/cognitive_complexity.rs:174:4 | LL | fn bar() { | ^^^ @@ -41,7 +41,7 @@ LL | fn bar() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:188:4 + --> tests/ui/cognitive_complexity.rs:187:4 | LL | fn dont_warn_on_tests() { | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn dont_warn_on_tests() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:198:4 + --> tests/ui/cognitive_complexity.rs:197:4 | LL | fn barr() { | ^^^^ @@ -57,7 +57,7 @@ LL | fn barr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> tests/ui/cognitive_complexity.rs:210:4 + --> tests/ui/cognitive_complexity.rs:209:4 | LL | fn barr2() { | ^^^^^ @@ -65,7 +65,7 @@ LL | fn barr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:228:4 + --> tests/ui/cognitive_complexity.rs:227:4 | LL | fn barrr() { | ^^^^^ @@ -73,7 +73,7 @@ LL | fn barrr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> tests/ui/cognitive_complexity.rs:240:4 + --> tests/ui/cognitive_complexity.rs:239:4 | LL | fn barrr2() { | ^^^^^^ @@ -81,7 +81,7 @@ LL | fn barrr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:258:4 + --> tests/ui/cognitive_complexity.rs:257:4 | LL | fn barrrr() { | ^^^^^^ @@ -89,7 +89,7 @@ LL | fn barrrr() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (3/1) - --> tests/ui/cognitive_complexity.rs:270:4 + --> tests/ui/cognitive_complexity.rs:269:4 | LL | fn barrrr2() { | ^^^^^^^ @@ -97,7 +97,7 @@ LL | fn barrrr2() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:288:4 + --> tests/ui/cognitive_complexity.rs:287:4 | LL | fn cake() { | ^^^^ @@ -105,7 +105,7 @@ LL | fn cake() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (4/1) - --> tests/ui/cognitive_complexity.rs:300:8 + --> tests/ui/cognitive_complexity.rs:299:8 | LL | pub fn read_file(input_path: &str) -> String { | ^^^^^^^^^ @@ -113,7 +113,7 @@ LL | pub fn read_file(input_path: &str) -> String { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:333:4 + --> tests/ui/cognitive_complexity.rs:332:4 | LL | fn void(void: Void) { | ^^^^ @@ -121,7 +121,7 @@ LL | fn void(void: Void) { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (8/1) - --> tests/ui/cognitive_complexity.rs:386:4 + --> tests/ui/cognitive_complexity.rs:385:4 | LL | fn early_ret() -> i32 { | ^^^^^^^^^ @@ -129,7 +129,7 @@ LL | fn early_ret() -> i32 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:409:13 + --> tests/ui/cognitive_complexity.rs:408:13 | LL | let x = |a: i32, b: i32| -> i32 { | ^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | let x = |a: i32, b: i32| -> i32 { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:424:8 + --> tests/ui/cognitive_complexity.rs:423:8 | LL | fn moo(&self) { | ^^^ @@ -145,7 +145,7 @@ LL | fn moo(&self) { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:435:14 + --> tests/ui/cognitive_complexity.rs:434:14 | LL | async fn a() { | ^ @@ -153,7 +153,7 @@ LL | async fn a() { = help: you could split it up into multiple smaller functions error: the function has a cognitive complexity of (2/1) - --> tests/ui/cognitive_complexity.rs:444:22 + --> tests/ui/cognitive_complexity.rs:443:22 | LL | pub async fn async_method() { | ^^^^^^^^^^^^ diff --git a/tests/ui/cognitive_complexity_attr_used.rs b/tests/ui/cognitive_complexity_attr_used.rs index ed62dd7b933e8..a260fdee3cfd3 100644 --- a/tests/ui/cognitive_complexity_attr_used.rs +++ b/tests/ui/cognitive_complexity_attr_used.rs @@ -7,7 +7,7 @@ fn main() { #[clippy::cognitive_complexity = "0"] fn kaboom() { -//~^ cognitive_complexity + //~^ cognitive_complexity if 42 == 43 { panic!(); diff --git a/tests/ui/collapsible_match.rs b/tests/ui/collapsible_match.rs index 14e3ab95dbd1d..796cabd4b669a 100644 --- a/tests/ui/collapsible_match.rs +++ b/tests/ui/collapsible_match.rs @@ -12,8 +12,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // match without block match res_opt { Ok(val) => match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), _ => return, }, @@ -23,8 +22,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // match with block match res_opt { Ok(val) => match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), _ => return, }, @@ -34,7 +32,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // if let, if let if let Ok(val) = res_opt { if let Some(n) = val { - //~^ collapsible_match + //~^ collapsible_match take(n); } @@ -43,7 +41,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // if let else, if let else if let Ok(val) = res_opt { if let Some(n) = val { - //~^ collapsible_match + //~^ collapsible_match take(n); } else { @@ -56,8 +54,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // if let, match if let Ok(val) = res_opt { match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), _ => (), } @@ -67,7 +64,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> match res_opt { Ok(val) => { if let Some(n) = val { - //~^ collapsible_match + //~^ collapsible_match take(n); } @@ -78,8 +75,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // if let else, match if let Ok(val) = res_opt { match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), _ => return, } @@ -91,7 +87,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> match res_opt { Ok(val) => { if let Some(n) = val { - //~^ collapsible_match + //~^ collapsible_match take(n); } else { @@ -104,8 +100,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // None in inner match same as outer wild branch match res_opt { Ok(val) => match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), None => return, }, @@ -115,8 +110,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // None in outer match same as inner wild branch match opt_opt { Some(val) => match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), _ => return, }, @@ -260,7 +254,7 @@ fn negative_cases(res_opt: Result, String>, res_res: Result>>() { Some(val) => match val { - //~^ collapsible_match + //~^ collapsible_match E::A(val) | E::B(val) => foo(val), _ => return, }, @@ -292,7 +286,7 @@ pub enum Issue9647 { pub fn test_1(x: Issue9647) { if let Issue9647::A { a, .. } = x { if let Some(u) = a { - //~^ collapsible_match + //~^ collapsible_match println!("{u:?}") } @@ -302,7 +296,7 @@ pub fn test_1(x: Issue9647) { pub fn test_2(x: Issue9647) { if let Issue9647::A { a: Some(a), .. } = x { if let Some(u) = a { - //~^ collapsible_match + //~^ collapsible_match println!("{u}") } diff --git a/tests/ui/collapsible_match.stderr b/tests/ui/collapsible_match.stderr index 471e58f277707..5294a9d6975db 100644 --- a/tests/ui/collapsible_match.stderr +++ b/tests/ui/collapsible_match.stderr @@ -4,7 +4,6 @@ error: this `match` can be collapsed into the outer `match` LL | Ok(val) => match val { | ____________________^ LL | | -LL | | LL | | Some(n) => foo(n), LL | | _ => return, LL | | }, @@ -15,35 +14,34 @@ help: the outer pattern can be modified to include the inner pattern | LL | Ok(val) => match val { | ^^^ replace this binding -... +LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern = note: `-D clippy::collapsible-match` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]` error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match.rs:25:20 + --> tests/ui/collapsible_match.rs:24:20 | LL | Ok(val) => match val { | ____________________^ LL | | -LL | | LL | | Some(n) => foo(n), LL | | _ => return, LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:25:12 + --> tests/ui/collapsible_match.rs:24:12 | LL | Ok(val) => match val { | ^^^ replace this binding -... +LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> tests/ui/collapsible_match.rs:36:9 + --> tests/ui/collapsible_match.rs:34:9 | LL | / if let Some(n) = val { LL | | @@ -53,7 +51,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:35:15 + --> tests/ui/collapsible_match.rs:33:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -61,7 +59,7 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> tests/ui/collapsible_match.rs:45:9 + --> tests/ui/collapsible_match.rs:43:9 | LL | / if let Some(n) = val { LL | | @@ -73,7 +71,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:44:15 + --> tests/ui/collapsible_match.rs:42:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -81,18 +79,17 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `if let` - --> tests/ui/collapsible_match.rs:58:9 + --> tests/ui/collapsible_match.rs:56:9 | LL | / match val { LL | | -LL | | LL | | Some(n) => foo(n), LL | | _ => (), LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:57:15 + --> tests/ui/collapsible_match.rs:55:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -101,7 +98,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `match` - --> tests/ui/collapsible_match.rs:69:13 + --> tests/ui/collapsible_match.rs:66:13 | LL | / if let Some(n) = val { LL | | @@ -111,7 +108,7 @@ LL | | } | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:68:12 + --> tests/ui/collapsible_match.rs:65:12 | LL | Ok(val) => { | ^^^ replace this binding @@ -119,18 +116,17 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `if let` - --> tests/ui/collapsible_match.rs:80:9 + --> tests/ui/collapsible_match.rs:77:9 | LL | / match val { LL | | -LL | | LL | | Some(n) => foo(n), LL | | _ => return, LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:79:15 + --> tests/ui/collapsible_match.rs:76:15 | LL | if let Ok(val) = res_opt { | ^^^ replace this binding @@ -139,7 +135,7 @@ LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `match` - --> tests/ui/collapsible_match.rs:93:13 + --> tests/ui/collapsible_match.rs:89:13 | LL | / if let Some(n) = val { LL | | @@ -151,7 +147,7 @@ LL | | } | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:92:12 + --> tests/ui/collapsible_match.rs:88:12 | LL | Ok(val) => { | ^^^ replace this binding @@ -159,49 +155,47 @@ LL | if let Some(n) = val { | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match.rs:106:20 + --> tests/ui/collapsible_match.rs:102:20 | LL | Ok(val) => match val { | ____________________^ LL | | -LL | | LL | | Some(n) => foo(n), LL | | None => return, LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:106:12 + --> tests/ui/collapsible_match.rs:102:12 | LL | Ok(val) => match val { | ^^^ replace this binding -... +LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match.rs:117:22 + --> tests/ui/collapsible_match.rs:112:22 | LL | Some(val) => match val { | ______________________^ LL | | -LL | | LL | | Some(n) => foo(n), LL | | _ => return, LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:117:14 + --> tests/ui/collapsible_match.rs:112:14 | LL | Some(val) => match val { | ^^^ replace this binding -... +LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match.rs:262:22 + --> tests/ui/collapsible_match.rs:256:22 | LL | Some(val) => match val { | ______________________^ @@ -212,7 +206,7 @@ LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:262:14 + --> tests/ui/collapsible_match.rs:256:14 | LL | Some(val) => match val { | ^^^ replace this binding @@ -221,7 +215,7 @@ LL | E::A(val) | E::B(val) => foo(val), | ^^^^^^^^^^^^^^^^^^^^^ with this pattern error: this `if let` can be collapsed into the outer `if let` - --> tests/ui/collapsible_match.rs:294:9 + --> tests/ui/collapsible_match.rs:288:9 | LL | / if let Some(u) = a { LL | | @@ -231,7 +225,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:293:27 + --> tests/ui/collapsible_match.rs:287:27 | LL | if let Issue9647::A { a, .. } = x { | ^ replace this binding @@ -239,7 +233,7 @@ LL | if let Some(u) = a { | ^^^^^^^ with this pattern, prefixed by `a`: error: this `if let` can be collapsed into the outer `if let` - --> tests/ui/collapsible_match.rs:304:9 + --> tests/ui/collapsible_match.rs:298:9 | LL | / if let Some(u) = a { LL | | @@ -249,7 +243,7 @@ LL | | } | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match.rs:303:35 + --> tests/ui/collapsible_match.rs:297:35 | LL | if let Issue9647::A { a: Some(a), .. } = x { | ^ replace this binding diff --git a/tests/ui/collapsible_match2.rs b/tests/ui/collapsible_match2.rs index 1831fc3f0e355..ba7f2f2720dc5 100644 --- a/tests/ui/collapsible_match2.rs +++ b/tests/ui/collapsible_match2.rs @@ -11,8 +11,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> { match res_opt { Ok(val) if make() => match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), _ => return, }, @@ -20,8 +19,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> } match res_opt { Ok(val) => match val { - //~^ collapsible_match - + //~^ collapsible_match Some(n) => foo(n), _ => return, }, @@ -36,7 +34,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> ($outer:expr => $pat:pat, $e:expr => $inner_pat:pat, $then:expr) => { match $outer { $pat => match $e { - //~^ collapsible_match + //~^ collapsible_match $inner_pat => $then, _ => return, }, @@ -54,8 +52,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // deref reference value match Some(&[1]) { Some(s) => match *s { - //~^ collapsible_match - + //~^ collapsible_match [n] => foo(n), _ => (), }, @@ -65,8 +62,7 @@ fn lint_cases(opt_opt: Option>, res_opt: Result, String> // ref pattern and deref match Some(&[1]) { Some(ref s) => match s { - //~^ collapsible_match - + //~^ collapsible_match [n] => foo(n), _ => (), }, diff --git a/tests/ui/collapsible_match2.stderr b/tests/ui/collapsible_match2.stderr index 322c583fda77b..7b27306375289 100644 --- a/tests/ui/collapsible_match2.stderr +++ b/tests/ui/collapsible_match2.stderr @@ -4,7 +4,6 @@ error: this `match` can be collapsed into the outer `match` LL | Ok(val) if make() => match val { | __________________________________^ LL | | -LL | | LL | | Some(n) => foo(n), LL | | _ => return, LL | | }, @@ -15,35 +14,34 @@ help: the outer pattern can be modified to include the inner pattern | LL | Ok(val) if make() => match val { | ^^^ replace this binding -... +LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern = note: `-D clippy::collapsible-match` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::collapsible_match)]` error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match2.rs:22:24 + --> tests/ui/collapsible_match2.rs:21:24 | LL | Ok(val) => match val { | ________________________^ LL | | -LL | | LL | | Some(n) => foo(n), LL | | _ => return, LL | | }, | |_____________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match2.rs:22:16 + --> tests/ui/collapsible_match2.rs:21:16 | LL | Ok(val) => match val { | ^^^ replace this binding -... +LL | LL | Some(n) => foo(n), | ^^^^^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match2.rs:38:29 + --> tests/ui/collapsible_match2.rs:36:29 | LL | $pat => match $e { | _____________________________^ @@ -57,7 +55,7 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); | ------------------------------------------------ in this macro invocation | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match2.rs:51:28 + --> tests/ui/collapsible_match2.rs:49:28 | LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); | ^^^ ^^^^^^^ with this pattern @@ -66,44 +64,42 @@ LL | mac!(res_opt => Ok(val), val => Some(n), foo(n)); = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match2.rs:56:20 + --> tests/ui/collapsible_match2.rs:54:20 | LL | Some(s) => match *s { | ____________________^ LL | | -LL | | LL | | [n] => foo(n), LL | | _ => (), LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match2.rs:56:14 + --> tests/ui/collapsible_match2.rs:54:14 | LL | Some(s) => match *s { | ^ replace this binding -... +LL | LL | [n] => foo(n), | ^^^ with this pattern error: this `match` can be collapsed into the outer `match` - --> tests/ui/collapsible_match2.rs:67:24 + --> tests/ui/collapsible_match2.rs:64:24 | LL | Some(ref s) => match s { | ________________________^ LL | | -LL | | LL | | [n] => foo(n), LL | | _ => (), LL | | }, | |_________^ | help: the outer pattern can be modified to include the inner pattern - --> tests/ui/collapsible_match2.rs:67:14 + --> tests/ui/collapsible_match2.rs:64:14 | LL | Some(ref s) => match s { | ^^^^^ replace this binding -... +LL | LL | [n] => foo(n), | ^^^ with this pattern diff --git a/tests/ui/collection_is_never_read.rs b/tests/ui/collection_is_never_read.rs index 406b5f8f9f69d..77cc84fef1777 100644 --- a/tests/ui/collection_is_never_read.rs +++ b/tests/ui/collection_is_never_read.rs @@ -21,7 +21,6 @@ fn write_without_read() { let mut x = HashMap::new(); //~^ collection_is_never_read - x.insert(1, 2); } diff --git a/tests/ui/collection_is_never_read.stderr b/tests/ui/collection_is_never_read.stderr index 674552629f7d6..d92b84c4a6528 100644 --- a/tests/ui/collection_is_never_read.stderr +++ b/tests/ui/collection_is_never_read.stderr @@ -8,115 +8,115 @@ LL | let mut x = HashMap::new(); = help: to override `-D warnings` add `#[allow(clippy::collection_is_never_read)]` error: collection is never read - --> tests/ui/collection_is_never_read.rs:63:5 + --> tests/ui/collection_is_never_read.rs:62:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:80:5 + --> tests/ui/collection_is_never_read.rs:79:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:87:5 + --> tests/ui/collection_is_never_read.rs:86:5 | LL | let mut x = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:97:5 + --> tests/ui/collection_is_never_read.rs:96:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:105:5 + --> tests/ui/collection_is_never_read.rs:104:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:113:5 + --> tests/ui/collection_is_never_read.rs:112:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:122:5 + --> tests/ui/collection_is_never_read.rs:121:5 | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:141:5 + --> tests/ui/collection_is_never_read.rs:140:5 | LL | let mut x = HashSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:157:5 + --> tests/ui/collection_is_never_read.rs:156:5 | LL | let x = vec![1, 2, 3]; | ^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:194:5 + --> tests/ui/collection_is_never_read.rs:193:5 | LL | let mut x = std::collections::BTreeMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:199:5 + --> tests/ui/collection_is_never_read.rs:198:5 | LL | let mut x = std::collections::BTreeSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:204:5 + --> tests/ui/collection_is_never_read.rs:203:5 | LL | let mut x = std::collections::BinaryHeap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:209:5 + --> tests/ui/collection_is_never_read.rs:208:5 | LL | let mut x = std::collections::HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:214:5 + --> tests/ui/collection_is_never_read.rs:213:5 | LL | let mut x = std::collections::HashSet::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:219:5 + --> tests/ui/collection_is_never_read.rs:218:5 | LL | let mut x = std::collections::LinkedList::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:224:5 + --> tests/ui/collection_is_never_read.rs:223:5 | LL | let mut x = Some(true); | ^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:229:5 + --> tests/ui/collection_is_never_read.rs:228:5 | LL | let mut x = String::from("hello"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:234:5 + --> tests/ui/collection_is_never_read.rs:233:5 | LL | let mut x = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^^ error: collection is never read - --> tests/ui/collection_is_never_read.rs:240:5 + --> tests/ui/collection_is_never_read.rs:239:5 | LL | let mut x = std::collections::VecDeque::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/comparison_chain.rs b/tests/ui/comparison_chain.rs index 418c88b7d5a34..669690a4d42ce 100644 --- a/tests/ui/comparison_chain.rs +++ b/tests/ui/comparison_chain.rs @@ -13,7 +13,7 @@ fn f(x: u8, y: u8, z: u8) { } if x > y { - //~^ comparison_chain + //~^ comparison_chain a() } else if x < y { @@ -28,7 +28,7 @@ fn f(x: u8, y: u8, z: u8) { } if x > y { - //~^ comparison_chain + //~^ comparison_chain a() } else if x < y { @@ -38,7 +38,7 @@ fn f(x: u8, y: u8, z: u8) { } if x > y { - //~^ comparison_chain + //~^ comparison_chain a() } else if y > x { @@ -48,7 +48,7 @@ fn f(x: u8, y: u8, z: u8) { } if x > 1 { - //~^ comparison_chain + //~^ comparison_chain a() } else if x < 1 { @@ -124,7 +124,7 @@ fn g(x: f64, y: f64, z: f64) { fn h(x: T, y: T, z: T) { if x > y { - //~^ comparison_chain + //~^ comparison_chain a() } else if x < y { @@ -132,7 +132,7 @@ fn h(x: T, y: T, z: T) { } if x > y { - //~^ comparison_chain + //~^ comparison_chain a() } else if x < y { @@ -142,7 +142,7 @@ fn h(x: T, y: T, z: T) { } if x > y { - //~^ comparison_chain + //~^ comparison_chain a() } else if y > x { @@ -249,7 +249,7 @@ const fn sign_i8(n: i8) -> Sign { fn needs_parens() -> &'static str { let (x, y) = (1, 2); if x + 1 > y * 2 { - //~^ comparison_chain + //~^ comparison_chain "aa" } else if x + 1 < y * 2 { diff --git a/tests/ui/comparison_to_empty.fixed b/tests/ui/comparison_to_empty.fixed index 205abe31cd86d..dfbb616838402 100644 --- a/tests/ui/comparison_to_empty.fixed +++ b/tests/ui/comparison_to_empty.fixed @@ -25,7 +25,7 @@ fn main() { if s.is_empty() //~^ comparison_to_empty && s.is_empty() - //~^ comparison_to_empty + //~^ comparison_to_empty {} // Allow comparisons to non-empty diff --git a/tests/ui/comparison_to_empty.rs b/tests/ui/comparison_to_empty.rs index 4da6327050a89..61cdb2bbe9f81 100644 --- a/tests/ui/comparison_to_empty.rs +++ b/tests/ui/comparison_to_empty.rs @@ -25,7 +25,7 @@ fn main() { if let [] = &*s //~^ comparison_to_empty && s == [] - //~^ comparison_to_empty + //~^ comparison_to_empty {} // Allow comparisons to non-empty diff --git a/tests/ui/const_comparisons.rs b/tests/ui/const_comparisons.rs index 0df4b8eb356ed..b732d7d142fc5 100644 --- a/tests/ui/const_comparisons.rs +++ b/tests/ui/const_comparisons.rs @@ -45,52 +45,38 @@ fn main() { status_code <= 400 && status_code > 500; //~^ impossible_comparisons - status_code > 500 && status_code < 400; //~^ impossible_comparisons - status_code < 500 && status_code > 500; //~^ impossible_comparisons - - // More complex expressions status_code < { 400 } && status_code > { 500 }; //~^ impossible_comparisons - status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR; //~^ impossible_comparisons - status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR; //~^ impossible_comparisons - status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR; //~^ impossible_comparisons - - // Comparing two different types, via the `impl PartialOrd for Status` status < { 400 } && status > { 500 }; //~^ impossible_comparisons - status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR; //~^ impossible_comparisons - status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR; //~^ impossible_comparisons - status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR; //~^ impossible_comparisons - - // Yoda conditions // Correct 500 <= status_code && 600 > status_code; @@ -100,13 +86,10 @@ fn main() { 500 >= status_code && 600 < status_code; //~^ impossible_comparisons - // Incorrect 500 >= status_code && status_code > 600; //~^ impossible_comparisons - - // Yoda conditions, comparing two different types // Correct 500 <= status && 600 > status; @@ -116,13 +99,10 @@ fn main() { 500 >= status && 600 < status; //~^ impossible_comparisons - // Incorrect 500 >= status && status > 600; //~^ impossible_comparisons - - // Expressions where one of the sides has no effect status_code < 200 && status_code <= 299; //~^ redundant_comparisons @@ -130,7 +110,6 @@ fn main() { status_code > 200 && status_code >= 299; //~^ redundant_comparisons - // Useless left status_code >= 500 && status_code > 500; //~^ redundant_comparisons @@ -147,29 +126,20 @@ fn main() { status_code < 500 && status_code <= 500; //~^ redundant_comparisons - // Other types let name = "Steve"; name < "Jennifer" && name > "Shannon"; //~^ impossible_comparisons - - let numbers = [1, 2]; numbers < [3, 4] && numbers > [5, 6]; //~^ impossible_comparisons - - let letter = 'a'; letter < 'b' && letter > 'c'; //~^ impossible_comparisons - - let area = 42.0; area < std::f32::consts::E && area > std::f32::consts::PI; //~^ impossible_comparisons - - } diff --git a/tests/ui/const_comparisons.stderr b/tests/ui/const_comparisons.stderr index 2f3f5c9523e35..48a2c6e8d4879 100644 --- a/tests/ui/const_comparisons.stderr +++ b/tests/ui/const_comparisons.stderr @@ -9,7 +9,7 @@ LL | status_code <= 400 && status_code > 500; = help: to override `-D warnings` add `#[allow(clippy::impossible_comparisons)]` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:49:5 + --> tests/ui/const_comparisons.rs:48:5 | LL | status_code > 500 && status_code < 400; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | status_code > 500 && status_code < 400; = note: since `500` > `400`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:53:5 + --> tests/ui/const_comparisons.rs:51:5 | LL | status_code < 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | status_code < 500 && status_code > 500; = note: `status_code` cannot simultaneously be greater than and less than `500` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:59:5 + --> tests/ui/const_comparisons.rs:55:5 | LL | status_code < { 400 } && status_code > { 500 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | status_code < { 400 } && status_code > { 500 }; = note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:63:5 + --> tests/ui/const_comparisons.rs:58:5 | LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR; = note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:67:5 + --> tests/ui/const_comparisons.rs:61:5 | LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR; = note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:71:5 + --> tests/ui/const_comparisons.rs:64:5 | LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR; = note: `status_code` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:77:5 + --> tests/ui/const_comparisons.rs:68:5 | LL | status < { 400 } && status > { 500 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | status < { 400 } && status > { 500 }; = note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:81:5 + --> tests/ui/const_comparisons.rs:71:5 | LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR; = note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:85:5 + --> tests/ui/const_comparisons.rs:74:5 | LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR; = note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:89:5 + --> tests/ui/const_comparisons.rs:77:5 | LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR; = note: `status` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:100:5 + --> tests/ui/const_comparisons.rs:86:5 | LL | 500 >= status_code && 600 < status_code; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | 500 >= status_code && 600 < status_code; = note: since `500` < `600`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:105:5 + --> tests/ui/const_comparisons.rs:90:5 | LL | 500 >= status_code && status_code > 600; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | 500 >= status_code && status_code > 600; = note: since `500` < `600`, the expression evaluates to false for any value of `status_code` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:116:5 + --> tests/ui/const_comparisons.rs:99:5 | LL | 500 >= status && 600 < status; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | 500 >= status && 600 < status; = note: since `500` < `600`, the expression evaluates to false for any value of `status` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:121:5 + --> tests/ui/const_comparisons.rs:103:5 | LL | 500 >= status && status > 600; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,13 +121,13 @@ LL | 500 >= status && status > 600; = note: since `500` < `600`, the expression evaluates to false for any value of `status` error: right-hand side of `&&` operator has no effect - --> tests/ui/const_comparisons.rs:127:5 + --> tests/ui/const_comparisons.rs:107:5 | LL | status_code < 200 && status_code <= 299; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 200` evaluates to true, status_code <= 299` will always evaluate to true as well - --> tests/ui/const_comparisons.rs:127:23 + --> tests/ui/const_comparisons.rs:107:23 | LL | status_code < 200 && status_code <= 299; | ^^^^^^^^^^^^^^^^^^^^^ @@ -135,67 +135,67 @@ LL | status_code < 200 && status_code <= 299; = help: to override `-D warnings` add `#[allow(clippy::redundant_comparisons)]` error: left-hand side of `&&` operator has no effect - --> tests/ui/const_comparisons.rs:130:5 + --> tests/ui/const_comparisons.rs:110:5 | LL | status_code > 200 && status_code >= 299; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code >= 299` evaluates to true, status_code > 200` will always evaluate to true as well - --> tests/ui/const_comparisons.rs:130:5 + --> tests/ui/const_comparisons.rs:110:5 | LL | status_code > 200 && status_code >= 299; | ^^^^^^^^^^^^^^^^^^^^^ error: left-hand side of `&&` operator has no effect - --> tests/ui/const_comparisons.rs:135:5 + --> tests/ui/const_comparisons.rs:114:5 | LL | status_code >= 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well - --> tests/ui/const_comparisons.rs:135:5 + --> tests/ui/const_comparisons.rs:114:5 | LL | status_code >= 500 && status_code > 500; | ^^^^^^^^^^^^^^^^^^^^^^ error: right-hand side of `&&` operator has no effect - --> tests/ui/const_comparisons.rs:139:5 + --> tests/ui/const_comparisons.rs:118:5 | LL | status_code > 500 && status_code >= 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well - --> tests/ui/const_comparisons.rs:139:23 + --> tests/ui/const_comparisons.rs:118:23 | LL | status_code > 500 && status_code >= 500; | ^^^^^^^^^^^^^^^^^^^^^ error: left-hand side of `&&` operator has no effect - --> tests/ui/const_comparisons.rs:143:5 + --> tests/ui/const_comparisons.rs:122:5 | LL | status_code <= 500 && status_code < 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well - --> tests/ui/const_comparisons.rs:143:5 + --> tests/ui/const_comparisons.rs:122:5 | LL | status_code <= 500 && status_code < 500; | ^^^^^^^^^^^^^^^^^^^^^^ error: right-hand side of `&&` operator has no effect - --> tests/ui/const_comparisons.rs:147:5 + --> tests/ui/const_comparisons.rs:126:5 | LL | status_code < 500 && status_code <= 500; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well - --> tests/ui/const_comparisons.rs:147:23 + --> tests/ui/const_comparisons.rs:126:23 | LL | status_code < 500 && status_code <= 500; | ^^^^^^^^^^^^^^^^^^^^^ error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:153:5 + --> tests/ui/const_comparisons.rs:131:5 | LL | name < "Jennifer" && name > "Shannon"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +203,7 @@ LL | name < "Jennifer" && name > "Shannon"; = note: since `"Jennifer"` < `"Shannon"`, the expression evaluates to false for any value of `name` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:159:5 + --> tests/ui/const_comparisons.rs:135:5 | LL | numbers < [3, 4] && numbers > [5, 6]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +211,7 @@ LL | numbers < [3, 4] && numbers > [5, 6]; = note: since `[3, 4]` < `[5, 6]`, the expression evaluates to false for any value of `numbers` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:165:5 + --> tests/ui/const_comparisons.rs:139:5 | LL | letter < 'b' && letter > 'c'; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ LL | letter < 'b' && letter > 'c'; = note: since `'b'` < `'c'`, the expression evaluates to false for any value of `letter` error: boolean expression will never evaluate to 'true' - --> tests/ui/const_comparisons.rs:171:5 + --> tests/ui/const_comparisons.rs:143:5 | LL | area < std::f32::consts::E && area > std::f32::consts::PI; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const_is_empty.rs b/tests/ui/const_is_empty.rs index 29891ae4c0e56..8bb4f0e5d9750 100644 --- a/tests/ui/const_is_empty.rs +++ b/tests/ui/const_is_empty.rs @@ -3,23 +3,19 @@ fn test_literal() { if "".is_empty() { - //~^ const_is_empty - + //~^ const_is_empty } if "foobar".is_empty() { - //~^ const_is_empty - + //~^ const_is_empty } } fn test_byte_literal() { if b"".is_empty() { - //~^ const_is_empty - + //~^ const_is_empty } if b"foobar".is_empty() { - //~^ const_is_empty - + //~^ const_is_empty } } @@ -36,12 +32,10 @@ fn test_propagated() { let empty2 = empty; let non_empty2 = non_empty; if empty2.is_empty() { - //~^ const_is_empty - + //~^ const_is_empty } if non_empty2.is_empty() { - //~^ const_is_empty - + //~^ const_is_empty } } @@ -106,7 +100,6 @@ fn test_from_const() { let _ = NON_EMPTY_SLICE_REPEAT.is_empty(); //~^ const_is_empty - } fn main() { @@ -123,7 +116,6 @@ fn main() { let _ = b"".is_empty(); //~^ const_is_empty - } fn str_from_arg(var: &str) { @@ -178,7 +170,6 @@ fn not_cfg_conditioned() { #[cfg(not(target_os = "inexistent"))] let _ = val.is_empty(); //~^ const_is_empty - } const fn const_rand() -> &'static str { diff --git a/tests/ui/const_is_empty.stderr b/tests/ui/const_is_empty.stderr index 9557ad18dfc8b..2ba189058e832 100644 --- a/tests/ui/const_is_empty.stderr +++ b/tests/ui/const_is_empty.stderr @@ -8,157 +8,157 @@ LL | if "".is_empty() { = help: to override `-D warnings` add `#[allow(clippy::const_is_empty)]` error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:9:8 + --> tests/ui/const_is_empty.rs:8:8 | LL | if "foobar".is_empty() { | ^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:16:8 + --> tests/ui/const_is_empty.rs:14:8 | LL | if b"".is_empty() { | ^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:20:8 + --> tests/ui/const_is_empty.rs:17:8 | LL | if b"foobar".is_empty() { | ^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:38:8 + --> tests/ui/const_is_empty.rs:34:8 | LL | if empty2.is_empty() { | ^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:42:8 + --> tests/ui/const_is_empty.rs:37:8 | LL | if non_empty2.is_empty() { | ^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:65:13 + --> tests/ui/const_is_empty.rs:59:13 | LL | let _ = EMPTY_STR.is_empty(); | ^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:68:13 + --> tests/ui/const_is_empty.rs:62:13 | LL | let _ = NON_EMPTY_STR.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:71:13 + --> tests/ui/const_is_empty.rs:65:13 | LL | let _ = EMPTY_BSTR.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:74:13 + --> tests/ui/const_is_empty.rs:68:13 | LL | let _ = NON_EMPTY_BSTR.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:77:13 + --> tests/ui/const_is_empty.rs:71:13 | LL | let _ = EMPTY_ARRAY.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:80:13 + --> tests/ui/const_is_empty.rs:74:13 | LL | let _ = EMPTY_ARRAY_REPEAT.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:83:13 + --> tests/ui/const_is_empty.rs:77:13 | LL | let _ = EMPTY_U8_SLICE.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:86:13 + --> tests/ui/const_is_empty.rs:80:13 | LL | let _ = NON_EMPTY_U8_SLICE.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:89:13 + --> tests/ui/const_is_empty.rs:83:13 | LL | let _ = NON_EMPTY_ARRAY.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:92:13 + --> tests/ui/const_is_empty.rs:86:13 | LL | let _ = NON_EMPTY_ARRAY_REPEAT.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:95:13 + --> tests/ui/const_is_empty.rs:89:13 | LL | let _ = EMPTY_REF_ARRAY.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:98:13 + --> tests/ui/const_is_empty.rs:92:13 | LL | let _ = NON_EMPTY_REF_ARRAY.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:101:13 + --> tests/ui/const_is_empty.rs:95:13 | LL | let _ = EMPTY_SLICE.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:104:13 + --> tests/ui/const_is_empty.rs:98:13 | LL | let _ = NON_EMPTY_SLICE.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:107:13 + --> tests/ui/const_is_empty.rs:101:13 | LL | let _ = NON_EMPTY_SLICE_REPEAT.is_empty(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:114:13 + --> tests/ui/const_is_empty.rs:107:13 | LL | let _ = value.is_empty(); | ^^^^^^^^^^^^^^^^ error: this expression always evaluates to false - --> tests/ui/const_is_empty.rs:118:13 + --> tests/ui/const_is_empty.rs:111:13 | LL | let _ = x.is_empty(); | ^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:121:13 + --> tests/ui/const_is_empty.rs:114:13 | LL | let _ = "".is_empty(); | ^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:124:13 + --> tests/ui/const_is_empty.rs:117:13 | LL | let _ = b"".is_empty(); | ^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:179:13 + --> tests/ui/const_is_empty.rs:171:13 | LL | let _ = val.is_empty(); | ^^^^^^^^^^^^^^ error: this expression always evaluates to true - --> tests/ui/const_is_empty.rs:211:9 + --> tests/ui/const_is_empty.rs:202:9 | LL | EMPTY_STR.is_empty(); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/copy_iterator.rs b/tests/ui/copy_iterator.rs index f048f7541bc61..5639583289d2d 100644 --- a/tests/ui/copy_iterator.rs +++ b/tests/ui/copy_iterator.rs @@ -5,8 +5,7 @@ struct Countdown(u8); impl Iterator for Countdown { -//~^ copy_iterator - + //~^ copy_iterator type Item = u8; diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index 86fd326c36c5e..2f6378a85feea 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -2,6 +2,9 @@ error: you are implementing `Iterator` on a `Copy` type --> tests/ui/copy_iterator.rs:7:1 | LL | / impl Iterator for Countdown { +LL | | +LL | | +LL | | type Item = u8; ... | LL | | } | |_^ diff --git a/tests/ui/crashes/ice-11803.rs b/tests/ui/crashes/ice-11803.rs index aced75b3ad12f..e85f319093880 100644 --- a/tests/ui/crashes/ice-11803.rs +++ b/tests/ui/crashes/ice-11803.rs @@ -3,8 +3,8 @@ #![warn(clippy::impl_trait_in_params)] pub fn g>>() { -//~^ impl_trait_in_params -//~| impl_trait_in_params + //~^ impl_trait_in_params + //~| impl_trait_in_params extern "C" fn implementation_detail() {} } diff --git a/tests/ui/crashes/ice-2774.fixed b/tests/ui/crashes/ice-2774.fixed index d096584fa75ca..35d969441763c 100644 --- a/tests/ui/crashes/ice-2774.fixed +++ b/tests/ui/crashes/ice-2774.fixed @@ -13,8 +13,7 @@ pub struct Foo; #[allow(clippy::implicit_hasher)] // This should not cause a "cannot relate bound region" ICE. pub fn add_barfoos_to_foos(bars: &HashSet<&Bar>) { -//~^ needless_lifetimes - + //~^ needless_lifetimes let mut foos = HashSet::new(); foos.extend(bars.iter().map(|b| &b.foo)); diff --git a/tests/ui/crashes/ice-2774.rs b/tests/ui/crashes/ice-2774.rs index 83fb7be626df0..1eb6df0095edd 100644 --- a/tests/ui/crashes/ice-2774.rs +++ b/tests/ui/crashes/ice-2774.rs @@ -13,8 +13,7 @@ pub struct Foo; #[allow(clippy::implicit_hasher)] // This should not cause a "cannot relate bound region" ICE. pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { -//~^ needless_lifetimes - + //~^ needless_lifetimes let mut foos = HashSet::new(); foos.extend(bars.iter().map(|b| &b.foo)); diff --git a/tests/ui/crashes/ice-360.rs b/tests/ui/crashes/ice-360.rs index 43becad3183f8..cb8176a2973fb 100644 --- a/tests/ui/crashes/ice-360.rs +++ b/tests/ui/crashes/ice-360.rs @@ -3,10 +3,8 @@ fn main() {} fn no_panic(slice: &[T]) { let mut iter = slice.iter(); loop { - //~^ never_loop - //~| while_let_loop - - + //~^ never_loop + //~| while_let_loop let _ = match iter.next() { Some(ele) => ele, @@ -14,6 +12,5 @@ fn no_panic(slice: &[T]) { }; loop {} //~^ empty_loop - } } diff --git a/tests/ui/crashes/ice-360.stderr b/tests/ui/crashes/ice-360.stderr index e4bd436abc542..9961eb21485da 100644 --- a/tests/ui/crashes/ice-360.stderr +++ b/tests/ui/crashes/ice-360.stderr @@ -20,7 +20,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: empty `loop {}` wastes CPU cycles - --> tests/ui/crashes/ice-360.rs:15:9 + --> tests/ui/crashes/ice-360.rs:13:9 | LL | loop {} | ^^^^^^^ diff --git a/tests/ui/crashes/ice-3717.fixed b/tests/ui/crashes/ice-3717.fixed index 0d7c38f95217b..5581b67fa5c44 100644 --- a/tests/ui/crashes/ice-3717.fixed +++ b/tests/ui/crashes/ice-3717.fixed @@ -5,7 +5,7 @@ use std::collections::HashSet; fn main() {} pub fn ice_3717(_: &HashSet) { -//~^ implicit_hasher + //~^ implicit_hasher let _ = [0u8; 0]; let _: HashSet = HashSet::default(); diff --git a/tests/ui/crashes/ice-3717.rs b/tests/ui/crashes/ice-3717.rs index 7c286abf32b08..c612270865c57 100644 --- a/tests/ui/crashes/ice-3717.rs +++ b/tests/ui/crashes/ice-3717.rs @@ -5,7 +5,7 @@ use std::collections::HashSet; fn main() {} pub fn ice_3717(_: &HashSet) { -//~^ implicit_hasher + //~^ implicit_hasher let _ = [0u8; 0]; let _: HashSet = HashSet::new(); diff --git a/tests/ui/crashes/ice-3969.rs b/tests/ui/crashes/ice-3969.rs index 1db7f0ad8b5b6..fa3ca6f1d5387 100644 --- a/tests/ui/crashes/ice-3969.rs +++ b/tests/ui/crashes/ice-3969.rs @@ -23,7 +23,7 @@ where fn unsized_local() where for<'a> Dst: Sized, -//~^ ERROR: trait bound + //~^ ERROR: trait bound { let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); } @@ -31,7 +31,7 @@ where fn return_str() -> str where str: Sized, -//~^ ERROR: trait bound + //~^ ERROR: trait bound { *"Sized".to_string().into_boxed_str() } @@ -39,7 +39,7 @@ where fn use_op(s: String) -> String where String: ::std::ops::Neg, -//~^ ERROR: trait bound + //~^ ERROR: trait bound { -s } @@ -47,7 +47,7 @@ where fn use_for() where i32: Iterator, -//~^ ERROR: trait bound + //~^ ERROR: trait bound { for _ in 2i32 {} } diff --git a/tests/ui/crashes/ice-5872.fixed b/tests/ui/crashes/ice-5872.fixed index a3235c3c7b7ce..521fa15e18460 100644 --- a/tests/ui/crashes/ice-5872.fixed +++ b/tests/ui/crashes/ice-5872.fixed @@ -3,6 +3,4 @@ fn main() { let _ = vec![1, 2, 3].into_iter().next().is_none(); //~^ needless_collect - - } diff --git a/tests/ui/crashes/ice-5872.rs b/tests/ui/crashes/ice-5872.rs index 7d3ad01f56e7e..10235ea8ab7fc 100644 --- a/tests/ui/crashes/ice-5872.rs +++ b/tests/ui/crashes/ice-5872.rs @@ -3,6 +3,4 @@ fn main() { let _ = vec![1, 2, 3].into_iter().collect::>().is_empty(); //~^ needless_collect - - } diff --git a/tests/ui/crashes/ice-6250.rs b/tests/ui/crashes/ice-6250.rs index 37db2ce687579..65cdce7931429 100644 --- a/tests/ui/crashes/ice-6250.rs +++ b/tests/ui/crashes/ice-6250.rs @@ -10,8 +10,8 @@ pub fn list_data(cache: &Cache, key: usize) { if /* let */ Some(reference) = cache.data.get(key) { - //~^ ERROR: mismatched types - //~| ERROR: mismatched types + //~^ ERROR: mismatched types + //~| ERROR: mismatched types unimplemented!() } } diff --git a/tests/ui/crashes/ice-6251.rs b/tests/ui/crashes/ice-6251.rs index 8191a53b3e59e..a58265752ec3c 100644 --- a/tests/ui/crashes/ice-6251.rs +++ b/tests/ui/crashes/ice-6251.rs @@ -2,8 +2,8 @@ // assertion failed: `(left == right)` ; different DefIds //@no-rustfix fn bug() -> impl Iterator { -//~^ ERROR: the size for values -//~| ERROR: the size for values -//~| ERROR: mismatched types + //~^ ERROR: the size for values + //~| ERROR: the size for values + //~| ERROR: mismatched types std::iter::empty() } diff --git a/tests/ui/crashes/ice-7169.fixed b/tests/ui/crashes/ice-7169.fixed index d69b472a36176..71a40ad7de71a 100644 --- a/tests/ui/crashes/ice-7169.fixed +++ b/tests/ui/crashes/ice-7169.fixed @@ -9,6 +9,4 @@ struct A { fn main() { if Ok::<_, ()>(A::::default()).is_ok() {} //~^ redundant_pattern_matching - - } diff --git a/tests/ui/crashes/ice-7169.rs b/tests/ui/crashes/ice-7169.rs index 918f2b0f0b3c1..d43e2cc164d75 100644 --- a/tests/ui/crashes/ice-7169.rs +++ b/tests/ui/crashes/ice-7169.rs @@ -9,6 +9,4 @@ struct A { fn main() { if let Ok(_) = Ok::<_, ()>(A::::default()) {} //~^ redundant_pattern_matching - - } diff --git a/tests/ui/crashes/ice-7869.rs b/tests/ui/crashes/ice-7869.rs index 68648462b57aa..a5b557849abaa 100644 --- a/tests/ui/crashes/ice-7869.rs +++ b/tests/ui/crashes/ice-7869.rs @@ -1,6 +1,5 @@ enum Tila { -//~^ enum_variant_names - + //~^ enum_variant_names TyöAlkoi, TyöKeskeytyi, TyöValmis, diff --git a/tests/ui/crashes/ice-7869.stderr b/tests/ui/crashes/ice-7869.stderr index 7d70e3834e9dd..2377b4fd5b6bb 100644 --- a/tests/ui/crashes/ice-7869.stderr +++ b/tests/ui/crashes/ice-7869.stderr @@ -3,7 +3,6 @@ error: all variants have the same prefix: `Työ` | LL | / enum Tila { LL | | -LL | | LL | | TyöAlkoi, LL | | TyöKeskeytyi, LL | | TyöValmis, diff --git a/tests/ui/crashes/ice-8250.fixed b/tests/ui/crashes/ice-8250.fixed index 2474c47944ef2..b0c2ddb2450d0 100644 --- a/tests/ui/crashes/ice-8250.fixed +++ b/tests/ui/crashes/ice-8250.fixed @@ -2,7 +2,6 @@ fn _f(s: &str) -> Option<()> { let _ = s[1..].split('.').next()?; //~^ needless_splitn - Some(()) } diff --git a/tests/ui/crashes/ice-8250.rs b/tests/ui/crashes/ice-8250.rs index 8f938246f37af..ee0eb8e1eb1a2 100644 --- a/tests/ui/crashes/ice-8250.rs +++ b/tests/ui/crashes/ice-8250.rs @@ -2,7 +2,6 @@ fn _f(s: &str) -> Option<()> { let _ = s[1..].splitn(2, '.').next()?; //~^ needless_splitn - Some(()) } diff --git a/tests/ui/crashes/ice-9041.rs b/tests/ui/crashes/ice-9041.rs index 69e74e6e394b1..4b2a0f9531148 100644 --- a/tests/ui/crashes/ice-9041.rs +++ b/tests/ui/crashes/ice-9041.rs @@ -4,8 +4,6 @@ pub fn has_thing(things: &[Thing]) -> bool { let is_thing_ready = |_peer: &Thing| -> bool { todo!() }; things.iter().find(|p| is_thing_ready(p)).is_some() //~^ search_is_some - - } fn main() {} diff --git a/tests/ui/crashes/needless_lifetimes_impl_trait.fixed b/tests/ui/crashes/needless_lifetimes_impl_trait.fixed index cc5ed052d264c..da3b82a60c5f2 100644 --- a/tests/ui/crashes/needless_lifetimes_impl_trait.fixed +++ b/tests/ui/crashes/needless_lifetimes_impl_trait.fixed @@ -14,7 +14,7 @@ impl Foo for Baz<'_> {} impl Bar { fn baz(&self) -> impl Foo + '_ { - //~^ needless_lifetimes + //~^ needless_lifetimes Baz { bar: self } } diff --git a/tests/ui/crashes/needless_lifetimes_impl_trait.rs b/tests/ui/crashes/needless_lifetimes_impl_trait.rs index 258fb3118ef0b..456d315926dbe 100644 --- a/tests/ui/crashes/needless_lifetimes_impl_trait.rs +++ b/tests/ui/crashes/needless_lifetimes_impl_trait.rs @@ -14,7 +14,7 @@ impl<'a> Foo for Baz<'a> {} impl Bar { fn baz<'a>(&'a self) -> impl Foo + 'a { - //~^ needless_lifetimes + //~^ needless_lifetimes Baz { bar: self } } diff --git a/tests/ui/crashes/needless_pass_by_value-w-late-bound.fixed b/tests/ui/crashes/needless_pass_by_value-w-late-bound.fixed index 128ff4a1c036d..7d7286ceb99a8 100644 --- a/tests/ui/crashes/needless_pass_by_value-w-late-bound.fixed +++ b/tests/ui/crashes/needless_pass_by_value-w-late-bound.fixed @@ -7,5 +7,4 @@ struct Foo<'a>(&'a [(); 100]); fn test(x: &Foo<'_>) {} //~^ needless_pass_by_value - fn main() {} diff --git a/tests/ui/crashes/needless_pass_by_value-w-late-bound.rs b/tests/ui/crashes/needless_pass_by_value-w-late-bound.rs index b82cc831c6e0d..949cd5de7fb84 100644 --- a/tests/ui/crashes/needless_pass_by_value-w-late-bound.rs +++ b/tests/ui/crashes/needless_pass_by_value-w-late-bound.rs @@ -7,5 +7,4 @@ struct Foo<'a>(&'a [(); 100]); fn test(x: Foo<'_>) {} //~^ needless_pass_by_value - fn main() {} diff --git a/tests/ui/crate_level_checks/no_std_swap.rs b/tests/ui/crate_level_checks/no_std_swap.rs index e332e10ea4bae..66ca97690c175 100644 --- a/tests/ui/crate_level_checks/no_std_swap.rs +++ b/tests/ui/crate_level_checks/no_std_swap.rs @@ -11,6 +11,5 @@ pub fn main() { a = b; //~^ almost_swapped - b = a; } diff --git a/tests/ui/crate_level_checks/std_main_recursion.rs b/tests/ui/crate_level_checks/std_main_recursion.rs index b582d560668a7..50f82b59a96ee 100644 --- a/tests/ui/crate_level_checks/std_main_recursion.rs +++ b/tests/ui/crate_level_checks/std_main_recursion.rs @@ -4,5 +4,4 @@ fn main() { println!("Hello, World!"); main(); //~^ main_recursion - } diff --git a/tests/ui/dbg_macro/dbg_macro.fixed b/tests/ui/dbg_macro/dbg_macro.fixed index de715db8faab4..fd1a0d8934b3c 100644 --- a/tests/ui/dbg_macro/dbg_macro.fixed +++ b/tests/ui/dbg_macro/dbg_macro.fixed @@ -4,21 +4,18 @@ fn foo(n: u32) -> u32 { if let Some(n) = n.checked_sub(4) { n } else { n } //~^ dbg_macro - } fn bar(_: ()) {} fn factorial(n: u32) -> u32 { if n <= 1 { - //~^ dbg_macro + //~^ dbg_macro 1 //~^ dbg_macro - } else { n * factorial(n - 1) //~^ dbg_macro - } } @@ -31,7 +28,6 @@ fn main() { (1, 2, 3, 4, 5); //~^ dbg_macro - } fn issue9914() { @@ -49,7 +45,6 @@ fn issue9914() { () => { //~^ dbg_macro - }; } @@ -91,7 +86,6 @@ mod issue7274 { define_thing!(MyThing, { 2; //~^ dbg_macro - }); } @@ -99,14 +93,12 @@ mod issue7274 { pub fn issue8481() { 1; //~^ dbg_macro - } #[cfg(test)] fn foo2() { 1; //~^ dbg_macro - } #[cfg(test)] @@ -114,7 +106,6 @@ mod mod1 { fn func() { 1; //~^ dbg_macro - } } @@ -125,6 +116,5 @@ mod issue12131 { print!("{}", s); //~^ dbg_macro - } } diff --git a/tests/ui/dbg_macro/dbg_macro.rs b/tests/ui/dbg_macro/dbg_macro.rs index 90a72d1316678..c96e2c7251c29 100644 --- a/tests/ui/dbg_macro/dbg_macro.rs +++ b/tests/ui/dbg_macro/dbg_macro.rs @@ -4,21 +4,18 @@ fn foo(n: u32) -> u32 { if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n } //~^ dbg_macro - } fn bar(_: ()) {} fn factorial(n: u32) -> u32 { if dbg!(n <= 1) { - //~^ dbg_macro + //~^ dbg_macro dbg!(1) //~^ dbg_macro - } else { dbg!(n * factorial(n - 1)) //~^ dbg_macro - } } @@ -31,7 +28,6 @@ fn main() { dbg!(1, 2, 3, 4, 5); //~^ dbg_macro - } fn issue9914() { @@ -49,7 +45,6 @@ fn issue9914() { () => { dbg!(); //~^ dbg_macro - }; } @@ -91,7 +86,6 @@ mod issue7274 { define_thing!(MyThing, { dbg!(2); //~^ dbg_macro - }); } @@ -99,14 +93,12 @@ mod issue7274 { pub fn issue8481() { dbg!(1); //~^ dbg_macro - } #[cfg(test)] fn foo2() { dbg!(1); //~^ dbg_macro - } #[cfg(test)] @@ -114,7 +106,6 @@ mod mod1 { fn func() { dbg!(1); //~^ dbg_macro - } } @@ -125,6 +116,5 @@ mod issue12131 { print!("{}", dbg!(s)); //~^ dbg_macro - } } diff --git a/tests/ui/dbg_macro/dbg_macro.stderr b/tests/ui/dbg_macro/dbg_macro.stderr index ee0cfc12b3479..83b497a539c07 100644 --- a/tests/ui/dbg_macro/dbg_macro.stderr +++ b/tests/ui/dbg_macro/dbg_macro.stderr @@ -12,7 +12,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n } | ~~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:12:8 + --> tests/ui/dbg_macro/dbg_macro.rs:11:8 | LL | if dbg!(n <= 1) { | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | if n <= 1 { | ~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:15:9 + --> tests/ui/dbg_macro/dbg_macro.rs:14:9 | LL | dbg!(1) | ^^^^^^^ @@ -34,7 +34,7 @@ LL | 1 | error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:19:9 + --> tests/ui/dbg_macro/dbg_macro.rs:17:9 | LL | dbg!(n * factorial(n - 1)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | n * factorial(n - 1) | error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:26:5 + --> tests/ui/dbg_macro/dbg_macro.rs:23:5 | LL | dbg!(42); | ^^^^^^^^ @@ -56,7 +56,7 @@ LL | 42; | ~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:29:14 + --> tests/ui/dbg_macro/dbg_macro.rs:26:14 | LL | foo(3) + dbg!(factorial(4)); | ^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | foo(3) + factorial(4); | ~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:32:5 + --> tests/ui/dbg_macro/dbg_macro.rs:29:5 | LL | dbg!(1, 2, 3, 4, 5); | ^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | (1, 2, 3, 4, 5); | ~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:56:5 + --> tests/ui/dbg_macro/dbg_macro.rs:51:5 | LL | dbg!(); | ^^^^^^ @@ -89,7 +89,7 @@ LL - dbg!(); | error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:60:13 + --> tests/ui/dbg_macro/dbg_macro.rs:55:13 | LL | let _ = dbg!(); | ^^^^^^ @@ -100,7 +100,7 @@ LL | let _ = (); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:63:9 + --> tests/ui/dbg_macro/dbg_macro.rs:58:9 | LL | bar(dbg!()); | ^^^^^^ @@ -111,7 +111,7 @@ LL | bar(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:66:10 + --> tests/ui/dbg_macro/dbg_macro.rs:61:10 | LL | foo!(dbg!()); | ^^^^^^ @@ -122,7 +122,7 @@ LL | foo!(()); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:69:16 + --> tests/ui/dbg_macro/dbg_macro.rs:64:16 | LL | foo2!(foo!(dbg!())); | ^^^^^^ @@ -133,7 +133,7 @@ LL | foo2!(foo!(())); | ~~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:50:13 + --> tests/ui/dbg_macro/dbg_macro.rs:46:13 | LL | dbg!(); | ^^^^^^ @@ -148,7 +148,7 @@ LL - dbg!(); | error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:92:9 + --> tests/ui/dbg_macro/dbg_macro.rs:87:9 | LL | dbg!(2); | ^^^^^^^ @@ -159,7 +159,7 @@ LL | 2; | ~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:100:5 + --> tests/ui/dbg_macro/dbg_macro.rs:94:5 | LL | dbg!(1); | ^^^^^^^ @@ -170,7 +170,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:107:5 + --> tests/ui/dbg_macro/dbg_macro.rs:100:5 | LL | dbg!(1); | ^^^^^^^ @@ -181,7 +181,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:115:9 + --> tests/ui/dbg_macro/dbg_macro.rs:107:9 | LL | dbg!(1); | ^^^^^^^ @@ -192,7 +192,7 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:123:31 + --> tests/ui/dbg_macro/dbg_macro.rs:114:31 | LL | println!("dbg: {:?}", dbg!(s)); | ^^^^^^^ @@ -203,7 +203,7 @@ LL | println!("dbg: {:?}", s); | ~ error: the `dbg!` macro is intended as a debugging tool - --> tests/ui/dbg_macro/dbg_macro.rs:126:22 + --> tests/ui/dbg_macro/dbg_macro.rs:117:22 | LL | print!("{}", dbg!(s)); | ^^^^^^^ diff --git a/tests/ui/dbg_macro/dbg_macro_unfixable.rs b/tests/ui/dbg_macro/dbg_macro_unfixable.rs index bd16306b89db2..1a5119651b539 100644 --- a/tests/ui/dbg_macro/dbg_macro_unfixable.rs +++ b/tests/ui/dbg_macro/dbg_macro_unfixable.rs @@ -14,5 +14,4 @@ fn main() { dbg!(1, 2, dbg!(3, 4)); //~^ dbg_macro //~| dbg_macro - } diff --git a/tests/ui/declare_interior_mutable_const/enums.rs b/tests/ui/declare_interior_mutable_const/enums.rs index 0f454786156e1..c87468277fb31 100644 --- a/tests/ui/declare_interior_mutable_const/enums.rs +++ b/tests/ui/declare_interior_mutable_const/enums.rs @@ -45,8 +45,7 @@ struct NestedOutermost { // a constant with enums should be linted according to its value, no matter how structs involve. const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost { -//~^ declare_interior_mutable_const - + //~^ declare_interior_mutable_const outer: NestedOuter::NestedInner(NestedInner { inner: NestedInnermost::Unfrozen(AtomicUsize::new(2)), }), @@ -60,14 +59,14 @@ const NESTED_FROZEN_VARIANT: NestedOutermost = NestedOutermost { trait AssocConsts { // When there's no default value, lint it only according to its type. // Further details are on the corresponding code (`NonCopyConst::check_trait_item`). -const TO_BE_UNFROZEN_VARIANT: OptionalCell; -//~^ declare_interior_mutable_const -const TO_BE_FROZEN_VARIANT: OptionalCell; -//~^ declare_interior_mutable_const + const TO_BE_UNFROZEN_VARIANT: OptionalCell; + //~^ declare_interior_mutable_const + const TO_BE_FROZEN_VARIANT: OptionalCell; + //~^ declare_interior_mutable_const // Lint default values accordingly. -const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); -//~^ declare_interior_mutable_const + const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); + //~^ declare_interior_mutable_const const DEFAULTED_ON_FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen; } @@ -93,8 +92,8 @@ trait AssocTypes { impl AssocTypes for u64 { type ToBeUnfrozen = AtomicUsize; -const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); -//~^ declare_interior_mutable_const + const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); + //~^ declare_interior_mutable_const const TO_BE_FROZEN_VARIANT: Option = None; } @@ -106,30 +105,30 @@ enum BothOfCellAndGeneric { } impl BothOfCellAndGeneric { -const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); -//~^ declare_interior_mutable_const + const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); + //~^ declare_interior_mutable_const // This is a false positive. The argument about this is on `is_value_unfrozen_raw` -const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); -//~^ declare_interior_mutable_const + const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); + //~^ declare_interior_mutable_const const FROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Frozen(5); // This is what is likely to be a false negative when one tries to fix // the `GENERIC_VARIANT` false positive. -const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); -//~^ declare_interior_mutable_const + const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); + //~^ declare_interior_mutable_const } // associated types here is basically the same as the one above. trait BothOfCellAndGenericWithAssocType { type AssocType; -const UNFROZEN_VARIANT: BothOfCellAndGeneric = -//~^ declare_interior_mutable_const + const UNFROZEN_VARIANT: BothOfCellAndGeneric = + //~^ declare_interior_mutable_const BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); -const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); -//~^ declare_interior_mutable_const + const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); + //~^ declare_interior_mutable_const const FROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Frozen(5); } diff --git a/tests/ui/declare_interior_mutable_const/enums.stderr b/tests/ui/declare_interior_mutable_const/enums.stderr index a6f14ec71febc..32839d14f0ed3 100644 --- a/tests/ui/declare_interior_mutable_const/enums.stderr +++ b/tests/ui/declare_interior_mutable_const/enums.stderr @@ -21,7 +21,6 @@ error: a `const` item should not be interior mutable | LL | / const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost { LL | | -LL | | LL | | outer: NestedOuter::NestedInner(NestedInner { LL | | inner: NestedInnermost::Unfrozen(AtomicUsize::new(2)), LL | | }), @@ -31,60 +30,60 @@ LL | | }; = help: consider making this a static item error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:63:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:62:5 | -LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:65:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:64:5 | -LL | const TO_BE_FROZEN_VARIANT: OptionalCell; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const TO_BE_FROZEN_VARIANT: OptionalCell; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:69:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:68:5 | -LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:96:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:95:5 | -LL | const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const TO_BE_UNFROZEN_VARIANT: Option = Some(Self::ToBeUnfrozen::new(4)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:109:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:108:5 | -LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:113:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:112:5 | -LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:120:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:119:5 | -LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:128:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:127:5 | -LL | / const UNFROZEN_VARIANT: BothOfCellAndGeneric = +LL | / const UNFROZEN_VARIANT: BothOfCellAndGeneric = LL | | LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); | |____________________________________________________________________^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/enums.rs:131:1 + --> tests/ui/declare_interior_mutable_const/enums.rs:130:5 | -LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const GENERIC_VARIANT: BothOfCellAndGeneric = BothOfCellAndGeneric::Generic(std::ptr::null()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/declare_interior_mutable_const/others.rs b/tests/ui/declare_interior_mutable_const/others.rs index 9820626ae4540..7ce04a3f2c340 100644 --- a/tests/ui/declare_interior_mutable_const/others.rs +++ b/tests/ui/declare_interior_mutable_const/others.rs @@ -14,12 +14,10 @@ const CELL: Cell = Cell::new(6); const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); //~^ declare_interior_mutable_const - macro_rules! declare_const { ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; //~^ declare_interior_mutable_const - }; } declare_const!(_ONCE: Once = Once::new()); diff --git a/tests/ui/declare_interior_mutable_const/others.stderr b/tests/ui/declare_interior_mutable_const/others.stderr index 3c388e3bcf376..09299b290416d 100644 --- a/tests/ui/declare_interior_mutable_const/others.stderr +++ b/tests/ui/declare_interior_mutable_const/others.stderr @@ -25,7 +25,7 @@ LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], V = help: consider making this a static item error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/others.rs:20:9 + --> tests/ui/declare_interior_mutable_const/others.rs:19:9 | LL | const $name: $ty = $e; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | declare_const!(_ONCE: Once = Once::new()); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/others.rs:49:13 + --> tests/ui/declare_interior_mutable_const/others.rs:47:13 | LL | const _BAZ: Cell = Cell::new(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/declare_interior_mutable_const/traits.rs b/tests/ui/declare_interior_mutable_const/traits.rs index 83d6c1307ea29..d3139be6859f3 100644 --- a/tests/ui/declare_interior_mutable_const/traits.rs +++ b/tests/ui/declare_interior_mutable_const/traits.rs @@ -8,14 +8,13 @@ macro_rules! declare_const { ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; //~^ declare_interior_mutable_const - }; } // a constant whose type is a concrete type should be linted at the definition site. trait ConcreteTypes { -const ATOMIC: AtomicUsize; -//~^ declare_interior_mutable_const + const ATOMIC: AtomicUsize; + //~^ declare_interior_mutable_const const INTEGER: u64; const STRING: String; declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); @@ -43,8 +42,8 @@ trait GenericTypes { impl GenericTypes for u64 { const TO_REMAIN_GENERIC: T = T::DEFAULT; -const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); -//~^ declare_interior_mutable_const + const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); + //~^ declare_interior_mutable_const } // a helper type used below @@ -69,10 +68,10 @@ impl AssocTypes for Vec { type ToBeGenericParam = T; const TO_BE_FROZEN: Self::ToBeFrozen = 12; -const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); -//~^ declare_interior_mutable_const -const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); -//~^ declare_interior_mutable_const + const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); + //~^ declare_interior_mutable_const + const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); + //~^ declare_interior_mutable_const const WRAPPED_TO_BE_GENERIC_PARAM: Wrapper = Wrapper(T::DEFAULT); } @@ -91,8 +90,8 @@ where T: AssocTypesHelper, { const NOT_BOUNDED: T::NotToBeBounded; -const BOUNDED: T::ToBeBounded; -//~^ declare_interior_mutable_const + const BOUNDED: T::ToBeBounded; + //~^ declare_interior_mutable_const } impl AssocTypesFromGenericParam for u64 @@ -120,24 +119,24 @@ impl SelfType for u64 { impl SelfType for AtomicUsize { // this (interior mutable `Self` const) exists in `parking_lot`. // `const_trait_impl` will replace it in the future, hopefully. -const SELF: Self = AtomicUsize::new(17); -//~^ declare_interior_mutable_const -const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); -//~^ declare_interior_mutable_const + const SELF: Self = AtomicUsize::new(17); + //~^ declare_interior_mutable_const + const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); + //~^ declare_interior_mutable_const } // Even though a constant contains a generic type, if it also have an interior mutable type, // it should be linted at the definition site. trait BothOfCellAndGeneric { -const DIRECT: Cell; -//~^ declare_interior_mutable_const -const INDIRECT: Cell<*const T>; -//~^ declare_interior_mutable_const + const DIRECT: Cell; + //~^ declare_interior_mutable_const + const INDIRECT: Cell<*const T>; + //~^ declare_interior_mutable_const } impl BothOfCellAndGeneric for u64 { -const DIRECT: Cell = Cell::new(T::DEFAULT); -//~^ declare_interior_mutable_const + const DIRECT: Cell = Cell::new(T::DEFAULT); + //~^ declare_interior_mutable_const const INDIRECT: Cell<*const T> = Cell::new(std::ptr::null()); } @@ -149,15 +148,15 @@ impl Local where T: ConstDefault + AssocTypesHelper, { -const ATOMIC: AtomicUsize = AtomicUsize::new(18); -//~^ declare_interior_mutable_const + const ATOMIC: AtomicUsize = AtomicUsize::new(18); + //~^ declare_interior_mutable_const const COW: Cow<'static, str> = Cow::Borrowed("tuvwxy"); const GENERIC_TYPE: T = T::DEFAULT; const ASSOC_TYPE: T::NotToBeBounded = T::NOT_TO_BE_BOUNDED; -const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); -//~^ declare_interior_mutable_const + const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); + //~^ declare_interior_mutable_const } fn main() {} diff --git a/tests/ui/declare_interior_mutable_const/traits.stderr b/tests/ui/declare_interior_mutable_const/traits.stderr index 1be6b9d2ec609..b03dd7a084033 100644 --- a/tests/ui/declare_interior_mutable_const/traits.stderr +++ b/tests/ui/declare_interior_mutable_const/traits.stderr @@ -1,8 +1,8 @@ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:17:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:16:5 | -LL | const ATOMIC: AtomicUsize; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const ATOMIC: AtomicUsize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::declare_interior_mutable_const)]` @@ -19,70 +19,70 @@ LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info) error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:46:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:45:5 | -LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:72:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:71:5 | -LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:74:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:73:5 | -LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper = Wrapper(AtomicUsize::new(14)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:94:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:93:5 | -LL | const BOUNDED: T::ToBeBounded; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const BOUNDED: T::ToBeBounded; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:123:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:122:5 | -LL | const SELF: Self = AtomicUsize::new(17); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const SELF: Self = AtomicUsize::new(17); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:125:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:124:5 | -LL | const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const WRAPPED_SELF: Option = Some(AtomicUsize::new(21)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:132:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:131:5 | -LL | const DIRECT: Cell; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | const DIRECT: Cell; + | ^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:134:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:133:5 | -LL | const INDIRECT: Cell<*const T>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const INDIRECT: Cell<*const T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:139:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:138:5 | -LL | const DIRECT: Cell = Cell::new(T::DEFAULT); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const DIRECT: Cell = Cell::new(T::DEFAULT); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:152:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:151:5 | -LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a `const` item should not be interior mutable - --> tests/ui/declare_interior_mutable_const/traits.rs:159:1 + --> tests/ui/declare_interior_mutable_const/traits.rs:158:5 | -LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 13 previous errors diff --git a/tests/ui/default_numeric_fallback_f64.fixed b/tests/ui/default_numeric_fallback_f64.fixed index a4d66f951f756..cf1ccab688c5d 100644 --- a/tests/ui/default_numeric_fallback_f64.fixed +++ b/tests/ui/default_numeric_fallback_f64.fixed @@ -30,7 +30,7 @@ mod basic_expr { //~| default_numeric_fallback //~| default_numeric_fallback let x = match 1.0_f64 { - //~^ default_numeric_fallback + //~^ default_numeric_fallback _ => 1.0_f64, //~^ default_numeric_fallback }; diff --git a/tests/ui/default_numeric_fallback_f64.rs b/tests/ui/default_numeric_fallback_f64.rs index d1446c35557fc..345e65e0b4f95 100644 --- a/tests/ui/default_numeric_fallback_f64.rs +++ b/tests/ui/default_numeric_fallback_f64.rs @@ -30,7 +30,7 @@ mod basic_expr { //~| default_numeric_fallback //~| default_numeric_fallback let x = match 1. { - //~^ default_numeric_fallback + //~^ default_numeric_fallback _ => 1., //~^ default_numeric_fallback }; diff --git a/tests/ui/default_numeric_fallback_i32.fixed b/tests/ui/default_numeric_fallback_i32.fixed index e95c49dd6b66a..496408aa9e87d 100644 --- a/tests/ui/default_numeric_fallback_i32.fixed +++ b/tests/ui/default_numeric_fallback_i32.fixed @@ -29,7 +29,7 @@ mod basic_expr { //~| default_numeric_fallback //~| default_numeric_fallback let x = match 1_i32 { - //~^ default_numeric_fallback + //~^ default_numeric_fallback 1_i32 => 1_i32, //~^ default_numeric_fallback //~| default_numeric_fallback diff --git a/tests/ui/default_numeric_fallback_i32.rs b/tests/ui/default_numeric_fallback_i32.rs index 377c8934c5be3..90fcf4091ddcf 100644 --- a/tests/ui/default_numeric_fallback_i32.rs +++ b/tests/ui/default_numeric_fallback_i32.rs @@ -29,7 +29,7 @@ mod basic_expr { //~| default_numeric_fallback //~| default_numeric_fallback let x = match 1 { - //~^ default_numeric_fallback + //~^ default_numeric_fallback 1 => 1, //~^ default_numeric_fallback //~| default_numeric_fallback diff --git a/tests/ui/default_union_representation.rs b/tests/ui/default_union_representation.rs index 90d1a20e6d8db..92c429c79a078 100644 --- a/tests/ui/default_union_representation.rs +++ b/tests/ui/default_union_representation.rs @@ -3,8 +3,7 @@ #![allow(clippy::repr_packed_without_abi)] union NoAttribute { -//~^ default_union_representation - + //~^ default_union_representation a: i32, b: u32, } @@ -17,8 +16,7 @@ union ReprC { #[repr(packed)] union ReprPacked { -//~^ default_union_representation - + //~^ default_union_representation a: i32, b: u32, } @@ -37,8 +35,7 @@ union ReprCAlign { #[repr(align(32))] union ReprAlign { -//~^ default_union_representation - + //~^ default_union_representation a: i32, b: u32, } @@ -59,8 +56,7 @@ union ZSTsAndField2 { f3: (), } union ZSTAndTwoFields { -//~^ default_union_representation - + //~^ default_union_representation f0: u32, f1: u64, f2: (), diff --git a/tests/ui/default_union_representation.stderr b/tests/ui/default_union_representation.stderr index 07c106d4092d7..d558a3e8de1b9 100644 --- a/tests/ui/default_union_representation.stderr +++ b/tests/ui/default_union_representation.stderr @@ -3,7 +3,6 @@ error: this union has the default representation | LL | / union NoAttribute { LL | | -LL | | LL | | a: i32, LL | | b: u32, LL | | } @@ -14,11 +13,10 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::default_union_representation)]` error: this union has the default representation - --> tests/ui/default_union_representation.rs:19:1 + --> tests/ui/default_union_representation.rs:18:1 | LL | / union ReprPacked { LL | | -LL | | LL | | a: i32, LL | | b: u32, LL | | } @@ -27,11 +25,10 @@ LL | | } = help: consider annotating `ReprPacked` with `#[repr(C)]` to explicitly specify memory layout error: this union has the default representation - --> tests/ui/default_union_representation.rs:39:1 + --> tests/ui/default_union_representation.rs:37:1 | LL | / union ReprAlign { LL | | -LL | | LL | | a: i32, LL | | b: u32, LL | | } @@ -40,11 +37,10 @@ LL | | } = help: consider annotating `ReprAlign` with `#[repr(C)]` to explicitly specify memory layout error: this union has the default representation - --> tests/ui/default_union_representation.rs:61:1 + --> tests/ui/default_union_representation.rs:58:1 | LL | / union ZSTAndTwoFields { LL | | -LL | | LL | | f0: u32, LL | | f1: u64, LL | | f2: (), diff --git a/tests/ui/deref_addrof_double_trigger.rs b/tests/ui/deref_addrof_double_trigger.rs index 928907f516a45..b08b2aba23196 100644 --- a/tests/ui/deref_addrof_double_trigger.rs +++ b/tests/ui/deref_addrof_double_trigger.rs @@ -10,13 +10,10 @@ fn main() { let b = **&&a; //~^ deref_addrof - - { let mut x = 10; let y = *&mut x; //~^ deref_addrof - } { @@ -25,6 +22,5 @@ fn main() { let mut x = 10; let y = **&mut &mut x; //~^ deref_addrof - } } diff --git a/tests/ui/deref_addrof_double_trigger.stderr b/tests/ui/deref_addrof_double_trigger.stderr index 8e69f986b056a..9ac60dd6d544f 100644 --- a/tests/ui/deref_addrof_double_trigger.stderr +++ b/tests/ui/deref_addrof_double_trigger.stderr @@ -8,13 +8,13 @@ LL | let b = **&&a; = help: to override `-D warnings` add `#[allow(clippy::deref_addrof)]` error: immediately dereferencing a reference - --> tests/ui/deref_addrof_double_trigger.rs:17:17 + --> tests/ui/deref_addrof_double_trigger.rs:15:17 | LL | let y = *&mut x; | ^^^^^^^ help: try: `x` error: immediately dereferencing a reference - --> tests/ui/deref_addrof_double_trigger.rs:26:18 + --> tests/ui/deref_addrof_double_trigger.rs:23:18 | LL | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try: `&mut x` diff --git a/tests/ui/derivable_impls.rs b/tests/ui/derivable_impls.rs index 1df2d88824b0b..4826c5497b4a3 100644 --- a/tests/ui/derivable_impls.rs +++ b/tests/ui/derivable_impls.rs @@ -18,7 +18,7 @@ struct FooDefault<'a> { } impl std::default::Default for FooDefault<'_> { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { Self { a: false, @@ -40,7 +40,7 @@ impl std::default::Default for FooDefault<'_> { struct TupleDefault(bool, i32, u64); impl std::default::Default for TupleDefault { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { Self(false, 0, 0u64) } @@ -93,7 +93,7 @@ impl Default for FooNDVec { struct StrDefault<'a>(&'a str); impl Default for StrDefault<'_> { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { Self("") } @@ -120,7 +120,7 @@ mac!(0); struct Y(u32); impl Default for Y { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { Self(mac!()) } @@ -160,7 +160,7 @@ struct WithoutSelfCurly { } impl Default for WithoutSelfCurly { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { WithoutSelfCurly { a: false } } @@ -169,7 +169,7 @@ impl Default for WithoutSelfCurly { struct WithoutSelfParan(bool); impl Default for WithoutSelfParan { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { WithoutSelfParan(false) } @@ -192,7 +192,7 @@ pub struct DirectDefaultDefaultCall { } impl Default for DirectDefaultDefaultCall { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { // When calling `Default::default()` in all fields, we know it is the same as deriving. Self { v: Default::default() } @@ -204,7 +204,7 @@ pub struct EquivalentToDefaultDefaultCallVec { } impl Default for EquivalentToDefaultDefaultCallVec { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { // The body of `::default()` is `Vec::new()`, so they are equivalent. Self { v: Vec::new() } @@ -232,7 +232,7 @@ pub struct EquivalentToDefaultDefaultCallLocal { } impl Default for EquivalentToDefaultDefaultCallLocal { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { // The body of `::default()` is `S::new()`, so they are equivalent. Self { v: S::new() } @@ -272,7 +272,7 @@ pub struct RepeatDefault1 { } impl Default for RepeatDefault1 { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { RepeatDefault1 { a: [0; 32] } } @@ -307,7 +307,7 @@ pub enum SimpleEnum { } impl Default for SimpleEnum { -//~^ derivable_impls + //~^ derivable_impls fn default() -> Self { SimpleEnum::Bar } diff --git a/tests/ui/derive.rs b/tests/ui/derive.rs index 2e8b5959d498d..75d888c31070a 100644 --- a/tests/ui/derive.rs +++ b/tests/ui/derive.rs @@ -11,7 +11,7 @@ struct Qux; impl Clone for Qux { -//~^ expl_impl_clone_on_copy + //~^ expl_impl_clone_on_copy fn clone(&self) -> Self { Qux @@ -37,7 +37,7 @@ struct Lt<'a> { } impl<'a> Clone for Lt<'a> { -//~^ expl_impl_clone_on_copy + //~^ expl_impl_clone_on_copy fn clone(&self) -> Self { unimplemented!() @@ -50,7 +50,7 @@ struct BigArray { } impl Clone for BigArray { -//~^ expl_impl_clone_on_copy + //~^ expl_impl_clone_on_copy fn clone(&self) -> Self { unimplemented!() @@ -63,7 +63,7 @@ struct FnPtr { } impl Clone for FnPtr { -//~^ expl_impl_clone_on_copy + //~^ expl_impl_clone_on_copy fn clone(&self) -> Self { unimplemented!() @@ -85,7 +85,7 @@ impl Clone for Generic { #[derive(Copy)] struct Generic2(T); impl Clone for Generic2 { -//~^ expl_impl_clone_on_copy + //~^ expl_impl_clone_on_copy fn clone(&self) -> Self { Self(self.0.clone()) diff --git a/tests/ui/derive_ord_xor_partial_ord.rs b/tests/ui/derive_ord_xor_partial_ord.rs index 0a2a1ee7bc9fa..3ef4ee9463dca 100644 --- a/tests/ui/derive_ord_xor_partial_ord.rs +++ b/tests/ui/derive_ord_xor_partial_ord.rs @@ -45,7 +45,7 @@ impl PartialOrd for DeriveOrdWithExplicitType struct DerivePartialOrd; impl std::cmp::Ord for DerivePartialOrd { -//~^ derive_ord_xor_partial_ord + //~^ derive_ord_xor_partial_ord fn cmp(&self, other: &Self) -> Ordering { Ordering::Less @@ -67,7 +67,7 @@ mod use_ord { struct DerivePartialOrdInUseOrd; impl Ord for DerivePartialOrdInUseOrd { - //~^ derive_ord_xor_partial_ord + //~^ derive_ord_xor_partial_ord fn cmp(&self, other: &Self) -> Ordering { Ordering::Less diff --git a/tests/ui/disallowed_names.rs b/tests/ui/disallowed_names.rs index d6e26dfcf202d..30fbdbc1fdc82 100644 --- a/tests/ui/disallowed_names.rs +++ b/tests/ui/disallowed_names.rs @@ -12,8 +12,6 @@ fn test(foo: ()) {} //~^ disallowed_names - - fn main() { let foo = 42; //~^ disallowed_names @@ -38,22 +36,18 @@ fn main() { //~^ disallowed_names //~| disallowed_names //~| disallowed_names - - - _ => (), } } fn issue_1647(mut foo: u8) { -//~^ disallowed_names + //~^ disallowed_names let mut baz = 0; //~^ disallowed_names if let Some(mut quux) = Some(42) {} //~^ disallowed_names - } fn issue_1647_ref() { @@ -62,7 +56,6 @@ fn issue_1647_ref() { if let Some(ref quux) = Some(42) {} //~^ disallowed_names - } fn issue_1647_ref_mut() { @@ -71,7 +64,6 @@ fn issue_1647_ref_mut() { if let Some(ref mut quux) = Some(42) {} //~^ disallowed_names - } #[cfg(test)] diff --git a/tests/ui/disallowed_names.stderr b/tests/ui/disallowed_names.stderr index e412d27e7fca8..09398ebbab77f 100644 --- a/tests/ui/disallowed_names.stderr +++ b/tests/ui/disallowed_names.stderr @@ -8,79 +8,79 @@ LL | fn test(foo: ()) {} = help: to override `-D warnings` add `#[allow(clippy::disallowed_names)]` error: use of a disallowed/placeholder name `foo` - --> tests/ui/disallowed_names.rs:18:9 + --> tests/ui/disallowed_names.rs:16:9 | LL | let foo = 42; | ^^^ error: use of a disallowed/placeholder name `baz` - --> tests/ui/disallowed_names.rs:21:9 + --> tests/ui/disallowed_names.rs:19:9 | LL | let baz = 42; | ^^^ error: use of a disallowed/placeholder name `quux` - --> tests/ui/disallowed_names.rs:24:9 + --> tests/ui/disallowed_names.rs:22:9 | LL | let quux = 42; | ^^^^ error: use of a disallowed/placeholder name `foo` - --> tests/ui/disallowed_names.rs:37:10 + --> tests/ui/disallowed_names.rs:35:10 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ error: use of a disallowed/placeholder name `baz` - --> tests/ui/disallowed_names.rs:37:20 + --> tests/ui/disallowed_names.rs:35:20 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^ error: use of a disallowed/placeholder name `quux` - --> tests/ui/disallowed_names.rs:37:26 + --> tests/ui/disallowed_names.rs:35:26 | LL | (foo, Some(baz), quux @ Some(_)) => (), | ^^^^ error: use of a disallowed/placeholder name `foo` - --> tests/ui/disallowed_names.rs:48:19 + --> tests/ui/disallowed_names.rs:43:19 | LL | fn issue_1647(mut foo: u8) { | ^^^ error: use of a disallowed/placeholder name `baz` - --> tests/ui/disallowed_names.rs:51:13 + --> tests/ui/disallowed_names.rs:46:13 | LL | let mut baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> tests/ui/disallowed_names.rs:54:21 + --> tests/ui/disallowed_names.rs:49:21 | LL | if let Some(mut quux) = Some(42) {} | ^^^^ error: use of a disallowed/placeholder name `baz` - --> tests/ui/disallowed_names.rs:60:13 + --> tests/ui/disallowed_names.rs:54:13 | LL | let ref baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> tests/ui/disallowed_names.rs:63:21 + --> tests/ui/disallowed_names.rs:57:21 | LL | if let Some(ref quux) = Some(42) {} | ^^^^ error: use of a disallowed/placeholder name `baz` - --> tests/ui/disallowed_names.rs:69:17 + --> tests/ui/disallowed_names.rs:62:17 | LL | let ref mut baz = 0; | ^^^ error: use of a disallowed/placeholder name `quux` - --> tests/ui/disallowed_names.rs:72:25 + --> tests/ui/disallowed_names.rs:65:25 | LL | if let Some(ref mut quux) = Some(42) {} | ^^^^ diff --git a/tests/ui/disallowed_script_idents.rs b/tests/ui/disallowed_script_idents.rs index 00308d0063a89..08fd1d9669ee9 100644 --- a/tests/ui/disallowed_script_idents.rs +++ b/tests/ui/disallowed_script_idents.rs @@ -14,5 +14,4 @@ fn main() { // Same for japanese. let カウンタ = 10; //~^ disallowed_script_idents - } diff --git a/tests/ui/diverging_sub_expression.rs b/tests/ui/diverging_sub_expression.rs index e3b40a0cae11f..b226ba69799e7 100644 --- a/tests/ui/diverging_sub_expression.rs +++ b/tests/ui/diverging_sub_expression.rs @@ -20,10 +20,8 @@ fn main() { b || diverge(); //~^ diverging_sub_expression - b || A.foo(); //~^ diverging_sub_expression - } #[allow(dead_code, unused_variables)] diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index 617c7a0be8abc..3e417aa39cd85 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -8,31 +8,31 @@ LL | b || diverge(); = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:24:10 + --> tests/ui/diverging_sub_expression.rs:23:10 | LL | b || A.foo(); | ^^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:36:26 + --> tests/ui/diverging_sub_expression.rs:34:26 | LL | 6 => true || return, | ^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:39:26 + --> tests/ui/diverging_sub_expression.rs:37:26 | LL | 7 => true || continue, | ^^^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:44:26 + --> tests/ui/diverging_sub_expression.rs:42:26 | LL | 3 => true || diverge(), | ^^^^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:49:30 + --> tests/ui/diverging_sub_expression.rs:47:30 | LL | _ => true || panic!("boo"), | ^^^^^^^^^^^^^ @@ -40,31 +40,31 @@ LL | _ => true || panic!("boo"), = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:54:29 + --> tests/ui/diverging_sub_expression.rs:52:29 | LL | 15 => true || { return; }, | ^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:57:30 + --> tests/ui/diverging_sub_expression.rs:55:30 | LL | 16 => false || { return; }, | ^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:61:29 + --> tests/ui/diverging_sub_expression.rs:59:29 | LL | 17 => true || { return }, | ^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:64:30 + --> tests/ui/diverging_sub_expression.rs:62:30 | LL | 18 => false || { return }, | ^^^^^^ error: sub-expression diverges - --> tests/ui/diverging_sub_expression.rs:75:26 + --> tests/ui/diverging_sub_expression.rs:73:26 | LL | _ => true || break, | ^^^^^ diff --git a/tests/ui/doc/issue_12795.fixed b/tests/ui/doc/issue_12795.fixed index ff252c07ae8c4..4172438a82a6e 100644 --- a/tests/ui/doc/issue_12795.fixed +++ b/tests/ui/doc/issue_12795.fixed @@ -6,8 +6,4 @@ //~| doc_markdown //~| doc_markdown - - - - pub fn main() {} diff --git a/tests/ui/doc/issue_12795.rs b/tests/ui/doc/issue_12795.rs index b7e89cf4ea0e9..dbc03cc708656 100644 --- a/tests/ui/doc/issue_12795.rs +++ b/tests/ui/doc/issue_12795.rs @@ -6,8 +6,4 @@ //~| doc_markdown //~| doc_markdown - - - - pub fn main() {} diff --git a/tests/ui/doc_errors.rs b/tests/ui/doc_errors.rs index 65783b22a58c0..f67e3216c01e8 100644 --- a/tests/ui/doc_errors.rs +++ b/tests/ui/doc_errors.rs @@ -5,28 +5,27 @@ use std::io; pub fn pub_fn_missing_errors_header() -> Result<(), ()> { -//~^ missing_errors_doc - + //~^ missing_errors_doc unimplemented!(); } pub async fn async_pub_fn_missing_errors_header() -> Result<(), ()> { -//~^ missing_errors_doc + //~^ missing_errors_doc unimplemented!(); } /// This is not sufficiently documented. pub fn pub_fn_returning_io_result() -> io::Result<()> { -//~^ missing_errors_doc + //~^ missing_errors_doc unimplemented!(); } /// This is not sufficiently documented. pub async fn async_pub_fn_returning_io_result() -> io::Result<()> { -//~^ missing_errors_doc + //~^ missing_errors_doc unimplemented!(); } @@ -58,14 +57,14 @@ pub struct Struct1; impl Struct1 { /// This is not sufficiently documented. pub fn pub_method_missing_errors_header() -> Result<(), ()> { - //~^ missing_errors_doc + //~^ missing_errors_doc unimplemented!(); } /// This is not sufficiently documented. pub async fn async_pub_method_missing_errors_header() -> Result<(), ()> { - //~^ missing_errors_doc + //~^ missing_errors_doc unimplemented!(); } @@ -119,7 +118,6 @@ pub trait Trait1 { fn trait_method_missing_errors_header() -> Result<(), ()>; //~^ missing_errors_doc - /// # Errors /// A description of the errors goes here. fn trait_method_with_errors_header() -> Result<(), ()>; diff --git a/tests/ui/doc_errors.stderr b/tests/ui/doc_errors.stderr index e719c186e6008..aeb2516e51231 100644 --- a/tests/ui/doc_errors.stderr +++ b/tests/ui/doc_errors.stderr @@ -8,37 +8,37 @@ LL | pub fn pub_fn_missing_errors_header() -> Result<(), ()> { = help: to override `-D warnings` add `#[allow(clippy::missing_errors_doc)]` error: docs for function returning `Result` missing `# Errors` section - --> tests/ui/doc_errors.rs:14:1 + --> tests/ui/doc_errors.rs:13:1 | LL | pub async fn async_pub_fn_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> tests/ui/doc_errors.rs:21:1 + --> tests/ui/doc_errors.rs:20:1 | LL | pub fn pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> tests/ui/doc_errors.rs:28:1 + --> tests/ui/doc_errors.rs:27:1 | LL | pub async fn async_pub_fn_returning_io_result() -> io::Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> tests/ui/doc_errors.rs:60:5 + --> tests/ui/doc_errors.rs:59:5 | LL | pub fn pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> tests/ui/doc_errors.rs:67:5 + --> tests/ui/doc_errors.rs:66:5 | LL | pub async fn async_pub_method_missing_errors_header() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function returning `Result` missing `# Errors` section - --> tests/ui/doc_errors.rs:119:5 + --> tests/ui/doc_errors.rs:118:5 | LL | fn trait_method_missing_errors_header() -> Result<(), ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/doc_unsafe.rs b/tests/ui/doc_unsafe.rs index ccdc59bfb5a2f..1bdf01e4e22e9 100644 --- a/tests/ui/doc_unsafe.rs +++ b/tests/ui/doc_unsafe.rs @@ -7,7 +7,7 @@ use proc_macros::external; /// This is not sufficiently documented pub unsafe fn destroy_the_planet() { -//~^ missing_safety_doc + //~^ missing_safety_doc unimplemented!(); } @@ -31,7 +31,7 @@ mod private_mod { } pub unsafe fn republished() { - //~^ missing_safety_doc + //~^ missing_safety_doc unimplemented!(); } } @@ -47,7 +47,7 @@ pub trait SafeTraitUnsafeMethods { } pub unsafe trait UnsafeTrait { -//~^ missing_safety_doc + //~^ missing_safety_doc fn method(); } @@ -78,7 +78,7 @@ unsafe impl DocumentedUnsafeTrait for Struct { impl Struct { pub unsafe fn more_undocumented_unsafe() -> Self { - //~^ missing_safety_doc + //~^ missing_safety_doc unimplemented!(); } @@ -95,7 +95,7 @@ impl Struct { macro_rules! very_unsafe { () => { pub unsafe fn whee() { - //~^ missing_safety_doc + //~^ missing_safety_doc unimplemented!() } diff --git a/tests/ui/double_comparison.fixed b/tests/ui/double_comparison.fixed index e9d707cdb53d9..685e3319bf9af 100644 --- a/tests/ui/double_comparison.fixed +++ b/tests/ui/double_comparison.fixed @@ -4,35 +4,35 @@ fn main() { let x = 1; let y = 2; if x <= y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x <= y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x >= y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x >= y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x != y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x != y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x == y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x == y { - //~^ double_comparisons + //~^ double_comparisons // do something } } diff --git a/tests/ui/double_comparison.rs b/tests/ui/double_comparison.rs index 4b9a141747db7..3670a050e88d1 100644 --- a/tests/ui/double_comparison.rs +++ b/tests/ui/double_comparison.rs @@ -4,35 +4,35 @@ fn main() { let x = 1; let y = 2; if x == y || x < y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x < y || x == y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x == y || x > y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x > y || x == y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x < y || x > y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x > y || x < y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x <= y && x >= y { - //~^ double_comparisons + //~^ double_comparisons // do something } if x >= y && x <= y { - //~^ double_comparisons + //~^ double_comparisons // do something } } diff --git a/tests/ui/double_must_use.rs b/tests/ui/double_must_use.rs index 1f69afad25d46..3d4aaa9baa49c 100644 --- a/tests/ui/double_must_use.rs +++ b/tests/ui/double_must_use.rs @@ -3,21 +3,21 @@ #[must_use] pub fn must_use_result() -> Result<(), ()> { -//~^ double_must_use + //~^ double_must_use unimplemented!(); } #[must_use] pub fn must_use_tuple() -> (Result<(), ()>, u8) { -//~^ double_must_use + //~^ double_must_use unimplemented!(); } #[must_use] pub fn must_use_array() -> [Result<(), ()>; 1] { -//~^ double_must_use + //~^ double_must_use unimplemented!(); } @@ -35,7 +35,7 @@ async fn async_must_use() -> usize { #[must_use] async fn async_must_use_result() -> Result<(), ()> { -//~^ double_must_use + //~^ double_must_use Ok(()) } diff --git a/tests/ui/duplicate_underscore_argument.rs b/tests/ui/duplicate_underscore_argument.rs index cb4930363e8f1..b71f5a20a8439 100644 --- a/tests/ui/duplicate_underscore_argument.rs +++ b/tests/ui/duplicate_underscore_argument.rs @@ -3,7 +3,6 @@ fn join_the_dark_side(darth: i32, _darth: i32) {} //~^ duplicate_underscore_argument - fn join_the_light_side(knight: i32, _master: i32) {} // the Force is strong with this one fn main() { diff --git a/tests/ui/else_if_without_else.rs b/tests/ui/else_if_without_else.rs index 8c0df6ee87868..05d56600e1006 100644 --- a/tests/ui/else_if_without_else.rs +++ b/tests/ui/else_if_without_else.rs @@ -49,7 +49,7 @@ fn main() { if bla1() { println!("if"); } else if bla2() { - //~^ else_if_without_else + //~^ else_if_without_else println!("else if"); } @@ -59,7 +59,7 @@ fn main() { } else if bla2() { println!("else if 1"); } else if bla3() { - //~^ else_if_without_else + //~^ else_if_without_else println!("else if 2"); } @@ -87,7 +87,7 @@ fn main() { } else if bla4() { println!("else if 3"); } else if bla5() { - //~^ else_if_without_else + //~^ else_if_without_else println!("else if 4"); } @@ -118,7 +118,7 @@ fn main() { } else if bla4() { println!("else if 3"); } else if bla5() { - //~^ else_if_without_else + //~^ else_if_without_else println!("else if 4"); } diff --git a/tests/ui/empty_drop.rs b/tests/ui/empty_drop.rs index c2dc7a0193a32..5793f783a7242 100644 --- a/tests/ui/empty_drop.rs +++ b/tests/ui/empty_drop.rs @@ -5,7 +5,7 @@ struct Foo; impl Drop for Foo { -//~^ empty_drop + //~^ empty_drop fn drop(&mut self) {} } @@ -22,7 +22,7 @@ impl Drop for Bar { struct Baz; impl Drop for Baz { -//~^ empty_drop + //~^ empty_drop fn drop(&mut self) { {} } diff --git a/tests/ui/empty_enum.rs b/tests/ui/empty_enum.rs index cc22a76734fe6..439fd0974f5f8 100644 --- a/tests/ui/empty_enum.rs +++ b/tests/ui/empty_enum.rs @@ -5,5 +5,4 @@ enum Empty {} //~^ empty_enum - fn main() {} diff --git a/tests/ui/empty_enum_variants_with_brackets.fixed b/tests/ui/empty_enum_variants_with_brackets.fixed index 8316d3b8fd341..885f6a50025e9 100644 --- a/tests/ui/empty_enum_variants_with_brackets.fixed +++ b/tests/ui/empty_enum_variants_with_brackets.fixed @@ -4,20 +4,20 @@ pub enum PublicTestEnum { NonEmptyBraces { x: i32, y: i32 }, // No error NonEmptyParentheses(i32, i32), // No error -EmptyBraces, -//~^ empty_enum_variants_with_brackets -EmptyParentheses, -//~^ empty_enum_variants_with_brackets + EmptyBraces, + //~^ empty_enum_variants_with_brackets + EmptyParentheses, + //~^ empty_enum_variants_with_brackets } enum TestEnum { NonEmptyBraces { x: i32, y: i32 }, // No error NonEmptyParentheses(i32, i32), // No error -EmptyBraces, -//~^ empty_enum_variants_with_brackets -EmptyParentheses, -//~^ empty_enum_variants_with_brackets - AnotherEnum, // No error + EmptyBraces, + //~^ empty_enum_variants_with_brackets + EmptyParentheses, + //~^ empty_enum_variants_with_brackets + AnotherEnum, // No error } enum TestEnumWithFeatures { diff --git a/tests/ui/empty_enum_variants_with_brackets.rs b/tests/ui/empty_enum_variants_with_brackets.rs index 6cce2533b9790..092712ee2ead4 100644 --- a/tests/ui/empty_enum_variants_with_brackets.rs +++ b/tests/ui/empty_enum_variants_with_brackets.rs @@ -4,20 +4,20 @@ pub enum PublicTestEnum { NonEmptyBraces { x: i32, y: i32 }, // No error NonEmptyParentheses(i32, i32), // No error -EmptyBraces {}, -//~^ empty_enum_variants_with_brackets -EmptyParentheses(), -//~^ empty_enum_variants_with_brackets + EmptyBraces {}, + //~^ empty_enum_variants_with_brackets + EmptyParentheses(), + //~^ empty_enum_variants_with_brackets } enum TestEnum { NonEmptyBraces { x: i32, y: i32 }, // No error NonEmptyParentheses(i32, i32), // No error -EmptyBraces {}, -//~^ empty_enum_variants_with_brackets -EmptyParentheses(), -//~^ empty_enum_variants_with_brackets - AnotherEnum, // No error + EmptyBraces {}, + //~^ empty_enum_variants_with_brackets + EmptyParentheses(), + //~^ empty_enum_variants_with_brackets + AnotherEnum, // No error } enum TestEnumWithFeatures { diff --git a/tests/ui/empty_enum_variants_with_brackets.stderr b/tests/ui/empty_enum_variants_with_brackets.stderr index f49e526584c88..a9ae3b476dd68 100644 --- a/tests/ui/empty_enum_variants_with_brackets.stderr +++ b/tests/ui/empty_enum_variants_with_brackets.stderr @@ -1,34 +1,34 @@ error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:7:12 + --> tests/ui/empty_enum_variants_with_brackets.rs:7:16 | -LL | EmptyBraces {}, - | ^^^ +LL | EmptyBraces {}, + | ^^^ | = note: `-D clippy::empty-enum-variants-with-brackets` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::empty_enum_variants_with_brackets)]` = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:9:17 + --> tests/ui/empty_enum_variants_with_brackets.rs:9:21 | -LL | EmptyParentheses(), - | ^^ +LL | EmptyParentheses(), + | ^^ | = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:16:12 + --> tests/ui/empty_enum_variants_with_brackets.rs:16:16 | -LL | EmptyBraces {}, - | ^^^ +LL | EmptyBraces {}, + | ^^^ | = help: remove the brackets error: enum variant has empty brackets - --> tests/ui/empty_enum_variants_with_brackets.rs:18:17 + --> tests/ui/empty_enum_variants_with_brackets.rs:18:21 | -LL | EmptyParentheses(), - | ^^ +LL | EmptyParentheses(), + | ^^ | = help: remove the brackets diff --git a/tests/ui/empty_line_after/doc_comments.1.fixed b/tests/ui/empty_line_after/doc_comments.1.fixed index cf2cc497799f3..c1a15f47ba101 100644 --- a/tests/ui/empty_line_after/doc_comments.1.fixed +++ b/tests/ui/empty_line_after/doc_comments.1.fixed @@ -1,6 +1,5 @@ #![warn(clippy::empty_line_after_outer_attr, clippy::empty_line_after_doc_comments)] - /// Meant to be an /// inner doc comment /// for the crate @@ -23,14 +22,12 @@ mod some_mod { fn some_noop() {} } - /// # Indented //~^ empty_line_after_doc_comments /// Blank line fn indented() {} } - /// This should produce a warning //~^ empty_line_after_doc_comments fn with_doc_and_newline() {} @@ -40,7 +37,6 @@ fn with_doc_and_newline() {} /// some comment fn with_no_newline_and_comment() {} - /// This doc comment should produce a warning //~^ empty_line_after_doc_comments /** This is also a doc comment and is part of the warning @@ -57,7 +53,6 @@ mod misattributed { // fn old_code() {} fn new_code() {} - /// Docs /// for OldA //~^ empty_line_after_doc_comments @@ -74,23 +69,21 @@ mod misattributed { mod block_comments { /** - //~^ empty_line_after_doc_comments * Meant to be inner doc comment */ + //~^^^ empty_line_after_doc_comments fn first_in_module() {} - /** - //~^ empty_line_after_doc_comments * Docs for `old_code` */ + //~^^^ empty_line_after_doc_comments /* fn old_code() {} */ /** * Docs for `new_code` */ fn new_code() {} - /// Docs for `old_code2` //~^ empty_line_after_doc_comments /* fn old_code2() {} */ diff --git a/tests/ui/empty_line_after/doc_comments.2.fixed b/tests/ui/empty_line_after/doc_comments.2.fixed index ee02e2f87d2d4..abec7b54c6328 100644 --- a/tests/ui/empty_line_after/doc_comments.2.fixed +++ b/tests/ui/empty_line_after/doc_comments.2.fixed @@ -1,6 +1,5 @@ #![warn(clippy::empty_line_after_outer_attr, clippy::empty_line_after_doc_comments)] - // /// Meant to be an // /// inner doc comment // /// for the crate @@ -25,7 +24,6 @@ mod some_mod { fn some_noop() {} } - // /// # Indented //~^ empty_line_after_doc_comments @@ -33,7 +31,6 @@ mod some_mod { fn indented() {} } - // /// This should produce a warning //~^ empty_line_after_doc_comments @@ -44,7 +41,6 @@ fn with_doc_and_newline() {} /// some comment fn with_no_newline_and_comment() {} - // /// This doc comment should produce a warning //~^ empty_line_after_doc_comments @@ -64,7 +60,6 @@ mod misattributed { fn new_code() {} - // /// Docs // /// for OldA //~^ empty_line_after_doc_comments @@ -82,18 +77,17 @@ mod misattributed { mod block_comments { - /*! - //~^ empty_line_after_doc_comments + /* * Meant to be inner doc comment */ + //~^^^ empty_line_after_doc_comments fn first_in_module() {} - /* - //~^ empty_line_after_doc_comments * Docs for `old_code` */ + //~^^^ empty_line_after_doc_comments /* fn old_code() {} */ /** @@ -101,7 +95,6 @@ mod block_comments { */ fn new_code() {} - // /// Docs for `old_code2` //~^ empty_line_after_doc_comments /* fn old_code2() {} */ diff --git a/tests/ui/empty_line_after/doc_comments.rs b/tests/ui/empty_line_after/doc_comments.rs index 789f14f39777f..d225768f61254 100644 --- a/tests/ui/empty_line_after/doc_comments.rs +++ b/tests/ui/empty_line_after/doc_comments.rs @@ -1,6 +1,5 @@ #![warn(clippy::empty_line_after_outer_attr, clippy::empty_line_after_doc_comments)] - /// Meant to be an /// inner doc comment /// for the crate @@ -25,7 +24,6 @@ mod some_mod { fn some_noop() {} } - /// # Indented //~^ empty_line_after_doc_comments @@ -33,7 +31,6 @@ mod some_mod { fn indented() {} } - /// This should produce a warning //~^ empty_line_after_doc_comments @@ -44,7 +41,6 @@ fn with_doc_and_newline() {} /// some comment fn with_no_newline_and_comment() {} - /// This doc comment should produce a warning //~^ empty_line_after_doc_comments @@ -64,7 +60,6 @@ mod misattributed { fn new_code() {} - /// Docs /// for OldA //~^ empty_line_after_doc_comments @@ -83,17 +78,16 @@ mod misattributed { mod block_comments { /** - //~^ empty_line_after_doc_comments * Meant to be inner doc comment */ + //~^^^ empty_line_after_doc_comments fn first_in_module() {} - /** - //~^ empty_line_after_doc_comments * Docs for `old_code` */ + //~^^^ empty_line_after_doc_comments /* fn old_code() {} */ /** @@ -101,7 +95,6 @@ mod block_comments { */ fn new_code() {} - /// Docs for `old_code2` //~^ empty_line_after_doc_comments /* fn old_code2() {} */ diff --git a/tests/ui/empty_line_after/doc_comments.stderr b/tests/ui/empty_line_after/doc_comments.stderr index 91745dac3a79d..9b627e8df1ffa 100644 --- a/tests/ui/empty_line_after/doc_comments.stderr +++ b/tests/ui/empty_line_after/doc_comments.stderr @@ -1,5 +1,5 @@ error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:6:1 + --> tests/ui/empty_line_after/doc_comments.rs:5:1 | LL | / /// for the crate LL | | @@ -19,7 +19,7 @@ LL ~ // /// for the crate | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:15:5 + --> tests/ui/empty_line_after/doc_comments.rs:14:5 | LL | / /// for the module LL | | @@ -37,7 +37,7 @@ LL ~ // /// for the module | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:29:5 + --> tests/ui/empty_line_after/doc_comments.rs:27:5 | LL | / /// # Indented LL | | @@ -54,7 +54,7 @@ LL | // /// # Indented | ++ error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:37:1 + --> tests/ui/empty_line_after/doc_comments.rs:34:1 | LL | / /// This should produce a warning LL | | @@ -70,7 +70,7 @@ LL | // /// This should produce a warning | ++ error: empty lines after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:48:1 + --> tests/ui/empty_line_after/doc_comments.rs:44:1 | LL | / /// This doc comment should produce a warning LL | | @@ -93,7 +93,7 @@ LL ~ /* This is also a doc comment and is part of the warning | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:61:5 + --> tests/ui/empty_line_after/doc_comments.rs:57:5 | LL | / /// docs for `old_code` ... | @@ -109,7 +109,7 @@ LL | // /// docs for `old_code` | ++ error: empty lines after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:69:5 + --> tests/ui/empty_line_after/doc_comments.rs:64:5 | LL | / /// for OldA ... | @@ -132,31 +132,31 @@ LL ~ // /// for OldB | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:85:5 + --> tests/ui/empty_line_after/doc_comments.rs:80:5 | LL | / /** -LL | | LL | | * Meant to be inner doc comment LL | | */ +LL | | LL | | | |_^ LL | fn first_in_module() {} | -------------------- the comment documents this function | = help: if the empty line is unintentional remove it -help: if the comment should document the parent module use an inner doc comment +help: if the doc comment should not document `first_in_module` comment it out + | +LL - /** +LL + /* | -LL | /*! - | ~ error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:93:5 + --> tests/ui/empty_line_after/doc_comments.rs:87:5 | LL | / /** -LL | | LL | | * Docs for `old_code` LL | | */ -LL | | /* fn old_code() {} */ +... | LL | | | |_^ ... @@ -171,7 +171,7 @@ LL + /* | error: empty line after doc comment - --> tests/ui/empty_line_after/doc_comments.rs:105:5 + --> tests/ui/empty_line_after/doc_comments.rs:98:5 | LL | / /// Docs for `old_code2` LL | | diff --git a/tests/ui/empty_loop_no_std.rs b/tests/ui/empty_loop_no_std.rs index c3b2bafe2f87e..6407bd678f9ca 100644 --- a/tests/ui/empty_loop_no_std.rs +++ b/tests/ui/empty_loop_no_std.rs @@ -9,5 +9,4 @@ pub fn main(argc: isize, argv: *const *const u8) -> isize { // This should trigger the lint loop {} //~^ empty_loop - } diff --git a/tests/ui/entry.fixed b/tests/ui/entry.fixed index 87dc7a8de9203..9856fa9b39fd0 100644 --- a/tests/ui/entry.fixed +++ b/tests/ui/entry.fixed @@ -25,7 +25,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // semicolon on insert, use or_insert_with(..) m.entry(k).or_insert_with(|| { - //~^ map_entry + //~^ map_entry if true { v } else { @@ -35,7 +35,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // semicolon on if, use or_insert_with(..) m.entry(k).or_insert_with(|| { - //~^ map_entry + //~^ map_entry if true { v } else { @@ -45,7 +45,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // early return, use if let if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) { - //~^ map_entry + //~^ map_entry if true { e.insert(v); } else { @@ -56,14 +56,14 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // use or_insert_with(..) m.entry(k).or_insert_with(|| { - //~^ map_entry + //~^ map_entry foo(); v }); // semicolon on insert and match, use or_insert_with(..) m.entry(k).or_insert_with(|| { - //~^ map_entry + //~^ map_entry match 0 { 1 if true => { v @@ -76,7 +76,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // one branch doesn't insert, use if let if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) { - //~^ map_entry + //~^ map_entry match 0 { 0 => foo(), _ => { @@ -87,7 +87,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // use or_insert_with m.entry(k).or_insert_with(|| { - //~^ map_entry + //~^ map_entry foo(); match 0 { 0 if false => { @@ -152,7 +152,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // or_insert_with. Partial move of a local declared in the closure is ok. m.entry(k).or_insert_with(|| { - //~^ map_entry + //~^ map_entry let x = (String::new(), String::new()); let _ = x.0; v @@ -186,7 +186,7 @@ pub fn issue_11935() { fn issue12489(map: &mut HashMap) -> Option<()> { if let std::collections::hash_map::Entry::Vacant(e) = map.entry(1) { - //~^ map_entry + //~^ map_entry let Some(1) = Some(2) else { return None; }; diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index c795d3b975906..bb8ebb4eac086 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -22,13 +22,13 @@ fn foo() {} fn hash_map(m: &mut HashMap, m2: &mut HashMap, k: K, k2: K, v: V, v2: V) { // or_insert(v) if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry m.insert(k, v); } // semicolon on insert, use or_insert_with(..) if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry if true { m.insert(k, v); } else { @@ -38,7 +38,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // semicolon on if, use or_insert_with(..) if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry if true { m.insert(k, v) } else { @@ -48,7 +48,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // early return, use if let if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry if true { m.insert(k, v); } else { @@ -59,14 +59,14 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // use or_insert_with(..) if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry foo(); m.insert(k, v); } // semicolon on insert and match, use or_insert_with(..) if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry match 0 { 1 if true => { m.insert(k, v); @@ -79,7 +79,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // one branch doesn't insert, use if let if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry match 0 { 0 => foo(), _ => { @@ -90,7 +90,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // use or_insert_with if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry foo(); match 0 { 0 if false => { @@ -125,7 +125,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // macro_expansion test, use or_insert(..) if !m.contains_key(&m!(k)) { - //~^ map_entry + //~^ map_entry m.insert(m!(k), m!(v)); } @@ -158,7 +158,7 @@ fn hash_map(m: &mut HashMap, m2: &mut HashMa // or_insert_with. Partial move of a local declared in the closure is ok. if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry let x = (String::new(), String::new()); let _ = x.0; m.insert(k, v); @@ -192,7 +192,7 @@ pub fn issue_11935() { fn issue12489(map: &mut HashMap) -> Option<()> { if !map.contains_key(&1) { - //~^ map_entry + //~^ map_entry let Some(1) = Some(2) else { return None; }; diff --git a/tests/ui/entry_btree.fixed b/tests/ui/entry_btree.fixed index 518f503475fc5..1218202f02b95 100644 --- a/tests/ui/entry_btree.fixed +++ b/tests/ui/entry_btree.fixed @@ -8,7 +8,7 @@ fn foo() {} fn btree_map(m: &mut BTreeMap, k: K, v: V) { // insert then do something, use if let if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) { - //~^ map_entry + //~^ map_entry e.insert(v); foo(); } diff --git a/tests/ui/entry_btree.rs b/tests/ui/entry_btree.rs index 4e4b3a502e039..b795e32158ad6 100644 --- a/tests/ui/entry_btree.rs +++ b/tests/ui/entry_btree.rs @@ -8,7 +8,7 @@ fn foo() {} fn btree_map(m: &mut BTreeMap, k: K, v: V) { // insert then do something, use if let if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry m.insert(k, v); foo(); } diff --git a/tests/ui/entry_with_else.fixed b/tests/ui/entry_with_else.fixed index 995611803908f..76e6998235c24 100644 --- a/tests/ui/entry_with_else.fixed +++ b/tests/ui/entry_with_else.fixed @@ -13,7 +13,7 @@ fn foo() {} fn insert_if_absent0(m: &mut HashMap, k: K, v: V, v2: V) { match m.entry(k) { std::collections::hash_map::Entry::Vacant(e) => { - //~^ map_entry + //~^ map_entry e.insert(v); } std::collections::hash_map::Entry::Occupied(mut e) => { @@ -23,7 +23,7 @@ fn insert_if_absent0(m: &mut HashMap, k: K, match m.entry(k) { std::collections::hash_map::Entry::Occupied(mut e) => { - //~^ map_entry + //~^ map_entry e.insert(v); } std::collections::hash_map::Entry::Vacant(e) => { @@ -32,7 +32,7 @@ fn insert_if_absent0(m: &mut HashMap, k: K, } if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) { - //~^ map_entry + //~^ map_entry e.insert(v); } else { foo(); @@ -41,13 +41,13 @@ fn insert_if_absent0(m: &mut HashMap, k: K, if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) { e.insert(v); } else { - //~^ map_entry + //~^ map_entry foo(); } match m.entry(k) { std::collections::hash_map::Entry::Vacant(e) => { - //~^ map_entry + //~^ map_entry e.insert(v); } std::collections::hash_map::Entry::Occupied(mut e) => { @@ -57,7 +57,7 @@ fn insert_if_absent0(m: &mut HashMap, k: K, match m.entry(k) { std::collections::hash_map::Entry::Occupied(mut e) => { - //~^ map_entry + //~^ map_entry if true { Some(e.insert(v)) } else { Some(e.insert(v2)) } } std::collections::hash_map::Entry::Vacant(e) => { @@ -67,7 +67,7 @@ fn insert_if_absent0(m: &mut HashMap, k: K, }; if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) { - //~^ map_entry + //~^ map_entry foo(); Some(e.insert(v)) } else { diff --git a/tests/ui/entry_with_else.rs b/tests/ui/entry_with_else.rs index dcfafedc11f8c..1669cdc0c7cf7 100644 --- a/tests/ui/entry_with_else.rs +++ b/tests/ui/entry_with_else.rs @@ -12,49 +12,49 @@ fn foo() {} fn insert_if_absent0(m: &mut HashMap, k: K, v: V, v2: V) { if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry m.insert(k, v); } else { m.insert(k, v2); } if m.contains_key(&k) { - //~^ map_entry + //~^ map_entry m.insert(k, v); } else { m.insert(k, v2); } if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry m.insert(k, v); } else { foo(); } if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry foo(); } else { m.insert(k, v); } if !m.contains_key(&k) { - //~^ map_entry + //~^ map_entry m.insert(k, v); } else { m.insert(k, v2); } if m.contains_key(&k) { - //~^ map_entry + //~^ map_entry if true { m.insert(k, v) } else { m.insert(k, v2) } } else { m.insert(k, v) }; if m.contains_key(&k) { - //~^ map_entry + //~^ map_entry foo(); m.insert(k, v) } else { diff --git a/tests/ui/enum_clike_unportable_variant.rs b/tests/ui/enum_clike_unportable_variant.rs index f54cca9c611cf..4ff2024b25e95 100644 --- a/tests/ui/enum_clike_unportable_variant.rs +++ b/tests/ui/enum_clike_unportable_variant.rs @@ -7,8 +7,6 @@ enum NonPortable { X = 0x1_0000_0000, //~^ enum_clike_unportable_variant - - Y = 0, Z = 0x7FFF_FFFF, A = 0xFFFF_FFFF, @@ -17,12 +15,10 @@ enum NonPortable { enum NonPortableNoHint { X = 0x1_0000_0000, //~^ enum_clike_unportable_variant - Y = 0, Z = 0x7FFF_FFFF, A = 0xFFFF_FFFF, //~^ enum_clike_unportable_variant - } #[repr(isize)] @@ -31,14 +27,11 @@ enum NonPortableSigned { Y = 0x7FFF_FFFF, Z = 0xFFFF_FFFF, //~^ enum_clike_unportable_variant - A = 0x1_0000_0000, //~^ enum_clike_unportable_variant - B = i32::MIN as isize, C = (i32::MIN as isize) - 1, //~^ enum_clike_unportable_variant - } enum NonPortableSignedNoHint { @@ -46,17 +39,14 @@ enum NonPortableSignedNoHint { Y = 0x7FFF_FFFF, Z = 0xFFFF_FFFF, //~^ enum_clike_unportable_variant - A = 0x1_0000_0000, //~^ enum_clike_unportable_variant - } #[repr(usize)] enum NonPortable2 { X = ::Number, //~^ enum_clike_unportable_variant - Y = 0, } diff --git a/tests/ui/enum_clike_unportable_variant.stderr b/tests/ui/enum_clike_unportable_variant.stderr index ade2106ad96cf..5a022a6fe8a61 100644 --- a/tests/ui/enum_clike_unportable_variant.stderr +++ b/tests/ui/enum_clike_unportable_variant.stderr @@ -8,49 +8,49 @@ LL | X = 0x1_0000_0000, = help: to override `-D warnings` add `#[allow(clippy::enum_clike_unportable_variant)]` error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:18:5 + --> tests/ui/enum_clike_unportable_variant.rs:16:5 | LL | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:23:5 + --> tests/ui/enum_clike_unportable_variant.rs:20:5 | LL | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:32:5 + --> tests/ui/enum_clike_unportable_variant.rs:28:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:35:5 + --> tests/ui/enum_clike_unportable_variant.rs:30:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:39:5 + --> tests/ui/enum_clike_unportable_variant.rs:33:5 | LL | C = (i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:47:5 + --> tests/ui/enum_clike_unportable_variant.rs:40:5 | LL | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:50:5 + --> tests/ui/enum_clike_unportable_variant.rs:42:5 | LL | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: C-like enum variant discriminant is not portable to 32-bit targets - --> tests/ui/enum_clike_unportable_variant.rs:57:5 + --> tests/ui/enum_clike_unportable_variant.rs:48:5 | LL | X = ::Number, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/enum_variants.rs b/tests/ui/enum_variants.rs index f3c81b2111ce8..f7bbf83654f11 100644 --- a/tests/ui/enum_variants.rs +++ b/tests/ui/enum_variants.rs @@ -12,7 +12,7 @@ enum FakeCallType2 { } enum Foo { -//~^ enum_variant_names + //~^ enum_variant_names cFoo, //~^ enum_variant_names cBar, @@ -25,7 +25,7 @@ enum Fooo { } enum Food { -//~^ enum_variant_names + //~^ enum_variant_names FoodGood, //~^ enum_variant_names FoodMiddle, @@ -39,8 +39,7 @@ enum Stuff { } enum BadCallType { -//~^ enum_variant_names - + //~^ enum_variant_names CallTypeCall, CallTypeCreate, CallTypeDestroy, @@ -53,7 +52,7 @@ enum TwoCallType { } enum Consts { -//~^ enum_variant_names + //~^ enum_variant_names ConstantInt, ConstantCake, ConstantLie, @@ -66,7 +65,7 @@ enum Two { } enum Something { -//~^ enum_variant_names + //~^ enum_variant_names CCall, CCreate, CCryogenize, @@ -89,7 +88,7 @@ enum Sealll { } enum Seallll { -//~^ enum_variant_names + //~^ enum_variant_names WithOutCake, WithOutTea, WithOut, @@ -145,14 +144,14 @@ pub enum NetworkLayer { // should lint suggesting `IData`, not only `Data` (see #4639) enum IDataRequest { -//~^ enum_variant_names + //~^ enum_variant_names PutIData(String), GetIData(String), DeleteUnpubIData(String), } enum HIDataRequest { -//~^ enum_variant_names + //~^ enum_variant_names PutHIData(String), GetHIData(String), DeleteUnpubHIData(String), @@ -173,7 +172,7 @@ enum Phase { mod issue9018 { enum DoLint { - //~^ enum_variant_names + //~^ enum_variant_names _TypeCreate, _TypeRead, _TypeUpdate, @@ -181,7 +180,7 @@ mod issue9018 { } enum DoLintToo { - //~^ enum_variant_names + //~^ enum_variant_names _CreateType, _UpdateType, _DeleteType, diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index 2f0b0e6149d2e..cca9d50033cfe 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -55,7 +55,6 @@ error: all variants have the same prefix: `CallType` | LL | / enum BadCallType { LL | | -LL | | LL | | CallTypeCall, LL | | CallTypeCreate, LL | | CallTypeDestroy, @@ -65,7 +64,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `Constant` - --> tests/ui/enum_variants.rs:55:1 + --> tests/ui/enum_variants.rs:54:1 | LL | / enum Consts { LL | | @@ -78,7 +77,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `C` - --> tests/ui/enum_variants.rs:68:1 + --> tests/ui/enum_variants.rs:67:1 | LL | / enum Something { LL | | @@ -91,7 +90,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `WithOut` - --> tests/ui/enum_variants.rs:91:1 + --> tests/ui/enum_variants.rs:90:1 | LL | / enum Seallll { LL | | @@ -104,7 +103,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `IData` - --> tests/ui/enum_variants.rs:147:1 + --> tests/ui/enum_variants.rs:146:1 | LL | / enum IDataRequest { LL | | @@ -117,7 +116,7 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `HIData` - --> tests/ui/enum_variants.rs:154:1 + --> tests/ui/enum_variants.rs:153:1 | LL | / enum HIDataRequest { LL | | @@ -130,7 +129,7 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: all variants have the same prefix: `_Type` - --> tests/ui/enum_variants.rs:175:5 + --> tests/ui/enum_variants.rs:174:5 | LL | / enum DoLint { LL | | @@ -144,7 +143,7 @@ LL | | } = help: remove the prefixes and use full paths to the variants instead of glob imports error: all variants have the same postfix: `Type` - --> tests/ui/enum_variants.rs:183:5 + --> tests/ui/enum_variants.rs:182:5 | LL | / enum DoLintToo { LL | | @@ -157,13 +156,13 @@ LL | | } = help: remove the postfixes and use full paths to the variants instead of glob imports error: variant name starts with the enum's name - --> tests/ui/enum_variants.rs:212:9 + --> tests/ui/enum_variants.rs:211:9 | LL | DataDependent, | ^^^^^^^^^^^^^ error: variant name starts with the enum's name - --> tests/ui/enum_variants.rs:217:9 + --> tests/ui/enum_variants.rs:216:9 | LL | DatasDependent, | ^^^^^^^^^^^^^^ diff --git a/tests/ui/eprint_with_newline.fixed b/tests/ui/eprint_with_newline.fixed index cb6cff419e9dd..c50a707ace92e 100644 --- a/tests/ui/eprint_with_newline.fixed +++ b/tests/ui/eprint_with_newline.fixed @@ -5,7 +5,6 @@ fn main() { eprintln!("Hello"); //~^ print_with_newline - eprintln!("Hello {}", "world"); //~^ print_with_newline @@ -18,7 +17,6 @@ fn main() { eprintln!(); //~^ print_with_newline - // these are all fine eprint!(""); eprint!("Hello"); @@ -50,13 +48,11 @@ fn main() { // Literal newlines should also fail eprintln!( - //~^ print_with_newline - + //~^ print_with_newline ); eprintln!( - //~^ print_with_newline - + //~^ print_with_newline ); diff --git a/tests/ui/eprint_with_newline.rs b/tests/ui/eprint_with_newline.rs index cfe503cec1f10..2c90480bdc781 100644 --- a/tests/ui/eprint_with_newline.rs +++ b/tests/ui/eprint_with_newline.rs @@ -5,7 +5,6 @@ fn main() { eprint!("Hello\n"); //~^ print_with_newline - eprint!("Hello {}\n", "world"); //~^ print_with_newline @@ -18,7 +17,6 @@ fn main() { eprint!("\n"); //~^ print_with_newline - // these are all fine eprint!(""); eprint!("Hello"); @@ -50,14 +48,12 @@ fn main() { // Literal newlines should also fail eprint!( - //~^ print_with_newline - + //~^ print_with_newline " " ); eprint!( - //~^ print_with_newline - + //~^ print_with_newline r" " ); diff --git a/tests/ui/eprint_with_newline.stderr b/tests/ui/eprint_with_newline.stderr index 87dcb9126b6db..c78cffd40c99e 100644 --- a/tests/ui/eprint_with_newline.stderr +++ b/tests/ui/eprint_with_newline.stderr @@ -13,7 +13,7 @@ LL + eprintln!("Hello"); | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:9:5 + --> tests/ui/eprint_with_newline.rs:8:5 | LL | eprint!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + eprintln!("Hello {}", "world"); | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:12:5 + --> tests/ui/eprint_with_newline.rs:11:5 | LL | eprint!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + eprintln!("Hello {} {}", "world", "#2"); | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:15:5 + --> tests/ui/eprint_with_newline.rs:14:5 | LL | eprint!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + eprintln!("{}", 1265); | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:18:5 + --> tests/ui/eprint_with_newline.rs:17:5 | LL | eprint!("\n"); | ^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + eprintln!(); | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:42:5 + --> tests/ui/eprint_with_newline.rs:40:5 | LL | eprint!("\\\n"); | ^^^^^^^^^^^^^^^ @@ -73,11 +73,10 @@ LL + eprintln!("\\"); | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:52:5 + --> tests/ui/eprint_with_newline.rs:50:5 | LL | / eprint!( LL | | -LL | | LL | | " LL | | " LL | | ); @@ -87,16 +86,14 @@ help: use `eprintln!` instead | LL ~ eprintln!( LL | -LL | LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:58:5 + --> tests/ui/eprint_with_newline.rs:55:5 | LL | / eprint!( LL | | -LL | | LL | | r" LL | | " LL | | ); @@ -106,12 +103,11 @@ help: use `eprintln!` instead | LL ~ eprintln!( LL | -LL | LL ~ | error: using `eprint!()` with a format string that ends in a single newline - --> tests/ui/eprint_with_newline.rs:68:5 + --> tests/ui/eprint_with_newline.rs:64:5 | LL | eprint!("\\r\n"); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/eq_op.rs b/tests/ui/eq_op.rs index 757a7e011903e..ced0452ee9a80 100644 --- a/tests/ui/eq_op.rs +++ b/tests/ui/eq_op.rs @@ -7,7 +7,6 @@ fn main() { let _ = 1 == 1; //~^ eq_op - let _ = "no" == "no"; //~^ eq_op @@ -25,8 +24,6 @@ fn main() { let _ = x != x; //~^ eq_op - - // casts, methods, parentheses let _ = (1u32 as u64) & (1u32 as u64); //~^ eq_op @@ -47,12 +44,9 @@ fn main() { //~| eq_op //~| eq_op - - let _ = (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; //~^ eq_op - // various other things let _ = ([1] != [1]); //~^ eq_op @@ -70,8 +64,6 @@ fn main() { //~^ eq_op //~| eq_op - - let _ = 1 - 1; //~^ eq_op @@ -81,11 +73,9 @@ fn main() { let _ = true && true; //~^ eq_op - let _ = true || true; //~^ eq_op - let a: u32 = 0; let b: u32 = 0; @@ -101,7 +91,6 @@ fn main() { let _ = a <= b && b >= a; //~^ eq_op - let mut a = vec![1]; let _ = a == a; //~^ eq_op @@ -117,7 +106,6 @@ fn main() { const C: u32 = A / B; // ok, different named constants const D: u32 = A / A; //~^ eq_op - } macro_rules! check_if_named_foo { @@ -150,7 +138,6 @@ fn check_nested(n1: &Nested, n2: &Nested) -> bool { // `n2.inner.0.0` mistyped as `n1.inner.0.0` (n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0 //~^ eq_op - } #[test] diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index bd9362f3e0dde..1696f09d6d178 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -8,31 +8,31 @@ LL | let _ = 1 == 1; = help: to override `-D warnings` add `#[allow(clippy::eq_op)]` error: equal expressions as operands to `==` - --> tests/ui/eq_op.rs:11:13 + --> tests/ui/eq_op.rs:10:13 | LL | let _ = "no" == "no"; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> tests/ui/eq_op.rs:15:13 + --> tests/ui/eq_op.rs:14:13 | LL | let _ = false != false; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> tests/ui/eq_op.rs:18:13 + --> tests/ui/eq_op.rs:17:13 | LL | let _ = 1.5 < 1.5; | ^^^^^^^^^ error: equal expressions as operands to `>=` - --> tests/ui/eq_op.rs:21:13 + --> tests/ui/eq_op.rs:20:13 | LL | let _ = 1u64 >= 1u64; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> tests/ui/eq_op.rs:25:13 + --> tests/ui/eq_op.rs:24:13 | LL | let _ = x != x; | ^^^^^^ @@ -40,139 +40,139 @@ LL | let _ = x != x; = note: if you intended to check if the operand is NaN, use `.is_nan()` instead error: equal expressions as operands to `&` - --> tests/ui/eq_op.rs:31:13 + --> tests/ui/eq_op.rs:28:13 | LL | let _ = (1u32 as u64) & (1u32 as u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `^` - --> tests/ui/eq_op.rs:36:17 + --> tests/ui/eq_op.rs:33:17 | LL | let _ = 1 ^ ((((((1)))))); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `<` - --> tests/ui/eq_op.rs:42:13 + --> tests/ui/eq_op.rs:39:13 | LL | let _ = (-(2) < -(2)); | ^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> tests/ui/eq_op.rs:45:13 + --> tests/ui/eq_op.rs:42:13 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> tests/ui/eq_op.rs:45:14 + --> tests/ui/eq_op.rs:42:14 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&` - --> tests/ui/eq_op.rs:45:35 + --> tests/ui/eq_op.rs:42:35 | LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> tests/ui/eq_op.rs:52:13 + --> tests/ui/eq_op.rs:47:13 | LL | let _ = (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> tests/ui/eq_op.rs:57:13 + --> tests/ui/eq_op.rs:51:13 | LL | let _ = ([1] != [1]); | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` - --> tests/ui/eq_op.rs:60:13 + --> tests/ui/eq_op.rs:54:13 | LL | let _ = ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> tests/ui/eq_op.rs:66:13 + --> tests/ui/eq_op.rs:60:13 | LL | let _ = 1 + 1 == 2; | ^^^^^^^^^^ error: equal expressions as operands to `==` - --> tests/ui/eq_op.rs:69:13 + --> tests/ui/eq_op.rs:63:13 | LL | let _ = 1 - 1 == 0; | ^^^^^^^^^^ error: equal expressions as operands to `-` - --> tests/ui/eq_op.rs:69:13 + --> tests/ui/eq_op.rs:63:13 | LL | let _ = 1 - 1 == 0; | ^^^^^ error: equal expressions as operands to `-` - --> tests/ui/eq_op.rs:75:13 + --> tests/ui/eq_op.rs:67:13 | LL | let _ = 1 - 1; | ^^^^^ error: equal expressions as operands to `/` - --> tests/ui/eq_op.rs:78:13 + --> tests/ui/eq_op.rs:70:13 | LL | let _ = 1 / 1; | ^^^^^ error: equal expressions as operands to `&&` - --> tests/ui/eq_op.rs:81:13 + --> tests/ui/eq_op.rs:73:13 | LL | let _ = true && true; | ^^^^^^^^^^^^ error: equal expressions as operands to `||` - --> tests/ui/eq_op.rs:85:13 + --> tests/ui/eq_op.rs:76:13 | LL | let _ = true || true; | ^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> tests/ui/eq_op.rs:92:13 + --> tests/ui/eq_op.rs:82:13 | LL | let _ = a == b && b == a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> tests/ui/eq_op.rs:95:13 + --> tests/ui/eq_op.rs:85:13 | LL | let _ = a != b && b != a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> tests/ui/eq_op.rs:98:13 + --> tests/ui/eq_op.rs:88:13 | LL | let _ = a < b && b > a; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` - --> tests/ui/eq_op.rs:101:13 + --> tests/ui/eq_op.rs:91:13 | LL | let _ = a <= b && b >= a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` - --> tests/ui/eq_op.rs:106:13 + --> tests/ui/eq_op.rs:95:13 | LL | let _ = a == a; | ^^^^^^ error: equal expressions as operands to `/` - --> tests/ui/eq_op.rs:118:20 + --> tests/ui/eq_op.rs:107:20 | LL | const D: u32 = A / A; | ^^^^^ error: equal expressions as operands to `==` - --> tests/ui/eq_op.rs:151:5 + --> tests/ui/eq_op.rs:139:5 | LL | (n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/equatable_if_let.fixed b/tests/ui/equatable_if_let.fixed index 2f39c34cb394c..166b1387ba265 100644 --- a/tests/ui/equatable_if_let.fixed +++ b/tests/ui/equatable_if_let.fixed @@ -97,7 +97,7 @@ fn main() { //~^ equatable_if_let if "abc" == inline!("abc") { - //~^ equatable_if_let + //~^ equatable_if_let println!("OK"); } diff --git a/tests/ui/equatable_if_let.rs b/tests/ui/equatable_if_let.rs index f7289a9ee56fb..09c2483ae6d43 100644 --- a/tests/ui/equatable_if_let.rs +++ b/tests/ui/equatable_if_let.rs @@ -97,7 +97,7 @@ fn main() { //~^ equatable_if_let if let inline!("abc") = "abc" { - //~^ equatable_if_let + //~^ equatable_if_let println!("OK"); } diff --git a/tests/ui/erasing_op.rs b/tests/ui/erasing_op.rs index 9387a20cb5a07..9237b9eb11f05 100644 --- a/tests/ui/erasing_op.rs +++ b/tests/ui/erasing_op.rs @@ -35,7 +35,6 @@ fn test(x: u8) { x * 0; //~^ erasing_op - 0 & x; //~^ erasing_op @@ -48,7 +47,6 @@ fn test(x: u8) { Vec1 { x: 5 } * 0; //~^ erasing_op - } fn main() { diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 7029fac6c1304..94730b0668011 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -8,25 +8,25 @@ LL | x * 0; = help: to override `-D warnings` add `#[allow(clippy::erasing_op)]` error: this operation will always return zero. This is likely not the intended outcome - --> tests/ui/erasing_op.rs:39:5 + --> tests/ui/erasing_op.rs:38:5 | LL | 0 & x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> tests/ui/erasing_op.rs:42:5 + --> tests/ui/erasing_op.rs:41:5 | LL | 0 / x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> tests/ui/erasing_op.rs:46:5 + --> tests/ui/erasing_op.rs:45:5 | LL | 0 * Vec1 { x: 5 }; | ^^^^^^^^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> tests/ui/erasing_op.rs:49:5 + --> tests/ui/erasing_op.rs:48:5 | LL | Vec1 { x: 5 } * 0; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/error_impl_error.rs b/tests/ui/error_impl_error.rs index 3606e1bcefbb5..5c88888f38eac 100644 --- a/tests/ui/error_impl_error.rs +++ b/tests/ui/error_impl_error.rs @@ -7,7 +7,6 @@ pub mod a { pub struct Error; //~^ error_impl_error - impl std::fmt::Display for Error { fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { todo!() @@ -22,7 +21,6 @@ mod b { pub(super) enum Error {} //~^ error_impl_error - impl std::fmt::Display for Error { fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { todo!() @@ -34,8 +32,7 @@ mod b { pub mod c { pub union Error { - //~^ error_impl_error - + //~^ error_impl_error a: u32, b: u32, } @@ -58,7 +55,6 @@ pub mod c { pub mod d { pub type Error = std::fmt::Error; //~^ error_impl_error - } mod e { diff --git a/tests/ui/error_impl_error.stderr b/tests/ui/error_impl_error.stderr index 4fa1ffeb4c928..087d43d1d083b 100644 --- a/tests/ui/error_impl_error.stderr +++ b/tests/ui/error_impl_error.stderr @@ -5,7 +5,7 @@ LL | pub struct Error; | ^^^^^ | note: `Error` was implemented here - --> tests/ui/error_impl_error.rs:17:5 + --> tests/ui/error_impl_error.rs:16:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,31 +13,31 @@ LL | impl std::error::Error for Error {} = help: to override `-D warnings` add `#[allow(clippy::error_impl_error)]` error: exported type named `Error` that implements `Error` - --> tests/ui/error_impl_error.rs:22:21 + --> tests/ui/error_impl_error.rs:21:21 | LL | pub(super) enum Error {} | ^^^^^ | note: `Error` was implemented here - --> tests/ui/error_impl_error.rs:32:5 + --> tests/ui/error_impl_error.rs:30:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: exported type named `Error` that implements `Error` - --> tests/ui/error_impl_error.rs:36:15 + --> tests/ui/error_impl_error.rs:34:15 | LL | pub union Error { | ^^^^^ | note: `Error` was implemented here - --> tests/ui/error_impl_error.rs:55:5 + --> tests/ui/error_impl_error.rs:52:5 | LL | impl std::error::Error for Error {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: exported type alias named `Error` that implements `Error` - --> tests/ui/error_impl_error.rs:59:14 + --> tests/ui/error_impl_error.rs:56:14 | LL | pub type Error = std::fmt::Error; | ^^^^^ diff --git a/tests/ui/exhaustive_items.fixed b/tests/ui/exhaustive_items.fixed index a3c584c2a2696..79c74aeefbd83 100644 --- a/tests/ui/exhaustive_items.fixed +++ b/tests/ui/exhaustive_items.fixed @@ -8,7 +8,7 @@ fn main() { pub mod enums { #[non_exhaustive] pub enum Exhaustive { - //~^ exhaustive_enums + //~^ exhaustive_enums Foo, Bar, Baz, @@ -19,7 +19,7 @@ pub mod enums { #[repr(C)] #[non_exhaustive] pub enum ExhaustiveWithAttrs { - //~^ exhaustive_enums + //~^ exhaustive_enums Foo, Bar, Baz, @@ -56,7 +56,7 @@ pub mod enums { pub mod structs { #[non_exhaustive] pub struct Exhaustive { - //~^ exhaustive_structs + //~^ exhaustive_structs pub foo: u8, pub bar: String, } diff --git a/tests/ui/exhaustive_items.rs b/tests/ui/exhaustive_items.rs index b1f0c789b709e..4e851f4c492e8 100644 --- a/tests/ui/exhaustive_items.rs +++ b/tests/ui/exhaustive_items.rs @@ -7,7 +7,7 @@ fn main() { pub mod enums { pub enum Exhaustive { - //~^ exhaustive_enums + //~^ exhaustive_enums Foo, Bar, Baz, @@ -17,7 +17,7 @@ pub mod enums { /// Some docs #[repr(C)] pub enum ExhaustiveWithAttrs { - //~^ exhaustive_enums + //~^ exhaustive_enums Foo, Bar, Baz, @@ -53,7 +53,7 @@ pub mod enums { pub mod structs { pub struct Exhaustive { - //~^ exhaustive_structs + //~^ exhaustive_structs pub foo: u8, pub bar: String, } diff --git a/tests/ui/exit1.rs b/tests/ui/exit1.rs index 127c72aac99f2..be8752cc7d8e2 100644 --- a/tests/ui/exit1.rs +++ b/tests/ui/exit1.rs @@ -4,8 +4,6 @@ fn not_main() { if true { std::process::exit(4); //~^ exit - - } } diff --git a/tests/ui/exit2.rs b/tests/ui/exit2.rs index 2e2c4828afe66..2be8a84b6d4bb 100644 --- a/tests/ui/exit2.rs +++ b/tests/ui/exit2.rs @@ -3,8 +3,6 @@ fn also_not_main() { std::process::exit(3); //~^ exit - - } fn main() { diff --git a/tests/ui/expect.rs b/tests/ui/expect.rs index 575c29e6f31cc..8f7379f002143 100644 --- a/tests/ui/expect.rs +++ b/tests/ui/expect.rs @@ -5,7 +5,6 @@ fn expect_option() { let opt = Some(0); let _ = opt.expect(""); //~^ expect_used - } fn expect_result() { @@ -15,7 +14,6 @@ fn expect_result() { let _ = res.expect_err(""); //~^ expect_used - } fn main() { diff --git a/tests/ui/expect.stderr b/tests/ui/expect.stderr index b44429a3b71df..70cf3072003e6 100644 --- a/tests/ui/expect.stderr +++ b/tests/ui/expect.stderr @@ -9,7 +9,7 @@ LL | let _ = opt.expect(""); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `expect()` on a `Result` value - --> tests/ui/expect.rs:13:13 + --> tests/ui/expect.rs:12:13 | LL | let _ = res.expect(""); | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = res.expect(""); = note: if this value is an `Err`, it will panic error: used `expect_err()` on a `Result` value - --> tests/ui/expect.rs:16:13 + --> tests/ui/expect.rs:15:13 | LL | let _ = res.expect_err(""); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/explicit_counter_loop.rs b/tests/ui/explicit_counter_loop.rs index 585e261c2f432..8340d99ace226 100644 --- a/tests/ui/explicit_counter_loop.rs +++ b/tests/ui/explicit_counter_loop.rs @@ -5,8 +5,7 @@ fn main() { let mut vec = vec![1, 2, 3, 4]; let mut _index = 0; for _v in &vec { - //~^ explicit_counter_loop - + //~^ explicit_counter_loop _index += 1 } @@ -14,21 +13,21 @@ fn main() { let mut _index = 1; _index = 0; for _v in &vec { - //~^ explicit_counter_loop + //~^ explicit_counter_loop _index += 1 } let mut _index = 0; for _v in &mut vec { - //~^ explicit_counter_loop + //~^ explicit_counter_loop _index += 1; } let mut _index = 0; for _v in vec { - //~^ explicit_counter_loop + //~^ explicit_counter_loop _index += 1; } @@ -117,7 +116,7 @@ mod issue_1219 { let text = "banana"; let mut count = 0; for ch in text.chars() { - //~^ explicit_counter_loop + //~^ explicit_counter_loop println!("{}", count); count += 1; @@ -130,7 +129,7 @@ mod issue_1219 { let text = "banana"; let mut count = 0; for ch in text.chars() { - //~^ explicit_counter_loop + //~^ explicit_counter_loop println!("{}", count); count += 1; @@ -190,7 +189,7 @@ mod issue_1670 { pub fn test() { let mut count = 0; for _i in 3..10 { - //~^ explicit_counter_loop + //~^ explicit_counter_loop count += 1; } @@ -232,7 +231,7 @@ mod issue_7920 { // should suggest `enumerate` for _item in slice { - //~^ explicit_counter_loop + //~^ explicit_counter_loop if idx_usize == index_usize { break; @@ -246,8 +245,7 @@ mod issue_7920 { // should suggest `zip` for _item in slice { - //~^ explicit_counter_loop - + //~^ explicit_counter_loop if idx_u32 == index_u32 { break; @@ -293,7 +291,7 @@ mod issue_13123 { let mut vec = vec![1, 2, 3, 4]; let mut _index = 0; 'label: for v in vec { - //~^ explicit_counter_loop + //~^ explicit_counter_loop _index += 1; if v == 1 { break 'label; diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index c565bd4cf356c..a73516558c20c 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -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 - --> tests/ui/explicit_counter_loop.rs:16:5 + --> tests/ui/explicit_counter_loop.rs:15: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 - --> tests/ui/explicit_counter_loop.rs:23:5 + --> tests/ui/explicit_counter_loop.rs:22: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 - --> tests/ui/explicit_counter_loop.rs:30:5 + --> tests/ui/explicit_counter_loop.rs:29: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 - --> tests/ui/explicit_counter_loop.rs:119:9 + --> tests/ui/explicit_counter_loop.rs:118: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 - --> tests/ui/explicit_counter_loop.rs:132:9 + --> tests/ui/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 - --> tests/ui/explicit_counter_loop.rs:192:9 + --> tests/ui/explicit_counter_loop.rs:191: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 - --> tests/ui/explicit_counter_loop.rs:234:9 + --> tests/ui/explicit_counter_loop.rs:233: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 - --> tests/ui/explicit_counter_loop.rs:248:9 + --> tests/ui/explicit_counter_loop.rs:247:9 | LL | for _item in slice { | ^^^^^^^^^^^^^^^^^^ help: consider using: `for (idx_u32, _item) in (0_u32..).zip(slice.iter())` @@ -58,7 +58,7 @@ LL | for _item in slice { = note: `idx_u32` is of type `u32`, making it ineligible for `Iterator::enumerate` error: the variable `_index` is used as a loop counter - --> tests/ui/explicit_counter_loop.rs:295:9 + --> tests/ui/explicit_counter_loop.rs:293:9 | LL | 'label: for v in vec { | ^^^^^^^^^^^^^^^^^^^^ help: consider using: `'label: for (_index, v) in vec.into_iter().enumerate()` diff --git a/tests/ui/explicit_deref_methods.fixed b/tests/ui/explicit_deref_methods.fixed index ae63f7cbfd8cb..0d1a5f80f3d5a 100644 --- a/tests/ui/explicit_deref_methods.fixed +++ b/tests/ui/explicit_deref_methods.fixed @@ -67,7 +67,7 @@ fn main() { #[allow(clippy::match_single_binding)] match &*a { - //~^ explicit_deref_methods + //~^ explicit_deref_methods _ => (), } diff --git a/tests/ui/explicit_deref_methods.rs b/tests/ui/explicit_deref_methods.rs index a1378bda85fa7..8d4a899cd2607 100644 --- a/tests/ui/explicit_deref_methods.rs +++ b/tests/ui/explicit_deref_methods.rs @@ -67,7 +67,7 @@ fn main() { #[allow(clippy::match_single_binding)] match a.deref() { - //~^ explicit_deref_methods + //~^ explicit_deref_methods _ => (), } diff --git a/tests/ui/extra_unused_lifetimes.rs b/tests/ui/extra_unused_lifetimes.rs index fb853bb583050..5fdcd5a7e0786 100644 --- a/tests/ui/extra_unused_lifetimes.rs +++ b/tests/ui/extra_unused_lifetimes.rs @@ -84,16 +84,16 @@ mod issue6437 { pub struct Scalar; impl<'a> std::ops::AddAssign<&Scalar> for &mut Scalar { - //~^ extra_unused_lifetimes + //~^ extra_unused_lifetimes fn add_assign(&mut self, _rhs: &Scalar) { unimplemented!(); } } impl<'b> Scalar { - //~^ extra_unused_lifetimes - pub fn something<'c>() -> Self { //~^ extra_unused_lifetimes + pub fn something<'c>() -> Self { + //~^ extra_unused_lifetimes Self } } @@ -123,7 +123,7 @@ mod second_case { // Should lint. The response to the above comment incorrectly called this a false positive. The // lifetime `'a` can be removed, as demonstrated below. impl<'a, T: Source + ?Sized + 'a> Source for Box { - //~^ extra_unused_lifetimes + //~^ extra_unused_lifetimes fn hey() {} } diff --git a/tests/ui/extra_unused_type_parameters.fixed b/tests/ui/extra_unused_type_parameters.fixed index 1ab74d398314f..32d4f6c693909 100644 --- a/tests/ui/extra_unused_type_parameters.fixed +++ b/tests/ui/extra_unused_type_parameters.fixed @@ -7,17 +7,17 @@ extern crate proc_macros; use proc_macros::with_span; fn unused_ty(x: u8) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } fn unused_multi(x: u8) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } fn unused_with_lt<'a>(x: &'a u8) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } @@ -30,12 +30,12 @@ fn used_ret(x: u8) -> T { } fn unused_bounded(x: U) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!(); } fn some_unused(b: B, c: C) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!(); } @@ -61,7 +61,7 @@ struct S; impl S { fn unused_ty_impl(&self) { - //~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } } @@ -84,7 +84,7 @@ where } fn unused_opaque(dummy: impl Default) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } @@ -98,7 +98,7 @@ mod unexported_trait_bounds { } fn unused_with_priv_trait_bound() { - //~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!(); } } diff --git a/tests/ui/extra_unused_type_parameters.rs b/tests/ui/extra_unused_type_parameters.rs index 0837efef27bb7..c1e6f32ca12f1 100644 --- a/tests/ui/extra_unused_type_parameters.rs +++ b/tests/ui/extra_unused_type_parameters.rs @@ -7,17 +7,17 @@ extern crate proc_macros; use proc_macros::with_span; fn unused_ty(x: u8) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } fn unused_multi(x: u8) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } fn unused_with_lt<'a, T>(x: &'a u8) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } @@ -30,12 +30,12 @@ fn used_ret(x: u8) -> T { } fn unused_bounded(x: U) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!(); } fn some_unused, E>(b: B, c: C) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!(); } @@ -61,7 +61,7 @@ struct S; impl S { fn unused_ty_impl(&self) { - //~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } } @@ -84,7 +84,7 @@ where } fn unused_opaque(dummy: impl Default) { -//~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!() } @@ -98,7 +98,7 @@ mod unexported_trait_bounds { } fn unused_with_priv_trait_bound() { - //~^ extra_unused_type_parameters + //~^ extra_unused_type_parameters unimplemented!(); } } diff --git a/tests/ui/extra_unused_type_parameters_unfixable.rs b/tests/ui/extra_unused_type_parameters_unfixable.rs index e69c924af00d3..87ce517a0a451 100644 --- a/tests/ui/extra_unused_type_parameters_unfixable.rs +++ b/tests/ui/extra_unused_type_parameters_unfixable.rs @@ -2,7 +2,6 @@ fn unused_where_clause(x: U) //~^ extra_unused_type_parameters - where T: Default, { @@ -11,7 +10,6 @@ where fn unused_multi_where_clause(x: U) //~^ extra_unused_type_parameters - where T: Default, { @@ -20,7 +18,6 @@ where fn unused_all_where_clause() //~^ extra_unused_type_parameters - where T: Default, { diff --git a/tests/ui/extra_unused_type_parameters_unfixable.stderr b/tests/ui/extra_unused_type_parameters_unfixable.stderr index 8accb7e5924e4..0765c41609368 100644 --- a/tests/ui/extra_unused_type_parameters_unfixable.stderr +++ b/tests/ui/extra_unused_type_parameters_unfixable.stderr @@ -9,7 +9,7 @@ LL | fn unused_where_clause(x: U) = help: to override `-D warnings` add `#[allow(clippy::extra_unused_type_parameters)]` error: type parameters go unused in function definition: T, V - --> tests/ui/extra_unused_type_parameters_unfixable.rs:12:30 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:11:30 | LL | fn unused_multi_where_clause(x: U) | ^ ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | fn unused_multi_where_clause(x: U) = help: consider removing the parameters error: type parameters go unused in function definition: T, U, V - --> tests/ui/extra_unused_type_parameters_unfixable.rs:21:28 + --> tests/ui/extra_unused_type_parameters_unfixable.rs:19:28 | LL | fn unused_all_where_clause() | ^ ^^^^^^^^^^ ^^^^^^^^^^ diff --git a/tests/ui/fallible_impl_from.rs b/tests/ui/fallible_impl_from.rs index 56bd8a4826847..1c62c1e937b63 100644 --- a/tests/ui/fallible_impl_from.rs +++ b/tests/ui/fallible_impl_from.rs @@ -4,7 +4,7 @@ // docs example struct Foo(i32); impl From for Foo { -//~^ fallible_impl_from + //~^ fallible_impl_from fn from(s: String) -> Self { Foo(s.parse().unwrap()) @@ -27,7 +27,7 @@ impl From for Valid { struct Invalid; impl From for Invalid { -//~^ fallible_impl_from + //~^ fallible_impl_from fn from(i: usize) -> Invalid { if i != 42 { @@ -38,7 +38,7 @@ impl From for Invalid { } impl From> for Invalid { -//~^ fallible_impl_from + //~^ fallible_impl_from fn from(s: Option) -> Invalid { let s = s.unwrap(); @@ -58,7 +58,7 @@ impl ProjStrTrait for Box { type ProjString = String; } impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { -//~^ fallible_impl_from + //~^ fallible_impl_from fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { if s.parse::().ok().unwrap() != 42 { diff --git a/tests/ui/filetype_is_file.rs b/tests/ui/filetype_is_file.rs index 0e9c160e4a907..8ca01b91210fb 100644 --- a/tests/ui/filetype_is_file.rs +++ b/tests/ui/filetype_is_file.rs @@ -7,21 +7,21 @@ fn main() -> std::io::Result<()> { // !filetype.is_dir() if fs::metadata("foo.txt")?.file_type().is_file() { - //~^ filetype_is_file + //~^ filetype_is_file // read file } // positive of filetype.is_dir() if !fs::metadata("foo.txt")?.file_type().is_file() { - //~^ filetype_is_file + //~^ filetype_is_file // handle dir } // false positive of filetype.is_dir() if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) { - //~^ filetype_is_file + //~^ filetype_is_file // ... } diff --git a/tests/ui/filter_map_bool_then.fixed b/tests/ui/filter_map_bool_then.fixed index 6d9564dc828b8..b3e112f19eb4a 100644 --- a/tests/ui/filter_map_bool_then.fixed +++ b/tests/ui/filter_map_bool_then.fixed @@ -23,17 +23,17 @@ fn main() { v.clone() .into_iter() .filter(|&i| (i % 2 == 0)).map(|i| i + 1); - //~^ filter_map_bool_then + //~^ filter_map_bool_then v.clone() .into_iter() .filter(|&i| i != 1000) .filter(|&i| (i % 2 == 0)).map(|i| i + 1); - //~^ filter_map_bool_then + //~^ filter_map_bool_then v.iter() .copied() .filter(|&i| i != 1000) .filter(|&i| (i.clone() % 2 == 0)).map(|i| i + 1); - //~^ filter_map_bool_then + //~^ filter_map_bool_then // Despite this is non-copy, `is_copy` still returns true (at least now) because it's `&NonCopy`, // and any `&` is `Copy`. So since we can dereference it in `filter` (since it's then `&&NonCopy`), // we can lint this and still get the same input type. diff --git a/tests/ui/filter_map_bool_then.rs b/tests/ui/filter_map_bool_then.rs index dffd798da2543..d996b3cb3c52a 100644 --- a/tests/ui/filter_map_bool_then.rs +++ b/tests/ui/filter_map_bool_then.rs @@ -23,17 +23,17 @@ fn main() { v.clone() .into_iter() .filter_map(|i| -> Option<_> { (i % 2 == 0).then(|| i + 1) }); - //~^ filter_map_bool_then + //~^ filter_map_bool_then v.clone() .into_iter() .filter(|&i| i != 1000) .filter_map(|i| (i % 2 == 0).then(|| i + 1)); - //~^ filter_map_bool_then + //~^ filter_map_bool_then v.iter() .copied() .filter(|&i| i != 1000) .filter_map(|i| (i.clone() % 2 == 0).then(|| i + 1)); - //~^ filter_map_bool_then + //~^ filter_map_bool_then // Despite this is non-copy, `is_copy` still returns true (at least now) because it's `&NonCopy`, // and any `&` is `Copy`. So since we can dereference it in `filter` (since it's then `&&NonCopy`), // we can lint this and still get the same input type. diff --git a/tests/ui/filter_map_identity.fixed b/tests/ui/filter_map_identity.fixed index 40c3f58da9765..c9e2c5f5049f3 100644 --- a/tests/ui/filter_map_identity.fixed +++ b/tests/ui/filter_map_identity.fixed @@ -40,14 +40,12 @@ fn main() { copy_vec_non_inferred().into_iter().flatten(); //~^ filter_map_identity - non_copy_vec().into_iter().flatten(); //~^ filter_map_identity non_copy_vec().into_iter().flatten(); //~^ filter_map_identity - non_copy_vec().into_iter().flatten(); //~^ filter_map_identity @@ -60,7 +58,6 @@ fn main() { non_copy_vec().into_iter().flatten(); //~^ filter_map_identity - copy_vec::().into_iter().flatten(); //~^ filter_map_identity @@ -73,7 +70,6 @@ fn main() { copy_vec::().into_iter().flatten(); //~^ filter_map_identity - // we are forced to pass the type in the call. copy_vec::().into_iter().flatten(); //~^ filter_map_identity @@ -89,18 +85,16 @@ fn main() { #[rustfmt::skip] copy_vec::().into_iter().flatten(); - //~^ filter_map_identity + //~^ filter_map_identity #[rustfmt::skip] copy_vec::().into_iter().flatten(); - //~^ filter_map_identity - + //~^ filter_map_identity // note, the compiler requires that we pass the type to `opaque`. This is mostly for reference, // it behaves the same as copy_vec. opaque::().into_iter().flatten(); //~^ filter_map_identity - } } diff --git a/tests/ui/filter_map_identity.rs b/tests/ui/filter_map_identity.rs index f11f80437e854..4c8d48f5221f1 100644 --- a/tests/ui/filter_map_identity.rs +++ b/tests/ui/filter_map_identity.rs @@ -40,14 +40,12 @@ fn main() { copy_vec_non_inferred().into_iter().filter_map(|x| return x); //~^ filter_map_identity - non_copy_vec().into_iter().filter_map(|x| x); //~^ filter_map_identity non_copy_vec().into_iter().filter_map(|x| x); //~^ filter_map_identity - non_copy_vec().into_iter().filter_map(std::convert::identity); //~^ filter_map_identity @@ -60,7 +58,6 @@ fn main() { non_copy_vec().into_iter().filter_map(|x| return x); //~^ filter_map_identity - copy_vec::().into_iter().filter_map(|x: Option<_>| x); //~^ filter_map_identity @@ -73,7 +70,6 @@ fn main() { copy_vec::().into_iter().filter_map(|x: Option<_>| return x); //~^ filter_map_identity - // we are forced to pass the type in the call. copy_vec::().into_iter().filter_map(|x: Option| x); //~^ filter_map_identity @@ -89,18 +85,16 @@ fn main() { #[rustfmt::skip] copy_vec::().into_iter().filter_map(|x: Option| -> Option {{ x }}); - //~^ filter_map_identity + //~^ filter_map_identity #[rustfmt::skip] copy_vec::().into_iter().filter_map(|x: Option| -> Option {{ return x }}); - //~^ filter_map_identity - + //~^ filter_map_identity // note, the compiler requires that we pass the type to `opaque`. This is mostly for reference, // it behaves the same as copy_vec. opaque::().into_iter().filter_map(|x| x); //~^ filter_map_identity - } } diff --git a/tests/ui/filter_map_identity.stderr b/tests/ui/filter_map_identity.stderr index 4223343251f11..26b6e0bc7b343 100644 --- a/tests/ui/filter_map_identity.stderr +++ b/tests/ui/filter_map_identity.stderr @@ -32,103 +32,103 @@ LL | copy_vec_non_inferred().into_iter().filter_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:44:36 + --> tests/ui/filter_map_identity.rs:43:36 | LL | non_copy_vec().into_iter().filter_map(|x| x); | ^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:47:36 + --> tests/ui/filter_map_identity.rs:46:36 | LL | non_copy_vec().into_iter().filter_map(|x| x); | ^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:51:36 + --> tests/ui/filter_map_identity.rs:49:36 | LL | non_copy_vec().into_iter().filter_map(std::convert::identity); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:54:36 + --> tests/ui/filter_map_identity.rs:52:36 | LL | non_copy_vec().into_iter().filter_map(identity); | ^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:57:36 + --> tests/ui/filter_map_identity.rs:55:36 | LL | non_copy_vec().into_iter().filter_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:60:36 + --> tests/ui/filter_map_identity.rs:58:36 | LL | non_copy_vec().into_iter().filter_map(|x| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:64:39 + --> tests/ui/filter_map_identity.rs:61:39 | LL | copy_vec::().into_iter().filter_map(|x: Option<_>| x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:67:39 + --> tests/ui/filter_map_identity.rs:64:39 | LL | copy_vec::().into_iter().filter_map(|x: Option<_>| x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:70:39 + --> tests/ui/filter_map_identity.rs:67:39 | LL | copy_vec::().into_iter().filter_map(|x: Option<_>| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:73:39 + --> tests/ui/filter_map_identity.rs:70:39 | LL | copy_vec::().into_iter().filter_map(|x: Option<_>| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:78:39 + --> tests/ui/filter_map_identity.rs:74:39 | LL | copy_vec::().into_iter().filter_map(|x: Option| x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:81:39 + --> tests/ui/filter_map_identity.rs:77:39 | LL | copy_vec::().into_iter().filter_map(|x: Option| x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:84:39 + --> tests/ui/filter_map_identity.rs:80:39 | LL | copy_vec::().into_iter().filter_map(|x: Option| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:87:39 + --> tests/ui/filter_map_identity.rs:83:39 | LL | copy_vec::().into_iter().filter_map(|x: Option| return x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:91:43 + --> tests/ui/filter_map_identity.rs:87:43 | LL | copy_vec::().into_iter().filter_map(|x: Option| -> Option {{ x }}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:95:43 + --> tests/ui/filter_map_identity.rs:91:43 | LL | copy_vec::().into_iter().filter_map(|x: Option| -> Option {{ return x }}); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()` error: use of `filter_map` with an identity function - --> tests/ui/filter_map_identity.rs:101:37 + --> tests/ui/filter_map_identity.rs:96:37 | LL | opaque::().into_iter().filter_map(|x| x); | ^^^^^^^^^^^^^^^^^ help: try: `flatten()` diff --git a/tests/ui/float_arithmetic.rs b/tests/ui/float_arithmetic.rs index 3b87d2ec066de..3c447bc94c666 100644 --- a/tests/ui/float_arithmetic.rs +++ b/tests/ui/float_arithmetic.rs @@ -58,30 +58,25 @@ pub fn float_arith_ref() { &3.5_f32 + &1.3_f32; //~^ float_arithmetic - } pub fn float_foo(f: &f32) -> f32 { let a = 5.1; a + f //~^ float_arithmetic - } pub fn float_bar(f1: &f32, f2: &f32) -> f32 { f1 + f2 //~^ float_arithmetic - } pub fn float_baz(f1: f32, f2: &f32) -> f32 { f1 + f2 //~^ float_arithmetic - } pub fn float_qux(f1: f32, f2: f32) -> f32 { (&f1 + &f2) //~^ float_arithmetic - } diff --git a/tests/ui/float_arithmetic.stderr b/tests/ui/float_arithmetic.stderr index c01fdf8b46ecd..8704f7bbd7c4e 100644 --- a/tests/ui/float_arithmetic.stderr +++ b/tests/ui/float_arithmetic.stderr @@ -80,25 +80,25 @@ LL | &3.5_f32 + &1.3_f32; | ^^^^^^^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> tests/ui/float_arithmetic.rs:66:5 + --> tests/ui/float_arithmetic.rs:65:5 | LL | a + f | ^^^^^ error: floating-point arithmetic detected - --> tests/ui/float_arithmetic.rs:72:5 + --> tests/ui/float_arithmetic.rs:70:5 | LL | f1 + f2 | ^^^^^^^ error: floating-point arithmetic detected - --> tests/ui/float_arithmetic.rs:78:5 + --> tests/ui/float_arithmetic.rs:75:5 | LL | f1 + f2 | ^^^^^^^ error: floating-point arithmetic detected - --> tests/ui/float_arithmetic.rs:84:5 + --> tests/ui/float_arithmetic.rs:80:5 | LL | (&f1 + &f2) | ^^^^^^^^^^^ diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index 84cf67ed4f100..ce0ffd8a21927 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -84,7 +84,6 @@ fn main() { twice(x) != twice(ONE as f64); //~^ float_cmp - x < 0.0; // no errors, lower or greater comparisons need no fuzzyness x > 0.0; x <= 0.0; @@ -106,7 +105,6 @@ fn main() { NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; //~^ float_cmp - let a1: [f32; 1] = [0.0]; let a2: [f32; 1] = [1.1]; @@ -116,7 +114,6 @@ fn main() { a1[0] == a2[0]; //~^ float_cmp - // no errors - comparing signums is ok let x32 = 3.21f32; 1.23f32.signum() == x32.signum(); diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 1b57e15bbb972..e573c0baeac26 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -20,19 +20,19 @@ LL | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(twice(x) - twice(ONE as f64)).abs() > error_margin` error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:106:5 + --> tests/ui/float_cmp.rs:105:5 | LL | NON_ZERO_ARRAY[i] == NON_ZERO_ARRAY[j]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(NON_ZERO_ARRAY[i] - NON_ZERO_ARRAY[j]).abs() < error_margin` error: strict comparison of `f32` or `f64` arrays - --> tests/ui/float_cmp.rs:113:5 + --> tests/ui/float_cmp.rs:111:5 | LL | a1 == a2; | ^^^^^^^^ error: strict comparison of `f32` or `f64` - --> tests/ui/float_cmp.rs:116:5 + --> tests/ui/float_cmp.rs:114:5 | LL | a1[0] == a2[0]; | ^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(a1[0] - a2[0]).abs() < error_margin` diff --git a/tests/ui/float_cmp_const.rs b/tests/ui/float_cmp_const.rs index 86b3e5d46a061..3af53f2e84a22 100644 --- a/tests/ui/float_cmp_const.rs +++ b/tests/ui/float_cmp_const.rs @@ -28,7 +28,6 @@ fn main() { x as f32 == ONE; //~^ float_cmp_const - let v = 0.9; v == ONE; //~^ float_cmp_const @@ -36,7 +35,6 @@ fn main() { v != ONE; //~^ float_cmp_const - // no errors, lower than or greater than comparisons v < ONE; v > ONE; @@ -69,5 +67,4 @@ fn main() { // has errors NON_ZERO_ARRAY == NON_ZERO_ARRAY2; //~^ float_cmp_const - } diff --git a/tests/ui/float_cmp_const.stderr b/tests/ui/float_cmp_const.stderr index c2c7b229870a1..482a55a54be69 100644 --- a/tests/ui/float_cmp_const.stderr +++ b/tests/ui/float_cmp_const.stderr @@ -32,19 +32,19 @@ LL | x as f32 == ONE; | ^^^^^^^^^^^^^^^ help: consider comparing them within some margin of error: `(x as f32 - ONE).abs() < error_margin` error: strict comparison of `f32` or `f64` constant - --> tests/ui/float_cmp_const.rs:33:5 + --> tests/ui/float_cmp_const.rs:32:5 | LL | v == ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() < error_margin` error: strict comparison of `f32` or `f64` constant - --> tests/ui/float_cmp_const.rs:36:5 + --> tests/ui/float_cmp_const.rs:35:5 | LL | v != ONE; | ^^^^^^^^ help: consider comparing them within some margin of error: `(v - ONE).abs() > error_margin` error: strict comparison of `f32` or `f64` constant arrays - --> tests/ui/float_cmp_const.rs:70:5 + --> tests/ui/float_cmp_const.rs:68:5 | LL | NON_ZERO_ARRAY == NON_ZERO_ARRAY2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/float_equality_without_abs.rs b/tests/ui/float_equality_without_abs.rs index db0a4f492607d..a1548db6710d1 100644 --- a/tests/ui/float_equality_without_abs.rs +++ b/tests/ui/float_equality_without_abs.rs @@ -6,8 +6,6 @@ pub fn is_roughly_equal(a: f32, b: f32) -> bool { (a - b) < f32::EPSILON //~^ float_equality_without_abs - - } pub fn main() { @@ -31,7 +29,6 @@ pub fn main() { let _ = 1.0 - 2.0 < f32::EPSILON; //~^ float_equality_without_abs - let _ = f32::EPSILON > (a - b); //~^ float_equality_without_abs @@ -47,7 +44,6 @@ pub fn main() { let _ = f32::EPSILON > 1.0 - 2.0; //~^ float_equality_without_abs - // those are correct let _ = (a - b).abs() < f32::EPSILON; let _ = (a as f64 - b as f64).abs() < f64::EPSILON; diff --git a/tests/ui/float_equality_without_abs.stderr b/tests/ui/float_equality_without_abs.stderr index 5696ec54d7650..d4c89ce72ba9b 100644 --- a/tests/ui/float_equality_without_abs.stderr +++ b/tests/ui/float_equality_without_abs.stderr @@ -10,7 +10,7 @@ LL | (a - b) < f32::EPSILON = help: to override `-D warnings` add `#[allow(clippy::float_equality_without_abs)]` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:19:13 + --> tests/ui/float_equality_without_abs.rs:17:13 | LL | let _ = (a - b) < f32::EPSILON; | -------^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | let _ = (a - b) < f32::EPSILON; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:22:13 + --> tests/ui/float_equality_without_abs.rs:20:13 | LL | let _ = a - b < f32::EPSILON; | -----^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _ = a - b < f32::EPSILON; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:25:13 + --> tests/ui/float_equality_without_abs.rs:23:13 | LL | let _ = a - b.abs() < f32::EPSILON; | -----------^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = a - b.abs() < f32::EPSILON; | help: add `.abs()`: `(a - b.abs()).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:28:13 + --> tests/ui/float_equality_without_abs.rs:26:13 | LL | let _ = (a as f64 - b as f64) < f64::EPSILON; | ---------------------^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | let _ = (a as f64 - b as f64) < f64::EPSILON; | help: add `.abs()`: `(a as f64 - b as f64).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:31:13 + --> tests/ui/float_equality_without_abs.rs:29:13 | LL | let _ = 1.0 - 2.0 < f32::EPSILON; | ---------^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | let _ = 1.0 - 2.0 < f32::EPSILON; | help: add `.abs()`: `(1.0 - 2.0).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:35:13 + --> tests/ui/float_equality_without_abs.rs:32:13 | LL | let _ = f32::EPSILON > (a - b); | ^^^^^^^^^^^^^^^------- @@ -58,7 +58,7 @@ LL | let _ = f32::EPSILON > (a - b); | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:38:13 + --> tests/ui/float_equality_without_abs.rs:35:13 | LL | let _ = f32::EPSILON > a - b; | ^^^^^^^^^^^^^^^----- @@ -66,7 +66,7 @@ LL | let _ = f32::EPSILON > a - b; | help: add `.abs()`: `(a - b).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:41:13 + --> tests/ui/float_equality_without_abs.rs:38:13 | LL | let _ = f32::EPSILON > a - b.abs(); | ^^^^^^^^^^^^^^^----------- @@ -74,7 +74,7 @@ LL | let _ = f32::EPSILON > a - b.abs(); | help: add `.abs()`: `(a - b.abs()).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:44:13 + --> tests/ui/float_equality_without_abs.rs:41:13 | LL | let _ = f64::EPSILON > (a as f64 - b as f64); | ^^^^^^^^^^^^^^^--------------------- @@ -82,7 +82,7 @@ LL | let _ = f64::EPSILON > (a as f64 - b as f64); | help: add `.abs()`: `(a as f64 - b as f64).abs()` error: float equality check without `.abs()` - --> tests/ui/float_equality_without_abs.rs:47:13 + --> tests/ui/float_equality_without_abs.rs:44:13 | LL | let _ = f32::EPSILON > 1.0 - 2.0; | ^^^^^^^^^^^^^^^--------- diff --git a/tests/ui/fn_to_numeric_cast_any.rs b/tests/ui/fn_to_numeric_cast_any.rs index 3359e24c2b6a4..42f2128cd3783 100644 --- a/tests/ui/fn_to_numeric_cast_any.rs +++ b/tests/ui/fn_to_numeric_cast_any.rs @@ -23,7 +23,6 @@ fn fn_pointer_to_integer() { let _ = foo as i8; //~^ fn_to_numeric_cast_any - let _ = foo as i16; //~^ fn_to_numeric_cast_any @@ -39,7 +38,6 @@ fn fn_pointer_to_integer() { let _ = foo as isize; //~^ fn_to_numeric_cast_any - let _ = foo as u8; //~^ fn_to_numeric_cast_any @@ -57,25 +55,21 @@ fn fn_pointer_to_integer() { let _ = foo as usize; //~^ fn_to_numeric_cast_any - } fn static_method_to_integer() { let _ = Struct::static_method as usize; //~^ fn_to_numeric_cast_any - } fn fn_with_fn_arg(f: fn(i32) -> u32) -> usize { f as usize //~^ fn_to_numeric_cast_any - } fn fn_with_generic_static_trait_method() -> usize { T::static_method as usize //~^ fn_to_numeric_cast_any - } fn closure_to_fn_to_integer() { @@ -83,13 +77,11 @@ fn closure_to_fn_to_integer() { let _ = (clos as fn(u32) -> u32) as usize; //~^ fn_to_numeric_cast_any - } fn fn_to_raw_ptr() { let _ = foo as *const (); //~^ fn_to_numeric_cast_any - } fn cast_fn_to_self() { diff --git a/tests/ui/fn_to_numeric_cast_any.stderr b/tests/ui/fn_to_numeric_cast_any.stderr index c6a7b24033952..0a98952faef19 100644 --- a/tests/ui/fn_to_numeric_cast_any.stderr +++ b/tests/ui/fn_to_numeric_cast_any.stderr @@ -12,7 +12,7 @@ LL | let _ = foo() as i8; | ~~~~~~~~~~~ error: casting function pointer `foo` to `i16` - --> tests/ui/fn_to_numeric_cast_any.rs:27:13 + --> tests/ui/fn_to_numeric_cast_any.rs:26:13 | LL | let _ = foo as i16; | ^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = foo() as i16; | ~~~~~~~~~~~~ error: casting function pointer `foo` to `i32` - --> tests/ui/fn_to_numeric_cast_any.rs:30:13 + --> tests/ui/fn_to_numeric_cast_any.rs:29:13 | LL | let _ = foo as i32; | ^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = foo() as i32; | ~~~~~~~~~~~~ error: casting function pointer `foo` to `i64` - --> tests/ui/fn_to_numeric_cast_any.rs:33:13 + --> tests/ui/fn_to_numeric_cast_any.rs:32:13 | LL | let _ = foo as i64; | ^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | let _ = foo() as i64; | ~~~~~~~~~~~~ error: casting function pointer `foo` to `i128` - --> tests/ui/fn_to_numeric_cast_any.rs:36:13 + --> tests/ui/fn_to_numeric_cast_any.rs:35:13 | LL | let _ = foo as i128; | ^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | let _ = foo() as i128; | ~~~~~~~~~~~~~ error: casting function pointer `foo` to `isize` - --> tests/ui/fn_to_numeric_cast_any.rs:39:13 + --> tests/ui/fn_to_numeric_cast_any.rs:38:13 | LL | let _ = foo as isize; | ^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | let _ = foo() as isize; | ~~~~~~~~~~~~~~ error: casting function pointer `foo` to `u8` - --> tests/ui/fn_to_numeric_cast_any.rs:43:13 + --> tests/ui/fn_to_numeric_cast_any.rs:41:13 | LL | let _ = foo as u8; | ^^^^^^^^^ @@ -78,7 +78,7 @@ LL | let _ = foo() as u8; | ~~~~~~~~~~~ error: casting function pointer `foo` to `u16` - --> tests/ui/fn_to_numeric_cast_any.rs:46:13 + --> tests/ui/fn_to_numeric_cast_any.rs:44:13 | LL | let _ = foo as u16; | ^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = foo() as u16; | ~~~~~~~~~~~~ error: casting function pointer `foo` to `u32` - --> tests/ui/fn_to_numeric_cast_any.rs:49:13 + --> tests/ui/fn_to_numeric_cast_any.rs:47:13 | LL | let _ = foo as u32; | ^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | let _ = foo() as u32; | ~~~~~~~~~~~~ error: casting function pointer `foo` to `u64` - --> tests/ui/fn_to_numeric_cast_any.rs:52:13 + --> tests/ui/fn_to_numeric_cast_any.rs:50:13 | LL | let _ = foo as u64; | ^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | let _ = foo() as u64; | ~~~~~~~~~~~~ error: casting function pointer `foo` to `u128` - --> tests/ui/fn_to_numeric_cast_any.rs:55:13 + --> tests/ui/fn_to_numeric_cast_any.rs:53:13 | LL | let _ = foo as u128; | ^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | let _ = foo() as u128; | ~~~~~~~~~~~~~ error: casting function pointer `foo` to `usize` - --> tests/ui/fn_to_numeric_cast_any.rs:58:13 + --> tests/ui/fn_to_numeric_cast_any.rs:56:13 | LL | let _ = foo as usize; | ^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | let _ = foo() as usize; | ~~~~~~~~~~~~~~ error: casting function pointer `Struct::static_method` to `usize` - --> tests/ui/fn_to_numeric_cast_any.rs:64:13 + --> tests/ui/fn_to_numeric_cast_any.rs:61:13 | LL | let _ = Struct::static_method as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +144,7 @@ LL | let _ = Struct::static_method() as usize; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting function pointer `f` to `usize` - --> tests/ui/fn_to_numeric_cast_any.rs:70:5 + --> tests/ui/fn_to_numeric_cast_any.rs:66:5 | LL | f as usize | ^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | f() as usize | error: casting function pointer `T::static_method` to `usize` - --> tests/ui/fn_to_numeric_cast_any.rs:76:5 + --> tests/ui/fn_to_numeric_cast_any.rs:71:5 | LL | T::static_method as usize | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | T::static_method() as usize | error: casting function pointer `(clos as fn(u32) -> u32)` to `usize` - --> tests/ui/fn_to_numeric_cast_any.rs:84:13 + --> tests/ui/fn_to_numeric_cast_any.rs:78:13 | LL | let _ = (clos as fn(u32) -> u32) as usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +177,7 @@ LL | let _ = (clos as fn(u32) -> u32)() as usize; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: casting function pointer `foo` to `*const ()` - --> tests/ui/fn_to_numeric_cast_any.rs:90:13 + --> tests/ui/fn_to_numeric_cast_any.rs:83:13 | LL | let _ = foo as *const (); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/for_kv_map.fixed b/tests/ui/for_kv_map.fixed index 402098e9394b0..2a68b7443fbf2 100644 --- a/tests/ui/for_kv_map.fixed +++ b/tests/ui/for_kv_map.fixed @@ -7,15 +7,14 @@ use std::rc::Rc; fn main() { let m: HashMap = HashMap::new(); for v in m.values() { - //~^ for_kv_map - + //~^ for_kv_map let _v = v; } let m: Rc> = Rc::new(HashMap::new()); for v in (*m).values() { - //~^ for_kv_map + //~^ for_kv_map let _v = v; // Here the `*` is not actually necessary, but the test tests that we don't @@ -25,14 +24,14 @@ fn main() { let mut m: HashMap = HashMap::new(); for v in m.values_mut() { - //~^ for_kv_map + //~^ for_kv_map let _v = v; } let m: &mut HashMap = &mut HashMap::new(); for v in (*m).values_mut() { - //~^ for_kv_map + //~^ for_kv_map let _v = v; } @@ -40,7 +39,7 @@ fn main() { let m: HashMap = HashMap::new(); let rm = &m; for k in rm.keys() { - //~^ for_kv_map + //~^ for_kv_map let _k = k; } @@ -48,7 +47,7 @@ fn main() { let m: HashMap = HashMap::new(); let rm = &m; 'label: for k in rm.keys() { - //~^ for_kv_map + //~^ for_kv_map let _k = k; if *k == 0u64 { diff --git a/tests/ui/for_kv_map.rs b/tests/ui/for_kv_map.rs index 407590747a4b4..485a97815e3cf 100644 --- a/tests/ui/for_kv_map.rs +++ b/tests/ui/for_kv_map.rs @@ -7,15 +7,14 @@ use std::rc::Rc; fn main() { let m: HashMap = HashMap::new(); for (_, v) in &m { - //~^ for_kv_map - + //~^ for_kv_map let _v = v; } let m: Rc> = Rc::new(HashMap::new()); for (_, v) in &*m { - //~^ for_kv_map + //~^ for_kv_map let _v = v; // Here the `*` is not actually necessary, but the test tests that we don't @@ -25,14 +24,14 @@ fn main() { let mut m: HashMap = HashMap::new(); for (_, v) in &mut m { - //~^ for_kv_map + //~^ for_kv_map let _v = v; } let m: &mut HashMap = &mut HashMap::new(); for (_, v) in &mut *m { - //~^ for_kv_map + //~^ for_kv_map let _v = v; } @@ -40,7 +39,7 @@ fn main() { let m: HashMap = HashMap::new(); let rm = &m; for (k, _value) in rm { - //~^ for_kv_map + //~^ for_kv_map let _k = k; } @@ -48,7 +47,7 @@ fn main() { let m: HashMap = HashMap::new(); let rm = &m; 'label: for (k, _value) in rm { - //~^ for_kv_map + //~^ for_kv_map let _k = k; if *k == 0u64 { diff --git a/tests/ui/for_kv_map.stderr b/tests/ui/for_kv_map.stderr index 5c28da81a9611..878c435321946 100644 --- a/tests/ui/for_kv_map.stderr +++ b/tests/ui/for_kv_map.stderr @@ -12,7 +12,7 @@ LL | for v in m.values() { | ~ ~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> tests/ui/for_kv_map.rs:17:19 + --> tests/ui/for_kv_map.rs:16:19 | LL | for (_, v) in &*m { | ^^^ @@ -23,7 +23,7 @@ LL | for v in (*m).values() { | ~ ~~~~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> tests/ui/for_kv_map.rs:27:19 + --> tests/ui/for_kv_map.rs:26:19 | LL | for (_, v) in &mut m { | ^^^^^^ @@ -34,7 +34,7 @@ LL | for v in m.values_mut() { | ~ ~~~~~~~~~~~~~~ error: you seem to want to iterate on a map's values - --> tests/ui/for_kv_map.rs:34:19 + --> tests/ui/for_kv_map.rs:33:19 | LL | for (_, v) in &mut *m { | ^^^^^^^ @@ -45,7 +45,7 @@ LL | for v in (*m).values_mut() { | ~ ~~~~~~~~~~~~~~~~~ error: you seem to want to iterate on a map's keys - --> tests/ui/for_kv_map.rs:42:24 + --> tests/ui/for_kv_map.rs:41:24 | LL | for (k, _value) in rm { | ^^ @@ -56,7 +56,7 @@ LL | for k in rm.keys() { | ~ ~~~~~~~~~ error: you seem to want to iterate on a map's keys - --> tests/ui/for_kv_map.rs:50:32 + --> tests/ui/for_kv_map.rs:49:32 | LL | 'label: for (k, _value) in rm { | ^^ diff --git a/tests/ui/forget_non_drop.rs b/tests/ui/forget_non_drop.rs index a69fa0f203597..0235709b1f1ca 100644 --- a/tests/ui/forget_non_drop.rs +++ b/tests/ui/forget_non_drop.rs @@ -13,7 +13,6 @@ fn main() { forget(Foo); //~^ forget_non_drop - struct Bar; impl Drop for Bar { fn drop(&mut self) {} diff --git a/tests/ui/forget_non_drop.stderr b/tests/ui/forget_non_drop.stderr index 0bff152a71326..e121984154c73 100644 --- a/tests/ui/forget_non_drop.stderr +++ b/tests/ui/forget_non_drop.stderr @@ -13,13 +13,13 @@ LL | forget(Foo); = help: to override `-D warnings` add `#[allow(clippy::forget_non_drop)]` error: call to `std::mem::forget` with a value that does not implement `Drop`. Forgetting such a type is the same as dropping it - --> tests/ui/forget_non_drop.rs:26:5 + --> tests/ui/forget_non_drop.rs:25:5 | LL | forget(Baz(Foo)); | ^^^^^^^^^^^^^^^^ | note: argument has type `main::Baz` - --> tests/ui/forget_non_drop.rs:26:12 + --> tests/ui/forget_non_drop.rs:25:12 | LL | forget(Baz(Foo)); | ^^^^^^^^ diff --git a/tests/ui/format.rs b/tests/ui/format.rs index b40eb9d1eb9e4..06371378f27ed 100644 --- a/tests/ui/format.rs +++ b/tests/ui/format.rs @@ -24,7 +24,7 @@ fn main() { format!("{{}} abc {{}}"); //~^ useless_format format!( - //~^ useless_format + //~^ useless_format r##"foo {{}} " bar"## ); diff --git a/tests/ui/format_args.fixed b/tests/ui/format_args.fixed index 075450451b245..edfdaa23ca124 100644 --- a/tests/ui/format_args.fixed +++ b/tests/ui/format_args.fixed @@ -79,13 +79,13 @@ fn main() { let _ = write!( stdout(), "error: something failed at {}", - Location::caller() + Location::caller(), //~^ to_string_in_format_args ); let _ = writeln!( stdout(), "error: something failed at {}", - Location::caller() + Location::caller(), //~^ to_string_in_format_args ); print!("error: something failed at {}", Location::caller()); diff --git a/tests/ui/format_args.rs b/tests/ui/format_args.rs index 4d7a018732c7c..367560d577ddd 100644 --- a/tests/ui/format_args.rs +++ b/tests/ui/format_args.rs @@ -79,13 +79,13 @@ fn main() { let _ = write!( stdout(), "error: something failed at {}", - Location::caller().to_string() + Location::caller().to_string(), //~^ to_string_in_format_args ); let _ = writeln!( stdout(), "error: something failed at {}", - Location::caller().to_string() + Location::caller().to_string(), //~^ to_string_in_format_args ); print!("error: something failed at {}", Location::caller().to_string()); diff --git a/tests/ui/format_args.stderr b/tests/ui/format_args.stderr index 68c3c9c322d91..589c341ce8590 100644 --- a/tests/ui/format_args.stderr +++ b/tests/ui/format_args.stderr @@ -10,13 +10,13 @@ LL | let _ = format!("error: something failed at {}", Location::caller().to_ error: `to_string` applied to a type that implements `Display` in `write!` args --> tests/ui/format_args.rs:82:27 | -LL | Location::caller().to_string() +LL | Location::caller().to_string(), | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `writeln!` args --> tests/ui/format_args.rs:88:27 | -LL | Location::caller().to_string() +LL | Location::caller().to_string(), | ^^^^^^^^^^^^ help: remove this error: `to_string` applied to a type that implements `Display` in `print!` args diff --git a/tests/ui/format_args_unfixable.rs b/tests/ui/format_args_unfixable.rs index adbdaca7313b1..08cd7dbe54f7f 100644 --- a/tests/ui/format_args_unfixable.rs +++ b/tests/ui/format_args_unfixable.rs @@ -48,15 +48,13 @@ fn main() { //~^ format_in_format_args let _ = write!( - //~^ format_in_format_args - + //~^ format_in_format_args stdout(), "error: {}", format!("something failed at {}", Location::caller()) ); let _ = writeln!( - //~^ format_in_format_args - + //~^ format_in_format_args stdout(), "error: {}", format!("something failed at {}", Location::caller()) @@ -85,7 +83,6 @@ fn main() { panic!("error: {}", format!("something failed at {}", Location::caller())); //~^ format_in_format_args - // negative tests println!("error: {}", format_args!("something failed at {}", Location::caller())); println!("error: {:>70}", format!("something failed at {}", Location::caller())); @@ -171,5 +168,4 @@ fn user_format() { usr_println!(true, "error: {}", format!("boom at {} {0}", Location::caller())); //~^ format_in_format_args - } diff --git a/tests/ui/format_args_unfixable.stderr b/tests/ui/format_args_unfixable.stderr index 82af722290660..1271e80b60a7b 100644 --- a/tests/ui/format_args_unfixable.stderr +++ b/tests/ui/format_args_unfixable.stderr @@ -78,7 +78,6 @@ error: `format!` in `write!` args LL | let _ = write!( | _____________^ LL | | -LL | | LL | | stdout(), LL | | "error: {}", LL | | format!("something failed at {}", Location::caller()) @@ -89,12 +88,11 @@ LL | | ); = help: or consider changing `format!` to `format_args!` error: `format!` in `writeln!` args - --> tests/ui/format_args_unfixable.rs:57:13 + --> tests/ui/format_args_unfixable.rs:56:13 | LL | let _ = writeln!( | _____________^ LL | | -LL | | LL | | stdout(), LL | | "error: {}", LL | | format!("something failed at {}", Location::caller()) @@ -105,7 +103,7 @@ LL | | ); = help: or consider changing `format!` to `format_args!` error: `format!` in `print!` args - --> tests/ui/format_args_unfixable.rs:64:5 + --> tests/ui/format_args_unfixable.rs:62:5 | LL | print!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +112,7 @@ LL | print!("error: {}", format!("something failed at {}", Location::caller( = help: or consider changing `format!` to `format_args!` error: `format!` in `eprint!` args - --> tests/ui/format_args_unfixable.rs:67:5 + --> tests/ui/format_args_unfixable.rs:65:5 | LL | eprint!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,7 +121,7 @@ LL | eprint!("error: {}", format!("something failed at {}", Location::caller = help: or consider changing `format!` to `format_args!` error: `format!` in `eprintln!` args - --> tests/ui/format_args_unfixable.rs:70:5 + --> tests/ui/format_args_unfixable.rs:68:5 | LL | eprintln!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -132,7 +130,7 @@ LL | eprintln!("error: {}", format!("something failed at {}", Location::call = help: or consider changing `format!` to `format_args!` error: `format!` in `format_args!` args - --> tests/ui/format_args_unfixable.rs:73:13 + --> tests/ui/format_args_unfixable.rs:71:13 | LL | let _ = format_args!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -141,7 +139,7 @@ LL | let _ = format_args!("error: {}", format!("something failed at {}", Loc = help: or consider changing `format!` to `format_args!` error: `format!` in `assert!` args - --> tests/ui/format_args_unfixable.rs:76:5 + --> tests/ui/format_args_unfixable.rs:74:5 | LL | assert!(true, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -150,7 +148,7 @@ LL | assert!(true, "error: {}", format!("something failed at {}", Location:: = help: or consider changing `format!` to `format_args!` error: `format!` in `assert_eq!` args - --> tests/ui/format_args_unfixable.rs:79:5 + --> tests/ui/format_args_unfixable.rs:77:5 | LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -159,7 +157,7 @@ LL | assert_eq!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: or consider changing `format!` to `format_args!` error: `format!` in `assert_ne!` args - --> tests/ui/format_args_unfixable.rs:82:5 + --> tests/ui/format_args_unfixable.rs:80:5 | LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -168,7 +166,7 @@ LL | assert_ne!(0, 0, "error: {}", format!("something failed at {}", Locatio = help: or consider changing `format!` to `format_args!` error: `format!` in `panic!` args - --> tests/ui/format_args_unfixable.rs:85:5 + --> tests/ui/format_args_unfixable.rs:83:5 | LL | panic!("error: {}", format!("something failed at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +175,7 @@ LL | panic!("error: {}", format!("something failed at {}", Location::caller( = help: or consider changing `format!` to `format_args!` error: `format!` in `usr_println!` args - --> tests/ui/format_args_unfixable.rs:154:5 + --> tests/ui/format_args_unfixable.rs:151:5 | LL | usr_println!(true, "error: {}", format!("boom at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -186,7 +184,7 @@ LL | usr_println!(true, "error: {}", format!("boom at {}", Location::caller( = help: or consider changing `format!` to `format_args!` error: `format!` in `usr_println!` args - --> tests/ui/format_args_unfixable.rs:157:5 + --> tests/ui/format_args_unfixable.rs:154:5 | LL | usr_println!(true, "{}: {}", error, format!("boom at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -195,7 +193,7 @@ LL | usr_println!(true, "{}: {}", error, format!("boom at {}", Location::cal = help: or consider changing `format!` to `format_args!` error: `format!` in `usr_println!` args - --> tests/ui/format_args_unfixable.rs:160:5 + --> tests/ui/format_args_unfixable.rs:157:5 | LL | usr_println!(true, "{:?}: {}", error, format!("boom at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -204,7 +202,7 @@ LL | usr_println!(true, "{:?}: {}", error, format!("boom at {}", Location::c = help: or consider changing `format!` to `format_args!` error: `format!` in `usr_println!` args - --> tests/ui/format_args_unfixable.rs:163:5 + --> tests/ui/format_args_unfixable.rs:160:5 | LL | usr_println!(true, "{{}}: {}", format!("boom at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -213,7 +211,7 @@ LL | usr_println!(true, "{{}}: {}", format!("boom at {}", Location::caller() = help: or consider changing `format!` to `format_args!` error: `format!` in `usr_println!` args - --> tests/ui/format_args_unfixable.rs:166:5 + --> tests/ui/format_args_unfixable.rs:163:5 | LL | usr_println!(true, r#"error: "{}""#, format!("boom at {}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -222,7 +220,7 @@ LL | usr_println!(true, r#"error: "{}""#, format!("boom at {}", Location::ca = help: or consider changing `format!` to `format_args!` error: `format!` in `usr_println!` args - --> tests/ui/format_args_unfixable.rs:169:5 + --> tests/ui/format_args_unfixable.rs:166:5 | LL | usr_println!(true, "error: {}", format!(r#"boom at "{}""#, Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -231,7 +229,7 @@ LL | usr_println!(true, "error: {}", format!(r#"boom at "{}""#, Location::ca = help: or consider changing `format!` to `format_args!` error: `format!` in `usr_println!` args - --> tests/ui/format_args_unfixable.rs:172:5 + --> tests/ui/format_args_unfixable.rs:169:5 | LL | usr_println!(true, "error: {}", format!("boom at {} {0}", Location::caller())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/format_collect.rs b/tests/ui/format_collect.rs index 85dbd5692fef7..8f8633a52d867 100644 --- a/tests/ui/format_collect.rs +++ b/tests/ui/format_collect.rs @@ -4,7 +4,6 @@ fn hex_encode(bytes: &[u8]) -> String { bytes.iter().map(|b| format!("{b:02X}")).collect() //~^ format_collect - } #[rustfmt::skip] @@ -26,8 +25,7 @@ fn from_macro(bytes: &[u8]) -> String { fn with_block() -> String { (1..10) - //~^ format_collect - + //~^ format_collect .map(|s| { let y = 1; format!("{s} {y}") diff --git a/tests/ui/format_collect.stderr b/tests/ui/format_collect.stderr index a87951efa5439..343e38a87b711 100644 --- a/tests/ui/format_collect.stderr +++ b/tests/ui/format_collect.stderr @@ -19,42 +19,42 @@ LL | bytes.iter().map(|b| format!("{b:02X}")).collect() = help: to override `-D warnings` add `#[allow(clippy::format_collect)]` error: use of `format!` to build up a string from an iterator - --> tests/ui/format_collect.rs:12:5 + --> tests/ui/format_collect.rs:11:5 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: call `fold` instead - --> tests/ui/format_collect.rs:12:18 + --> tests/ui/format_collect.rs:11:18 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^ help: ... and use the `write!` macro here - --> tests/ui/format_collect.rs:12:32 + --> tests/ui/format_collect.rs:11:32 | LL | bytes.iter().map(|b| {{{{{ format!("{b:02X}") }}}}}).collect() | ^^^^^^^^^^^^^^^^^^ = note: this can be written more efficiently by appending to a `String` directly error: use of `format!` to build up a string from an iterator - --> tests/ui/format_collect.rs:28:5 + --> tests/ui/format_collect.rs:27:5 | LL | / (1..10) LL | | -LL | | LL | | .map(|s| { -... | +LL | | let y = 1; +LL | | format!("{s} {y}") LL | | }) LL | | .collect() | |__________________^ | help: call `fold` instead - --> tests/ui/format_collect.rs:31:10 + --> tests/ui/format_collect.rs:29:10 | LL | .map(|s| { | ^^^ help: ... and use the `write!` macro here - --> tests/ui/format_collect.rs:33:13 + --> tests/ui/format_collect.rs:31:13 | LL | format!("{s} {y}") | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/format_push_string.rs b/tests/ui/format_push_string.rs index c047118b5f507..056ef59ff0e2b 100644 --- a/tests/ui/format_push_string.rs +++ b/tests/ui/format_push_string.rs @@ -7,7 +7,6 @@ fn main() { string.push_str(&format!("{:?}", 5678)); //~^ format_push_string - } mod issue9493 { @@ -15,7 +14,7 @@ mod issue9493 { let mut hex = String::with_capacity(vector.len() * 2); for byte in vector { hex += &(if upper { - //~^ format_push_string + //~^ format_push_string format!("{byte:02X}") } else { @@ -29,7 +28,7 @@ mod issue9493 { let mut s = String::new(); // if let s += &(if let Some(_a) = Some(1234) { - //~^ format_push_string + //~^ format_push_string format!("{}", 1234) } else { @@ -37,8 +36,7 @@ mod issue9493 { }); // match s += &(match Some(1234) { - //~^ format_push_string - + //~^ format_push_string Some(_) => format!("{}", 1234), None => format!("{}", 1234), }); diff --git a/tests/ui/format_push_string.stderr b/tests/ui/format_push_string.stderr index a496371938e92..bba2a8947c43f 100644 --- a/tests/ui/format_push_string.stderr +++ b/tests/ui/format_push_string.stderr @@ -17,7 +17,7 @@ LL | string.push_str(&format!("{:?}", 5678)); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:17:13 + --> tests/ui/format_push_string.rs:16:13 | LL | / hex += &(if upper { LL | | @@ -31,7 +31,7 @@ LL | | }); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:31:9 + --> tests/ui/format_push_string.rs:30:9 | LL | / s += &(if let Some(_a) = Some(1234) { LL | | @@ -45,11 +45,10 @@ LL | | }); = help: consider using `write!` to avoid the extra allocation error: `format!(..)` appended to existing `String` - --> tests/ui/format_push_string.rs:39:9 + --> tests/ui/format_push_string.rs:38:9 | LL | / s += &(match Some(1234) { LL | | -LL | | LL | | Some(_) => format!("{}", 1234), LL | | None => format!("{}", 1234), LL | | }); diff --git a/tests/ui/from_over_into.fixed b/tests/ui/from_over_into.fixed index 85befb87fe5b0..7d6780a0e02c8 100644 --- a/tests/ui/from_over_into.fixed +++ b/tests/ui/from_over_into.fixed @@ -7,7 +7,7 @@ struct StringWrapper(String); impl From for StringWrapper { -//~^ from_over_into + //~^ from_over_into fn from(val: String) -> Self { StringWrapper(val) } @@ -16,7 +16,7 @@ impl From for StringWrapper { struct SelfType(String); impl From for SelfType { -//~^ from_over_into + //~^ from_over_into fn from(val: String) -> Self { SelfType(String::new()) } @@ -32,7 +32,7 @@ impl X { struct SelfKeywords; impl From for SelfKeywords { -//~^ from_over_into + //~^ from_over_into fn from(val: X) -> Self { let _ = X; let _ = X::FOO; @@ -45,7 +45,7 @@ impl From for SelfKeywords { struct ExplicitPaths(bool); impl core::convert::From for bool { -//~^ from_over_into + //~^ from_over_into fn from(mut val: crate::ExplicitPaths) -> Self { let in_closure = || val.0; @@ -66,7 +66,7 @@ impl From for A { struct PathInExpansion; impl From for String { -//~^ from_over_into + //~^ from_over_into fn from(val: PathInExpansion) -> Self { // non self/Self paths in expansions are fine panic!() @@ -89,7 +89,7 @@ fn msrv_1_41() { struct FromOverInto(Vec); impl From> for FromOverInto { - //~^ from_over_into + //~^ from_over_into fn from(val: Vec) -> Self { FromOverInto(val) } @@ -100,7 +100,7 @@ fn issue_12138() { struct Hello; impl From for () { - //~^ from_over_into + //~^ from_over_into fn from(val: Hello) {} } } diff --git a/tests/ui/from_over_into.rs b/tests/ui/from_over_into.rs index d4bdad56473ae..387ddde359c16 100644 --- a/tests/ui/from_over_into.rs +++ b/tests/ui/from_over_into.rs @@ -7,7 +7,7 @@ struct StringWrapper(String); impl Into for String { -//~^ from_over_into + //~^ from_over_into fn into(self) -> StringWrapper { StringWrapper(self) } @@ -16,7 +16,7 @@ impl Into for String { struct SelfType(String); impl Into for String { -//~^ from_over_into + //~^ from_over_into fn into(self) -> SelfType { SelfType(Self::new()) } @@ -32,7 +32,7 @@ impl X { struct SelfKeywords; impl Into for X { -//~^ from_over_into + //~^ from_over_into fn into(self) -> SelfKeywords { let _ = Self; let _ = Self::FOO; @@ -45,7 +45,7 @@ impl Into for X { struct ExplicitPaths(bool); impl core::convert::Into for crate::ExplicitPaths { -//~^ from_over_into + //~^ from_over_into fn into(mut self) -> bool { let in_closure = || self.0; @@ -66,7 +66,7 @@ impl From for A { struct PathInExpansion; impl Into for PathInExpansion { -//~^ from_over_into + //~^ from_over_into fn into(self) -> String { // non self/Self paths in expansions are fine panic!() @@ -89,7 +89,7 @@ fn msrv_1_41() { struct FromOverInto(Vec); impl Into> for Vec { - //~^ from_over_into + //~^ from_over_into fn into(self) -> FromOverInto { FromOverInto(self) } @@ -100,7 +100,7 @@ fn issue_12138() { struct Hello; impl Into<()> for Hello { - //~^ from_over_into + //~^ from_over_into fn into(self) {} } } diff --git a/tests/ui/from_over_into_unfixable.rs b/tests/ui/from_over_into_unfixable.rs index 23aab9b52e1ba..de90c7c21a65d 100644 --- a/tests/ui/from_over_into_unfixable.rs +++ b/tests/ui/from_over_into_unfixable.rs @@ -9,7 +9,7 @@ macro_rules! in_macro { } impl Into for String { -//~^ from_over_into + //~^ from_over_into fn into(self) -> InMacro { InMacro(in_macro!()) @@ -19,7 +19,7 @@ impl Into for String { struct WeirdUpperSelf; impl Into for &'static [u8] { -//~^ from_over_into + //~^ from_over_into fn into(self) -> WeirdUpperSelf { let _ = Self::default(); @@ -30,7 +30,7 @@ impl Into for &'static [u8] { struct ContainsVal; impl Into for ContainsVal { -//~^ from_over_into + //~^ from_over_into fn into(self) -> u8 { let val = 1; @@ -43,7 +43,7 @@ pub struct Lval(T); pub struct Rval(T); impl Into> for Lval { -//~^ from_over_into + //~^ from_over_into fn into(self) -> Rval { Rval(self) diff --git a/tests/ui/from_raw_with_void_ptr.rs b/tests/ui/from_raw_with_void_ptr.rs index 840508ad340dd..3903138844339 100644 --- a/tests/ui/from_raw_with_void_ptr.rs +++ b/tests/ui/from_raw_with_void_ptr.rs @@ -11,7 +11,6 @@ fn main() { let _ = unsafe { Box::from_raw(ptr) }; //~^ from_raw_with_void_ptr - // shouldn't be linted let _ = unsafe { Box::from_raw(ptr as *mut usize) }; @@ -24,22 +23,18 @@ fn main() { let _ = unsafe { Rc::from_raw(ptr) }; //~^ from_raw_with_void_ptr - // must lint let ptr = Arc::into_raw(Arc::new(42usize)) as *mut c_void; let _ = unsafe { Arc::from_raw(ptr) }; //~^ from_raw_with_void_ptr - // must lint let ptr = std::rc::Weak::into_raw(Rc::downgrade(&Rc::new(42usize))) as *mut c_void; let _ = unsafe { std::rc::Weak::from_raw(ptr) }; //~^ from_raw_with_void_ptr - // must lint let ptr = std::sync::Weak::into_raw(Arc::downgrade(&Arc::new(42usize))) as *mut c_void; let _ = unsafe { std::sync::Weak::from_raw(ptr) }; //~^ from_raw_with_void_ptr - } diff --git a/tests/ui/from_raw_with_void_ptr.stderr b/tests/ui/from_raw_with_void_ptr.stderr index ab55cfd48a5be..e5bcb783d18b5 100644 --- a/tests/ui/from_raw_with_void_ptr.stderr +++ b/tests/ui/from_raw_with_void_ptr.stderr @@ -13,49 +13,49 @@ LL | let _ = unsafe { Box::from_raw(ptr) }; = help: to override `-D warnings` add `#[allow(clippy::from_raw_with_void_ptr)]` error: creating a `Rc` from a void raw pointer - --> tests/ui/from_raw_with_void_ptr.rs:24:22 + --> tests/ui/from_raw_with_void_ptr.rs:23:22 | LL | let _ = unsafe { Rc::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> tests/ui/from_raw_with_void_ptr.rs:24:35 + --> tests/ui/from_raw_with_void_ptr.rs:23:35 | LL | let _ = unsafe { Rc::from_raw(ptr) }; | ^^^ error: creating a `Arc` from a void raw pointer - --> tests/ui/from_raw_with_void_ptr.rs:30:22 + --> tests/ui/from_raw_with_void_ptr.rs:28:22 | LL | let _ = unsafe { Arc::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> tests/ui/from_raw_with_void_ptr.rs:30:36 + --> tests/ui/from_raw_with_void_ptr.rs:28:36 | LL | let _ = unsafe { Arc::from_raw(ptr) }; | ^^^ error: creating a `Weak` from a void raw pointer - --> tests/ui/from_raw_with_void_ptr.rs:36:22 + --> tests/ui/from_raw_with_void_ptr.rs:33:22 | LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> tests/ui/from_raw_with_void_ptr.rs:36:46 + --> tests/ui/from_raw_with_void_ptr.rs:33:46 | LL | let _ = unsafe { std::rc::Weak::from_raw(ptr) }; | ^^^ error: creating a `Weak` from a void raw pointer - --> tests/ui/from_raw_with_void_ptr.rs:42:22 + --> tests/ui/from_raw_with_void_ptr.rs:38:22 | LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: cast this to a pointer of the appropriate type - --> tests/ui/from_raw_with_void_ptr.rs:42:48 + --> tests/ui/from_raw_with_void_ptr.rs:38:48 | LL | let _ = unsafe { std::sync::Weak::from_raw(ptr) }; | ^^^ diff --git a/tests/ui/from_str_radix_10.fixed b/tests/ui/from_str_radix_10.fixed index e9f4de518bbca..4b8fd778685e0 100644 --- a/tests/ui/from_str_radix_10.fixed +++ b/tests/ui/from_str_radix_10.fixed @@ -28,7 +28,6 @@ fn main() -> Result<(), Box> { "30".parse::()?; //~^ from_str_radix_10 - "24".parse::()?; //~^ from_str_radix_10 @@ -44,17 +43,14 @@ fn main() -> Result<(), Box> { (Test + Test).parse::()?; //~^ from_str_radix_10 - let string = "300"; string.parse::()?; //~^ from_str_radix_10 - let stringier = "400".to_string(); stringier.parse::()?; //~^ from_str_radix_10 - // none of these should trigger the lint u16::from_str_radix("20", 3)?; i32::from_str_radix("45", 12)?; diff --git a/tests/ui/from_str_radix_10.rs b/tests/ui/from_str_radix_10.rs index 9ebead7f75ba9..89002b11a9950 100644 --- a/tests/ui/from_str_radix_10.rs +++ b/tests/ui/from_str_radix_10.rs @@ -28,7 +28,6 @@ fn main() -> Result<(), Box> { u32::from_str_radix("30", 10)?; //~^ from_str_radix_10 - i64::from_str_radix("24", 10)?; //~^ from_str_radix_10 @@ -44,17 +43,14 @@ fn main() -> Result<(), Box> { i128::from_str_radix(Test + Test, 10)?; //~^ from_str_radix_10 - let string = "300"; i32::from_str_radix(string, 10)?; //~^ from_str_radix_10 - let stringier = "400".to_string(); i32::from_str_radix(&stringier, 10)?; //~^ from_str_radix_10 - // none of these should trigger the lint u16::from_str_radix("20", 3)?; i32::from_str_radix("45", 12)?; diff --git a/tests/ui/from_str_radix_10.stderr b/tests/ui/from_str_radix_10.stderr index 7f0a12a03f3c9..c693e8f50ff68 100644 --- a/tests/ui/from_str_radix_10.stderr +++ b/tests/ui/from_str_radix_10.stderr @@ -8,43 +8,43 @@ LL | u32::from_str_radix("30", 10)?; = help: to override `-D warnings` add `#[allow(clippy::from_str_radix_10)]` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> tests/ui/from_str_radix_10.rs:32:5 + --> tests/ui/from_str_radix_10.rs:31:5 | LL | i64::from_str_radix("24", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"24".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> tests/ui/from_str_radix_10.rs:35:5 + --> tests/ui/from_str_radix_10.rs:34:5 | LL | isize::from_str_radix("100", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"100".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> tests/ui/from_str_radix_10.rs:38:5 + --> tests/ui/from_str_radix_10.rs:37:5 | LL | u8::from_str_radix("7", 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"7".parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> tests/ui/from_str_radix_10.rs:41:5 + --> tests/ui/from_str_radix_10.rs:40:5 | LL | u16::from_str_radix(&("10".to_owned() + "5"), 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("10".to_owned() + "5").parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> tests/ui/from_str_radix_10.rs:44:5 + --> tests/ui/from_str_radix_10.rs:43:5 | LL | i128::from_str_radix(Test + Test, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(Test + Test).parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> tests/ui/from_str_radix_10.rs:49:5 + --> tests/ui/from_str_radix_10.rs:47:5 | LL | i32::from_str_radix(string, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.parse::()` error: this call to `from_str_radix` can be replaced with a call to `str::parse` - --> tests/ui/from_str_radix_10.rs:54:5 + --> tests/ui/from_str_radix_10.rs:51:5 | LL | i32::from_str_radix(&stringier, 10)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `stringier.parse::()` diff --git a/tests/ui/functions.rs b/tests/ui/functions.rs index 9114dd96ce4d9..9c1ca8bf93009 100644 --- a/tests/ui/functions.rs +++ b/tests/ui/functions.rs @@ -8,8 +8,6 @@ fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} //~^ too_many_arguments - - #[rustfmt::skip] fn bad_multiline( //~^ too_many_arguments @@ -50,7 +48,6 @@ pub trait Foo { fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); //~^ too_many_arguments - fn ptr(p: *const u8); } @@ -60,7 +57,6 @@ impl Bar { fn good_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {} fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} //~^ too_many_arguments - } // ok, we don’t want to warn implementations @@ -72,13 +68,11 @@ impl Foo for Bar { println!("{}", unsafe { *p }); //~^ not_unsafe_ptr_arg_deref - println!("{:?}", unsafe { p.as_ref() }); //~^ not_unsafe_ptr_arg_deref unsafe { std::ptr::read(p) }; //~^ not_unsafe_ptr_arg_deref - } } @@ -97,7 +91,6 @@ pub fn public(p: *const u8) { unsafe { std::ptr::read(p) }; //~^ not_unsafe_ptr_arg_deref - } type Alias = *const u8; @@ -111,7 +104,6 @@ pub fn type_alias(p: Alias) { unsafe { std::ptr::read(p) }; //~^ not_unsafe_ptr_arg_deref - } impl Bar { @@ -128,7 +120,6 @@ impl Bar { unsafe { std::ptr::read(p) }; //~^ not_unsafe_ptr_arg_deref - } pub fn public_ok(self, p: *const u8) { diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 4e3cf2edb085d..c8770023f77a0 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -8,7 +8,7 @@ LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f = help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]` error: this function has too many arguments (8/7) - --> tests/ui/functions.rs:14:1 + --> tests/ui/functions.rs:12:1 | LL | / fn bad_multiline( LL | | @@ -20,19 +20,19 @@ LL | | ) { | |_^ error: this function has too many arguments (8/7) - --> tests/ui/functions.rs:50:5 + --> tests/ui/functions.rs:48:5 | LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this function has too many arguments (8/7) - --> tests/ui/functions.rs:61:5 + --> tests/ui/functions.rs:58:5 | LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:72:34 + --> tests/ui/functions.rs:68:34 | LL | println!("{}", unsafe { *p }); | ^ @@ -41,67 +41,67 @@ LL | println!("{}", unsafe { *p }); = help: to override `-D warnings` add `#[allow(clippy::not_unsafe_ptr_arg_deref)]` error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:76:35 + --> tests/ui/functions.rs:71:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:79:33 + --> tests/ui/functions.rs:74:33 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:92:30 + --> tests/ui/functions.rs:86:30 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:95:31 + --> tests/ui/functions.rs:89:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:98:29 + --> tests/ui/functions.rs:92:29 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:106:30 + --> tests/ui/functions.rs:99:30 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:109:31 + --> tests/ui/functions.rs:102:31 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:112:29 + --> tests/ui/functions.rs:105:29 | LL | unsafe { std::ptr::read(p) }; | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:123:34 + --> tests/ui/functions.rs:115:34 | LL | println!("{}", unsafe { *p }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:126:35 + --> tests/ui/functions.rs:118:35 | LL | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function might dereference a raw pointer but is not marked `unsafe` - --> tests/ui/functions.rs:129:33 + --> tests/ui/functions.rs:121:33 | LL | unsafe { std::ptr::read(p) }; | ^ diff --git a/tests/ui/functions_maxlines.rs b/tests/ui/functions_maxlines.rs index 3c32e88c6880e..e0990dadaaa91 100644 --- a/tests/ui/functions_maxlines.rs +++ b/tests/ui/functions_maxlines.rs @@ -56,8 +56,7 @@ fn good_lines() { } fn bad_lines() { -//~^ too_many_lines - + //~^ too_many_lines println!("Dont get confused by braces: {{}}"); println!("This is bad."); diff --git a/tests/ui/functions_maxlines.stderr b/tests/ui/functions_maxlines.stderr index 82d5fc8d5859f..f42a2b2a22a2f 100644 --- a/tests/ui/functions_maxlines.stderr +++ b/tests/ui/functions_maxlines.stderr @@ -2,6 +2,9 @@ error: this function has too many lines (102/100) --> tests/ui/functions_maxlines.rs:58:1 | LL | / fn bad_lines() { +LL | | +LL | | +LL | | println!("Dont get confused by braces: {{}}"); ... | LL | | println!("This is bad."); LL | | } diff --git a/tests/ui/future_not_send.rs b/tests/ui/future_not_send.rs index 1df0b13348277..662ecb9c955de 100644 --- a/tests/ui/future_not_send.rs +++ b/tests/ui/future_not_send.rs @@ -6,13 +6,13 @@ use std::rc::Rc; use std::sync::Arc; async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { -//~^ future_not_send + //~^ future_not_send async { true }.await } pub async fn public_future(rc: Rc<[u8]>) { -//~^ future_not_send + //~^ future_not_send async { true }.await; } @@ -22,7 +22,7 @@ pub async fn public_send(arc: Arc<[u8]>) -> bool { } async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { -//~^ future_not_send + //~^ future_not_send true } @@ -30,7 +30,6 @@ async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { pub async fn public_future2(rc: Rc<[u8]>) {} //~^ future_not_send - pub async fn public_send2(arc: Arc<[u8]>) -> bool { false } @@ -41,14 +40,14 @@ struct Dummy { impl Dummy { async fn private_future(&self) -> usize { - //~^ future_not_send + //~^ future_not_send async { true }.await; self.rc.len() } pub async fn public_future(&self) { - //~^ future_not_send + //~^ future_not_send self.private_future().await; } @@ -61,7 +60,6 @@ impl Dummy { async fn generic_future(t: T) -> T //~^ future_not_send - where T: Send, { @@ -83,7 +81,7 @@ async fn maybe_send_generic_future2 Fut, Fut: Future>(f: F) { } async fn generic_future_always_unsend(_: Rc) { -//~^ future_not_send + //~^ future_not_send async { true }.await; } diff --git a/tests/ui/future_not_send.stderr b/tests/ui/future_not_send.stderr index 4dcff55942a64..e366dc2d21958 100644 --- a/tests/ui/future_not_send.stderr +++ b/tests/ui/future_not_send.stderr @@ -71,13 +71,13 @@ LL | pub async fn public_future2(rc: Rc<[u8]>) {} = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:43:5 + --> tests/ui/future_not_send.rs:42:5 | LL | async fn private_future(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> tests/ui/future_not_send.rs:46:24 + --> tests/ui/future_not_send.rs:45:24 | LL | async fn private_future(&self) -> usize { | ----- has type `&Dummy` which is not `Send` @@ -87,30 +87,29 @@ LL | async { true }.await; = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:50:5 + --> tests/ui/future_not_send.rs:49:5 | LL | pub async fn public_future(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send` | note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` - --> tests/ui/future_not_send.rs:50:32 + --> tests/ui/future_not_send.rs:49:32 | LL | pub async fn public_future(&self) { | ^^^^^ has type `&Dummy` which is not `Send`, because `Dummy` is not `Sync` = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:62:1 + --> tests/ui/future_not_send.rs:61:1 | LL | / async fn generic_future(t: T) -> T LL | | -LL | | LL | | where LL | | T: Send, | |____________^ future returned by `generic_future` is not `Send` | note: future is not `Send` as this value is used across an await - --> tests/ui/future_not_send.rs:69:20 + --> tests/ui/future_not_send.rs:67:20 | LL | let rt = &t; | -- has type `&T` which is not `Send` @@ -119,13 +118,13 @@ LL | async { true }.await; = note: `T` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:85:1 + --> tests/ui/future_not_send.rs:83:1 | LL | async fn generic_future_always_unsend(_: Rc) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `generic_future_always_unsend` is not `Send` | note: future is not `Send` as this value is used across an await - --> tests/ui/future_not_send.rs:88:20 + --> tests/ui/future_not_send.rs:86:20 | LL | async fn generic_future_always_unsend(_: Rc) { | - has type `std::rc::Rc` which is not `Send` diff --git a/tests/ui/get_first.fixed b/tests/ui/get_first.fixed index 090fe48096ae5..584080defa1e4 100644 --- a/tests/ui/get_first.fixed +++ b/tests/ui/get_first.fixed @@ -51,5 +51,4 @@ fn main() { let non_primitives = [vec![1, 2], vec![3, 4]]; let _ = non_primitives.first(); //~^ get_first - } diff --git a/tests/ui/get_first.rs b/tests/ui/get_first.rs index c85d5aa89ca20..f01fbdf43c6dd 100644 --- a/tests/ui/get_first.rs +++ b/tests/ui/get_first.rs @@ -51,5 +51,4 @@ fn main() { let non_primitives = [vec![1, 2], vec![3, 4]]; let _ = non_primitives.get(0); //~^ get_first - } diff --git a/tests/ui/identity_op.fixed b/tests/ui/identity_op.fixed index b3836bda2b6f8..a1b556029987a 100644 --- a/tests/ui/identity_op.fixed +++ b/tests/ui/identity_op.fixed @@ -217,7 +217,6 @@ fn issue_12050() { let _: i32 = *x; //~^ identity_op - } { let x = &&0i32; @@ -227,7 +226,6 @@ fn issue_12050() { let x = &&0i32; let _: i32 = **x; //~^ identity_op - } { // this is just silly @@ -250,7 +248,6 @@ fn issue_12050() { let _: i32 = **&&*&x; //~^ identity_op - } { // this is getting ridiculous, but we should still see the same @@ -261,7 +258,6 @@ fn issue_12050() { let _: i32 = ***&&*&x; //~^ identity_op - } } @@ -284,7 +280,6 @@ fn issue_13470() { let _: u64 = 5u64 + ((x + y)) as u64; //~^ identity_op - // If we don't maintain the parens here, the behavior changes let _ = -(x + y); //~^ identity_op @@ -312,10 +307,8 @@ fn issue_13470() { let _ = 2i32 + (x * y); //~^ identity_op - let x = 1i16; let y = 1i16; let _: u64 = 1u64 + ((x as i32 + y as i32) as u64); //~^ identity_op - } diff --git a/tests/ui/identity_op.rs b/tests/ui/identity_op.rs index 9d545a95bdd39..f603e1078e4ec 100644 --- a/tests/ui/identity_op.rs +++ b/tests/ui/identity_op.rs @@ -217,7 +217,6 @@ fn issue_12050() { let _: i32 = x + 0; //~^ identity_op - } { let x = &&0i32; @@ -227,7 +226,6 @@ fn issue_12050() { let x = &&0i32; let _: i32 = *x + 0; //~^ identity_op - } { // this is just silly @@ -250,7 +248,6 @@ fn issue_12050() { let _: i32 = **&&*&x + 0; //~^ identity_op - } { // this is getting ridiculous, but we should still see the same @@ -261,7 +258,6 @@ fn issue_12050() { let _: i32 = **&&*&x + 0; //~^ identity_op - } } @@ -284,7 +280,6 @@ fn issue_13470() { let _: u64 = 5u64 + ((x + y) + 0i32) as u64; //~^ identity_op - // If we don't maintain the parens here, the behavior changes let _ = -(x + y + 0i32); //~^ identity_op @@ -312,10 +307,8 @@ fn issue_13470() { let _ = 2i32 + (x * y * 1i32); //~^ identity_op - let x = 1i16; let y = 1i16; let _: u64 = 1u64 + ((x as i32 + y as i32) as u64 + 0u64); //~^ identity_op - } diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 8952f2fb7b8be..8f9c2b603c49c 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -254,127 +254,127 @@ LL | let _: i32 = x + 0; | ^^^^^ help: consider reducing it to: `*x` error: this operation has no effect - --> tests/ui/identity_op.rs:224:22 + --> tests/ui/identity_op.rs:223:22 | LL | let _: i32 = **x + 0; | ^^^^^^^ help: consider reducing it to: `**x` error: this operation has no effect - --> tests/ui/identity_op.rs:228:22 + --> tests/ui/identity_op.rs:227:22 | LL | let _: i32 = *x + 0; | ^^^^^^ help: consider reducing it to: `**x` error: this operation has no effect - --> tests/ui/identity_op.rs:235:22 + --> tests/ui/identity_op.rs:233:22 | LL | let _: i32 = ***x + 0; | ^^^^^^^^ help: consider reducing it to: `***x` error: this operation has no effect - --> tests/ui/identity_op.rs:238:22 + --> tests/ui/identity_op.rs:236:22 | LL | let _: i32 = **x + 0; | ^^^^^^^ help: consider reducing it to: `***x` error: this operation has no effect - --> tests/ui/identity_op.rs:242:22 + --> tests/ui/identity_op.rs:240:22 | LL | let _: i32 = *&x + 0; | ^^^^^^^ help: consider reducing it to: `*&x` error: this operation has no effect - --> tests/ui/identity_op.rs:245:22 + --> tests/ui/identity_op.rs:243:22 | LL | let _: i32 = **&&x + 0; | ^^^^^^^^^ help: consider reducing it to: `**&&x` error: this operation has no effect - --> tests/ui/identity_op.rs:248:22 + --> tests/ui/identity_op.rs:246:22 | LL | let _: i32 = *&*&x + 0; | ^^^^^^^^^ help: consider reducing it to: `*&*&x` error: this operation has no effect - --> tests/ui/identity_op.rs:251:22 + --> tests/ui/identity_op.rs:249:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `**&&*&x` error: this operation has no effect - --> tests/ui/identity_op.rs:259:22 + --> tests/ui/identity_op.rs:256:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `***&&*&x` error: this operation has no effect - --> tests/ui/identity_op.rs:262:22 + --> tests/ui/identity_op.rs:259:22 | LL | let _: i32 = **&&*&x + 0; | ^^^^^^^^^^^ help: consider reducing it to: `***&&*&x` error: this operation has no effect - --> tests/ui/identity_op.rs:272:18 + --> tests/ui/identity_op.rs:268:18 | LL | let _: u64 = (x + y + 0i32) as u64; | ^^^^^^^^^^^^^^ help: consider reducing it to: `(x + y)` error: this operation has no effect - --> tests/ui/identity_op.rs:276:25 + --> tests/ui/identity_op.rs:272:25 | LL | let _: u64 = 1u64 & (x + y + 0i32) as u64; | ^^^^^^^^^^^^^^ help: consider reducing it to: `(x + y)` error: this operation has no effect - --> tests/ui/identity_op.rs:280:25 + --> tests/ui/identity_op.rs:276:25 | LL | let _: u64 = 1u64 & ((x + y) + 0i32) as u64; | ^^^^^^^^^^^^^^^^ help: consider reducing it to: `((x + y))` error: this operation has no effect - --> tests/ui/identity_op.rs:284:25 + --> tests/ui/identity_op.rs:280:25 | LL | let _: u64 = 5u64 + ((x + y) + 0i32) as u64; | ^^^^^^^^^^^^^^^^ help: consider reducing it to: `((x + y))` error: this operation has no effect - --> tests/ui/identity_op.rs:289:14 + --> tests/ui/identity_op.rs:284:14 | LL | let _ = -(x + y + 0i32); | ^^^^^^^^^^^^^^ help: consider reducing it to: `(x + y)` error: this operation has no effect - --> tests/ui/identity_op.rs:293:14 + --> tests/ui/identity_op.rs:288:14 | LL | let _ = -(x / y / 1i32); | ^^^^^^^^^^^^^^ help: consider reducing it to: `(x / y)` error: this operation has no effect - --> tests/ui/identity_op.rs:297:20 + --> tests/ui/identity_op.rs:292:20 | LL | let _ = 2i32 * (x + y + 0i32); | ^^^^^^^^^^^^^^ help: consider reducing it to: `(x + y)` error: this operation has no effect - --> tests/ui/identity_op.rs:302:20 + --> tests/ui/identity_op.rs:297:20 | LL | let _ = 2i32 - (x - y - 0i32); | ^^^^^^^^^^^^^^ help: consider reducing it to: `(x - y)` error: this operation has no effect - --> tests/ui/identity_op.rs:307:17 + --> tests/ui/identity_op.rs:302:17 | LL | let _ = 2 + (x + (y * z) + 0); | ^^^^^^^^^^^^^^^^^ help: consider reducing it to: `(x + (y * z))` error: this operation has no effect - --> tests/ui/identity_op.rs:312:20 + --> tests/ui/identity_op.rs:307:20 | LL | let _ = 2i32 + (x * y * 1i32); | ^^^^^^^^^^^^^^ help: consider reducing it to: `(x * y)` error: this operation has no effect - --> tests/ui/identity_op.rs:318:25 + --> tests/ui/identity_op.rs:312:25 | LL | let _: u64 = 1u64 + ((x as i32 + y as i32) as u64 + 0u64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `((x as i32 + y as i32) as u64)` diff --git a/tests/ui/if_not_else.fixed b/tests/ui/if_not_else.fixed index 1b58bdda52172..d26a15156cd89 100644 --- a/tests/ui/if_not_else.fixed +++ b/tests/ui/if_not_else.fixed @@ -12,14 +12,14 @@ fn main() { if bla() { println!("Bunny"); } else { - //~^ if_not_else + //~^ if_not_else println!("Bugs"); } if 4 == 5 { println!("Bunny"); } else { - //~^ if_not_else + //~^ if_not_else println!("Bugs"); } @@ -34,7 +34,7 @@ fn main() { if (foo() && bla()) { println!("both true"); } else { - //~^ if_not_else + //~^ if_not_else #[cfg(not(debug_assertions))] println!("not debug"); #[cfg(debug_assertions)] @@ -53,7 +53,7 @@ fn with_comments() { if foo() { println!("foo"); /* foo */ } else { - //~^ if_not_else + //~^ if_not_else /* foo is false */ println!("foo is false"); } @@ -61,7 +61,7 @@ fn with_comments() { if bla() { println!("bla"); // bla } else { - //~^ if_not_else + //~^ if_not_else // bla is false println!("bla"); } @@ -72,7 +72,7 @@ fn with_annotations() { if foo() { println!("foo"); /* foo */ } else { - //~^ if_not_else + //~^ if_not_else /* foo is false */ println!("foo is false"); } diff --git a/tests/ui/if_not_else.rs b/tests/ui/if_not_else.rs index 0d035e2837749..6171cf1164955 100644 --- a/tests/ui/if_not_else.rs +++ b/tests/ui/if_not_else.rs @@ -10,14 +10,14 @@ fn bla() -> bool { fn main() { if !bla() { - //~^ if_not_else + //~^ if_not_else println!("Bugs"); } else { println!("Bunny"); } if 4 != 5 { - //~^ if_not_else + //~^ if_not_else println!("Bugs"); } else { @@ -32,7 +32,7 @@ fn main() { } if !(foo() && bla()) { - //~^ if_not_else + //~^ if_not_else #[cfg(not(debug_assertions))] println!("not debug"); #[cfg(debug_assertions)] @@ -51,7 +51,7 @@ fn main() { fn with_comments() { if !foo() { - //~^ if_not_else + //~^ if_not_else /* foo is false */ println!("foo is false"); } else { @@ -59,7 +59,7 @@ fn with_comments() { } if !bla() { - //~^ if_not_else + //~^ if_not_else // bla is false println!("bla"); } else { @@ -70,7 +70,7 @@ fn with_comments() { fn with_annotations() { #[cfg(debug_assertions)] if !foo() { - //~^ if_not_else + //~^ if_not_else /* foo is false */ println!("foo is false"); } else { diff --git a/tests/ui/if_same_then_else.rs b/tests/ui/if_same_then_else.rs index 5eaf4015b77b0..6d2e63e7299a8 100644 --- a/tests/ui/if_same_then_else.rs +++ b/tests/ui/if_same_then_else.rs @@ -39,7 +39,6 @@ fn if_same_then_else() { } //~^^^^^^^^^^^^^^^^^ if_same_then_else - if true { Foo { bar: 42 }; } else { @@ -68,11 +67,9 @@ fn if_same_then_else() { let _ = if true { 0.0 } else { 0.0 }; //~^ if_same_then_else - let _ = if true { -0.0 } else { -0.0 }; //~^ if_same_then_else - let _ = if true { 0.0 } else { -0.0 }; // Different NaNs @@ -85,7 +82,6 @@ fn if_same_then_else() { let _ = if true { 42 } else { 42 }; //~^ if_same_then_else - if true { let bar = if true { 42 } else { 43 }; @@ -103,7 +99,6 @@ fn if_same_then_else() { } //~^^^^^^^^^^^^^^^ if_same_then_else - if true { let _ = match 42 { 42 => 1, diff --git a/tests/ui/if_same_then_else.stderr b/tests/ui/if_same_then_else.stderr index e715dbfa22580..b76da3fb1cb58 100644 --- a/tests/ui/if_same_then_else.stderr +++ b/tests/ui/if_same_then_else.stderr @@ -27,43 +27,43 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::if_same_then_else)]` error: this `if` has identical blocks - --> tests/ui/if_same_then_else.rs:68:21 + --> tests/ui/if_same_then_else.rs:67:21 | LL | let _ = if true { 0.0 } else { 0.0 }; | ^^^^^^^ | note: same as this - --> tests/ui/if_same_then_else.rs:68:34 + --> tests/ui/if_same_then_else.rs:67:34 | LL | let _ = if true { 0.0 } else { 0.0 }; | ^^^^^^^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else.rs:72:21 + --> tests/ui/if_same_then_else.rs:70:21 | LL | let _ = if true { -0.0 } else { -0.0 }; | ^^^^^^^^ | note: same as this - --> tests/ui/if_same_then_else.rs:72:35 + --> tests/ui/if_same_then_else.rs:70:35 | LL | let _ = if true { -0.0 } else { -0.0 }; | ^^^^^^^^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else.rs:85:21 + --> tests/ui/if_same_then_else.rs:82:21 | LL | let _ = if true { 42 } else { 42 }; | ^^^^^^ | note: same as this - --> tests/ui/if_same_then_else.rs:85:33 + --> tests/ui/if_same_then_else.rs:82:33 | LL | let _ = if true { 42 } else { 42 }; | ^^^^^^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else.rs:89:13 + --> tests/ui/if_same_then_else.rs:85:13 | LL | if true { | _____________^ @@ -76,7 +76,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/if_same_then_else.rs:96:12 + --> tests/ui/if_same_then_else.rs:92:12 | LL | } else { | ____________^ @@ -89,7 +89,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else.rs:243:14 + --> tests/ui/if_same_then_else.rs:238:14 | LL | if x { | ______________^ @@ -98,7 +98,7 @@ LL | | } else { | |_________^ | note: same as this - --> tests/ui/if_same_then_else.rs:245:16 + --> tests/ui/if_same_then_else.rs:240:16 | LL | } else { | ________________^ diff --git a/tests/ui/if_same_then_else2.rs b/tests/ui/if_same_then_else2.rs index 2ccd85224cd3b..5b74aecdacbe5 100644 --- a/tests/ui/if_same_then_else2.rs +++ b/tests/ui/if_same_then_else2.rs @@ -33,7 +33,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> { } //~^^^^^^^^^^^^^^^^^^^ if_same_then_else - if true { if let Some(a) = Some(42) {} } else { @@ -41,7 +40,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> { } //~^^^^^ if_same_then_else - if true { if let (1, .., 3) = (1, 2, 3) {} } else { @@ -49,7 +47,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> { } //~^^^^^ if_same_then_else - if true { if let (1, .., 3) = (1, 2, 3) {} } else { @@ -96,7 +93,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> { let _ = if true { f32::NAN } else { f32::NAN }; //~^ if_same_then_else - if true { Ok("foo")?; } else { @@ -104,7 +100,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> { } //~^^^^^ if_same_then_else - if true { let foo = ""; return Ok(&foo[0..]); @@ -131,7 +126,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> { } //~^^^^^^^ if_same_then_else - // False positive `if_same_then_else`: `let (x, y)` vs. `let (y, x)`; see issue #3559. if true { let foo = ""; diff --git a/tests/ui/if_same_then_else2.stderr b/tests/ui/if_same_then_else2.stderr index 3465482f98729..369d6f6673722 100644 --- a/tests/ui/if_same_then_else2.stderr +++ b/tests/ui/if_same_then_else2.stderr @@ -25,7 +25,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::if_same_then_else)]` error: this `if` has identical blocks - --> tests/ui/if_same_then_else2.rs:37:13 + --> tests/ui/if_same_then_else2.rs:36:13 | LL | if true { | _____________^ @@ -34,7 +34,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/if_same_then_else2.rs:39:12 + --> tests/ui/if_same_then_else2.rs:38:12 | LL | } else { | ____________^ @@ -43,7 +43,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else2.rs:45:13 + --> tests/ui/if_same_then_else2.rs:43:13 | LL | if true { | _____________^ @@ -52,7 +52,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/if_same_then_else2.rs:47:12 + --> tests/ui/if_same_then_else2.rs:45:12 | LL | } else { | ____________^ @@ -61,19 +61,19 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else2.rs:96:21 + --> tests/ui/if_same_then_else2.rs:93:21 | LL | let _ = if true { f32::NAN } else { f32::NAN }; | ^^^^^^^^^^^^ | note: same as this - --> tests/ui/if_same_then_else2.rs:96:39 + --> tests/ui/if_same_then_else2.rs:93:39 | LL | let _ = if true { f32::NAN } else { f32::NAN }; | ^^^^^^^^^^^^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else2.rs:100:13 + --> tests/ui/if_same_then_else2.rs:96:13 | LL | if true { | _____________^ @@ -82,7 +82,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/if_same_then_else2.rs:102:12 + --> tests/ui/if_same_then_else2.rs:98:12 | LL | } else { | ____________^ @@ -91,7 +91,7 @@ LL | | } | |_____^ error: this `if` has identical blocks - --> tests/ui/if_same_then_else2.rs:125:20 + --> tests/ui/if_same_then_else2.rs:120:20 | LL | } else if true { | ____________________^ @@ -101,7 +101,7 @@ LL | | } else { | |_____^ | note: same as this - --> tests/ui/if_same_then_else2.rs:128:12 + --> tests/ui/if_same_then_else2.rs:123:12 | LL | } else { | ____________^ diff --git a/tests/ui/if_then_some_else_none.fixed b/tests/ui/if_then_some_else_none.fixed index 1f9ea9bf9bc01..f774608712d1a 100644 --- a/tests/ui/if_then_some_else_none.fixed +++ b/tests/ui/if_then_some_else_none.fixed @@ -13,13 +13,11 @@ fn main() { let _ = x.and_then(|o| (o < 32).then_some(o)); //~^ if_then_some_else_none - // Should issue an error. Unary expression `!x` should be parenthesized. let x = true; let _ = (!x).then_some(0); //~^ if_then_some_else_none - // Should not issue an error since the `else` block has a statement besides `None`. let _ = if foo() { println!("true!"); diff --git a/tests/ui/if_then_some_else_none.rs b/tests/ui/if_then_some_else_none.rs index 238d524a5522b..8b8ff0a6ea006 100644 --- a/tests/ui/if_then_some_else_none.rs +++ b/tests/ui/if_then_some_else_none.rs @@ -4,7 +4,7 @@ fn main() { // Should issue an error. let _ = if foo() { - //~^ if_then_some_else_none + //~^ if_then_some_else_none println!("true!"); Some("foo") @@ -14,7 +14,7 @@ fn main() { // Should issue an error when macros are used. let _ = if matches!(true, true) { - //~^ if_then_some_else_none + //~^ if_then_some_else_none println!("true!"); Some(matches!(true, false)) @@ -27,13 +27,11 @@ fn main() { let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); //~^ if_then_some_else_none - // Should issue an error. Unary expression `!x` should be parenthesized. let x = true; let _ = if !x { Some(0) } else { None }; //~^ if_then_some_else_none - // Should not issue an error since the `else` block has a statement besides `None`. let _ = if foo() { println!("true!"); @@ -88,7 +86,7 @@ fn _msrv_1_49() { #[clippy::msrv = "1.50"] fn _msrv_1_50() { let _ = if foo() { - //~^ if_then_some_else_none + //~^ if_then_some_else_none println!("true!"); Some(150) diff --git a/tests/ui/if_then_some_else_none.stderr b/tests/ui/if_then_some_else_none.stderr index a996dec236d67..71285574ef242 100644 --- a/tests/ui/if_then_some_else_none.stderr +++ b/tests/ui/if_then_some_else_none.stderr @@ -34,13 +34,13 @@ LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(o < 32).then_some(o)` error: this could be simplified with `bool::then_some` - --> tests/ui/if_then_some_else_none.rs:33:13 + --> tests/ui/if_then_some_else_none.rs:32:13 | LL | let _ = if !x { Some(0) } else { None }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!x).then_some(0)` error: this could be simplified with `bool::then` - --> tests/ui/if_then_some_else_none.rs:90:13 + --> tests/ui/if_then_some_else_none.rs:88:13 | LL | let _ = if foo() { | _____________^ @@ -53,7 +53,7 @@ LL | | }; | |_____^ help: try: `foo().then(|| { println!("true!"); 150 })` error: this could be simplified with `bool::then` - --> tests/ui/if_then_some_else_none.rs:140:5 + --> tests/ui/if_then_some_else_none.rs:138:5 | LL | if s == "1" { Some(true) } else { None } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(s == "1").then(|| true)` diff --git a/tests/ui/ifs_same_cond.rs b/tests/ui/ifs_same_cond.rs index 202b164d03baa..6ecb7cb1eba9d 100644 --- a/tests/ui/ifs_same_cond.rs +++ b/tests/ui/ifs_same_cond.rs @@ -12,21 +12,18 @@ fn ifs_same_cond() { if b { } else if b { - //~^ ifs_same_cond - + //~^ ifs_same_cond } if a == 1 { } else if a == 1 { - //~^ ifs_same_cond - + //~^ ifs_same_cond } if 2 * a == 1 { } else if 2 * a == 2 { } else if 2 * a == 1 { - //~^ ifs_same_cond - + //~^ ifs_same_cond } else if a == 1 { } @@ -59,7 +56,7 @@ fn issue10272() { let a = String::from("ha"); if a.contains("ah") { } else if a.contains("ah") { - //~^ ifs_same_cond + //~^ ifs_same_cond // Trigger this lint } else if a.contains("ha") { diff --git a/tests/ui/ifs_same_cond.stderr b/tests/ui/ifs_same_cond.stderr index a45e01d262273..81fbb921e8463 100644 --- a/tests/ui/ifs_same_cond.stderr +++ b/tests/ui/ifs_same_cond.stderr @@ -13,37 +13,37 @@ LL | if b { = help: to override `-D warnings` add `#[allow(clippy::ifs_same_cond)]` error: this `if` has the same condition as a previous `if` - --> tests/ui/ifs_same_cond.rs:20:15 + --> tests/ui/ifs_same_cond.rs:19:15 | LL | } else if a == 1 { | ^^^^^^ | note: same as this - --> tests/ui/ifs_same_cond.rs:19:8 + --> tests/ui/ifs_same_cond.rs:18:8 | LL | if a == 1 { | ^^^^^^ error: this `if` has the same condition as a previous `if` - --> tests/ui/ifs_same_cond.rs:27:15 + --> tests/ui/ifs_same_cond.rs:25:15 | LL | } else if 2 * a == 1 { | ^^^^^^^^^^ | note: same as this - --> tests/ui/ifs_same_cond.rs:25:8 + --> tests/ui/ifs_same_cond.rs:23:8 | LL | if 2 * a == 1 { | ^^^^^^^^^^ error: this `if` has the same condition as a previous `if` - --> tests/ui/ifs_same_cond.rs:61:15 + --> tests/ui/ifs_same_cond.rs:58:15 | LL | } else if a.contains("ah") { | ^^^^^^^^^^^^^^^^ | note: same as this - --> tests/ui/ifs_same_cond.rs:60:8 + --> tests/ui/ifs_same_cond.rs:57:8 | LL | if a.contains("ah") { | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl.rs b/tests/ui/impl.rs index 423c8d501741f..1b9e4a5cdee13 100644 --- a/tests/ui/impl.rs +++ b/tests/ui/impl.rs @@ -8,7 +8,7 @@ impl MyStruct { } impl MyStruct { -//~^ multiple_inherent_impl + //~^ multiple_inherent_impl fn second() {} } @@ -24,7 +24,7 @@ mod submod { } impl super::MyStruct { - //~^ multiple_inherent_impl + //~^ multiple_inherent_impl fn third() {} } @@ -46,7 +46,7 @@ impl WithArgs { fn f2() {} } impl WithArgs { -//~^ multiple_inherent_impl + //~^ multiple_inherent_impl fn f3() {} } @@ -71,5 +71,4 @@ impl OneAllowedImpl {} impl OneAllowedImpl {} // Lint, only one of the three blocks is allowed. //~^ multiple_inherent_impl - fn main() {} diff --git a/tests/ui/impl_trait_in_params.rs b/tests/ui/impl_trait_in_params.rs index 6d502a685bf7d..2039f6339a878 100644 --- a/tests/ui/impl_trait_in_params.rs +++ b/tests/ui/impl_trait_in_params.rs @@ -12,7 +12,6 @@ pub fn a(_: impl Trait) {} pub fn c(_: C, _: impl Trait) {} //~^ impl_trait_in_params - // Shouldn't warn pub fn b(_: B) {} @@ -35,12 +34,12 @@ trait Private { struct S; impl S { -pub fn h(_: impl Trait) {} -//~^ impl_trait_in_params + pub fn h(_: impl Trait) {} + //~^ impl_trait_in_params fn i(_: impl Trait) {} pub fn j(_: J) {} -pub fn k>(_: K, _: impl AnotherTrait) {} -//~^ impl_trait_in_params + pub fn k>(_: K, _: impl AnotherTrait) {} + //~^ impl_trait_in_params } // Trying with traits diff --git a/tests/ui/impl_trait_in_params.stderr b/tests/ui/impl_trait_in_params.stderr index ad735d034317d..c904d5843c93f 100644 --- a/tests/ui/impl_trait_in_params.stderr +++ b/tests/ui/impl_trait_in_params.stderr @@ -23,26 +23,26 @@ LL | pub fn c(_: C, _: impl Trait) {} | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> tests/ui/impl_trait_in_params.rs:38:13 + --> tests/ui/impl_trait_in_params.rs:37:17 | -LL | pub fn h(_: impl Trait) {} - | ^^^^^^^^^^ +LL | pub fn h(_: impl Trait) {} + | ^^^^^^^^^^ | help: add a type parameter | -LL | pub fn h<{ /* Generic name */ }: Trait>(_: impl Trait) {} - | +++++++++++++++++++++++++++++++ +LL | pub fn h<{ /* Generic name */ }: Trait>(_: impl Trait) {} + | +++++++++++++++++++++++++++++++ error: `impl Trait` used as a function parameter - --> tests/ui/impl_trait_in_params.rs:42:41 + --> tests/ui/impl_trait_in_params.rs:41:45 | -LL | pub fn k>(_: K, _: impl AnotherTrait) {} - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | pub fn k>(_: K, _: impl AnotherTrait) {} + | ^^^^^^^^^^^^^^^^^^^^^^ | help: add a type parameter | -LL | pub fn k, { /* Generic name */ }: AnotherTrait>(_: K, _: impl AnotherTrait) {} - | +++++++++++++++++++++++++++++++++++++++++++ +LL | pub fn k, { /* Generic name */ }: AnotherTrait>(_: K, _: impl AnotherTrait) {} + | +++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/implicit_hasher.fixed b/tests/ui/implicit_hasher.fixed index fd6c4ffc91221..bea5b9afc43ac 100644 --- a/tests/ui/implicit_hasher.fixed +++ b/tests/ui/implicit_hasher.fixed @@ -13,7 +13,7 @@ pub trait Foo: Sized { } impl Foo for HashMap { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { // OK, don't suggest to modify these let _: HashMap = HashMap::new(); @@ -23,13 +23,13 @@ impl Foo for HashMap } } impl Foo for (HashMap,) { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) } } impl Foo for HashMap { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) } @@ -47,13 +47,13 @@ impl Foo for HashMap { } impl Foo for HashSet { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) } } impl Foo for HashSet { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) } diff --git a/tests/ui/implicit_hasher.rs b/tests/ui/implicit_hasher.rs index 29a1afd2efc86..afdf4da61650b 100644 --- a/tests/ui/implicit_hasher.rs +++ b/tests/ui/implicit_hasher.rs @@ -13,7 +13,7 @@ pub trait Foo: Sized { } impl Foo for HashMap { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { // OK, don't suggest to modify these let _: HashMap = HashMap::new(); @@ -23,13 +23,13 @@ impl Foo for HashMap { } } impl Foo for (HashMap,) { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { ((HashMap::new(),), (HashMap::with_capacity(10),)) } } impl Foo for HashMap { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { (HashMap::new(), HashMap::with_capacity(10)) } @@ -47,13 +47,13 @@ impl Foo for HashMap { } impl Foo for HashSet { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { (HashSet::new(), HashSet::with_capacity(10)) } } impl Foo for HashSet { -//~^ implicit_hasher + //~^ implicit_hasher fn make() -> (Self, Self) { (HashSet::new(), HashSet::with_capacity(10)) } diff --git a/tests/ui/implicit_saturating_add.rs b/tests/ui/implicit_saturating_add.rs index 2396db8daa0c0..d9d035bdcd31b 100644 --- a/tests/ui/implicit_saturating_add.rs +++ b/tests/ui/implicit_saturating_add.rs @@ -19,12 +19,12 @@ fn main() { } if u_8 != u8::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_8 += 1; } if u_8 < u8::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_8 += 1; } @@ -33,107 +33,107 @@ fn main() { } if u_16 != u16::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_16 += 1; } if u_16 < u16::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_16 += 1; } if u16::MAX > u_16 { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_16 += 1; } if u_32 != u32::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_32 += 1; } if u_32 < u32::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_32 += 1; } if u32::MAX > u_32 { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_32 += 1; } if u_64 != u64::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_64 += 1; } if u_64 < u64::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_64 += 1; } if u64::MAX > u_64 { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_64 += 1; } if i_8 != i8::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_8 += 1; } if i_8 < i8::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_8 += 1; } if i8::MAX > i_8 { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_8 += 1; } if i_16 != i16::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_16 += 1; } if i_16 < i16::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_16 += 1; } if i16::MAX > i_16 { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_16 += 1; } if i_32 != i32::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_32 += 1; } if i_32 < i32::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_32 += 1; } if i32::MAX > i_32 { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_32 += 1; } if i_64 != i64::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_64 += 1; } if i_64 < i64::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_64 += 1; } if i64::MAX > i_64 { - //~^ implicit_saturating_add + //~^ implicit_saturating_add i_64 += 1; } @@ -170,7 +170,7 @@ fn main() { if u_32 < 42 { println!("brace yourself!"); } else if u_32 < u32::MAX { - //~^ implicit_saturating_add + //~^ implicit_saturating_add u_32 += 1; } } diff --git a/tests/ui/implicit_saturating_sub.rs b/tests/ui/implicit_saturating_sub.rs index 5b7221b7060f1..140cf0338602d 100644 --- a/tests/ui/implicit_saturating_sub.rs +++ b/tests/ui/implicit_saturating_sub.rs @@ -25,7 +25,7 @@ fn main() { // Lint if u_8 > 0 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_8 = u_8 - 1; } @@ -33,7 +33,7 @@ fn main() { 10 => { // Lint if u_8 > 0 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_8 -= 1; } }, @@ -48,7 +48,7 @@ fn main() { // Lint if u_16 > 0 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_16 -= 1; } @@ -59,7 +59,7 @@ fn main() { // Lint if u_32 != 0 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_32 -= 1; } @@ -81,19 +81,19 @@ fn main() { // Lint if u_64 > 0 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_64 -= 1; } // Lint if 0 < u_64 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_64 -= 1; } // Lint if 0 != u_64 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_64 -= 1; } @@ -115,7 +115,7 @@ fn main() { // Lint if u_usize > 0 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub u_usize -= 1; } @@ -128,25 +128,25 @@ fn main() { // Lint if i_8 > i8::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_8 -= 1; } // Lint if i_8 > i8::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_8 -= 1; } // Lint if i_8 != i8::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_8 -= 1; } // Lint if i_8 != i8::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_8 -= 1; } @@ -157,25 +157,25 @@ fn main() { // Lint if i_16 > i16::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_16 -= 1; } // Lint if i_16 > i16::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_16 -= 1; } // Lint if i_16 != i16::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_16 -= 1; } // Lint if i_16 != i16::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_16 -= 1; } @@ -186,25 +186,25 @@ fn main() { // Lint if i_32 > i32::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_32 -= 1; } // Lint if i_32 > i32::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_32 -= 1; } // Lint if i_32 != i32::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_32 -= 1; } // Lint if i_32 != i32::MIN { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_32 -= 1; } @@ -215,19 +215,19 @@ fn main() { // Lint if i64::MIN < i_64 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_64 -= 1; } // Lint if i64::MIN != i_64 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_64 -= 1; } // Lint if i64::MIN < i_64 { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub i_64 -= 1; } @@ -296,7 +296,7 @@ fn regression_13524(a: usize, b: usize, c: bool) -> usize { if c { 123 } else if a >= b { - //~^ implicit_saturating_sub + //~^ implicit_saturating_sub 0 } else { b - a diff --git a/tests/ui/implied_bounds_in_impls.fixed b/tests/ui/implied_bounds_in_impls.fixed index fe44d7c64b6ee..bac7af59491f1 100644 --- a/tests/ui/implied_bounds_in_impls.fixed +++ b/tests/ui/implied_bounds_in_impls.fixed @@ -11,7 +11,7 @@ fn normal_deref(x: T) -> impl Deref { // Deref implied by DerefMut fn deref_derefmut(x: T) -> impl DerefMut { -//~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls Box::new(x) } @@ -63,14 +63,14 @@ struct SomeStruct; impl SomeStruct { // Check that it works in inherent impl blocks. fn f() -> impl DerefMut { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls Box::new(123) } } impl SomeTrait for SomeStruct { // Check that it works in trait impls. fn f() -> impl DerefMut { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls Box::new(42) } } @@ -98,13 +98,13 @@ mod issue11422 { mod issue11435 { // Associated type needs to be included on DoubleEndedIterator in the suggestion fn my_iter() -> impl DoubleEndedIterator { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls 0..5 } // Removing the `Clone` bound should include the `+` behind it in its remove suggestion fn f() -> impl Copy { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls 1 } diff --git a/tests/ui/implied_bounds_in_impls.rs b/tests/ui/implied_bounds_in_impls.rs index 0e100262d2d94..2014cd46ada7b 100644 --- a/tests/ui/implied_bounds_in_impls.rs +++ b/tests/ui/implied_bounds_in_impls.rs @@ -11,7 +11,7 @@ fn normal_deref(x: T) -> impl Deref { // Deref implied by DerefMut fn deref_derefmut(x: T) -> impl Deref + DerefMut { -//~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls Box::new(x) } @@ -63,14 +63,14 @@ struct SomeStruct; impl SomeStruct { // Check that it works in inherent impl blocks. fn f() -> impl Deref + DerefMut { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls Box::new(123) } } impl SomeTrait for SomeStruct { // Check that it works in trait impls. fn f() -> impl Deref + DerefMut { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls Box::new(42) } } @@ -98,13 +98,13 @@ mod issue11422 { mod issue11435 { // Associated type needs to be included on DoubleEndedIterator in the suggestion fn my_iter() -> impl Iterator + DoubleEndedIterator { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls 0..5 } // Removing the `Clone` bound should include the `+` behind it in its remove suggestion fn f() -> impl Copy + Clone { - //~^ implied_bounds_in_impls + //~^ implied_bounds_in_impls 1 } diff --git a/tests/ui/incompatible_msrv.rs b/tests/ui/incompatible_msrv.rs index 523c754437aa7..b4fea4cae5edf 100644 --- a/tests/ui/incompatible_msrv.rs +++ b/tests/ui/incompatible_msrv.rs @@ -16,12 +16,10 @@ fn foo() { if let Entry::Vacant(v) = map.entry("poneyland") { v.into_key(); //~^ incompatible_msrv - } // Should warn for `sleep` but not for `Duration` (which was added in `1.3.0`). sleep(Duration::new(1, 0)); //~^ incompatible_msrv - } #[test] diff --git a/tests/ui/incompatible_msrv.stderr b/tests/ui/incompatible_msrv.stderr index f14e9810b203e..56c9eae5aafa7 100644 --- a/tests/ui/incompatible_msrv.stderr +++ b/tests/ui/incompatible_msrv.stderr @@ -14,7 +14,7 @@ LL | v.into_key(); | ^^^^^^^^^^ error: current MSRV (Minimum Supported Rust Version) is `1.3.0` but this item is stable since `1.4.0` - --> tests/ui/incompatible_msrv.rs:22:5 + --> tests/ui/incompatible_msrv.rs:21:5 | LL | sleep(Duration::new(1, 0)); | ^^^^^ diff --git a/tests/ui/inconsistent_struct_constructor.fixed b/tests/ui/inconsistent_struct_constructor.fixed index 1b3f27a45d6a4..66232c0b9d8ef 100644 --- a/tests/ui/inconsistent_struct_constructor.fixed +++ b/tests/ui/inconsistent_struct_constructor.fixed @@ -34,7 +34,7 @@ mod without_base { // Should lint. Foo { x, y, z }; - //~^ inconsistent_struct_constructor + //~^ inconsistent_struct_constructor // Should NOT lint. // issue #7069. @@ -66,7 +66,7 @@ mod with_base { z, ..Default::default() }; - //~^^^^ inconsistent_struct_constructor + //~^^^^ inconsistent_struct_constructor // Should NOT lint because the order is consistent with the definition. Foo { diff --git a/tests/ui/inconsistent_struct_constructor.rs b/tests/ui/inconsistent_struct_constructor.rs index ec29bdaf93f0d..8dd228e72ed78 100644 --- a/tests/ui/inconsistent_struct_constructor.rs +++ b/tests/ui/inconsistent_struct_constructor.rs @@ -34,7 +34,7 @@ mod without_base { // Should lint. Foo { y, x, z }; - //~^ inconsistent_struct_constructor + //~^ inconsistent_struct_constructor // Should NOT lint. // issue #7069. @@ -66,7 +66,7 @@ mod with_base { x, ..Default::default() }; - //~^^^^ inconsistent_struct_constructor + //~^^^^ inconsistent_struct_constructor // Should NOT lint because the order is consistent with the definition. Foo { diff --git a/tests/ui/index_refutable_slice/if_let_slice_binding.fixed b/tests/ui/index_refutable_slice/if_let_slice_binding.fixed index f5f66d6eca613..e19aa4acb4c12 100644 --- a/tests/ui/index_refutable_slice/if_let_slice_binding.fixed +++ b/tests/ui/index_refutable_slice/if_let_slice_binding.fixed @@ -12,7 +12,7 @@ fn lintable_examples() { // Try with reference let slice: Option<&[u32]> = Some(&[1, 2, 3]); if let Some([slice_0, ..]) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice_0); } @@ -20,7 +20,7 @@ fn lintable_examples() { // Try with copy let slice: Option<[u32; 3]> = Some([1, 2, 3]); if let Some([slice_0, ..]) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice_0); } @@ -28,7 +28,7 @@ fn lintable_examples() { // Try with long slice and small indices let slice: Option<[u32; 9]> = Some([1, 2, 3, 4, 5, 6, 7, 8, 9]); if let Some([slice_0, _, slice_2, ..]) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice_2); println!("{}", slice_0); @@ -37,7 +37,7 @@ fn lintable_examples() { // Multiple bindings let slice_wrapped: SomeEnum<[u32; 3]> = SomeEnum::One([5, 6, 7]); if let SomeEnum::One([slice_0, ..]) | SomeEnum::Three([slice_0, ..]) = slice_wrapped { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice_0); } @@ -46,9 +46,8 @@ fn lintable_examples() { let a_wrapped: SomeEnum<[u32; 3]> = SomeEnum::One([9, 5, 1]); let b_wrapped: Option<[u32; 2]> = Some([4, 6]); if let (SomeEnum::Three([_, _, a_2, ..]), Some([_, b_1, ..])) = (a_wrapped, b_wrapped) { - //~^ index_refutable_slice - //~| index_refutable_slice - + //~^ index_refutable_slice + //~| index_refutable_slice println!("{} -> {}", a_2, b_1); } @@ -57,7 +56,7 @@ fn lintable_examples() { // borrowed and `String` doesn't implement copy let slice: Option<[String; 2]> = Some([String::from("1"), String::from("2")]); if let Some([_, ref slice_1, ..]) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{:?}", slice_1); } @@ -67,7 +66,7 @@ fn lintable_examples() { // a reference let slice: Option<[String; 2]> = Some([String::from("1"), String::from("2")]); if let Some([slice_0, ..]) = &slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{:?}", slice_0); } @@ -138,7 +137,7 @@ fn check_slice_in_struct() { // Test 1: Field access if let Some([slice_0, ..]) = wrap.inner { - //~^ index_refutable_slice + //~^ index_refutable_slice if wrap.is_awesome { println!("This is awesome! {}", slice_0); @@ -147,7 +146,7 @@ fn check_slice_in_struct() { // Test 2: function access if let Some([slice_0, ..]) = wrap.inner { - //~^ index_refutable_slice + //~^ index_refutable_slice if wrap.is_super_awesome() { println!("This is super awesome! {}", slice_0); diff --git a/tests/ui/index_refutable_slice/if_let_slice_binding.rs b/tests/ui/index_refutable_slice/if_let_slice_binding.rs index 408fd85cfe6a2..2903935685541 100644 --- a/tests/ui/index_refutable_slice/if_let_slice_binding.rs +++ b/tests/ui/index_refutable_slice/if_let_slice_binding.rs @@ -12,7 +12,7 @@ fn lintable_examples() { // Try with reference let slice: Option<&[u32]> = Some(&[1, 2, 3]); if let Some(slice) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice[0]); } @@ -20,7 +20,7 @@ fn lintable_examples() { // Try with copy let slice: Option<[u32; 3]> = Some([1, 2, 3]); if let Some(slice) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice[0]); } @@ -28,7 +28,7 @@ fn lintable_examples() { // Try with long slice and small indices let slice: Option<[u32; 9]> = Some([1, 2, 3, 4, 5, 6, 7, 8, 9]); if let Some(slice) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice[2]); println!("{}", slice[0]); @@ -37,7 +37,7 @@ fn lintable_examples() { // Multiple bindings let slice_wrapped: SomeEnum<[u32; 3]> = SomeEnum::One([5, 6, 7]); if let SomeEnum::One(slice) | SomeEnum::Three(slice) = slice_wrapped { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{}", slice[0]); } @@ -46,9 +46,8 @@ fn lintable_examples() { let a_wrapped: SomeEnum<[u32; 3]> = SomeEnum::One([9, 5, 1]); let b_wrapped: Option<[u32; 2]> = Some([4, 6]); if let (SomeEnum::Three(a), Some(b)) = (a_wrapped, b_wrapped) { - //~^ index_refutable_slice - //~| index_refutable_slice - + //~^ index_refutable_slice + //~| index_refutable_slice println!("{} -> {}", a[2], b[1]); } @@ -57,7 +56,7 @@ fn lintable_examples() { // borrowed and `String` doesn't implement copy let slice: Option<[String; 2]> = Some([String::from("1"), String::from("2")]); if let Some(ref slice) = slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{:?}", slice[1]); } @@ -67,7 +66,7 @@ fn lintable_examples() { // a reference let slice: Option<[String; 2]> = Some([String::from("1"), String::from("2")]); if let Some(slice) = &slice { - //~^ index_refutable_slice + //~^ index_refutable_slice println!("{:?}", slice[0]); } @@ -138,7 +137,7 @@ fn check_slice_in_struct() { // Test 1: Field access if let Some(slice) = wrap.inner { - //~^ index_refutable_slice + //~^ index_refutable_slice if wrap.is_awesome { println!("This is awesome! {}", slice[0]); @@ -147,7 +146,7 @@ fn check_slice_in_struct() { // Test 2: function access if let Some(slice) = wrap.inner { - //~^ index_refutable_slice + //~^ index_refutable_slice if wrap.is_super_awesome() { println!("This is super awesome! {}", slice[0]); diff --git a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr index 6abbc3d7dfad9..04bc9838d0c22 100644 --- a/tests/ui/index_refutable_slice/if_let_slice_binding.stderr +++ b/tests/ui/index_refutable_slice/if_let_slice_binding.stderr @@ -70,7 +70,7 @@ help: replace the binding and indexed access with a slice pattern | LL ~ if let (SomeEnum::Three([_, _, a_2, ..]), Some(b)) = (a_wrapped, b_wrapped) { LL | -... +LL | LL | LL ~ println!("{} -> {}", a_2, b[1]); | @@ -85,13 +85,13 @@ help: replace the binding and indexed access with a slice pattern | LL ~ if let (SomeEnum::Three(a), Some([_, b_1, ..])) = (a_wrapped, b_wrapped) { LL | -... +LL | LL | LL ~ println!("{} -> {}", a[2], b_1); | error: this binding can be a slice pattern to avoid indexing - --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:59:21 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:58:21 | LL | if let Some(ref slice) = slice { | ^^^^^ @@ -105,7 +105,7 @@ LL ~ println!("{:?}", slice_1); | error: this binding can be a slice pattern to avoid indexing - --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:69:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:68:17 | LL | if let Some(slice) = &slice { | ^^^^^ @@ -119,7 +119,7 @@ LL ~ println!("{:?}", slice_0); | error: this binding can be a slice pattern to avoid indexing - --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:140:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:139:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ @@ -134,7 +134,7 @@ LL ~ println!("This is awesome! {}", slice_0); | error: this binding can be a slice pattern to avoid indexing - --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:149:17 + --> tests/ui/index_refutable_slice/if_let_slice_binding.rs:148:17 | LL | if let Some(slice) = wrap.inner { | ^^^^^ diff --git a/tests/ui/ineffective_open_options.fixed b/tests/ui/ineffective_open_options.fixed index c229278e78b22..03b73f99961a6 100644 --- a/tests/ui/ineffective_open_options.fixed +++ b/tests/ui/ineffective_open_options.fixed @@ -5,7 +5,8 @@ use std::fs::OpenOptions; fn main() { let file = OpenOptions::new() .create(true) -//~^ ineffective_open_options + + //~^ ineffective_open_options .append(true) .open("dump.json") .unwrap(); @@ -13,7 +14,8 @@ fn main() { let file = OpenOptions::new() .create(true) .append(true) -//~^ ineffective_open_options + + //~^ ineffective_open_options .open("dump.json") .unwrap(); diff --git a/tests/ui/ineffective_open_options.rs b/tests/ui/ineffective_open_options.rs index ed1fe79a27820..e333a71490fb6 100644 --- a/tests/ui/ineffective_open_options.rs +++ b/tests/ui/ineffective_open_options.rs @@ -5,8 +5,8 @@ use std::fs::OpenOptions; fn main() { let file = OpenOptions::new() .create(true) -.write(true) -//~^ ineffective_open_options + .write(true) + //~^ ineffective_open_options .append(true) .open("dump.json") .unwrap(); @@ -14,8 +14,8 @@ fn main() { let file = OpenOptions::new() .create(true) .append(true) -.write(true) -//~^ ineffective_open_options + .write(true) + //~^ ineffective_open_options .open("dump.json") .unwrap(); diff --git a/tests/ui/ineffective_open_options.stderr b/tests/ui/ineffective_open_options.stderr index afc97ecd755c5..42bb0438dcee8 100644 --- a/tests/ui/ineffective_open_options.stderr +++ b/tests/ui/ineffective_open_options.stderr @@ -1,17 +1,17 @@ error: unnecessary use of `.write(true)` because there is `.append(true)` - --> tests/ui/ineffective_open_options.rs:8:1 + --> tests/ui/ineffective_open_options.rs:8:9 | -LL | .write(true) - | ^^^^^^^^^^^^ help: remove `.write(true)` +LL | .write(true) + | ^^^^^^^^^^^^ help: remove `.write(true)` | = note: `-D clippy::ineffective-open-options` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::ineffective_open_options)]` error: unnecessary use of `.write(true)` because there is `.append(true)` - --> tests/ui/ineffective_open_options.rs:17:1 + --> tests/ui/ineffective_open_options.rs:17:9 | -LL | .write(true) - | ^^^^^^^^^^^^ help: remove `.write(true)` +LL | .write(true) + | ^^^^^^^^^^^^ help: remove `.write(true)` error: aborting due to 2 previous errors diff --git a/tests/ui/infallible_destructuring_match.rs b/tests/ui/infallible_destructuring_match.rs index 3db3aca18f232..5db30ebca88fa 100644 --- a/tests/ui/infallible_destructuring_match.rs +++ b/tests/ui/infallible_destructuring_match.rs @@ -26,7 +26,7 @@ fn infallible_destructuring_match_enum() { // This should lint! let data = match wrapper { - //~^ infallible_destructuring_match + //~^ infallible_destructuring_match SingleVariantEnum::Variant(i) => i, }; @@ -59,7 +59,7 @@ fn infallible_destructuring_match_struct() { // This should lint! let data = match wrapper { - //~^ infallible_destructuring_match + //~^ infallible_destructuring_match TupleStruct(i) => i, }; @@ -84,7 +84,7 @@ fn infallible_destructuring_match_struct_with_noncopy() { // This should lint! (keeping `ref` in the suggestion) let data = match wrapper { - //~^ infallible_destructuring_match + //~^ infallible_destructuring_match TupleStructWithNonCopy(ref n) => n, }; @@ -104,7 +104,7 @@ fn never_enum() { // This should lint! let data = match wrapper { - //~^ infallible_destructuring_match + //~^ infallible_destructuring_match Ok(i) => i, }; diff --git a/tests/ui/infinite_iter.rs b/tests/ui/infinite_iter.rs index 2f8cc954e70c8..002a791a65793 100644 --- a/tests/ui/infinite_iter.rs +++ b/tests/ui/infinite_iter.rs @@ -26,8 +26,7 @@ fn infinite_iters() { .min(); // infinite iter (0..8_u32) - //~^ infinite_iter - + //~^ infinite_iter .rev() .cycle() .map(|x| x + 1_u32) @@ -60,8 +59,7 @@ fn potential_infinite_iters() { // maybe infinite iter (1..) - //~^ maybe_infinite_iter - + //~^ maybe_infinite_iter .scan(0, |state, x| { *state += x; Some(*state) @@ -83,7 +81,6 @@ fn potential_infinite_iters() { (0..).all(|x| x == 24); //~^ maybe_infinite_iter - // not infinite (0..).zip(0..42).take_while(|&(x, _)| x != 42).count(); // iterator is not exhausted @@ -110,8 +107,6 @@ mod finite_collect { let _: HashSet = (0..).collect(); //~^ infinite_iter - - // Some data structures don't collect infinitely, such as `ArrayVec` let _: C = (0..).collect(); } diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index ef3836a5ab590..47133a2ea62e1 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -27,7 +27,6 @@ error: infinite iteration detected | LL | / (0..8_u32) LL | | -LL | | LL | | .rev() LL | | .cycle() LL | | .map(|x| x + 1_u32) @@ -35,73 +34,73 @@ LL | | .for_each(|x| println!("{}", x)); | |________________________________________^ error: infinite iteration detected - --> tests/ui/infinite_iter.rs:38:5 + --> tests/ui/infinite_iter.rs:37:5 | LL | (0_usize..).flat_map(|x| 0..x).product::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> tests/ui/infinite_iter.rs:42:5 + --> tests/ui/infinite_iter.rs:41:5 | LL | (0_u64..).filter(|x| x % 2 == 0).last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> tests/ui/infinite_iter.rs:54:5 + --> tests/ui/infinite_iter.rs:53:5 | LL | (0..).zip((0..).take_while(square_is_lower_64)).count(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> tests/ui/infinite_iter.rs:51:8 + --> tests/ui/infinite_iter.rs:50:8 | LL | #[deny(clippy::maybe_infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> tests/ui/infinite_iter.rs:58:5 + --> tests/ui/infinite_iter.rs:57:5 | LL | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> tests/ui/infinite_iter.rs:62:5 + --> tests/ui/infinite_iter.rs:61:5 | LL | / (1..) LL | | -LL | | LL | | .scan(0, |state, x| { -... | +LL | | *state += x; +LL | | Some(*state) LL | | }) LL | | .min(); | |______________^ error: possible infinite iteration detected - --> tests/ui/infinite_iter.rs:71:5 + --> tests/ui/infinite_iter.rs:69:5 | LL | (0..).find(|x| *x == 24); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> tests/ui/infinite_iter.rs:75:5 + --> tests/ui/infinite_iter.rs:73:5 | LL | (0..).position(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> tests/ui/infinite_iter.rs:79:5 + --> tests/ui/infinite_iter.rs:77:5 | LL | (0..).any(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> tests/ui/infinite_iter.rs:83:5 + --> tests/ui/infinite_iter.rs:81:5 | LL | (0..).all(|x| x == 24); | ^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> tests/ui/infinite_iter.rs:110:31 + --> tests/ui/infinite_iter.rs:107:31 | LL | let _: HashSet = (0..).collect(); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/infinite_loop.rs b/tests/ui/infinite_loop.rs index 02d40e84eed9d..4a0968918bfbe 100644 --- a/tests/ui/infinite_loop.rs +++ b/tests/ui/infinite_loop.rs @@ -20,16 +20,14 @@ fn immutable_condition() { // Should warn when all vars mentioned are immutable let y = 0; while y < 10 { - //~^ while_immutable_condition - + //~^ while_immutable_condition println!("KO - y is immutable"); } let x = 0; while y < 10 && x < 3 { - //~^ while_immutable_condition - + //~^ while_immutable_condition let mut k = 1; k += 2; @@ -38,8 +36,7 @@ fn immutable_condition() { let cond = false; while !cond { - //~^ while_immutable_condition - + //~^ while_immutable_condition println!("KO - cond immutable"); } @@ -85,23 +82,20 @@ fn unused_var() { let (mut i, mut j) = (0, 0); while i < 3 { - //~^ while_immutable_condition - + //~^ while_immutable_condition j = 3; println!("KO - i not mentioned"); } while i < 3 && j > 0 { - //~^ while_immutable_condition - + //~^ while_immutable_condition println!("KO - i and j not mentioned"); } while i < 3 { - //~^ while_immutable_condition - + //~^ while_immutable_condition let mut i = 5; fn_mutref(&mut i); @@ -118,16 +112,14 @@ fn used_immutable() { let mut i = 0; while i < 3 { - //~^ while_immutable_condition - + //~^ while_immutable_condition fn_constref(&i); println!("KO - const reference"); } while i < 3 { - //~^ while_immutable_condition - + //~^ while_immutable_condition fn_val(i); println!("KO - passed by value"); @@ -195,8 +187,7 @@ impl Counter { fn print_n(&self, n: usize) { while self.count < n { - //~^ while_immutable_condition - + //~^ while_immutable_condition println!("KO - {} is not mutated", self.count); } @@ -206,8 +197,7 @@ impl Counter { fn while_loop_with_break_and_return() { let y = 0; while y < 10 { - //~^ while_immutable_condition - + //~^ while_immutable_condition if y == 0 { break; @@ -216,8 +206,7 @@ fn while_loop_with_break_and_return() { } while y < 10 { - //~^ while_immutable_condition - + //~^ while_immutable_condition if y == 0 { return; diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index f2876fd6ddb88..7ba1374d64f46 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -8,7 +8,7 @@ LL | while y < 10 { = note: `#[deny(clippy::while_immutable_condition)]` on by default error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:30:11 + --> tests/ui/infinite_loop.rs:29:11 | LL | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | while y < 10 && x < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:40:11 + --> tests/ui/infinite_loop.rs:38:11 | LL | while !cond { | ^^^^^ @@ -24,7 +24,7 @@ LL | while !cond { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:87:11 + --> tests/ui/infinite_loop.rs:84:11 | LL | while i < 3 { | ^^^^^ @@ -32,7 +32,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:95:11 + --> tests/ui/infinite_loop.rs:91:11 | LL | while i < 3 && j > 0 { | ^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | while i < 3 && j > 0 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:102:11 + --> tests/ui/infinite_loop.rs:97:11 | LL | while i < 3 { | ^^^^^ @@ -48,7 +48,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:120:11 + --> tests/ui/infinite_loop.rs:114:11 | LL | while i < 3 { | ^^^^^ @@ -56,7 +56,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:128:11 + --> tests/ui/infinite_loop.rs:121:11 | LL | while i < 3 { | ^^^^^ @@ -64,7 +64,7 @@ LL | while i < 3 { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:197:15 + --> tests/ui/infinite_loop.rs:189:15 | LL | while self.count < n { | ^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | while self.count < n { = note: this may lead to an infinite or to a never running loop error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:208:11 + --> tests/ui/infinite_loop.rs:199:11 | LL | while y < 10 { | ^^^^^^ @@ -82,7 +82,7 @@ LL | while y < 10 { = help: rewrite it as `if cond { loop { } }` error: variables in the condition are not mutated in the loop body - --> tests/ui/infinite_loop.rs:218:11 + --> tests/ui/infinite_loop.rs:208:11 | LL | while y < 10 { | ^^^^^^ diff --git a/tests/ui/infinite_loops.rs b/tests/ui/infinite_loops.rs index b5c1a5688eca6..eaa8d00880682 100644 --- a/tests/ui/infinite_loops.rs +++ b/tests/ui/infinite_loops.rs @@ -11,18 +11,18 @@ fn do_something() {} fn no_break() { loop { - //~^ infinite_loop + //~^ infinite_loop do_something(); } } fn all_inf() { loop { - //~^ infinite_loop - loop { //~^ infinite_loop - loop { + loop { //~^ infinite_loop + loop { + //~^ infinite_loop do_something(); } } @@ -36,7 +36,7 @@ fn no_break_return_some_ty() -> Option { return None; } loop { - //~^ infinite_loop + //~^ infinite_loop do_something(); } } @@ -49,7 +49,7 @@ fn no_break_never_ret() -> ! { fn no_break_never_ret_noise() { loop { - //~^ infinite_loop + //~^ infinite_loop fn inner_fn() -> ! { std::process::exit(0); } @@ -93,7 +93,7 @@ fn has_indirect_break_2(stop_num: i32) { fn break_inner_but_not_outer_1(cond: bool) { loop { - //~^ infinite_loop + //~^ infinite_loop loop { if cond { break; @@ -104,7 +104,7 @@ fn break_inner_but_not_outer_1(cond: bool) { fn break_inner_but_not_outer_2(cond: bool) { loop { - //~^ infinite_loop + //~^ infinite_loop 'inner: loop { loop { if cond { @@ -118,7 +118,7 @@ fn break_inner_but_not_outer_2(cond: bool) { fn break_outer_but_not_inner() { loop { loop { - //~^ infinite_loop + //~^ infinite_loop do_something(); } break; @@ -141,7 +141,7 @@ fn break_wrong_loop(cond: bool) { // 'inner has statement to break 'outer loop, but it was broken out of early by a labeled child loop 'outer: loop { loop { - //~^ infinite_loop + //~^ infinite_loop 'inner: loop { loop { loop { @@ -181,7 +181,7 @@ enum Foo { fn match_like() { let opt: Option = Some(1); loop { - //~^ infinite_loop + //~^ infinite_loop match opt { Some(v) => { println!("{v}"); @@ -222,12 +222,12 @@ fn match_like() { } loop { - //~^ infinite_loop + //~^ infinite_loop let _x = matches!(result, Ok(v) if v != 0).then_some(0); } loop { - //~^ infinite_loop + //~^ infinite_loop // This `return` does not return the function, so it doesn't count let _x = matches!(result, Ok(v) if v != 0).then(|| { if true { @@ -332,7 +332,7 @@ fn exit_directly(cond: bool) { trait MyTrait { fn problematic_trait_method() { loop { - //~^ infinite_loop + //~^ infinite_loop do_something(); } } @@ -342,7 +342,7 @@ trait MyTrait { impl MyTrait for String { fn could_be_problematic() { loop { - //~^ infinite_loop + //~^ infinite_loop do_something(); } } @@ -351,7 +351,7 @@ impl MyTrait for String { fn inf_loop_in_closure() { let _loop_forever = || { loop { - //~^ infinite_loop + //~^ infinite_loop do_something(); } }; @@ -365,7 +365,7 @@ fn inf_loop_in_closure() { fn inf_loop_in_res() -> Result<(), i32> { Ok(loop { - //~^ infinite_loop + //~^ infinite_loop do_something() }) } @@ -408,16 +408,16 @@ fn continue_outer() { // This should lint as we continue the loop itself 'infinite: loop { - //~^ infinite_loop + //~^ infinite_loop loop { continue 'infinite; } } // This should lint as we continue an inner loop loop { - //~^ infinite_loop - 'inner: loop { //~^ infinite_loop + 'inner: loop { + //~^ infinite_loop loop { continue 'inner; } @@ -426,7 +426,7 @@ fn continue_outer() { // This should lint as we continue the loop itself loop { - //~^ infinite_loop + //~^ infinite_loop continue; } } diff --git a/tests/ui/inherent_to_string.rs b/tests/ui/inherent_to_string.rs index a1a810dad1e47..30977f2d93ac6 100644 --- a/tests/ui/inherent_to_string.rs +++ b/tests/ui/inherent_to_string.rs @@ -20,7 +20,7 @@ struct J; impl A { // Should be detected; emit warning fn to_string(&self) -> String { - //~^ inherent_to_string + //~^ inherent_to_string "A.to_string()".to_string() } @@ -46,7 +46,7 @@ impl B { impl C { // Should be detected and emit error as C also implements Display fn to_string(&self) -> String { - //~^ inherent_to_string_shadow_display + //~^ inherent_to_string_shadow_display "C.to_string()".to_string() } diff --git a/tests/ui/init_numbered_fields.rs b/tests/ui/init_numbered_fields.rs index dc33921e3df9d..ae5dfe889575b 100644 --- a/tests/ui/init_numbered_fields.rs +++ b/tests/ui/init_numbered_fields.rs @@ -15,7 +15,7 @@ fn main() { // This should lint let _ = TupleStruct { - //~^ init_numbered_fields + //~^ init_numbered_fields 0: 1u32, 1: 42, 2: 23u8, @@ -23,7 +23,7 @@ fn main() { // This should also lint and order the fields correctly let _ = TupleStruct { - //~^ init_numbered_fields + //~^ init_numbered_fields 0: 1u32, 2: 2u8, 1: 3u32, diff --git a/tests/ui/inspect_for_each.rs b/tests/ui/inspect_for_each.rs index d3eb7fcbba4dc..8bfd9cec66dc5 100644 --- a/tests/ui/inspect_for_each.rs +++ b/tests/ui/inspect_for_each.rs @@ -5,7 +5,7 @@ fn main() { let mut b: Vec = Vec::new(); a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| { - //~^ inspect_for_each + //~^ inspect_for_each let y = do_some(x); let z = do_more(y); diff --git a/tests/ui/into_iter_on_ref.fixed b/tests/ui/into_iter_on_ref.fixed index 6d62a6547427d..7626569fd422f 100644 --- a/tests/ui/into_iter_on_ref.fixed +++ b/tests/ui/into_iter_on_ref.fixed @@ -10,60 +10,60 @@ fn main() { for _ in &vec![X, X] {} let _ = vec![1, 2, 3].into_iter(); -let _ = (&vec![1, 2, 3]).iter(); -//~^ into_iter_on_ref -let _ = std::rc::Rc::from(&[X][..]).iter(); -//~^ into_iter_on_ref -let _ = std::sync::Arc::from(&[X][..]).iter(); -//~^ into_iter_on_ref + let _ = (&vec![1, 2, 3]).iter(); + //~^ into_iter_on_ref + let _ = std::rc::Rc::from(&[X][..]).iter(); + //~^ into_iter_on_ref + let _ = std::sync::Arc::from(&[X][..]).iter(); + //~^ into_iter_on_ref -let _ = (&&&&&&&[1, 2, 3]).iter(); -//~^ into_iter_on_ref -let _ = (&&&&mut &&&[1, 2, 3]).iter(); -//~^ into_iter_on_ref -let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); -//~^ into_iter_on_ref + let _ = (&&&&&&&[1, 2, 3]).iter(); + //~^ into_iter_on_ref + let _ = (&&&&mut &&&[1, 2, 3]).iter(); + //~^ into_iter_on_ref + let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); + //~^ into_iter_on_ref -let _ = (&Some(4)).iter(); -//~^ into_iter_on_ref -let _ = (&mut Some(5)).iter_mut(); -//~^ into_iter_on_ref -let _ = (&Ok::<_, i32>(6)).iter(); -//~^ into_iter_on_ref -let _ = (&mut Err::(7)).iter_mut(); -//~^ into_iter_on_ref -let _ = (&Vec::::new()).iter(); -//~^ into_iter_on_ref -let _ = (&mut Vec::::new()).iter_mut(); -//~^ into_iter_on_ref -let _ = (&BTreeMap::::new()).iter(); -//~^ into_iter_on_ref -let _ = (&mut BTreeMap::::new()).iter_mut(); -//~^ into_iter_on_ref -let _ = (&VecDeque::::new()).iter(); -//~^ into_iter_on_ref -let _ = (&mut VecDeque::::new()).iter_mut(); -//~^ into_iter_on_ref -let _ = (&LinkedList::::new()).iter(); -//~^ into_iter_on_ref -let _ = (&mut LinkedList::::new()).iter_mut(); -//~^ into_iter_on_ref -let _ = (&HashMap::::new()).iter(); -//~^ into_iter_on_ref -let _ = (&mut HashMap::::new()).iter_mut(); -//~^ into_iter_on_ref + let _ = (&Some(4)).iter(); + //~^ into_iter_on_ref + let _ = (&mut Some(5)).iter_mut(); + //~^ into_iter_on_ref + let _ = (&Ok::<_, i32>(6)).iter(); + //~^ into_iter_on_ref + let _ = (&mut Err::(7)).iter_mut(); + //~^ into_iter_on_ref + let _ = (&Vec::::new()).iter(); + //~^ into_iter_on_ref + let _ = (&mut Vec::::new()).iter_mut(); + //~^ into_iter_on_ref + let _ = (&BTreeMap::::new()).iter(); + //~^ into_iter_on_ref + let _ = (&mut BTreeMap::::new()).iter_mut(); + //~^ into_iter_on_ref + let _ = (&VecDeque::::new()).iter(); + //~^ into_iter_on_ref + let _ = (&mut VecDeque::::new()).iter_mut(); + //~^ into_iter_on_ref + let _ = (&LinkedList::::new()).iter(); + //~^ into_iter_on_ref + let _ = (&mut LinkedList::::new()).iter_mut(); + //~^ into_iter_on_ref + let _ = (&HashMap::::new()).iter(); + //~^ into_iter_on_ref + let _ = (&mut HashMap::::new()).iter_mut(); + //~^ into_iter_on_ref -let _ = (&BTreeSet::::new()).iter(); -//~^ into_iter_on_ref -let _ = (&BinaryHeap::::new()).iter(); -//~^ into_iter_on_ref -let _ = (&HashSet::::new()).iter(); -//~^ into_iter_on_ref -let _ = std::path::Path::new("12/34").iter(); -//~^ into_iter_on_ref -let _ = std::path::PathBuf::from("12/34").iter(); -//~^ into_iter_on_ref + let _ = (&BTreeSet::::new()).iter(); + //~^ into_iter_on_ref + let _ = (&BinaryHeap::::new()).iter(); + //~^ into_iter_on_ref + let _ = (&HashSet::::new()).iter(); + //~^ into_iter_on_ref + let _ = std::path::Path::new("12/34").iter(); + //~^ into_iter_on_ref + let _ = std::path::PathBuf::from("12/34").iter(); + //~^ into_iter_on_ref -let _ = (&[1, 2, 3]).iter().next(); -//~^ into_iter_on_ref + let _ = (&[1, 2, 3]).iter().next(); + //~^ into_iter_on_ref } diff --git a/tests/ui/into_iter_on_ref.rs b/tests/ui/into_iter_on_ref.rs index 3e678761d7517..286a62c69ce5c 100644 --- a/tests/ui/into_iter_on_ref.rs +++ b/tests/ui/into_iter_on_ref.rs @@ -10,60 +10,60 @@ fn main() { for _ in &vec![X, X] {} let _ = vec![1, 2, 3].into_iter(); -let _ = (&vec![1, 2, 3]).into_iter(); -//~^ into_iter_on_ref -let _ = std::rc::Rc::from(&[X][..]).into_iter(); -//~^ into_iter_on_ref -let _ = std::sync::Arc::from(&[X][..]).into_iter(); -//~^ into_iter_on_ref + let _ = (&vec![1, 2, 3]).into_iter(); + //~^ into_iter_on_ref + let _ = std::rc::Rc::from(&[X][..]).into_iter(); + //~^ into_iter_on_ref + let _ = std::sync::Arc::from(&[X][..]).into_iter(); + //~^ into_iter_on_ref -let _ = (&&&&&&&[1, 2, 3]).into_iter(); -//~^ into_iter_on_ref -let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); -//~^ into_iter_on_ref + let _ = (&&&&&&&[1, 2, 3]).into_iter(); + //~^ into_iter_on_ref + let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); + //~^ into_iter_on_ref -let _ = (&Some(4)).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut Some(5)).into_iter(); -//~^ into_iter_on_ref -let _ = (&Ok::<_, i32>(6)).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut Err::(7)).into_iter(); -//~^ into_iter_on_ref -let _ = (&Vec::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut Vec::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&BTreeMap::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut BTreeMap::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&VecDeque::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut VecDeque::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&LinkedList::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut LinkedList::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&HashMap::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&mut HashMap::::new()).into_iter(); -//~^ into_iter_on_ref + let _ = (&Some(4)).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut Some(5)).into_iter(); + //~^ into_iter_on_ref + let _ = (&Ok::<_, i32>(6)).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut Err::(7)).into_iter(); + //~^ into_iter_on_ref + let _ = (&Vec::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut Vec::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&BTreeMap::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut BTreeMap::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&VecDeque::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut VecDeque::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&LinkedList::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut LinkedList::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&HashMap::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&mut HashMap::::new()).into_iter(); + //~^ into_iter_on_ref -let _ = (&BTreeSet::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&BinaryHeap::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = (&HashSet::::new()).into_iter(); -//~^ into_iter_on_ref -let _ = std::path::Path::new("12/34").into_iter(); -//~^ into_iter_on_ref -let _ = std::path::PathBuf::from("12/34").into_iter(); -//~^ into_iter_on_ref + let _ = (&BTreeSet::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&BinaryHeap::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = (&HashSet::::new()).into_iter(); + //~^ into_iter_on_ref + let _ = std::path::Path::new("12/34").into_iter(); + //~^ into_iter_on_ref + let _ = std::path::PathBuf::from("12/34").into_iter(); + //~^ into_iter_on_ref -let _ = (&[1, 2, 3]).into_iter().next(); -//~^ into_iter_on_ref + let _ = (&[1, 2, 3]).into_iter().next(); + //~^ into_iter_on_ref } diff --git a/tests/ui/into_iter_on_ref.stderr b/tests/ui/into_iter_on_ref.stderr index 2c472fca9da58..57ff097a6ca24 100644 --- a/tests/ui/into_iter_on_ref.stderr +++ b/tests/ui/into_iter_on_ref.stderr @@ -1,161 +1,161 @@ error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` - --> tests/ui/into_iter_on_ref.rs:13:26 + --> tests/ui/into_iter_on_ref.rs:13:30 | -LL | let _ = (&vec![1, 2, 3]).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&vec![1, 2, 3]).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` | = note: `-D clippy::into-iter-on-ref` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::into_iter_on_ref)]` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` - --> tests/ui/into_iter_on_ref.rs:15:37 + --> tests/ui/into_iter_on_ref.rs:15:41 | -LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice` - --> tests/ui/into_iter_on_ref.rs:17:40 + --> tests/ui/into_iter_on_ref.rs:17:44 | -LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> tests/ui/into_iter_on_ref.rs:20:28 + --> tests/ui/into_iter_on_ref.rs:20:32 | -LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> tests/ui/into_iter_on_ref.rs:22:32 + --> tests/ui/into_iter_on_ref.rs:22:36 | -LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `array` - --> tests/ui/into_iter_on_ref.rs:24:36 + --> tests/ui/into_iter_on_ref.rs:24:40 | -LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Option` - --> tests/ui/into_iter_on_ref.rs:27:20 + --> tests/ui/into_iter_on_ref.rs:27:24 | -LL | let _ = (&Some(4)).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&Some(4)).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Option` - --> tests/ui/into_iter_on_ref.rs:29:24 + --> tests/ui/into_iter_on_ref.rs:29:28 | -LL | let _ = (&mut Some(5)).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut Some(5)).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Result` - --> tests/ui/into_iter_on_ref.rs:31:28 + --> tests/ui/into_iter_on_ref.rs:31:32 | -LL | let _ = (&Ok::<_, i32>(6)).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&Ok::<_, i32>(6)).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Result` - --> tests/ui/into_iter_on_ref.rs:33:33 + --> tests/ui/into_iter_on_ref.rs:33:37 | -LL | let _ = (&mut Err::(7)).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut Err::(7)).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec` - --> tests/ui/into_iter_on_ref.rs:35:30 + --> tests/ui/into_iter_on_ref.rs:35:34 | -LL | let _ = (&Vec::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&Vec::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Vec` - --> tests/ui/into_iter_on_ref.rs:37:34 + --> tests/ui/into_iter_on_ref.rs:37:38 | -LL | let _ = (&mut Vec::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut Vec::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeMap` - --> tests/ui/into_iter_on_ref.rs:39:40 + --> tests/ui/into_iter_on_ref.rs:39:44 | -LL | let _ = (&BTreeMap::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&BTreeMap::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `BTreeMap` - --> tests/ui/into_iter_on_ref.rs:41:44 + --> tests/ui/into_iter_on_ref.rs:41:48 | -LL | let _ = (&mut BTreeMap::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut BTreeMap::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `VecDeque` - --> tests/ui/into_iter_on_ref.rs:43:35 + --> tests/ui/into_iter_on_ref.rs:43:39 | -LL | let _ = (&VecDeque::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&VecDeque::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `VecDeque` - --> tests/ui/into_iter_on_ref.rs:45:39 + --> tests/ui/into_iter_on_ref.rs:45:43 | -LL | let _ = (&mut VecDeque::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut VecDeque::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `LinkedList` - --> tests/ui/into_iter_on_ref.rs:47:37 + --> tests/ui/into_iter_on_ref.rs:47:41 | -LL | let _ = (&LinkedList::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&LinkedList::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `LinkedList` - --> tests/ui/into_iter_on_ref.rs:49:41 + --> tests/ui/into_iter_on_ref.rs:49:45 | -LL | let _ = (&mut LinkedList::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut LinkedList::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashMap` - --> tests/ui/into_iter_on_ref.rs:51:39 + --> tests/ui/into_iter_on_ref.rs:51:43 | -LL | let _ = (&HashMap::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&HashMap::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `HashMap` - --> tests/ui/into_iter_on_ref.rs:53:43 + --> tests/ui/into_iter_on_ref.rs:53:47 | -LL | let _ = (&mut HashMap::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter_mut` +LL | let _ = (&mut HashMap::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter_mut` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeSet` - --> tests/ui/into_iter_on_ref.rs:56:35 + --> tests/ui/into_iter_on_ref.rs:56:39 | -LL | let _ = (&BTreeSet::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&BTreeSet::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BinaryHeap` - --> tests/ui/into_iter_on_ref.rs:58:37 + --> tests/ui/into_iter_on_ref.rs:58:41 | -LL | let _ = (&BinaryHeap::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&BinaryHeap::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashSet` - --> tests/ui/into_iter_on_ref.rs:60:34 + --> tests/ui/into_iter_on_ref.rs:60:38 | -LL | let _ = (&HashSet::::new()).into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&HashSet::::new()).into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Path` - --> tests/ui/into_iter_on_ref.rs:62:39 + --> tests/ui/into_iter_on_ref.rs:62:43 | -LL | let _ = std::path::Path::new("12/34").into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = std::path::Path::new("12/34").into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `PathBuf` - --> tests/ui/into_iter_on_ref.rs:64:43 + --> tests/ui/into_iter_on_ref.rs:64:47 | -LL | let _ = std::path::PathBuf::from("12/34").into_iter(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = std::path::PathBuf::from("12/34").into_iter(); + | ^^^^^^^^^ help: call directly: `iter` error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array` - --> tests/ui/into_iter_on_ref.rs:67:22 + --> tests/ui/into_iter_on_ref.rs:67:26 | -LL | let _ = (&[1, 2, 3]).into_iter().next(); - | ^^^^^^^^^ help: call directly: `iter` +LL | let _ = (&[1, 2, 3]).into_iter().next(); + | ^^^^^^^^^ help: call directly: `iter` error: aborting due to 26 previous errors diff --git a/tests/ui/into_iter_without_iter.rs b/tests/ui/into_iter_without_iter.rs index 368313af6f912..45e34b3930ad0 100644 --- a/tests/ui/into_iter_without_iter.rs +++ b/tests/ui/into_iter_without_iter.rs @@ -7,7 +7,7 @@ use std::iter::IntoIterator; pub struct S1; impl<'a> IntoIterator for &'a S1 { -//~^ into_iter_without_iter + //~^ into_iter_without_iter type IntoIter = std::slice::Iter<'a, u8>; type Item = &'a u8; fn into_iter(self) -> Self::IntoIter { @@ -15,7 +15,7 @@ impl<'a> IntoIterator for &'a S1 { } } impl<'a> IntoIterator for &'a mut S1 { -//~^ into_iter_without_iter + //~^ into_iter_without_iter type IntoIter = std::slice::IterMut<'a, u8>; type Item = &'a mut u8; fn into_iter(self) -> Self::IntoIter { @@ -25,7 +25,7 @@ impl<'a> IntoIterator for &'a mut S1 { pub struct S2(T); impl<'a, T> IntoIterator for &'a S2 { -//~^ into_iter_without_iter + //~^ into_iter_without_iter type IntoIter = std::slice::Iter<'a, T>; type Item = &'a T; fn into_iter(self) -> Self::IntoIter { @@ -33,7 +33,7 @@ impl<'a, T> IntoIterator for &'a S2 { } } impl<'a, T> IntoIterator for &'a mut S2 { -//~^ into_iter_without_iter + //~^ into_iter_without_iter type IntoIter = std::slice::IterMut<'a, T>; type Item = &'a mut T; fn into_iter(self) -> Self::IntoIter { @@ -84,7 +84,7 @@ impl<'a, T> IntoIterator for &S4<'a, T> { } impl<'a, T> IntoIterator for &mut S4<'a, T> { -//~^ into_iter_without_iter + //~^ into_iter_without_iter type IntoIter = std::slice::IterMut<'a, T>; type Item = &'a mut T; fn into_iter(self) -> Self::IntoIter { @@ -118,7 +118,7 @@ pub struct Issue12037; macro_rules! generate_impl { () => { impl<'a> IntoIterator for &'a Issue12037 { - //~^ into_iter_without_iter + //~^ into_iter_without_iter type IntoIter = std::slice::Iter<'a, u8>; type Item = &'a u8; fn into_iter(self) -> Self::IntoIter { diff --git a/tests/ui/invalid_upcast_comparisons.rs b/tests/ui/invalid_upcast_comparisons.rs index bb2166862efce..4f3194869f430 100644 --- a/tests/ui/invalid_upcast_comparisons.rs +++ b/tests/ui/invalid_upcast_comparisons.rs @@ -21,7 +21,6 @@ fn main() { (u8 as u32) > 300; //~^ invalid_upcast_comparisons - (u8 as i32) > 300; //~^ invalid_upcast_comparisons @@ -68,7 +67,6 @@ fn main() { 300 != (u8 as i32); //~^ invalid_upcast_comparisons - // always false, since u8 -> i32 doesn't wrap (u8 as i32) < 0; //~^ invalid_upcast_comparisons @@ -83,7 +81,6 @@ fn main() { -5 == (u8 as i32); //~^ invalid_upcast_comparisons - // always false, since no u8 can be 1337 1337 == (u8 as i32); //~^ invalid_upcast_comparisons @@ -98,7 +95,6 @@ fn main() { 1337 != (u8 as u32); //~^ invalid_upcast_comparisons - // Those are Ok: (u8 as u32) > 20; 42 == (u8 as i32); @@ -135,6 +131,5 @@ fn main() { -5 >= (u8 as i32); //~^ invalid_upcast_comparisons - -5 == (u32 as i32); } diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index 911022c005c99..ef36f18eabc9a 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -8,157 +8,157 @@ LL | (u8 as u32) > 300; = help: to override `-D warnings` add `#[allow(clippy::invalid_upcast_comparisons)]` error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:25:5 + --> tests/ui/invalid_upcast_comparisons.rs:24:5 | LL | (u8 as i32) > 300; | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:28:5 + --> tests/ui/invalid_upcast_comparisons.rs:27:5 | LL | (u8 as u32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:31:5 + --> tests/ui/invalid_upcast_comparisons.rs:30:5 | LL | (u8 as i32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:34:5 + --> tests/ui/invalid_upcast_comparisons.rs:33:5 | LL | 300 < (u8 as u32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:37:5 + --> tests/ui/invalid_upcast_comparisons.rs:36:5 | LL | 300 < (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:40:5 + --> tests/ui/invalid_upcast_comparisons.rs:39:5 | LL | 300 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:43:5 + --> tests/ui/invalid_upcast_comparisons.rs:42:5 | LL | 300 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:47:5 + --> tests/ui/invalid_upcast_comparisons.rs:46:5 | LL | (u8 as u32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:50:5 + --> tests/ui/invalid_upcast_comparisons.rs:49:5 | LL | (u8 as i32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:53:5 + --> tests/ui/invalid_upcast_comparisons.rs:52:5 | LL | (u8 as u32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:56:5 + --> tests/ui/invalid_upcast_comparisons.rs:55:5 | LL | (u8 as i32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:59:5 + --> tests/ui/invalid_upcast_comparisons.rs:58:5 | LL | 300 >= (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:62:5 + --> tests/ui/invalid_upcast_comparisons.rs:61:5 | LL | 300 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:65:5 + --> tests/ui/invalid_upcast_comparisons.rs:64:5 | LL | 300 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:68:5 + --> tests/ui/invalid_upcast_comparisons.rs:67:5 | LL | 300 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:73:5 + --> tests/ui/invalid_upcast_comparisons.rs:71:5 | LL | (u8 as i32) < 0; | ^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:76:5 + --> tests/ui/invalid_upcast_comparisons.rs:74:5 | LL | -5 != (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:80:5 + --> tests/ui/invalid_upcast_comparisons.rs:78:5 | LL | (u8 as i32) >= 0; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:83:5 + --> tests/ui/invalid_upcast_comparisons.rs:81:5 | LL | -5 == (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:88:5 + --> tests/ui/invalid_upcast_comparisons.rs:85:5 | LL | 1337 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:91:5 + --> tests/ui/invalid_upcast_comparisons.rs:88:5 | LL | 1337 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:95:5 + --> tests/ui/invalid_upcast_comparisons.rs:92:5 | LL | 1337 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:98:5 + --> tests/ui/invalid_upcast_comparisons.rs:95:5 | LL | 1337 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> tests/ui/invalid_upcast_comparisons.rs:114:5 + --> tests/ui/invalid_upcast_comparisons.rs:110:5 | LL | (u8 as i32) > -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:117:5 + --> tests/ui/invalid_upcast_comparisons.rs:113:5 | LL | (u8 as i32) < -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> tests/ui/invalid_upcast_comparisons.rs:135:5 + --> tests/ui/invalid_upcast_comparisons.rs:131:5 | LL | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issue-7447.rs b/tests/ui/issue-7447.rs index 25ace345ad14b..452011de1195e 100644 --- a/tests/ui/issue-7447.rs +++ b/tests/ui/issue-7447.rs @@ -26,8 +26,6 @@ fn main() { byte_view(panic!()); //~^ diverging_sub_expression - group_entries(panic!()); //~^ diverging_sub_expression - } diff --git a/tests/ui/issue-7447.stderr b/tests/ui/issue-7447.stderr index 1ba53631b52db..5e28c1423840f 100644 --- a/tests/ui/issue-7447.stderr +++ b/tests/ui/issue-7447.stderr @@ -9,7 +9,7 @@ LL | byte_view(panic!()); = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: sub-expression diverges - --> tests/ui/issue-7447.rs:30:19 + --> tests/ui/issue-7447.rs:29:19 | LL | group_entries(panic!()); | ^^^^^^^^ diff --git a/tests/ui/issue_2356.fixed b/tests/ui/issue_2356.fixed index c96d3c1a24f97..46ba653eba2cf 100644 --- a/tests/ui/issue_2356.fixed +++ b/tests/ui/issue_2356.fixed @@ -15,7 +15,7 @@ impl Foo { fn foo2>(mut it: I) { for e in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{:?}", e); } } diff --git a/tests/ui/issue_2356.rs b/tests/ui/issue_2356.rs index a4040cb37ceda..defe2584a93e1 100644 --- a/tests/ui/issue_2356.rs +++ b/tests/ui/issue_2356.rs @@ -15,7 +15,7 @@ impl Foo { fn foo2>(mut it: I) { while let Some(e) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{:?}", e); } } diff --git a/tests/ui/issue_4266.rs b/tests/ui/issue_4266.rs index aabf72a93ce21..664f0b84a2077 100644 --- a/tests/ui/issue_4266.rs +++ b/tests/ui/issue_4266.rs @@ -4,12 +4,11 @@ async fn sink1<'a>(_: &'a str) {} // lint //~^ needless_lifetimes - async fn sink1_elided(_: &str) {} // ok // lint async fn one_to_one<'a>(s: &'a str) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes s } @@ -31,7 +30,7 @@ struct Foo; impl Foo { // ok pub async fn new(&mut self) -> Self { - //~^ wrong_self_convention + //~^ wrong_self_convention Foo {} } diff --git a/tests/ui/issue_4266.stderr b/tests/ui/issue_4266.stderr index ce0588521810a..0e181025430f3 100644 --- a/tests/ui/issue_4266.stderr +++ b/tests/ui/issue_4266.stderr @@ -8,13 +8,13 @@ LL | async fn sink1<'a>(_: &'a str) {} // lint = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` error: the following explicit lifetimes could be elided: 'a - --> tests/ui/issue_4266.rs:11:21 + --> tests/ui/issue_4266.rs:10:21 | LL | async fn one_to_one<'a>(s: &'a str) -> &'a str { | ^^ ^^ ^^ error: methods called `new` usually take no `self` - --> tests/ui/issue_4266.rs:33:22 + --> tests/ui/issue_4266.rs:32:22 | LL | pub async fn new(&mut self) -> Self { | ^^^^^^^^^ diff --git a/tests/ui/items_after_statement.rs b/tests/ui/items_after_statement.rs index db3583464e9a7..b97c831f37ecc 100644 --- a/tests/ui/items_after_statement.rs +++ b/tests/ui/items_after_statement.rs @@ -11,8 +11,7 @@ fn ok() { fn last() { foo(); fn foo() { - //~^ items_after_statements - + //~^ items_after_statements println!("foo"); } @@ -21,7 +20,7 @@ fn last() { fn main() { foo(); fn foo() { - //~^ items_after_statements + //~^ items_after_statements println!("foo"); } @@ -36,7 +35,7 @@ fn mac() { () => {{ a = 6; fn say_something() { - //~^ items_after_statements + //~^ items_after_statements println!("something"); } }}; diff --git a/tests/ui/items_after_statement.stderr b/tests/ui/items_after_statement.stderr index d6186f1305a02..7a5ae2c8d47d2 100644 --- a/tests/ui/items_after_statement.stderr +++ b/tests/ui/items_after_statement.stderr @@ -2,7 +2,9 @@ error: adding items after statements is confusing, since items exist from the st --> tests/ui/items_after_statement.rs:13:5 | LL | / fn foo() { -... | +LL | | +LL | | +LL | | println!("foo"); LL | | } | |_____^ | @@ -10,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::items_after_statements)]` error: adding items after statements is confusing, since items exist from the start of the scope - --> tests/ui/items_after_statement.rs:23:5 + --> tests/ui/items_after_statement.rs:22:5 | LL | / fn foo() { LL | | @@ -20,7 +22,7 @@ LL | | } | |_____^ error: adding items after statements is confusing, since items exist from the start of the scope - --> tests/ui/items_after_statement.rs:38:13 + --> tests/ui/items_after_statement.rs:37:13 | LL | / fn say_something() { LL | | diff --git a/tests/ui/items_after_test_module/root_module.fixed b/tests/ui/items_after_test_module/root_module.fixed index 25eff3d38f762..f036b368a6676 100644 --- a/tests/ui/items_after_test_module/root_module.fixed +++ b/tests/ui/items_after_test_module/root_module.fixed @@ -17,7 +17,7 @@ macro_rules! should_lint { #[allow(clippy::allow_attributes)] #[cfg(test)] mod tests { -//~^ items_after_test_module + //~^ items_after_test_module #[test] fn hi() {} } diff --git a/tests/ui/items_after_test_module/root_module.rs b/tests/ui/items_after_test_module/root_module.rs index 94afffd92de50..de0cbb120330e 100644 --- a/tests/ui/items_after_test_module/root_module.rs +++ b/tests/ui/items_after_test_module/root_module.rs @@ -10,7 +10,7 @@ fn should_not_lint() {} #[allow(clippy::allow_attributes)] #[cfg(test)] mod tests { -//~^ items_after_test_module + //~^ items_after_test_module #[test] fn hi() {} } diff --git a/tests/ui/iter_filter_is_ok.fixed b/tests/ui/iter_filter_is_ok.fixed index d3aeeff7d7b4b..3223e19d23a78 100644 --- a/tests/ui/iter_filter_is_ok.fixed +++ b/tests/ui/iter_filter_is_ok.fixed @@ -17,55 +17,46 @@ fn main() { #[rustfmt::skip] let _ = vec![Ok(1), Err(2)].into_iter().flatten(); //~^ iter_filter_is_ok - } { let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().flatten(); //~^ iter_filter_is_ok - let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().flatten(); //~^ iter_filter_is_ok - #[rustfmt::skip] let _ = vec![Ok(1), Err(2)].into_iter().flatten(); //~^ iter_filter_is_ok - } { let _ = vec![Ok(1), Err(2), Ok(3)] .into_iter() .flatten(); - //~^ iter_filter_is_ok - + //~^ iter_filter_is_ok let _ = vec![Ok(1), Err(2), Ok(3)] .into_iter() .flatten(); - //~^ iter_filter_is_ok + //~^ iter_filter_is_ok #[rustfmt::skip] let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().flatten(); //~^ iter_filter_is_ok - } { let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().flatten(); //~^ iter_filter_is_ok - let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().flatten(); //~^ iter_filter_is_ok - #[rustfmt::skip] let _ = vec![Ok(1), Err(2)].into_iter().flatten(); //~^ iter_filter_is_ok - } } diff --git a/tests/ui/iter_filter_is_ok.rs b/tests/ui/iter_filter_is_ok.rs index 7ed9748766933..973653819850d 100644 --- a/tests/ui/iter_filter_is_ok.rs +++ b/tests/ui/iter_filter_is_ok.rs @@ -17,55 +17,46 @@ fn main() { #[rustfmt::skip] let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { o.is_ok() }); //~^ iter_filter_is_ok - } { let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); //~^ iter_filter_is_ok - let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); //~^ iter_filter_is_ok - #[rustfmt::skip] let _ = vec![Ok(1), Err(2)].into_iter().filter(|&o| { o.is_ok() }); //~^ iter_filter_is_ok - } { let _ = vec![Ok(1), Err(2), Ok(3)] .into_iter() .filter(std::result::Result::is_ok); - //~^ iter_filter_is_ok - + //~^ iter_filter_is_ok let _ = vec![Ok(1), Err(2), Ok(3)] .into_iter() .filter(|a| std::result::Result::is_ok(a)); - //~^ iter_filter_is_ok + //~^ iter_filter_is_ok #[rustfmt::skip] let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| { std::result::Result::is_ok(a) }); //~^ iter_filter_is_ok - } { let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); //~^ iter_filter_is_ok - let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); //~^ iter_filter_is_ok - #[rustfmt::skip] let _ = vec![Ok(1), Err(2)].into_iter().filter(|ref o| { o.is_ok() }); //~^ iter_filter_is_ok - } } diff --git a/tests/ui/iter_filter_is_ok.stderr b/tests/ui/iter_filter_is_ok.stderr index 56c60c093a4b5..b7fd0d25cc235 100644 --- a/tests/ui/iter_filter_is_ok.stderr +++ b/tests/ui/iter_filter_is_ok.stderr @@ -20,55 +20,55 @@ LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:24:56 + --> tests/ui/iter_filter_is_ok.rs:23:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:28:56 + --> tests/ui/iter_filter_is_ok.rs:26:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|&a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:33:49 + --> tests/ui/iter_filter_is_ok.rs:30:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|&o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:41:14 + --> tests/ui/iter_filter_is_ok.rs:37:14 | LL | .filter(std::result::Result::is_ok); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:47:14 + --> tests/ui/iter_filter_is_ok.rs:42:14 | LL | .filter(|a| std::result::Result::is_ok(a)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:51:56 + --> tests/ui/iter_filter_is_ok.rs:46:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|a| { std::result::Result::is_ok(a) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:57:56 + --> tests/ui/iter_filter_is_ok.rs:51:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:61:56 + --> tests/ui/iter_filter_is_ok.rs:54:56 | LL | let _ = vec![Ok(1), Err(2), Ok(3)].into_iter().filter(|ref a| a.is_ok()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_ok` on iterator over `Result`s - --> tests/ui/iter_filter_is_ok.rs:66:49 + --> tests/ui/iter_filter_is_ok.rs:58:49 | LL | let _ = vec![Ok(1), Err(2)].into_iter().filter(|ref o| { o.is_ok() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` diff --git a/tests/ui/iter_filter_is_some.fixed b/tests/ui/iter_filter_is_some.fixed index f76e7a6190798..99e764e957fb0 100644 --- a/tests/ui/iter_filter_is_some.fixed +++ b/tests/ui/iter_filter_is_some.fixed @@ -21,47 +21,40 @@ fn main() { #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().flatten(); //~^ iter_filter_is_some - } { let _ = vec![Some(1), None, Some(3)] .into_iter() .flatten(); - //~^ iter_filter_is_some - + //~^ iter_filter_is_some let _ = vec![Some(1), None, Some(3)] .into_iter() .flatten(); - //~^ iter_filter_is_some + //~^ iter_filter_is_some #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().flatten(); //~^ iter_filter_is_some - } { let _ = vec![Some(1), None, Some(3)].into_iter().flatten(); //~^ iter_filter_is_some - #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().flatten(); //~^ iter_filter_is_some - } { let _ = vec![Some(1), None, Some(3)].into_iter().flatten(); //~^ iter_filter_is_some - #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().flatten(); //~^ iter_filter_is_some - } } diff --git a/tests/ui/iter_filter_is_some.rs b/tests/ui/iter_filter_is_some.rs index 536af0021420c..ecb7a04ab4dff 100644 --- a/tests/ui/iter_filter_is_some.rs +++ b/tests/ui/iter_filter_is_some.rs @@ -21,47 +21,40 @@ fn main() { #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().filter(|o| { o.is_some() }); //~^ iter_filter_is_some - } { let _ = vec![Some(1), None, Some(3)] .into_iter() .filter(std::option::Option::is_some); - //~^ iter_filter_is_some - + //~^ iter_filter_is_some let _ = vec![Some(1), None, Some(3)] .into_iter() .filter(|a| std::option::Option::is_some(a)); - //~^ iter_filter_is_some + //~^ iter_filter_is_some #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| { std::option::Option::is_some(a) }); //~^ iter_filter_is_some - } { let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&a| a.is_some()); //~^ iter_filter_is_some - #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&o| { o.is_some() }); //~^ iter_filter_is_some - } { let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref a| a.is_some()); //~^ iter_filter_is_some - #[rustfmt::skip] let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref o| { o.is_some() }); //~^ iter_filter_is_some - } } diff --git a/tests/ui/iter_filter_is_some.stderr b/tests/ui/iter_filter_is_some.stderr index d1653fe1b7a3c..cd01a3e05cd0d 100644 --- a/tests/ui/iter_filter_is_some.stderr +++ b/tests/ui/iter_filter_is_some.stderr @@ -20,43 +20,43 @@ LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|o| { o.is_ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:30:14 + --> tests/ui/iter_filter_is_some.rs:29:14 | LL | .filter(std::option::Option::is_some); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:36:14 + --> tests/ui/iter_filter_is_some.rs:34:14 | LL | .filter(|a| std::option::Option::is_some(a)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:40:58 + --> tests/ui/iter_filter_is_some.rs:38:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|a| { std::option::Option::is_some(a) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:46:58 + --> tests/ui/iter_filter_is_some.rs:43:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:51:58 + --> tests/ui/iter_filter_is_some.rs:47:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|&o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:57:58 + --> tests/ui/iter_filter_is_some.rs:52:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref a| a.is_some()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `is_some` on iterator over `Option` - --> tests/ui/iter_filter_is_some.rs:62:58 + --> tests/ui/iter_filter_is_some.rs:56:58 | LL | let _ = vec![Some(1), None, Some(3)].into_iter().filter(|ref o| { o.is_some() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` diff --git a/tests/ui/iter_kv_map.fixed b/tests/ui/iter_kv_map.fixed index b9d86d8dd803b..7fcab6592e26c 100644 --- a/tests/ui/iter_kv_map.fixed +++ b/tests/ui/iter_kv_map.fixed @@ -52,7 +52,7 @@ fn main() { // Preserve the mut in the fix. let _ = map - //~^ iter_kv_map + //~^ iter_kv_map .clone().into_values().map(|mut val| { val += 2; val @@ -106,7 +106,7 @@ fn main() { // Preserve the mut in the fix. let _ = map - //~^ iter_kv_map + //~^ iter_kv_map .clone().into_values().map(|mut val| { val += 2; val @@ -138,7 +138,6 @@ fn msrv_1_53() { let _ = map.values().map(|v| v + 2).collect::>(); //~^ iter_kv_map - } #[clippy::msrv = "1.54"] @@ -152,14 +151,12 @@ fn msrv_1_54() { let _ = map.clone().into_keys().map(|key| key + 2).collect::>(); //~^ iter_kv_map - let _ = map.clone().into_values().collect::>(); //~^ iter_kv_map let _ = map.clone().into_values().map(|val| val + 2).collect::>(); //~^ iter_kv_map - let _ = map.keys().collect::>(); //~^ iter_kv_map @@ -168,5 +165,4 @@ fn msrv_1_54() { let _ = map.values().map(|v| v + 2).collect::>(); //~^ iter_kv_map - } diff --git a/tests/ui/iter_kv_map.rs b/tests/ui/iter_kv_map.rs index b14786180b1fe..b590aef7b8031 100644 --- a/tests/ui/iter_kv_map.rs +++ b/tests/ui/iter_kv_map.rs @@ -52,7 +52,7 @@ fn main() { // Preserve the mut in the fix. let _ = map - //~^ iter_kv_map + //~^ iter_kv_map .clone() .into_iter() .map(|(_, mut val)| { @@ -108,7 +108,7 @@ fn main() { // Preserve the mut in the fix. let _ = map - //~^ iter_kv_map + //~^ iter_kv_map .clone() .into_iter() .map(|(_, mut val)| { @@ -142,7 +142,6 @@ fn msrv_1_53() { let _ = map.iter().map(|(_, v)| v + 2).collect::>(); //~^ iter_kv_map - } #[clippy::msrv = "1.54"] @@ -156,14 +155,12 @@ fn msrv_1_54() { let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); //~^ iter_kv_map - let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); //~^ iter_kv_map let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); //~^ iter_kv_map - let _ = map.iter().map(|(key, _)| key).collect::>(); //~^ iter_kv_map @@ -172,5 +169,4 @@ fn msrv_1_54() { let _ = map.iter().map(|(_, v)| v + 2).collect::>(); //~^ iter_kv_map - } diff --git a/tests/ui/iter_kv_map.stderr b/tests/ui/iter_kv_map.stderr index d99fea1124a73..00d566ed14a28 100644 --- a/tests/ui/iter_kv_map.stderr +++ b/tests/ui/iter_kv_map.stderr @@ -222,43 +222,43 @@ LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` error: iterating on a map's keys - --> tests/ui/iter_kv_map.rs:153:13 + --> tests/ui/iter_kv_map.rs:152:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys()` error: iterating on a map's keys - --> tests/ui/iter_kv_map.rs:156:13 + --> tests/ui/iter_kv_map.rs:155:13 | LL | let _ = map.clone().into_iter().map(|(key, _)| key + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_keys().map(|key| key + 2)` error: iterating on a map's values - --> tests/ui/iter_kv_map.rs:160:13 + --> tests/ui/iter_kv_map.rs:158:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values()` error: iterating on a map's values - --> tests/ui/iter_kv_map.rs:163:13 + --> tests/ui/iter_kv_map.rs:161:13 | LL | let _ = map.clone().into_iter().map(|(_, val)| val + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.clone().into_values().map(|val| val + 2)` error: iterating on a map's keys - --> tests/ui/iter_kv_map.rs:167:13 + --> tests/ui/iter_kv_map.rs:164:13 | LL | let _ = map.iter().map(|(key, _)| key).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.keys()` error: iterating on a map's values - --> tests/ui/iter_kv_map.rs:170:13 + --> tests/ui/iter_kv_map.rs:167:13 | LL | let _ = map.iter().map(|(_, value)| value).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values()` error: iterating on a map's values - --> tests/ui/iter_kv_map.rs:173:13 + --> tests/ui/iter_kv_map.rs:170:13 | LL | let _ = map.iter().map(|(_, v)| v + 2).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `map.values().map(|v| v + 2)` diff --git a/tests/ui/iter_not_returning_iterator.rs b/tests/ui/iter_not_returning_iterator.rs index 4c0c667be80f4..5c8c8eb4a43d4 100644 --- a/tests/ui/iter_not_returning_iterator.rs +++ b/tests/ui/iter_not_returning_iterator.rs @@ -28,14 +28,13 @@ struct Counter2 { impl Data2 { fn iter(&self) -> Counter2 { - //~^ iter_not_returning_iterator - + //~^ iter_not_returning_iterator todo!() } fn iter_mut(&self) -> Counter2 { - //~^ iter_not_returning_iterator + //~^ iter_not_returning_iterator todo!() } @@ -54,7 +53,6 @@ trait Iter { type I; fn iter(&self) -> Self::I; //~^ iter_not_returning_iterator - } impl Iter for () { diff --git a/tests/ui/iter_not_returning_iterator.stderr b/tests/ui/iter_not_returning_iterator.stderr index 8c0ebd847110f..74ee8325d53e1 100644 --- a/tests/ui/iter_not_returning_iterator.stderr +++ b/tests/ui/iter_not_returning_iterator.stderr @@ -8,13 +8,13 @@ LL | fn iter(&self) -> Counter2 { = help: to override `-D warnings` add `#[allow(clippy::iter_not_returning_iterator)]` error: this method is named `iter_mut` but its return type does not implement `Iterator` - --> tests/ui/iter_not_returning_iterator.rs:37:5 + --> tests/ui/iter_not_returning_iterator.rs:36:5 | LL | fn iter_mut(&self) -> Counter2 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this method is named `iter` but its return type does not implement `Iterator` - --> tests/ui/iter_not_returning_iterator.rs:55:5 + --> tests/ui/iter_not_returning_iterator.rs:54:5 | LL | fn iter(&self) -> Self::I; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/iter_on_empty_collections.fixed b/tests/ui/iter_on_empty_collections.fixed index e1e4e331843bf..0c2100034e184 100644 --- a/tests/ui/iter_on_empty_collections.fixed +++ b/tests/ui/iter_on_empty_collections.fixed @@ -32,7 +32,7 @@ fn array() { // Don't trigger when the empty collection iter is relied upon for its concrete type // But do trigger if it is just an iterator, despite being an argument to a method for i in smth.as_ref().map_or([].iter(), |s| s.iter()).chain(std::iter::empty()) { - //~^ iter_on_empty_collections + //~^ iter_on_empty_collections println!("{i}"); } diff --git a/tests/ui/iter_on_empty_collections.rs b/tests/ui/iter_on_empty_collections.rs index 3a4ad7fb372a0..0fb7a32d3691f 100644 --- a/tests/ui/iter_on_empty_collections.rs +++ b/tests/ui/iter_on_empty_collections.rs @@ -32,7 +32,7 @@ fn array() { // Don't trigger when the empty collection iter is relied upon for its concrete type // But do trigger if it is just an iterator, despite being an argument to a method for i in smth.as_ref().map_or([].iter(), |s| s.iter()).chain([].iter()) { - //~^ iter_on_empty_collections + //~^ iter_on_empty_collections println!("{i}"); } diff --git a/tests/ui/iter_out_of_bounds.rs b/tests/ui/iter_out_of_bounds.rs index 243dce9939c13..b34e4ad782409 100644 --- a/tests/ui/iter_out_of_bounds.rs +++ b/tests/ui/iter_out_of_bounds.rs @@ -10,12 +10,12 @@ fn opaque_empty_iter() -> impl Iterator { fn main() { #[allow(clippy::never_loop)] for _ in [1, 2, 3].iter().skip(4) { - //~^ iter_out_of_bounds + //~^ iter_out_of_bounds unreachable!(); } for (i, _) in [1, 2, 3].iter().take(4).enumerate() { - //~^ iter_out_of_bounds + //~^ iter_out_of_bounds assert!(i <= 2); } @@ -24,56 +24,45 @@ fn main() { for _ in (&&&&&&[1, 2, 3]).iter().take(4) {} //~^ iter_out_of_bounds - for _ in [1, 2, 3].iter().skip(4) {} //~^ iter_out_of_bounds - for _ in [1; 3].iter().skip(4) {} //~^ iter_out_of_bounds - // Should not lint for _ in opaque_empty_iter().skip(1) {} for _ in vec![1, 2, 3].iter().skip(4) {} //~^ iter_out_of_bounds - for _ in vec![1; 3].iter().skip(4) {} //~^ iter_out_of_bounds - let x = [1, 2, 3]; for _ in x.iter().skip(4) {} //~^ iter_out_of_bounds - let n = 4; for _ in x.iter().skip(n) {} //~^ iter_out_of_bounds - let empty = std::iter::empty::; for _ in empty().skip(1) {} //~^ iter_out_of_bounds - for _ in empty().take(1) {} //~^ iter_out_of_bounds - for _ in std::iter::once(1).skip(2) {} //~^ iter_out_of_bounds - for _ in std::iter::once(1).take(2) {} //~^ iter_out_of_bounds - for x in [].iter().take(1) { - //~^ iter_out_of_bounds + //~^ iter_out_of_bounds let _: &i32 = x; } diff --git a/tests/ui/iter_out_of_bounds.stderr b/tests/ui/iter_out_of_bounds.stderr index 42984e00e1d49..19ac60b9d0ac0 100644 --- a/tests/ui/iter_out_of_bounds.stderr +++ b/tests/ui/iter_out_of_bounds.stderr @@ -28,7 +28,7 @@ LL | for _ in (&&&&&&[1, 2, 3]).iter().take(4) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:28:14 + --> tests/ui/iter_out_of_bounds.rs:27:14 | LL | for _ in [1, 2, 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | for _ in [1, 2, 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:32:14 + --> tests/ui/iter_out_of_bounds.rs:30:14 | LL | for _ in [1; 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | for _ in [1; 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:39:14 + --> tests/ui/iter_out_of_bounds.rs:36:14 | LL | for _ in vec![1, 2, 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | for _ in vec![1, 2, 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:43:14 + --> tests/ui/iter_out_of_bounds.rs:39:14 | LL | for _ in vec![1; 3].iter().skip(4) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | for _ in vec![1; 3].iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:48:14 + --> tests/ui/iter_out_of_bounds.rs:43:14 | LL | for _ in x.iter().skip(4) {} | ^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | for _ in x.iter().skip(4) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:53:14 + --> tests/ui/iter_out_of_bounds.rs:47:14 | LL | for _ in x.iter().skip(n) {} | ^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | for _ in x.iter().skip(n) {} = note: this operation is useless and will create an empty iterator error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:59:14 + --> tests/ui/iter_out_of_bounds.rs:52:14 | LL | for _ in empty().skip(1) {} | ^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | for _ in empty().skip(1) {} = note: this operation is useless and will create an empty iterator error: this `.take()` call takes more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:63:14 + --> tests/ui/iter_out_of_bounds.rs:55:14 | LL | for _ in empty().take(1) {} | ^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL | for _ in empty().take(1) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.skip()` call skips more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:67:14 + --> tests/ui/iter_out_of_bounds.rs:58:14 | LL | for _ in std::iter::once(1).skip(2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | for _ in std::iter::once(1).skip(2) {} = note: this operation is useless and will create an empty iterator error: this `.take()` call takes more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:71:14 + --> tests/ui/iter_out_of_bounds.rs:61:14 | LL | for _ in std::iter::once(1).take(2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | for _ in std::iter::once(1).take(2) {} = note: this operation is useless and the returned iterator will simply yield the same items error: this `.take()` call takes more items than the iterator will produce - --> tests/ui/iter_out_of_bounds.rs:75:14 + --> tests/ui/iter_out_of_bounds.rs:64:14 | LL | for x in [].iter().take(1) { | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/iter_over_hash_type.rs b/tests/ui/iter_over_hash_type.rs index 0dd9544cfe01f..914cc9df0de99 100644 --- a/tests/ui/iter_over_hash_type.rs +++ b/tests/ui/iter_over_hash_type.rs @@ -16,59 +16,59 @@ fn main() { // test hashset for x in &hash_set { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in hash_set.iter() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in hash_set.clone() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in hash_set.drain() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } // test hashmap for (x, y) in &hash_map { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = (x, y); } for x in hash_map.keys() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in hash_map.values() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in hash_map.values_mut() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type *x += 1; } for x in hash_map.iter() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in hash_map.clone() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in hash_map.drain() { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } // test type-aliased hashers for x in fx_hash_set { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } for x in fx_hash_map { - //~^ iter_over_hash_type + //~^ iter_over_hash_type let _ = x; } diff --git a/tests/ui/iter_overeager_cloned.fixed b/tests/ui/iter_overeager_cloned.fixed index bc6cf76a58d8d..9999126902903 100644 --- a/tests/ui/iter_overeager_cloned.fixed +++ b/tests/ui/iter_overeager_cloned.fixed @@ -28,7 +28,7 @@ fn main() { //~^ iter_overeager_cloned let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))] - //~^ iter_overeager_cloned + //~^ iter_overeager_cloned .iter() .flatten().cloned(); diff --git a/tests/ui/iter_overeager_cloned.rs b/tests/ui/iter_overeager_cloned.rs index 094760893c3e6..6a860dad5afd8 100644 --- a/tests/ui/iter_overeager_cloned.rs +++ b/tests/ui/iter_overeager_cloned.rs @@ -28,7 +28,7 @@ fn main() { //~^ iter_overeager_cloned let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))] - //~^ iter_overeager_cloned + //~^ iter_overeager_cloned .iter() .cloned() .flatten(); diff --git a/tests/ui/iter_skip_next_unfixable.rs b/tests/ui/iter_skip_next_unfixable.rs index 273ccd25ddcc0..3f855b54d12a3 100644 --- a/tests/ui/iter_skip_next_unfixable.rs +++ b/tests/ui/iter_skip_next_unfixable.rs @@ -12,7 +12,6 @@ fn main() { if let Some(s) = Some(test_string.split('|').map(|s| s.trim())) { let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); //~^ iter_skip_next - }; fn check(s: T) where @@ -20,6 +19,5 @@ fn main() { { let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); //~^ iter_skip_next - } } diff --git a/tests/ui/iter_skip_next_unfixable.stderr b/tests/ui/iter_skip_next_unfixable.stderr index cfbf75d853048..44c5c1f854428 100644 --- a/tests/ui/iter_skip_next_unfixable.stderr +++ b/tests/ui/iter_skip_next_unfixable.stderr @@ -25,13 +25,13 @@ LL | if let Some(s) = Some(test_string.split('|').map(|s| s.trim())) { | ^ error: called `skip(..).next()` on an iterator - --> tests/ui/iter_skip_next_unfixable.rs:21:29 + --> tests/ui/iter_skip_next_unfixable.rs:20:29 | LL | let _: Vec<&str> = s.skip(1).next().unwrap().split(' ').collect(); | ^^^^^^^^^^^^^^^ help: use `nth` instead: `.nth(1)` | help: for this change `s` has to be mutable - --> tests/ui/iter_skip_next_unfixable.rs:17:17 + --> tests/ui/iter_skip_next_unfixable.rs:16:17 | LL | fn check(s: T) | ^ diff --git a/tests/ui/iter_without_into_iter.rs b/tests/ui/iter_without_into_iter.rs index 80fb736b9bde7..dc3149be2cb4b 100644 --- a/tests/ui/iter_without_into_iter.rs +++ b/tests/ui/iter_without_into_iter.rs @@ -7,11 +7,11 @@ extern crate proc_macros; pub struct S1; impl S1 { pub fn iter(&self) -> std::slice::Iter<'_, u8> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter [].iter() } pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, u8> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter [].iter_mut() } } @@ -27,11 +27,11 @@ impl S2 { pub struct S3<'a>(&'a mut [u8]); impl<'a> S3<'a> { pub fn iter(&self) -> std::slice::Iter<'_, u8> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter self.0.iter() } pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, u8> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter self.0.iter_mut() } } @@ -68,7 +68,7 @@ impl S7 { pub struct S8(T); impl S8 { pub fn iter(&self) -> std::slice::Iter<'static, T> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter todo!() } } @@ -77,11 +77,11 @@ impl S8 { pub struct S9(T); impl S9 { pub fn iter(&self) -> std::slice::Iter<'_, T> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter todo!() } pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, T> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter todo!() } } @@ -130,7 +130,7 @@ macro_rules! generate_impl { () => { impl Issue12037 { fn iter(&self) -> std::slice::Iter<'_, u8> { - //~^ iter_without_into_iter + //~^ iter_without_into_iter todo!() } } diff --git a/tests/ui/iterator_step_by_zero.rs b/tests/ui/iterator_step_by_zero.rs index c416095cb4260..a729101bd4036 100644 --- a/tests/ui/iterator_step_by_zero.rs +++ b/tests/ui/iterator_step_by_zero.rs @@ -4,14 +4,12 @@ fn main() { let _ = vec!["A", "B", "B"].iter().step_by(0); //~^ iterator_step_by_zero - let _ = "XXX".chars().step_by(0); //~^ iterator_step_by_zero let _ = (0..1).step_by(0); //~^ iterator_step_by_zero - // No error, not an iterator. let y = NotIterator; y.step_by(0); @@ -25,17 +23,14 @@ fn main() { let _ = (1..=2).step_by(0); //~^ iterator_step_by_zero - let x = 0..1; let _ = x.step_by(0); //~^ iterator_step_by_zero - // check const eval let v1 = vec![1, 2, 3]; let _ = v1.iter().step_by(2 / 3); //~^ iterator_step_by_zero - } struct NotIterator; diff --git a/tests/ui/iterator_step_by_zero.stderr b/tests/ui/iterator_step_by_zero.stderr index 8cc79a978bcac..0ff916b6dd5eb 100644 --- a/tests/ui/iterator_step_by_zero.stderr +++ b/tests/ui/iterator_step_by_zero.stderr @@ -8,37 +8,37 @@ LL | let _ = vec!["A", "B", "B"].iter().step_by(0); = help: to override `-D warnings` add `#[allow(clippy::iterator_step_by_zero)]` error: `Iterator::step_by(0)` will panic at runtime - --> tests/ui/iterator_step_by_zero.rs:8:13 + --> tests/ui/iterator_step_by_zero.rs:7:13 | LL | let _ = "XXX".chars().step_by(0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> tests/ui/iterator_step_by_zero.rs:11:13 + --> tests/ui/iterator_step_by_zero.rs:10:13 | LL | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> tests/ui/iterator_step_by_zero.rs:22:13 + --> tests/ui/iterator_step_by_zero.rs:20:13 | LL | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> tests/ui/iterator_step_by_zero.rs:25:13 + --> tests/ui/iterator_step_by_zero.rs:23:13 | LL | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> tests/ui/iterator_step_by_zero.rs:30:13 + --> tests/ui/iterator_step_by_zero.rs:27:13 | LL | let _ = x.step_by(0); | ^^^^^^^^^^^^ error: `Iterator::step_by(0)` will panic at runtime - --> tests/ui/iterator_step_by_zero.rs:36:13 + --> tests/ui/iterator_step_by_zero.rs:32:13 | LL | let _ = v1.iter().step_by(2 / 3); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/join_absolute_paths.rs b/tests/ui/join_absolute_paths.rs index ada160d963a65..144c9147c2a1b 100644 --- a/tests/ui/join_absolute_paths.rs +++ b/tests/ui/join_absolute_paths.rs @@ -10,22 +10,18 @@ fn main() { path.join("/sh"); //~^ join_absolute_paths - let path = Path::new("C:\\Users"); path.join("\\user"); //~^ join_absolute_paths - let path = PathBuf::from("/bin"); path.join("/sh"); //~^ join_absolute_paths - let path = PathBuf::from("/bin"); path.join(r#"/sh"#); //~^ join_absolute_paths - let path: &[&str] = &["/bin"]; path.join("/sh"); diff --git a/tests/ui/join_absolute_paths.stderr b/tests/ui/join_absolute_paths.stderr index 94e8beb38446b..e7fd5508823ae 100644 --- a/tests/ui/join_absolute_paths.stderr +++ b/tests/ui/join_absolute_paths.stderr @@ -17,7 +17,7 @@ LL | PathBuf::from("/sh"); | ~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> tests/ui/join_absolute_paths.rs:15:15 + --> tests/ui/join_absolute_paths.rs:14:15 | LL | path.join("\\user"); | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | PathBuf::from("\\user"); | ~~~~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> tests/ui/join_absolute_paths.rs:20:15 + --> tests/ui/join_absolute_paths.rs:18:15 | LL | path.join("/sh"); | ^^^^^ @@ -49,7 +49,7 @@ LL | PathBuf::from("/sh"); | ~~~~~~~~~~~~~~~~~~~~ error: argument to `Path::join` starts with a path separator - --> tests/ui/join_absolute_paths.rs:25:15 + --> tests/ui/join_absolute_paths.rs:22:15 | LL | path.join(r#"/sh"#); | ^^^^^^^^ diff --git a/tests/ui/large_enum_variant.rs b/tests/ui/large_enum_variant.rs index 0ed562f90bc05..9e0fc03cb4e1c 100644 --- a/tests/ui/large_enum_variant.rs +++ b/tests/ui/large_enum_variant.rs @@ -9,7 +9,7 @@ extern crate proc_macros; use proc_macros::external; enum LargeEnum { -//~^ large_enum_variant + //~^ large_enum_variant A(i32), B([i32; 8000]), } @@ -34,26 +34,26 @@ enum LargeEnumGeneric { } enum LargeEnum2 { -//~^ large_enum_variant + //~^ large_enum_variant VariantOk(i32, u32), ContainingLargeEnum(LargeEnum), } enum LargeEnum3 { -//~^ large_enum_variant + //~^ large_enum_variant ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), VoidVariant, StructLikeLittle { x: i32, y: i32 }, } enum LargeEnum4 { -//~^ large_enum_variant + //~^ large_enum_variant VariantOk(i32, u32), StructLikeLarge { x: [i32; 8000], y: i32 }, } enum LargeEnum5 { -//~^ large_enum_variant + //~^ large_enum_variant VariantOk(i32, u32), StructLikeLarge2 { x: [i32; 8000] }, } @@ -70,32 +70,32 @@ enum LargeEnum6 { } enum LargeEnum7 { -//~^ large_enum_variant + //~^ large_enum_variant A, B([u8; 1255]), C([u8; 200]), } enum LargeEnum8 { -//~^ large_enum_variant + //~^ large_enum_variant VariantOk(i32, u32), ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]), } enum LargeEnum9 { -//~^ large_enum_variant + //~^ large_enum_variant A(Struct<()>), B(Struct2), } enum LargeEnumOk2 { -//~^ large_enum_variant + //~^ large_enum_variant A(T), B(Struct2), } enum LargeEnumOk3 { -//~^ large_enum_variant + //~^ large_enum_variant A(Struct), B(Struct2), } @@ -111,13 +111,13 @@ struct Struct2 { #[derive(Copy, Clone)] enum CopyableLargeEnum { -//~^ large_enum_variant + //~^ large_enum_variant A(bool), B([u64; 8000]), } enum ManuallyCopyLargeEnum { -//~^ large_enum_variant + //~^ large_enum_variant A(bool), B([u64; 8000]), } @@ -131,7 +131,7 @@ impl Clone for ManuallyCopyLargeEnum { impl Copy for ManuallyCopyLargeEnum {} enum SomeGenericPossiblyCopyEnum { -//~^ large_enum_variant + //~^ large_enum_variant A(bool, std::marker::PhantomData), B([u64; 4000]), } @@ -145,7 +145,7 @@ impl Clone for SomeGenericPossiblyCopyEnum { impl Copy for SomeGenericPossiblyCopyEnum {} enum LargeEnumWithGenerics { -//~^ large_enum_variant + //~^ large_enum_variant Small, Large((T, [u8; 512])), } @@ -155,7 +155,7 @@ struct Foo { } enum WithGenerics { -//~^ large_enum_variant + //~^ large_enum_variant Large([Foo; 64]), Small(u8), } @@ -166,13 +166,13 @@ enum PossiblyLargeEnumWithConst { } enum LargeEnumOfConst { -//~^ large_enum_variant + //~^ large_enum_variant Ok, Error(PossiblyLargeEnumWithConst<256>), } enum WithRecursion { -//~^ large_enum_variant + //~^ large_enum_variant Large([u64; 64]), Recursive(Box), } @@ -183,7 +183,7 @@ enum WithRecursionAndGenerics { } enum LargeEnumWithGenericsAndRecursive { -//~^ large_enum_variant + //~^ large_enum_variant Ok(), Error(WithRecursionAndGenerics), } @@ -219,13 +219,13 @@ mod issue11915 { } enum NoWarnings { - //~^ large_enum_variant + //~^ large_enum_variant BigBoi(PublishWithBytes), _SmallBoi(u8), } enum MakesClippyAngry { - //~^ large_enum_variant + //~^ large_enum_variant BigBoi(PublishWithVec), _SmallBoi(u8), } diff --git a/tests/ui/large_futures.fixed b/tests/ui/large_futures.fixed index dabb96e42918f..c2159c58de1ec 100644 --- a/tests/ui/large_futures.fixed +++ b/tests/ui/large_futures.fixed @@ -9,12 +9,9 @@ async fn wait() { let f = async { Box::pin(big_fut([0u8; 1024 * 16])).await; //~^ large_futures - - }; Box::pin(f).await //~^ large_futures - } async fn calls_fut(fut: impl std::future::Future) { loop { @@ -26,7 +23,6 @@ async fn calls_fut(fut: impl std::future::Future) { } else { Box::pin(wait()).await; //~^ large_futures - } } } @@ -38,7 +34,6 @@ pub async fn test() { Box::pin(calls_fut(fut)).await; //~^ large_futures - } pub fn foo() -> impl std::future::Future { @@ -51,7 +46,7 @@ pub fn foo() -> impl std::future::Future { pub async fn lines() { Box::pin(async { - //~^ large_futures + //~^ large_futures let x = [0i32; 1024 * 16]; async {}.await; @@ -64,7 +59,7 @@ pub async fn macro_expn() { macro_rules! macro_ { () => { Box::pin(async { - //~^ large_futures + //~^ large_futures let x = [0i32; 1024 * 16]; async {}.await; println!("macro: {:?}", x); diff --git a/tests/ui/large_futures.rs b/tests/ui/large_futures.rs index bafb0e2e3ba5b..567f6344afeac 100644 --- a/tests/ui/large_futures.rs +++ b/tests/ui/large_futures.rs @@ -9,12 +9,9 @@ async fn wait() { let f = async { big_fut([0u8; 1024 * 16]).await; //~^ large_futures - - }; f.await //~^ large_futures - } async fn calls_fut(fut: impl std::future::Future) { loop { @@ -26,7 +23,6 @@ async fn calls_fut(fut: impl std::future::Future) { } else { wait().await; //~^ large_futures - } } } @@ -38,7 +34,6 @@ pub async fn test() { calls_fut(fut).await; //~^ large_futures - } pub fn foo() -> impl std::future::Future { @@ -51,7 +46,7 @@ pub fn foo() -> impl std::future::Future { pub async fn lines() { async { - //~^ large_futures + //~^ large_futures let x = [0i32; 1024 * 16]; async {}.await; @@ -64,7 +59,7 @@ pub async fn macro_expn() { macro_rules! macro_ { () => { async { - //~^ large_futures + //~^ large_futures let x = [0i32; 1024 * 16]; async {}.await; println!("macro: {:?}", x); diff --git a/tests/ui/large_futures.stderr b/tests/ui/large_futures.stderr index cefc4769e846c..fd6ba4e3563de 100644 --- a/tests/ui/large_futures.stderr +++ b/tests/ui/large_futures.stderr @@ -8,37 +8,37 @@ LL | big_fut([0u8; 1024 * 16]).await; = help: to override `-D warnings` add `#[allow(clippy::large_futures)]` error: large future with a size of 16386 bytes - --> tests/ui/large_futures.rs:15:5 + --> tests/ui/large_futures.rs:13:5 | LL | f.await | ^ help: consider `Box::pin` on it: `Box::pin(f)` error: large future with a size of 16387 bytes - --> tests/ui/large_futures.rs:21:9 + --> tests/ui/large_futures.rs:18:9 | LL | wait().await; | ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())` error: large future with a size of 16387 bytes - --> tests/ui/large_futures.rs:27:13 + --> tests/ui/large_futures.rs:24:13 | LL | wait().await; | ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())` error: large future with a size of 65540 bytes - --> tests/ui/large_futures.rs:36:5 + --> tests/ui/large_futures.rs:32:5 | LL | foo().await; | ^^^^^ help: consider `Box::pin` on it: `Box::pin(foo())` error: large future with a size of 49159 bytes - --> tests/ui/large_futures.rs:39:5 + --> tests/ui/large_futures.rs:35:5 | LL | calls_fut(fut).await; | ^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(calls_fut(fut))` error: large future with a size of 65540 bytes - --> tests/ui/large_futures.rs:53:5 + --> tests/ui/large_futures.rs:48:5 | LL | / async { LL | | @@ -61,7 +61,7 @@ LL + }) | error: large future with a size of 65540 bytes - --> tests/ui/large_futures.rs:66:13 + --> tests/ui/large_futures.rs:61:13 | LL | / async { LL | | diff --git a/tests/ui/large_stack_frames.rs b/tests/ui/large_stack_frames.rs index 81d89cc1c5ca7..3ed124f69ef35 100644 --- a/tests/ui/large_stack_frames.rs +++ b/tests/ui/large_stack_frames.rs @@ -25,7 +25,7 @@ impl Default for ArrayDefault { } fn many_small_arrays() { -//~^ large_stack_frames + //~^ large_stack_frames let x = [0u8; 500_000]; let x2 = [0u8; 500_000]; @@ -36,13 +36,13 @@ fn many_small_arrays() { } fn large_return_value() -> ArrayDefault<1_000_000> { -//~^ large_stack_frames + //~^ large_stack_frames Default::default() } fn large_fn_arg(x: ArrayDefault<1_000_000>) { -//~^ large_stack_frames + //~^ large_stack_frames black_box(&x); } diff --git a/tests/ui/large_types_passed_by_value.rs b/tests/ui/large_types_passed_by_value.rs index cd0c88b6834c0..562a46306e065 100644 --- a/tests/ui/large_types_passed_by_value.rs +++ b/tests/ui/large_types_passed_by_value.rs @@ -62,12 +62,12 @@ fn foo_always(x: LargeAndCopy) { } #[inline(never)] fn foo_never(x: LargeAndCopy) { -//~^ large_types_passed_by_value + //~^ large_types_passed_by_value todo!(); } #[inline] fn foo(x: LargeAndCopy) { -//~^ large_types_passed_by_value + //~^ large_types_passed_by_value todo!(); } diff --git a/tests/ui/len_without_is_empty.rs b/tests/ui/len_without_is_empty.rs index 781c28d04bec4..011833072d762 100644 --- a/tests/ui/len_without_is_empty.rs +++ b/tests/ui/len_without_is_empty.rs @@ -5,8 +5,7 @@ pub struct PubOne; impl PubOne { pub fn len(&self) -> isize { - //~^ len_without_is_empty - + //~^ len_without_is_empty 1 } @@ -56,7 +55,7 @@ impl PubAllowedStruct { } pub trait PubTraitsToo { -//~^ len_without_is_empty + //~^ len_without_is_empty fn len(&self) -> isize; } @@ -71,7 +70,7 @@ pub struct HasIsEmpty; impl HasIsEmpty { pub fn len(&self) -> isize { - //~^ len_without_is_empty + //~^ len_without_is_empty 1 } @@ -85,7 +84,7 @@ pub struct HasWrongIsEmpty; impl HasWrongIsEmpty { pub fn len(&self) -> isize { - //~^ len_without_is_empty + //~^ len_without_is_empty 1 } @@ -99,7 +98,7 @@ pub struct MismatchedSelf; impl MismatchedSelf { pub fn len(self) -> isize { - //~^ len_without_is_empty + //~^ len_without_is_empty 1 } @@ -180,7 +179,7 @@ pub trait InheritingEmpty: Empty { pub trait Foo: Sized {} pub trait DependsOnFoo: Foo { -//~^ len_without_is_empty + //~^ len_without_is_empty fn len(&mut self) -> usize; } @@ -227,7 +226,7 @@ impl OptionalLen2 { pub struct OptionalLen3; impl OptionalLen3 { pub fn len(&self) -> usize { - //~^ len_without_is_empty + //~^ len_without_is_empty 0 } @@ -241,9 +240,8 @@ impl OptionalLen3 { pub struct ResultLen; impl ResultLen { pub fn len(&self) -> Result { - //~^ len_without_is_empty - //~| result_unit_err - + //~^ len_without_is_empty + //~| result_unit_err Ok(0) } @@ -257,13 +255,13 @@ impl ResultLen { pub struct ResultLen2; impl ResultLen2 { pub fn len(&self) -> Result { - //~^ result_unit_err + //~^ result_unit_err Ok(0) } pub fn is_empty(&self) -> Result { - //~^ result_unit_err + //~^ result_unit_err Ok(true) } @@ -272,7 +270,7 @@ impl ResultLen2 { pub struct ResultLen3; impl ResultLen3 { pub fn len(&self) -> Result { - //~^ result_unit_err + //~^ result_unit_err Ok(0) } @@ -315,7 +313,7 @@ impl AsyncLenWithoutIsEmpty { } pub async fn len(&self) -> usize { - //~^ len_without_is_empty + //~^ len_without_is_empty usize::from(!self.async_task().await) } @@ -329,7 +327,7 @@ impl AsyncOptionLenWithoutIsEmpty { } pub async fn len(&self) -> Option { - //~^ len_without_is_empty + //~^ len_without_is_empty None } @@ -352,7 +350,7 @@ impl AsyncResultLenWithoutIsEmpty { } pub async fn len(&self) -> Result { - //~^ len_without_is_empty + //~^ len_without_is_empty Err(()) } @@ -469,7 +467,7 @@ pub struct Aliased2; pub type Alias2 = Aliased2; impl Alias2 { pub fn len(&self) -> usize { - //~^ len_without_is_empty + //~^ len_without_is_empty todo!() } diff --git a/tests/ui/len_without_is_empty.stderr b/tests/ui/len_without_is_empty.stderr index 0fd445c720bdb..748a55712f882 100644 --- a/tests/ui/len_without_is_empty.stderr +++ b/tests/ui/len_without_is_empty.stderr @@ -8,7 +8,7 @@ LL | pub fn len(&self) -> isize { = help: to override `-D warnings` add `#[allow(clippy::len_without_is_empty)]` error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method - --> tests/ui/len_without_is_empty.rs:58:1 + --> tests/ui/len_without_is_empty.rs:57:1 | LL | / pub trait PubTraitsToo { LL | | @@ -18,45 +18,45 @@ LL | | } | |_^ error: struct `HasIsEmpty` has a public `len` method, but a private `is_empty` method - --> tests/ui/len_without_is_empty.rs:73:5 + --> tests/ui/len_without_is_empty.rs:72:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> tests/ui/len_without_is_empty.rs:79:5 + --> tests/ui/len_without_is_empty.rs:78:5 | LL | fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `HasWrongIsEmpty` has a public `len` method, but the `is_empty` method has an unexpected signature - --> tests/ui/len_without_is_empty.rs:87:5 + --> tests/ui/len_without_is_empty.rs:86:5 | LL | pub fn len(&self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> tests/ui/len_without_is_empty.rs:93:5 + --> tests/ui/len_without_is_empty.rs:92:5 | LL | pub fn is_empty(&self, x: u32) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` error: struct `MismatchedSelf` has a public `len` method, but the `is_empty` method has an unexpected signature - --> tests/ui/len_without_is_empty.rs:101:5 + --> tests/ui/len_without_is_empty.rs:100:5 | LL | pub fn len(self) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> tests/ui/len_without_is_empty.rs:107:5 + --> tests/ui/len_without_is_empty.rs:106:5 | LL | pub fn is_empty(&self) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(self) -> bool` error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method - --> tests/ui/len_without_is_empty.rs:182:1 + --> tests/ui/len_without_is_empty.rs:181:1 | LL | / pub trait DependsOnFoo: Foo { LL | | @@ -66,33 +66,33 @@ LL | | } | |_^ error: struct `OptionalLen3` has a public `len` method, but the `is_empty` method has an unexpected signature - --> tests/ui/len_without_is_empty.rs:229:5 + --> tests/ui/len_without_is_empty.rs:228:5 | LL | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> tests/ui/len_without_is_empty.rs:236:5 + --> tests/ui/len_without_is_empty.rs:235:5 | LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` error: struct `ResultLen` has a public `len` method, but the `is_empty` method has an unexpected signature - --> tests/ui/len_without_is_empty.rs:243:5 + --> tests/ui/len_without_is_empty.rs:242:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `is_empty` defined here - --> tests/ui/len_without_is_empty.rs:252:5 + --> tests/ui/len_without_is_empty.rs:250:5 | LL | pub fn is_empty(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature: `(&self) -> bool` or `(&self) -> Result error: this returns a `Result<_, ()>` - --> tests/ui/len_without_is_empty.rs:243:5 + --> tests/ui/len_without_is_empty.rs:242:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -102,7 +102,7 @@ LL | pub fn len(&self) -> Result { = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]` error: this returns a `Result<_, ()>` - --> tests/ui/len_without_is_empty.rs:259:5 + --> tests/ui/len_without_is_empty.rs:257:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ LL | pub fn len(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> tests/ui/len_without_is_empty.rs:265:5 + --> tests/ui/len_without_is_empty.rs:263:5 | LL | pub fn is_empty(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | pub fn is_empty(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> tests/ui/len_without_is_empty.rs:274:5 + --> tests/ui/len_without_is_empty.rs:272:5 | LL | pub fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -126,25 +126,25 @@ LL | pub fn len(&self) -> Result { = help: use a custom `Error` type instead error: struct `AsyncLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> tests/ui/len_without_is_empty.rs:317:5 + --> tests/ui/len_without_is_empty.rs:315:5 | LL | pub async fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `AsyncOptionLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> tests/ui/len_without_is_empty.rs:331:5 + --> tests/ui/len_without_is_empty.rs:329:5 | LL | pub async fn len(&self) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: struct `AsyncResultLenWithoutIsEmpty` has a public `len` method, but no `is_empty` method - --> tests/ui/len_without_is_empty.rs:354:5 + --> tests/ui/len_without_is_empty.rs:352:5 | LL | pub async fn len(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `Alias2` has a public `len` method, but no `is_empty` method - --> tests/ui/len_without_is_empty.rs:471:5 + --> tests/ui/len_without_is_empty.rs:469:5 | LL | pub fn len(&self) -> usize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/len_zero.fixed b/tests/ui/len_zero.fixed index e24a569cfde8d..b8573ef13b0e8 100644 --- a/tests/ui/len_zero.fixed +++ b/tests/ui/len_zero.fixed @@ -86,7 +86,7 @@ impl Deref for DerefToString { fn main() { let x = [1, 2]; if x.is_empty() { - //~^ len_zero + //~^ len_zero println!("This should not happen!"); } @@ -134,23 +134,23 @@ fn main() { let has_is_empty = HasIsEmpty; if has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if !has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if !has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if !has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.len() > 1 { @@ -162,23 +162,23 @@ fn main() { println!("This can happen."); } if has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if !has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if !has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if !has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if 1 < has_is_empty.len() { @@ -193,7 +193,7 @@ fn main() { let with_is_empty: &dyn WithIsEmpty = &Wither; if with_is_empty.is_empty() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } assert!(!with_is_empty.is_empty()); diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs index b558dd9a215ea..ef3c49c1ab309 100644 --- a/tests/ui/len_zero.rs +++ b/tests/ui/len_zero.rs @@ -86,7 +86,7 @@ impl Deref for DerefToString { fn main() { let x = [1, 2]; if x.len() == 0 { - //~^ len_zero + //~^ len_zero println!("This should not happen!"); } @@ -134,23 +134,23 @@ fn main() { let has_is_empty = HasIsEmpty; if has_is_empty.len() == 0 { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.len() != 0 { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.len() > 0 { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.len() < 1 { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.len() >= 1 { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if has_is_empty.len() > 1 { @@ -162,23 +162,23 @@ fn main() { println!("This can happen."); } if 0 == has_is_empty.len() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if 0 != has_is_empty.len() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if 0 < has_is_empty.len() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if 1 <= has_is_empty.len() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if 1 > has_is_empty.len() { - //~^ len_zero + //~^ len_zero println!("Or this!"); } if 1 < has_is_empty.len() { @@ -193,7 +193,7 @@ fn main() { let with_is_empty: &dyn WithIsEmpty = &Wither; if with_is_empty.len() == 0 { - //~^ len_zero + //~^ len_zero println!("Or this!"); } assert!(!with_is_empty.is_empty()); diff --git a/tests/ui/let_and_return.edition2021.fixed b/tests/ui/let_and_return.edition2021.fixed index 83e4a0298a7dd..70d503018e0fe 100644 --- a/tests/ui/let_and_return.edition2021.fixed +++ b/tests/ui/let_and_return.edition2021.fixed @@ -12,8 +12,6 @@ fn test() -> i32 { 5 //~^ let_and_return - - } fn test_inner() -> i32 { @@ -21,7 +19,6 @@ fn test_inner() -> i32 { 5 //~^ let_and_return - } else { 0 } @@ -85,7 +82,6 @@ fn issue_3792() -> String { stdin.lock().lines().next().unwrap().unwrap() //~^ let_and_return - } tuple_encode!(T0, T1, T2, T3, T4, T5, T6, T7); @@ -181,7 +177,6 @@ mod issue_5729 { (Arc::clone(&self.foo)) as _ //~^ let_and_return - } } } @@ -201,7 +196,6 @@ mod issue_11335 { E::B(x) => x, }) as _ //~^ let_and_return - } } } @@ -228,21 +222,18 @@ fn issue12801() { (if true { "a".to_string() } else { "b".to_string() } + "c") //~^ let_and_return - } fn no_par_needed() -> String { "c".to_string() + if true { "a" } else { "b" } //~^ let_and_return - } fn conjunctive_blocks() -> String { ({ "a".to_string() } + "b" + { "c" } + "d") //~^ let_and_return - } #[allow(clippy::overly_complex_bool_expr)] @@ -251,13 +242,11 @@ fn issue12801() { (if true { 2 } else { 3 } << 4) //~^ let_and_return - }; let _ = || { ({ true } || { false } && { 2 <= 3 }) //~^ let_and_return - }; } } diff --git a/tests/ui/let_and_return.edition2021.stderr b/tests/ui/let_and_return.edition2021.stderr index 4302053c78156..f9536d1b54776 100644 --- a/tests/ui/let_and_return.edition2021.stderr +++ b/tests/ui/let_and_return.edition2021.stderr @@ -15,7 +15,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:22:9 + --> tests/ui/let_and_return.rs:20:9 | LL | let x = 5; | ---------- unnecessary `let` binding @@ -29,7 +29,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:86:5 + --> tests/ui/let_and_return.rs:83:5 | LL | let line = stdin.lock().lines().next().unwrap().unwrap(); | --------------------------------------------------------- unnecessary `let` binding @@ -43,7 +43,7 @@ LL ~ stdin.lock().lines().next().unwrap().unwrap() | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:182:13 + --> tests/ui/let_and_return.rs:178:13 | LL | let clone = Arc::clone(&self.foo); | ---------------------------------- unnecessary `let` binding @@ -57,7 +57,7 @@ LL ~ (Arc::clone(&self.foo)) as _ | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:202:13 + --> tests/ui/let_and_return.rs:197:13 | LL | / let result = match self { LL | | E::A(x) => x, @@ -79,7 +79,7 @@ LL + }) as _ | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:229:9 + --> tests/ui/let_and_return.rs:223:9 | LL | let s = if true { "a".to_string() } else { "b".to_string() } + "c"; | ------------------------------------------------------------------- unnecessary `let` binding @@ -93,7 +93,7 @@ LL ~ (if true { "a".to_string() } else { "b".to_string() } + "c") | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:236:9 + --> tests/ui/let_and_return.rs:229:9 | LL | let s = "c".to_string() + if true { "a" } else { "b" }; | ------------------------------------------------------- unnecessary `let` binding @@ -107,7 +107,7 @@ LL ~ "c".to_string() + if true { "a" } else { "b" } | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:243:9 + --> tests/ui/let_and_return.rs:235:9 | LL | let s = { "a".to_string() } + "b" + { "c" } + "d"; | -------------------------------------------------- unnecessary `let` binding @@ -121,7 +121,7 @@ LL ~ ({ "a".to_string() } + "b" + { "c" } + "d") | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:252:13 + --> tests/ui/let_and_return.rs:243:13 | LL | let s = if true { 2 } else { 3 } << 4; | -------------------------------------- unnecessary `let` binding @@ -135,7 +135,7 @@ LL ~ (if true { 2 } else { 3 } << 4) | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:258:13 + --> tests/ui/let_and_return.rs:248:13 | LL | let s = { true } || { false } && { 2 <= 3 }; | -------------------------------------------- unnecessary `let` binding diff --git a/tests/ui/let_and_return.edition2024.fixed b/tests/ui/let_and_return.edition2024.fixed index 4846d6ada3ca1..9990c3b712055 100644 --- a/tests/ui/let_and_return.edition2024.fixed +++ b/tests/ui/let_and_return.edition2024.fixed @@ -12,8 +12,6 @@ fn test() -> i32 { 5 //~^ let_and_return - - } fn test_inner() -> i32 { @@ -21,7 +19,6 @@ fn test_inner() -> i32 { 5 //~^ let_and_return - } else { 0 } @@ -85,7 +82,6 @@ fn issue_3792() -> String { stdin.lock().lines().next().unwrap().unwrap() //~^ let_and_return - } tuple_encode!(T0, T1, T2, T3, T4, T5, T6, T7); @@ -181,7 +177,6 @@ mod issue_5729 { (Arc::clone(&self.foo)) as _ //~^ let_and_return - } } } @@ -201,7 +196,6 @@ mod issue_11335 { E::B(x) => x, }) as _ //~^ let_and_return - } } } @@ -228,21 +222,18 @@ fn issue12801() { (if true { "a".to_string() } else { "b".to_string() } + "c") //~^ let_and_return - } fn no_par_needed() -> String { "c".to_string() + if true { "a" } else { "b" } //~^ let_and_return - } fn conjunctive_blocks() -> String { ({ "a".to_string() } + "b" + { "c" } + "d") //~^ let_and_return - } #[allow(clippy::overly_complex_bool_expr)] @@ -251,13 +242,11 @@ fn issue12801() { (if true { 2 } else { 3 } << 4) //~^ let_and_return - }; let _ = || { ({ true } || { false } && { 2 <= 3 }) //~^ let_and_return - }; } } diff --git a/tests/ui/let_and_return.edition2024.stderr b/tests/ui/let_and_return.edition2024.stderr index 4b7f1a019f270..ca378fa432327 100644 --- a/tests/ui/let_and_return.edition2024.stderr +++ b/tests/ui/let_and_return.edition2024.stderr @@ -15,7 +15,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:22:9 + --> tests/ui/let_and_return.rs:20:9 | LL | let x = 5; | ---------- unnecessary `let` binding @@ -29,7 +29,7 @@ LL ~ 5 | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:86:5 + --> tests/ui/let_and_return.rs:83:5 | LL | let line = stdin.lock().lines().next().unwrap().unwrap(); | --------------------------------------------------------- unnecessary `let` binding @@ -43,7 +43,7 @@ LL ~ stdin.lock().lines().next().unwrap().unwrap() | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:110:9 + --> tests/ui/let_and_return.rs:106:9 | LL | let ret = value.borrow().baz(); | ------------------------------- unnecessary `let` binding @@ -57,7 +57,7 @@ LL ~ value.borrow().baz() | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:121:9 + --> tests/ui/let_and_return.rs:117:9 | LL | let ret = f(|| value.borrow().baz())(); | --------------------------------------- unnecessary `let` binding @@ -71,7 +71,7 @@ LL ~ f(|| value.borrow().baz())() | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:153:13 + --> tests/ui/let_and_return.rs:149:13 | LL | let value = some_foo(&x).value(); | --------------------------------- unnecessary `let` binding @@ -85,7 +85,7 @@ LL ~ some_foo(&x).value() | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:160:13 + --> tests/ui/let_and_return.rs:156:13 | LL | let value = Foo::new(&x).value(); | --------------------------------- unnecessary `let` binding @@ -99,7 +99,7 @@ LL ~ Foo::new(&x).value() | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:182:13 + --> tests/ui/let_and_return.rs:178:13 | LL | let clone = Arc::clone(&self.foo); | ---------------------------------- unnecessary `let` binding @@ -113,7 +113,7 @@ LL ~ (Arc::clone(&self.foo)) as _ | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:202:13 + --> tests/ui/let_and_return.rs:197:13 | LL | / let result = match self { LL | | E::A(x) => x, @@ -135,7 +135,7 @@ LL + }) as _ | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:229:9 + --> tests/ui/let_and_return.rs:223:9 | LL | let s = if true { "a".to_string() } else { "b".to_string() } + "c"; | ------------------------------------------------------------------- unnecessary `let` binding @@ -149,7 +149,7 @@ LL ~ (if true { "a".to_string() } else { "b".to_string() } + "c") | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:236:9 + --> tests/ui/let_and_return.rs:229:9 | LL | let s = "c".to_string() + if true { "a" } else { "b" }; | ------------------------------------------------------- unnecessary `let` binding @@ -163,7 +163,7 @@ LL ~ "c".to_string() + if true { "a" } else { "b" } | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:243:9 + --> tests/ui/let_and_return.rs:235:9 | LL | let s = { "a".to_string() } + "b" + { "c" } + "d"; | -------------------------------------------------- unnecessary `let` binding @@ -177,7 +177,7 @@ LL ~ ({ "a".to_string() } + "b" + { "c" } + "d") | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:252:13 + --> tests/ui/let_and_return.rs:243:13 | LL | let s = if true { 2 } else { 3 } << 4; | -------------------------------------- unnecessary `let` binding @@ -191,7 +191,7 @@ LL ~ (if true { 2 } else { 3 } << 4) | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:258:13 + --> tests/ui/let_and_return.rs:248:13 | LL | let s = { true } || { false } && { 2 <= 3 }; | -------------------------------------------- unnecessary `let` binding @@ -205,7 +205,7 @@ LL ~ ({ true } || { false } && { 2 <= 3 }) | error: returning the result of a `let` binding from a block - --> tests/ui/let_and_return.rs:271:5 + --> tests/ui/let_and_return.rs:260:5 | LL | / let r = match &*v.borrow() { LL | | Some(v) => Ok(Ok(v[0])), diff --git a/tests/ui/let_and_return.rs b/tests/ui/let_and_return.rs index ab5338837a535..48c20cdd60dbe 100644 --- a/tests/ui/let_and_return.rs +++ b/tests/ui/let_and_return.rs @@ -12,8 +12,6 @@ fn test() -> i32 { let x = 5; x //~^ let_and_return - - } fn test_inner() -> i32 { @@ -21,7 +19,6 @@ fn test_inner() -> i32 { let x = 5; x //~^ let_and_return - } else { 0 } @@ -85,7 +82,6 @@ fn issue_3792() -> String { let line = stdin.lock().lines().next().unwrap().unwrap(); line //~^ let_and_return - } tuple_encode!(T0, T1, T2, T3, T4, T5, T6, T7); @@ -181,7 +177,6 @@ mod issue_5729 { let clone = Arc::clone(&self.foo); clone //~^ let_and_return - } } } @@ -201,7 +196,6 @@ mod issue_11335 { result //~^ let_and_return - } } } @@ -228,21 +222,18 @@ fn issue12801() { let s = if true { "a".to_string() } else { "b".to_string() } + "c"; s //~^ let_and_return - } fn no_par_needed() -> String { let s = "c".to_string() + if true { "a" } else { "b" }; s //~^ let_and_return - } fn conjunctive_blocks() -> String { let s = { "a".to_string() } + "b" + { "c" } + "d"; s //~^ let_and_return - } #[allow(clippy::overly_complex_bool_expr)] @@ -251,13 +242,11 @@ fn issue12801() { let s = if true { 2 } else { 3 } << 4; s //~^ let_and_return - }; let _ = || { let s = { true } || { false } && { 2 <= 3 }; s //~^ let_and_return - }; } } diff --git a/tests/ui/let_if_seq.rs b/tests/ui/let_if_seq.rs index cc482155eda73..2db206212aa5d 100644 --- a/tests/ui/let_if_seq.rs +++ b/tests/ui/let_if_seq.rs @@ -77,7 +77,6 @@ fn main() { let mut foo = 0; //~^ useless_let_if_seq - if f() { foo = 42; } @@ -85,7 +84,6 @@ fn main() { let mut bar = 0; //~^ useless_let_if_seq - if f() { f(); bar = 42; @@ -127,7 +125,6 @@ fn main() { let mut baz = 0; //~^ useless_let_if_seq - if f() { baz = 42; } diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index b63a31b99129c..f59d42bf4c8dc 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -2,7 +2,9 @@ error: `if _ { .. } else { .. }` is an expression --> tests/ui/let_if_seq.rs:77:5 | LL | / let mut foo = 0; -... | +LL | | +LL | | +LL | | if f() { LL | | foo = 42; LL | | } | |_____^ help: it is more idiomatic to write: `let foo = if f() { 42 } else { 0 };` @@ -12,9 +14,12 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::useless_let_if_seq)]` error: `if _ { .. } else { .. }` is an expression - --> tests/ui/let_if_seq.rs:85:5 + --> tests/ui/let_if_seq.rs:84:5 | LL | / let mut bar = 0; +LL | | +LL | | +LL | | if f() { ... | LL | | f(); LL | | } @@ -23,7 +28,7 @@ LL | | } = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> tests/ui/let_if_seq.rs:96:5 + --> tests/ui/let_if_seq.rs:94:5 | LL | / let quz; LL | | @@ -35,10 +40,12 @@ LL | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> tests/ui/let_if_seq.rs:127:5 + --> tests/ui/let_if_seq.rs:125:5 | LL | / let mut baz = 0; -... | +LL | | +LL | | +LL | | if f() { LL | | baz = 42; LL | | } | |_____^ help: it is more idiomatic to write: `let baz = if f() { 42 } else { 0 };` diff --git a/tests/ui/let_underscore_future.rs b/tests/ui/let_underscore_future.rs index 2d57e83fd54d0..6347c792280e9 100644 --- a/tests/ui/let_underscore_future.rs +++ b/tests/ui/let_underscore_future.rs @@ -17,10 +17,8 @@ fn main() { let _ = custom(); //~^ let_underscore_future - let mut future = some_async_fn(); do_something_to_future(&mut future); let _ = future; //~^ let_underscore_future - } diff --git a/tests/ui/let_underscore_future.stderr b/tests/ui/let_underscore_future.stderr index e59e1f68911ae..baa489551d4a3 100644 --- a/tests/ui/let_underscore_future.stderr +++ b/tests/ui/let_underscore_future.stderr @@ -17,7 +17,7 @@ LL | let _ = custom(); = help: consider awaiting the future or dropping explicitly with `std::mem::drop` error: non-binding `let` on a future - --> tests/ui/let_underscore_future.rs:23:5 + --> tests/ui/let_underscore_future.rs:22:5 | LL | let _ = future; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/let_underscore_must_use.rs b/tests/ui/let_underscore_must_use.rs index 730e586eea790..5cf31ec63c66f 100644 --- a/tests/ui/let_underscore_must_use.rs +++ b/tests/ui/let_underscore_must_use.rs @@ -74,7 +74,6 @@ fn main() { let _ = l(0_u32); //~^ let_underscore_must_use - let s = S {}; let _ = s.f(); @@ -91,29 +90,23 @@ fn main() { let _ = S::p(); //~^ let_underscore_must_use - let _ = S::a(); //~^ let_underscore_must_use - let _ = if true { Ok(()) } else { Err(()) }; //~^ let_underscore_must_use - let a = Result::<(), ()>::Ok(()); let _ = a.is_ok(); //~^ let_underscore_must_use - let _ = a.map(|_| ()); //~^ let_underscore_must_use - let _ = a; //~^ let_underscore_must_use - #[allow(clippy::let_underscore_must_use)] let _ = a; } diff --git a/tests/ui/let_underscore_must_use.stderr b/tests/ui/let_underscore_must_use.stderr index fda2a2b2adaa5..130ea11646fd1 100644 --- a/tests/ui/let_underscore_must_use.stderr +++ b/tests/ui/let_underscore_must_use.stderr @@ -25,7 +25,7 @@ LL | let _ = l(0_u32); = help: consider explicitly using function result error: non-binding `let` on a result of a `#[must_use]` function - --> tests/ui/let_underscore_must_use.rs:80:5 + --> tests/ui/let_underscore_must_use.rs:79:5 | LL | let _ = s.f(); | ^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = s.f(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> tests/ui/let_underscore_must_use.rs:83:5 + --> tests/ui/let_underscore_must_use.rs:82:5 | LL | let _ = s.g(); | ^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = s.g(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> tests/ui/let_underscore_must_use.rs:88:5 + --> tests/ui/let_underscore_must_use.rs:87:5 | LL | let _ = S::h(); | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = S::h(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> tests/ui/let_underscore_must_use.rs:91:5 + --> tests/ui/let_underscore_must_use.rs:90:5 | LL | let _ = S::p(); | ^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = S::p(); = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> tests/ui/let_underscore_must_use.rs:95:5 + --> tests/ui/let_underscore_must_use.rs:93:5 | LL | let _ = S::a(); | ^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = S::a(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> tests/ui/let_underscore_must_use.rs:99:5 + --> tests/ui/let_underscore_must_use.rs:96:5 | LL | let _ = if true { Ok(()) } else { Err(()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | let _ = if true { Ok(()) } else { Err(()) }; = help: consider explicitly using expression value error: non-binding `let` on a result of a `#[must_use]` function - --> tests/ui/let_underscore_must_use.rs:105:5 + --> tests/ui/let_underscore_must_use.rs:101:5 | LL | let _ = a.is_ok(); | ^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _ = a.is_ok(); = help: consider explicitly using function result error: non-binding `let` on an expression with `#[must_use]` type - --> tests/ui/let_underscore_must_use.rs:109:5 + --> tests/ui/let_underscore_must_use.rs:104:5 | LL | let _ = a.map(|_| ()); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _ = a.map(|_| ()); = help: consider explicitly using expression value error: non-binding `let` on an expression with `#[must_use]` type - --> tests/ui/let_underscore_must_use.rs:113:5 + --> tests/ui/let_underscore_must_use.rs:107:5 | LL | let _ = a; | ^^^^^^^^^^ diff --git a/tests/ui/let_unit.fixed b/tests/ui/let_unit.fixed index 23145bd132f52..5e7a2ad37a846 100644 --- a/tests/ui/let_unit.fixed +++ b/tests/ui/let_unit.fixed @@ -58,7 +58,7 @@ fn multiline_sugg() { let v: Vec = vec![2]; v - //~^ let_unit_value + //~^ let_unit_value .into_iter() .map(|i| i * 2) .filter(|i| i % 2 == 0) @@ -108,7 +108,7 @@ fn _returns_generic() { let x: () = if true { f() } else { f2(0) }; match Some(0) { - //~^ let_unit_value + //~^ let_unit_value None => f2(1), Some(0) => f(), Some(1) => f2(3), diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index 59800b553a8c1..7b06f6940121d 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -58,7 +58,7 @@ fn multiline_sugg() { let v: Vec = vec![2]; let _ = v - //~^ let_unit_value + //~^ let_unit_value .into_iter() .map(|i| i * 2) .filter(|i| i % 2 == 0) @@ -108,7 +108,7 @@ fn _returns_generic() { let x: () = if true { f() } else { f2(0) }; let x = match Some(0) { - //~^ let_unit_value + //~^ let_unit_value None => f2(1), Some(0) => f(), Some(1) => f2(3), diff --git a/tests/ui/linkedlist.rs b/tests/ui/linkedlist.rs index eddbe730c174a..64a9ba0029da4 100644 --- a/tests/ui/linkedlist.rs +++ b/tests/ui/linkedlist.rs @@ -11,7 +11,6 @@ const C: LinkedList = LinkedList::new(); static S: LinkedList = LinkedList::new(); //~^ linkedlist - trait Foo { type Baz = LinkedList; //~^ linkedlist @@ -21,7 +20,6 @@ trait Foo { const BAR: Option>; //~^ linkedlist - } // Ok, we don’t want to warn for implementations; see issue #605. @@ -33,13 +31,11 @@ impl Foo for LinkedList { pub struct Bar { priv_linked_list_field: LinkedList, //~^ linkedlist - pub pub_linked_list_field: LinkedList, } impl Bar { fn foo(_: LinkedList) {} //~^ linkedlist - } // All of these test should be trigger the lint because they are not @@ -48,7 +44,7 @@ fn test(my_favorite_linked_list: LinkedList) {} //~^ linkedlist fn test_ret() -> Option> { -//~^ linkedlist + //~^ linkedlist None } diff --git a/tests/ui/linkedlist.stderr b/tests/ui/linkedlist.stderr index 22382d49e3a4d..419fbcc7e1884 100644 --- a/tests/ui/linkedlist.stderr +++ b/tests/ui/linkedlist.stderr @@ -17,7 +17,7 @@ LL | static S: LinkedList = LinkedList::new(); = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> tests/ui/linkedlist.rs:16:16 + --> tests/ui/linkedlist.rs:15:16 | LL | type Baz = LinkedList; | ^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type Baz = LinkedList; = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> tests/ui/linkedlist.rs:19:15 + --> tests/ui/linkedlist.rs:18:15 | LL | fn foo(_: LinkedList); | ^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | fn foo(_: LinkedList); = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> tests/ui/linkedlist.rs:22:23 + --> tests/ui/linkedlist.rs:21:23 | LL | const BAR: Option>; | ^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | const BAR: Option>; = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> tests/ui/linkedlist.rs:34:29 + --> tests/ui/linkedlist.rs:32:29 | LL | priv_linked_list_field: LinkedList, | ^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | priv_linked_list_field: LinkedList, = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> tests/ui/linkedlist.rs:40:15 + --> tests/ui/linkedlist.rs:37:15 | LL | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn foo(_: LinkedList) {} = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> tests/ui/linkedlist.rs:47:34 + --> tests/ui/linkedlist.rs:43:34 | LL | fn test(my_favorite_linked_list: LinkedList) {} | ^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn test(my_favorite_linked_list: LinkedList) {} = help: a `VecDeque` might work error: you seem to be using a `LinkedList`! Perhaps you meant some other data structure? - --> tests/ui/linkedlist.rs:50:25 + --> tests/ui/linkedlist.rs:46:25 | LL | fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ diff --git a/tests/ui/literals.rs b/tests/ui/literals.rs index 300a2d7802dd4..d21d49310a077 100644 --- a/tests/ui/literals.rs +++ b/tests/ui/literals.rs @@ -13,7 +13,6 @@ fn main() { let ok4 = 0xab_cd_i32; //~^ separated_literal_suffix - let ok5 = 0xAB_CD_u32; //~^ separated_literal_suffix @@ -23,25 +22,18 @@ fn main() { let fail1 = 0xabCD; //~^ mixed_case_hex_literals - let fail2 = 0xabCD_u32; //~^ separated_literal_suffix //~| mixed_case_hex_literals - let fail2 = 0xabCD_isize; //~^ separated_literal_suffix //~| mixed_case_hex_literals - let fail_multi_zero = 000_123usize; //~^ unseparated_literal_suffix //~| zero_prefixed_literal - - - - let ok9 = 0; let ok10 = 0_i64; //~^ separated_literal_suffix @@ -49,7 +41,6 @@ fn main() { let fail8 = 0123; //~^ zero_prefixed_literal - let ok11 = 0o123; let ok12 = 0b10_1010; @@ -65,18 +56,15 @@ fn main() { let fail19 = 12_3456_21; //~^ inconsistent_digit_grouping - let fail22 = 3__4___23; //~^ inconsistent_digit_grouping let fail23 = 3__16___23; //~^ inconsistent_digit_grouping - let fail24 = 0xAB_ABC_AB; //~^ unusual_byte_groupings - let fail25 = 0b01_100_101; let ok26 = 0x6_A0_BF; let ok27 = 0b1_0010_0101; @@ -92,5 +80,4 @@ fn issue9651() { let _ = 089; //~^ zero_prefixed_literal - } diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index 1e19af071f826..dcee7169c0a83 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -8,19 +8,19 @@ LL | let ok4 = 0xab_cd_i32; = help: to override `-D warnings` add `#[allow(clippy::separated_literal_suffix)]` error: integer type suffix should not be separated by an underscore - --> tests/ui/literals.rs:17:15 + --> tests/ui/literals.rs:16:15 | LL | let ok5 = 0xAB_CD_u32; | ^^^^^^^^^^^ help: remove the underscore: `0xAB_CDu32` error: integer type suffix should not be separated by an underscore - --> tests/ui/literals.rs:20:15 + --> tests/ui/literals.rs:19:15 | LL | let ok5 = 0xAB_CD_isize; | ^^^^^^^^^^^^^ help: remove the underscore: `0xAB_CDisize` error: inconsistent casing in hexadecimal literal - --> tests/ui/literals.rs:23:17 + --> tests/ui/literals.rs:22:17 | LL | let fail1 = 0xabCD; | ^^^^^^ @@ -29,31 +29,31 @@ LL | let fail1 = 0xabCD; = help: to override `-D warnings` add `#[allow(clippy::mixed_case_hex_literals)]` error: integer type suffix should not be separated by an underscore - --> tests/ui/literals.rs:27:17 + --> tests/ui/literals.rs:25:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ help: remove the underscore: `0xabCDu32` error: inconsistent casing in hexadecimal literal - --> tests/ui/literals.rs:27:17 + --> tests/ui/literals.rs:25:17 | LL | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ error: integer type suffix should not be separated by an underscore - --> tests/ui/literals.rs:32:17 + --> tests/ui/literals.rs:29:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ help: remove the underscore: `0xabCDisize` error: inconsistent casing in hexadecimal literal - --> tests/ui/literals.rs:32:17 + --> tests/ui/literals.rs:29:17 | LL | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ error: integer type suffix should be separated by an underscore - --> tests/ui/literals.rs:37:27 + --> tests/ui/literals.rs:33:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ help: add an underscore: `000_123_usize` @@ -62,7 +62,7 @@ LL | let fail_multi_zero = 000_123usize; = help: to override `-D warnings` add `#[allow(clippy::unseparated_literal_suffix)]` error: this is a decimal constant - --> tests/ui/literals.rs:37:27 + --> tests/ui/literals.rs:33:27 | LL | let fail_multi_zero = 000_123usize; | ^^^^^^^^^^^^ @@ -79,13 +79,13 @@ LL | let fail_multi_zero = 0o123usize; | ~~~~~~~~~~ error: integer type suffix should not be separated by an underscore - --> tests/ui/literals.rs:46:16 + --> tests/ui/literals.rs:38:16 | LL | let ok10 = 0_i64; | ^^^^^ help: remove the underscore: `0i64` error: this is a decimal constant - --> tests/ui/literals.rs:49:17 + --> tests/ui/literals.rs:41:17 | LL | let fail8 = 0123; | ^^^^ @@ -100,13 +100,13 @@ LL | let fail8 = 0o123; | ~~~~~ error: integer type suffix should not be separated by an underscore - --> tests/ui/literals.rs:60:16 + --> tests/ui/literals.rs:51:16 | LL | let ok17 = 0x123_4567_8901_usize; | ^^^^^^^^^^^^^^^^^^^^^ help: remove the underscore: `0x123_4567_8901usize` error: digits grouped inconsistently by underscores - --> tests/ui/literals.rs:65:18 + --> tests/ui/literals.rs:56:18 | LL | let fail19 = 12_3456_21; | ^^^^^^^^^^ help: consider: `12_345_621` @@ -115,19 +115,19 @@ LL | let fail19 = 12_3456_21; = help: to override `-D warnings` add `#[allow(clippy::inconsistent_digit_grouping)]` error: digits grouped inconsistently by underscores - --> tests/ui/literals.rs:69:18 + --> tests/ui/literals.rs:59:18 | LL | let fail22 = 3__4___23; | ^^^^^^^^^ help: consider: `3_423` error: digits grouped inconsistently by underscores - --> tests/ui/literals.rs:72:18 + --> tests/ui/literals.rs:62:18 | LL | let fail23 = 3__16___23; | ^^^^^^^^^^ help: consider: `31_623` error: digits of hex, binary or octal literal not in groups of equal size - --> tests/ui/literals.rs:76:18 + --> tests/ui/literals.rs:65:18 | LL | let fail24 = 0xAB_ABC_AB; | ^^^^^^^^^^^ help: consider: `0x0ABA_BCAB` @@ -136,7 +136,7 @@ LL | let fail24 = 0xAB_ABC_AB; = help: to override `-D warnings` add `#[allow(clippy::unusual_byte_groupings)]` error: this is a decimal constant - --> tests/ui/literals.rs:87:13 + --> tests/ui/literals.rs:75:13 | LL | let _ = 08; | ^^ @@ -147,7 +147,7 @@ LL | let _ = 8; | ~ error: this is a decimal constant - --> tests/ui/literals.rs:90:13 + --> tests/ui/literals.rs:78:13 | LL | let _ = 09; | ^^ @@ -158,7 +158,7 @@ LL | let _ = 9; | ~ error: this is a decimal constant - --> tests/ui/literals.rs:93:13 + --> tests/ui/literals.rs:81:13 | LL | let _ = 089; | ^^^ diff --git a/tests/ui/manual_arithmetic_check-2.rs b/tests/ui/manual_arithmetic_check-2.rs index 51515e7d9dcf9..749d15f1cbd81 100644 --- a/tests/ui/manual_arithmetic_check-2.rs +++ b/tests/ui/manual_arithmetic_check-2.rs @@ -12,7 +12,6 @@ fn main() { let result = if b < a { b - a } else { 0 }; //~^ inverted_saturating_sub - let result = if a > b { 0 } else { a - b }; //~^ inverted_saturating_sub @@ -25,7 +24,6 @@ fn main() { let result = if b <= a { 0 } else { a - b }; //~^ inverted_saturating_sub - let af = 12f32; let bf = 13f32; // Should not lint! diff --git a/tests/ui/manual_arithmetic_check-2.stderr b/tests/ui/manual_arithmetic_check-2.stderr index 3d51a8be670c3..8841210befda7 100644 --- a/tests/ui/manual_arithmetic_check-2.stderr +++ b/tests/ui/manual_arithmetic_check-2.stderr @@ -24,49 +24,49 @@ LL | let result = if b < a { b - a } else { 0 }; | ^^^^^ error: inverted arithmetic check before subtraction - --> tests/ui/manual_arithmetic_check-2.rs:16:23 + --> tests/ui/manual_arithmetic_check-2.rs:15:23 | LL | let result = if a > b { 0 } else { a - b }; | ^ ----- help: try replacing it with: `b - a` | note: this subtraction underflows when `a < b` - --> tests/ui/manual_arithmetic_check-2.rs:16:40 + --> tests/ui/manual_arithmetic_check-2.rs:15:40 | LL | let result = if a > b { 0 } else { a - b }; | ^^^^^ error: inverted arithmetic check before subtraction - --> tests/ui/manual_arithmetic_check-2.rs:19:23 + --> tests/ui/manual_arithmetic_check-2.rs:18:23 | LL | let result = if a >= b { 0 } else { a - b }; | ^^ ----- help: try replacing it with: `b - a` | note: this subtraction underflows when `a < b` - --> tests/ui/manual_arithmetic_check-2.rs:19:41 + --> tests/ui/manual_arithmetic_check-2.rs:18:41 | LL | let result = if a >= b { 0 } else { a - b }; | ^^^^^ error: inverted arithmetic check before subtraction - --> tests/ui/manual_arithmetic_check-2.rs:22:23 + --> tests/ui/manual_arithmetic_check-2.rs:21:23 | LL | let result = if b < a { 0 } else { a - b }; | ^ ----- help: try replacing it with: `b - a` | note: this subtraction underflows when `a < b` - --> tests/ui/manual_arithmetic_check-2.rs:22:40 + --> tests/ui/manual_arithmetic_check-2.rs:21:40 | LL | let result = if b < a { 0 } else { a - b }; | ^^^^^ error: inverted arithmetic check before subtraction - --> tests/ui/manual_arithmetic_check-2.rs:25:23 + --> tests/ui/manual_arithmetic_check-2.rs:24:23 | LL | let result = if b <= a { 0 } else { a - b }; | ^^ ----- help: try replacing it with: `b - a` | note: this subtraction underflows when `a < b` - --> tests/ui/manual_arithmetic_check-2.rs:25:41 + --> tests/ui/manual_arithmetic_check-2.rs:24:41 | LL | let result = if b <= a { 0 } else { a - b }; | ^^^^^ diff --git a/tests/ui/manual_arithmetic_check.fixed b/tests/ui/manual_arithmetic_check.fixed index 5bda101c7b7c8..99ed1faf90a6c 100644 --- a/tests/ui/manual_arithmetic_check.fixed +++ b/tests/ui/manual_arithmetic_check.fixed @@ -12,14 +12,12 @@ fn main() { let result = a.saturating_sub(b); //~^ implicit_saturating_sub - let result = a.saturating_sub(b); //~^ implicit_saturating_sub let result = a.saturating_sub(b); //~^ implicit_saturating_sub - // Should not warn! let result = if a > b { a - b } else { a - c }; diff --git a/tests/ui/manual_arithmetic_check.rs b/tests/ui/manual_arithmetic_check.rs index ba296c736f016..cf202fa35a6a6 100644 --- a/tests/ui/manual_arithmetic_check.rs +++ b/tests/ui/manual_arithmetic_check.rs @@ -12,14 +12,12 @@ fn main() { let result = if b < a { a - b } else { 0 }; //~^ implicit_saturating_sub - let result = if a < b { 0 } else { a - b }; //~^ implicit_saturating_sub let result = if b > a { 0 } else { a - b }; //~^ implicit_saturating_sub - // Should not warn! let result = if a > b { a - b } else { a - c }; diff --git a/tests/ui/manual_arithmetic_check.stderr b/tests/ui/manual_arithmetic_check.stderr index fe5663f586f43..b1598a5d06dc1 100644 --- a/tests/ui/manual_arithmetic_check.stderr +++ b/tests/ui/manual_arithmetic_check.stderr @@ -14,13 +14,13 @@ LL | let result = if b < a { a - b } else { 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)` error: manual arithmetic check found - --> tests/ui/manual_arithmetic_check.rs:16:18 + --> tests/ui/manual_arithmetic_check.rs:15:18 | LL | let result = if a < b { 0 } else { a - b }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)` error: manual arithmetic check found - --> tests/ui/manual_arithmetic_check.rs:19:18 + --> tests/ui/manual_arithmetic_check.rs:18:18 | LL | let result = if b > a { 0 } else { a - b }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)` diff --git a/tests/ui/manual_assert.rs b/tests/ui/manual_assert.rs index 2c9b17bb8b1b0..46a42c3d00af5 100644 --- a/tests/ui/manual_assert.rs +++ b/tests/ui/manual_assert.rs @@ -30,11 +30,11 @@ fn main() { panic!("qaqaq{:?}", a); } if !a.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("qaqaq{:?}", a); } if !a.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("qwqwq"); } if a.len() == 3 { @@ -52,27 +52,27 @@ fn main() { } let b = vec![1, 2, 3]; if b.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("panic1"); } if b.is_empty() && a.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("panic2"); } if a.is_empty() && !b.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("panic3"); } if b.is_empty() || a.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("panic4"); } if a.is_empty() || !b.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("panic5"); } if a.is_empty() { - //~^ manual_assert + //~^ manual_assert panic!("with expansion {}", one!()) } if a.is_empty() { @@ -85,7 +85,7 @@ fn main() { fn issue7730(a: u8) { // Suggestion should preserve comment if a > 2 { - //~^ manual_assert + //~^ manual_assert // comment /* this is a multiline @@ -100,7 +100,7 @@ fn issue12505() { impl Foo { const BAR: () = if N == 0 { - //~^ manual_assert + //~^ manual_assert panic!() }; } diff --git a/tests/ui/manual_async_fn.rs b/tests/ui/manual_async_fn.rs index a699e40868d74..fe367b4bc7b9b 100644 --- a/tests/ui/manual_async_fn.rs +++ b/tests/ui/manual_async_fn.rs @@ -4,7 +4,7 @@ use std::future::Future; fn fut() -> impl Future { -//~^ manual_async_fn + //~^ manual_async_fn async { 42 } } @@ -21,7 +21,7 @@ fn fut3()-> impl Future { } fn empty_fut() -> impl Future { -//~^ manual_async_fn + //~^ manual_async_fn async {} } @@ -38,7 +38,7 @@ fn empty_fut3()-> impl Future { } fn core_fut() -> impl core::future::Future { -//~^ manual_async_fn + //~^ manual_async_fn async move { 42 } } @@ -61,7 +61,7 @@ async fn already_async() -> impl Future { struct S; impl S { fn inh_fut() -> impl Future { - //~^ manual_async_fn + //~^ manual_async_fn async { // NOTE: this code is here just to check that the indentation is correct in the suggested fix let a = 42; @@ -97,7 +97,7 @@ impl S { // Tests related to lifetime capture fn elided(_: &i32) -> impl Future + '_ { -//~^ manual_async_fn + //~^ manual_async_fn async { 42 } } @@ -108,7 +108,7 @@ fn elided_not_bound(_: &i32) -> impl Future { #[allow(clippy::needless_lifetimes)] fn explicit<'a, 'b>(_: &'a i32, _: &'b i32) -> impl Future + 'a + 'b { -//~^ manual_async_fn + //~^ manual_async_fn async { 42 } } @@ -138,17 +138,17 @@ mod issue_5765 { } pub fn issue_10450() -> impl Future { -//~^ manual_async_fn + //~^ manual_async_fn async { 42 } } pub(crate) fn issue_10450_2() -> impl Future { -//~^ manual_async_fn + //~^ manual_async_fn async { 42 } } pub(self) fn issue_10450_3() -> impl Future { -//~^ manual_async_fn + //~^ manual_async_fn async { 42 } } diff --git a/tests/ui/manual_clamp.fixed b/tests/ui/manual_clamp.fixed index 1e2b1d009907a..2450a4f4c6115 100644 --- a/tests/ui/manual_clamp.fixed +++ b/tests/ui/manual_clamp.fixed @@ -152,13 +152,9 @@ fn const_main() { let x4 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - - let x5 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - - let x6 = input.clamp(CONST_MIN, CONST_MAX); let x7 = input.clamp(CONST_MIN, CONST_MAX); @@ -191,68 +187,51 @@ fn const_main() { let x16 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let x17 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let x18 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let x19 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let x20 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let x21 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let x22 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let x23 = input.clamp(CONST_MIN, CONST_MAX); //~^ manual_clamp - let input: f64 = cmp_min_max(1) as f64; let x24 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - let x25 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - let x26 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - let x27 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - let x28 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - let x29 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - let x30 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - let x31 = input.clamp(CONST_F64_MIN, CONST_F64_MAX); //~^ manual_clamp - - } let mut x32 = input; x32 = x32.clamp(CONST_MIN, CONST_MAX); diff --git a/tests/ui/manual_clamp.rs b/tests/ui/manual_clamp.rs index bf40e09969a41..ee341d50768f8 100644 --- a/tests/ui/manual_clamp.rs +++ b/tests/ui/manual_clamp.rs @@ -142,8 +142,7 @@ fn const_main() { let input = 0; // Min and max are const, so this should trigger the lint. let x0 = if CONST_MAX < input { - //~^ manual_clamp - + //~^ manual_clamp CONST_MAX } else if CONST_MIN > input { @@ -153,8 +152,7 @@ fn const_main() { }; let x1 = if input > CONST_MAX { - //~^ manual_clamp - + //~^ manual_clamp CONST_MAX } else if input < CONST_MIN { @@ -164,8 +162,7 @@ fn const_main() { }; let x2 = if input < CONST_MIN { - //~^ manual_clamp - + //~^ manual_clamp CONST_MIN } else if input > CONST_MAX { @@ -175,8 +172,7 @@ fn const_main() { }; let x3 = if CONST_MIN > input { - //~^ manual_clamp - + //~^ manual_clamp CONST_MIN } else if CONST_MAX < input { @@ -188,35 +184,25 @@ fn const_main() { let x4 = input.max(CONST_MIN).min(CONST_MAX); //~^ manual_clamp - - let x5 = input.min(CONST_MAX).max(CONST_MIN); //~^ manual_clamp - - let x6 = match input { - //~^ manual_clamp - - + //~^ manual_clamp x if x > CONST_MAX => CONST_MAX, x if x < CONST_MIN => CONST_MIN, x => x, }; let x7 = match input { - //~^ manual_clamp - - + //~^ manual_clamp x if x < CONST_MIN => CONST_MIN, x if x > CONST_MAX => CONST_MAX, x => x, }; let x8 = match input { - //~^ manual_clamp - - + //~^ manual_clamp x if CONST_MAX < x => CONST_MAX, x if CONST_MIN > x => CONST_MIN, x => x, @@ -224,8 +210,7 @@ fn const_main() { let mut x9 = input; if x9 < CONST_MIN { - //~^ manual_clamp - + //~^ manual_clamp x9 = CONST_MIN; } @@ -234,9 +219,7 @@ fn const_main() { } let x10 = match input { - //~^ manual_clamp - - + //~^ manual_clamp x if CONST_MIN > x => CONST_MIN, x if CONST_MAX < x => CONST_MAX, x => x, @@ -245,8 +228,7 @@ fn const_main() { let mut x11 = input; let _ = 1; if x11 > CONST_MAX { - //~^ manual_clamp - + //~^ manual_clamp x11 = CONST_MAX; } @@ -256,8 +238,7 @@ fn const_main() { let mut x12 = input; if CONST_MIN > x12 { - //~^ manual_clamp - + //~^ manual_clamp x12 = CONST_MIN; } @@ -267,8 +248,7 @@ fn const_main() { let mut x13 = input; if CONST_MAX < x13 { - //~^ manual_clamp - + //~^ manual_clamp x13 = CONST_MAX; } @@ -277,8 +257,7 @@ fn const_main() { } let x14 = if input > CONST_MAX { - //~^ manual_clamp - + //~^ manual_clamp CONST_MAX } else if input < CONST_MIN { @@ -289,8 +268,7 @@ fn const_main() { { let input = 0.0f64; let x15 = if input > CONST_F64_MAX { - //~^ manual_clamp - + //~^ manual_clamp CONST_F64_MAX } else if input < CONST_F64_MIN { @@ -305,73 +283,55 @@ fn const_main() { let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); //~^ manual_clamp - let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); //~^ manual_clamp - let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); //~^ manual_clamp - let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); //~^ manual_clamp - let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); //~^ manual_clamp - let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); //~^ manual_clamp - let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); //~^ manual_clamp - let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); //~^ manual_clamp - let input: f64 = cmp_min_max(1) as f64; let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN); //~^ manual_clamp - let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX); //~^ manual_clamp - let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX)); //~^ manual_clamp - let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN)); //~^ manual_clamp - let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN); //~^ manual_clamp - let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX); //~^ manual_clamp - let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input)); //~^ manual_clamp - let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input)); //~^ manual_clamp - - } let mut x32 = input; if x32 < CONST_MIN { - //~^ manual_clamp - + //~^ manual_clamp x32 = CONST_MIN; } else if x32 > CONST_MAX { @@ -401,8 +361,7 @@ fn const_main() { // It's important this be the last set of statements let mut x35 = input; if CONST_MAX < x35 { - //~^ manual_clamp - + //~^ manual_clamp x35 = CONST_MAX; } @@ -564,8 +523,7 @@ fn msrv_1_49() { fn msrv_1_50() { let input = 0; let _ = if input > CONST_MAX { - //~^ manual_clamp - + //~^ manual_clamp CONST_MAX } else if input < CONST_MIN { diff --git a/tests/ui/manual_clamp.stderr b/tests/ui/manual_clamp.stderr index ca7da23efec23..4a0e4fa516469 100644 --- a/tests/ui/manual_clamp.stderr +++ b/tests/ui/manual_clamp.stderr @@ -1,7 +1,10 @@ error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:226:5 + --> tests/ui/manual_clamp.rs:212:5 | LL | / if x9 < CONST_MIN { +LL | | +LL | | +LL | | x9 = CONST_MIN; ... | LL | | x9 = CONST_MAX; LL | | } @@ -12,9 +15,12 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_clamp)]` error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:247:5 + --> tests/ui/manual_clamp.rs:230:5 | LL | / if x11 > CONST_MAX { +LL | | +LL | | +LL | | x11 = CONST_MAX; ... | LL | | x11 = CONST_MIN; LL | | } @@ -23,9 +29,12 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:258:5 + --> tests/ui/manual_clamp.rs:240:5 | LL | / if CONST_MIN > x12 { +LL | | +LL | | +LL | | x12 = CONST_MIN; ... | LL | | x12 = CONST_MAX; LL | | } @@ -34,9 +43,12 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:269:5 + --> tests/ui/manual_clamp.rs:250:5 | LL | / if CONST_MAX < x13 { +LL | | +LL | | +LL | | x13 = CONST_MAX; ... | LL | | x13 = CONST_MIN; LL | | } @@ -45,9 +57,12 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:403:5 + --> tests/ui/manual_clamp.rs:363:5 | LL | / if CONST_MAX < x35 { +LL | | +LL | | +LL | | x35 = CONST_MAX; ... | LL | | x35 = CONST_MIN; LL | | } @@ -60,6 +75,9 @@ error: clamp-like pattern without using clamp function | LL | let x0 = if CONST_MAX < input { | ______________^ +LL | | +LL | | +LL | | CONST_MAX ... | LL | | input LL | | }; @@ -68,10 +86,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:155:14 + --> tests/ui/manual_clamp.rs:154:14 | LL | let x1 = if input > CONST_MAX { | ______________^ +LL | | +LL | | +LL | | CONST_MAX ... | LL | | input LL | | }; @@ -80,10 +101,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:166:14 + --> tests/ui/manual_clamp.rs:164:14 | LL | let x2 = if input < CONST_MIN { | ______________^ +LL | | +LL | | +LL | | CONST_MIN ... | LL | | input LL | | }; @@ -92,10 +116,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:177:14 + --> tests/ui/manual_clamp.rs:174:14 | LL | let x3 = if CONST_MIN > input { | ______________^ +LL | | +LL | | +LL | | CONST_MIN ... | LL | | input LL | | }; @@ -104,7 +131,7 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:188:14 + --> tests/ui/manual_clamp.rs:184:14 | LL | let x4 = input.max(CONST_MIN).min(CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -112,7 +139,7 @@ LL | let x4 = input.max(CONST_MIN).min(CONST_MAX); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:193:14 + --> tests/ui/manual_clamp.rs:187:14 | LL | let x5 = input.min(CONST_MAX).max(CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -120,11 +147,13 @@ LL | let x5 = input.min(CONST_MAX).max(CONST_MIN); = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:198:14 + --> tests/ui/manual_clamp.rs:190:14 | LL | let x6 = match input { | ______________^ -... | +LL | | +LL | | x if x > CONST_MAX => CONST_MAX, +LL | | x if x < CONST_MIN => CONST_MIN, LL | | x => x, LL | | }; | |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -132,11 +161,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:207:14 + --> tests/ui/manual_clamp.rs:197:14 | LL | let x7 = match input { | ______________^ -... | +LL | | +LL | | x if x < CONST_MIN => CONST_MIN, +LL | | x if x > CONST_MAX => CONST_MAX, LL | | x => x, LL | | }; | |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -144,11 +175,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:216:14 + --> tests/ui/manual_clamp.rs:204:14 | LL | let x8 = match input { | ______________^ -... | +LL | | +LL | | x if CONST_MAX < x => CONST_MAX, +LL | | x if CONST_MIN > x => CONST_MIN, LL | | x => x, LL | | }; | |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -156,11 +189,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:236:15 + --> tests/ui/manual_clamp.rs:221:15 | LL | let x10 = match input { | _______________^ -... | +LL | | +LL | | x if CONST_MIN > x => CONST_MIN, +LL | | x if CONST_MAX < x => CONST_MAX, LL | | x => x, LL | | }; | |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -168,10 +203,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:279:15 + --> tests/ui/manual_clamp.rs:259:15 | LL | let x14 = if input > CONST_MAX { | _______________^ +LL | | +LL | | +LL | | CONST_MAX ... | LL | | input LL | | }; @@ -180,10 +218,13 @@ LL | | }; = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:291:19 + --> tests/ui/manual_clamp.rs:270:19 | LL | let x15 = if input > CONST_F64_MAX { | ___________________^ +LL | | +LL | | +LL | | CONST_F64_MAX ... | LL | | input LL | | }; @@ -193,7 +234,7 @@ LL | | }; = note: clamp returns NaN if the input is NaN error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:305:19 + --> tests/ui/manual_clamp.rs:283:19 | LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -201,7 +242,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 - --> tests/ui/manual_clamp.rs:309:19 + --> tests/ui/manual_clamp.rs:286:19 | LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -209,7 +250,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 - --> tests/ui/manual_clamp.rs:313:19 + --> tests/ui/manual_clamp.rs:289:19 | LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -217,7 +258,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 - --> tests/ui/manual_clamp.rs:317:19 + --> tests/ui/manual_clamp.rs:292:19 | LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -225,7 +266,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 - --> tests/ui/manual_clamp.rs:321:19 + --> tests/ui/manual_clamp.rs:295:19 | LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -233,7 +274,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 - --> tests/ui/manual_clamp.rs:325:19 + --> tests/ui/manual_clamp.rs:298:19 | LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -241,7 +282,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 - --> tests/ui/manual_clamp.rs:329:19 + --> tests/ui/manual_clamp.rs:301:19 | LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -249,7 +290,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 - --> tests/ui/manual_clamp.rs:333:19 + --> tests/ui/manual_clamp.rs:304:19 | LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)` @@ -257,7 +298,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 - --> tests/ui/manual_clamp.rs:338:19 + --> tests/ui/manual_clamp.rs:308: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)` @@ -266,7 +307,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 - --> tests/ui/manual_clamp.rs:342:19 + --> tests/ui/manual_clamp.rs:311: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)` @@ -275,7 +316,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 - --> tests/ui/manual_clamp.rs:346:19 + --> tests/ui/manual_clamp.rs:314: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)` @@ -284,7 +325,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 - --> tests/ui/manual_clamp.rs:350:19 + --> tests/ui/manual_clamp.rs:317: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)` @@ -293,7 +334,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 - --> tests/ui/manual_clamp.rs:354:19 + --> tests/ui/manual_clamp.rs:320: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)` @@ -302,7 +343,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 - --> tests/ui/manual_clamp.rs:358:19 + --> tests/ui/manual_clamp.rs:323: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)` @@ -311,7 +352,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 - --> tests/ui/manual_clamp.rs:362:19 + --> tests/ui/manual_clamp.rs:326: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)` @@ -320,7 +361,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 - --> tests/ui/manual_clamp.rs:366:19 + --> tests/ui/manual_clamp.rs:329: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)` @@ -329,10 +370,13 @@ 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 - --> tests/ui/manual_clamp.rs:372:5 + --> tests/ui/manual_clamp.rs:333:5 | LL | / if x32 < CONST_MIN { -... | +LL | | +LL | | +LL | | x32 = CONST_MIN; +LL | | } else if x32 > CONST_MAX { LL | | x32 = CONST_MAX; LL | | } | |_____^ help: replace with clamp: `x32 = x32.clamp(CONST_MIN, CONST_MAX);` @@ -340,10 +384,13 @@ LL | | } = note: clamp will panic if max < min error: clamp-like pattern without using clamp function - --> tests/ui/manual_clamp.rs:566:13 + --> tests/ui/manual_clamp.rs:525:13 | LL | let _ = if input > CONST_MAX { | _____________^ +LL | | +LL | | +LL | | CONST_MAX ... | LL | | input LL | | }; diff --git a/tests/ui/manual_div_ceil.fixed b/tests/ui/manual_div_ceil.fixed index 6657c695abea7..57fe8917afe88 100644 --- a/tests/ui/manual_div_ceil.fixed +++ b/tests/ui/manual_div_ceil.fixed @@ -6,17 +6,17 @@ fn main() { let z = 11_u32; // Lint -let _ = x.div_ceil(y); -//~^ manual_div_ceil -let _ = x.div_ceil(y); -//~^ manual_div_ceil -let _ = x.div_ceil(y); -//~^ manual_div_ceil - -let _ = 7_u32.div_ceil(4); -//~^ manual_div_ceil -let _ = (7_i32 as u32).div_ceil(4); -//~^ manual_div_ceil + let _ = x.div_ceil(y); + //~^ manual_div_ceil + let _ = x.div_ceil(y); + //~^ manual_div_ceil + let _ = x.div_ceil(y); + //~^ manual_div_ceil + + let _ = 7_u32.div_ceil(4); + //~^ manual_div_ceil + let _ = (7_i32 as u32).div_ceil(4); + //~^ manual_div_ceil // No lint let _ = (x + (y - 2)) / y; diff --git a/tests/ui/manual_div_ceil.rs b/tests/ui/manual_div_ceil.rs index 2c8506e84cb59..ec343513e5ce3 100644 --- a/tests/ui/manual_div_ceil.rs +++ b/tests/ui/manual_div_ceil.rs @@ -6,17 +6,17 @@ fn main() { let z = 11_u32; // Lint -let _ = (x + (y - 1)) / y; -//~^ manual_div_ceil -let _ = ((y - 1) + x) / y; -//~^ manual_div_ceil -let _ = (x + y - 1) / y; -//~^ manual_div_ceil - -let _ = (7_u32 + (4 - 1)) / 4; -//~^ manual_div_ceil -let _ = (7_i32 as u32 + (4 - 1)) / 4; -//~^ manual_div_ceil + let _ = (x + (y - 1)) / y; + //~^ manual_div_ceil + let _ = ((y - 1) + x) / y; + //~^ manual_div_ceil + let _ = (x + y - 1) / y; + //~^ manual_div_ceil + + let _ = (7_u32 + (4 - 1)) / 4; + //~^ manual_div_ceil + let _ = (7_i32 as u32 + (4 - 1)) / 4; + //~^ manual_div_ceil // No lint let _ = (x + (y - 2)) / y; diff --git a/tests/ui/manual_div_ceil.stderr b/tests/ui/manual_div_ceil.stderr index d6793dcfb5f34..8e14ab274269a 100644 --- a/tests/ui/manual_div_ceil.stderr +++ b/tests/ui/manual_div_ceil.stderr @@ -1,35 +1,35 @@ error: manually reimplementing `div_ceil` - --> tests/ui/manual_div_ceil.rs:9:9 + --> tests/ui/manual_div_ceil.rs:9:13 | -LL | let _ = (x + (y - 1)) / y; - | ^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `x.div_ceil(y)` +LL | let _ = (x + (y - 1)) / y; + | ^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `x.div_ceil(y)` | = note: `-D clippy::manual-div-ceil` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_div_ceil)]` error: manually reimplementing `div_ceil` - --> tests/ui/manual_div_ceil.rs:11:9 + --> tests/ui/manual_div_ceil.rs:11:13 | -LL | let _ = ((y - 1) + x) / y; - | ^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `x.div_ceil(y)` +LL | let _ = ((y - 1) + x) / y; + | ^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `x.div_ceil(y)` error: manually reimplementing `div_ceil` - --> tests/ui/manual_div_ceil.rs:13:9 + --> tests/ui/manual_div_ceil.rs:13:13 | -LL | let _ = (x + y - 1) / y; - | ^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `x.div_ceil(y)` +LL | let _ = (x + y - 1) / y; + | ^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `x.div_ceil(y)` error: manually reimplementing `div_ceil` - --> tests/ui/manual_div_ceil.rs:16:9 + --> tests/ui/manual_div_ceil.rs:16:13 | -LL | let _ = (7_u32 + (4 - 1)) / 4; - | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `7_u32.div_ceil(4)` +LL | let _ = (7_u32 + (4 - 1)) / 4; + | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `7_u32.div_ceil(4)` error: manually reimplementing `div_ceil` - --> tests/ui/manual_div_ceil.rs:18:9 + --> tests/ui/manual_div_ceil.rs:18:13 | -LL | let _ = (7_i32 as u32 + (4 - 1)) / 4; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `(7_i32 as u32).div_ceil(4)` +LL | let _ = (7_i32 as u32 + (4 - 1)) / 4; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `(7_i32 as u32).div_ceil(4)` error: manually reimplementing `div_ceil` --> tests/ui/manual_div_ceil.rs:39:13 diff --git a/tests/ui/manual_filter.rs b/tests/ui/manual_filter.rs index a83a316f95ad4..a9d0c35f8bb72 100644 --- a/tests/ui/manual_filter.rs +++ b/tests/ui/manual_filter.rs @@ -3,7 +3,7 @@ fn main() { match Some(0) { - //~^ manual_filter + //~^ manual_filter None => None, Some(x) => { if x > 0 { @@ -15,7 +15,7 @@ fn main() { }; match Some(1) { - //~^ manual_filter + //~^ manual_filter Some(x) => { if x > 0 { None @@ -27,7 +27,7 @@ fn main() { }; match Some(2) { - //~^ manual_filter + //~^ manual_filter Some(x) => { if x > 0 { None @@ -39,7 +39,7 @@ fn main() { }; match Some(3) { - //~^ manual_filter + //~^ manual_filter Some(x) => { if x > 0 { Some(x) @@ -52,7 +52,7 @@ fn main() { let y = Some(4); match y { - //~^ manual_filter + //~^ manual_filter // Some(4) None => None, Some(x) => { @@ -65,7 +65,7 @@ fn main() { }; match Some(5) { - //~^ manual_filter + //~^ manual_filter Some(x) => { if x > 0 { Some(x) @@ -77,7 +77,7 @@ fn main() { }; match Some(6) { - //~^ manual_filter + //~^ manual_filter Some(ref x) => { if x > &0 { Some(x) @@ -90,7 +90,7 @@ fn main() { let external_cond = true; match Some(String::new()) { - //~^ manual_filter + //~^ manual_filter Some(x) => { if external_cond { Some(x) @@ -102,14 +102,14 @@ fn main() { }; if let Some(x) = Some(7) { - //~^ manual_filter + //~^ manual_filter if external_cond { Some(x) } else { None } } else { None }; match &Some(8) { - //~^ manual_filter + //~^ manual_filter &Some(x) => { if x != 0 { Some(x) @@ -121,7 +121,7 @@ fn main() { }; match Some(9) { - //~^ manual_filter + //~^ manual_filter Some(x) => { if x > 10 && x < 100 { Some(x) @@ -148,7 +148,7 @@ fn main() { #[allow(clippy::blocks_in_conditions)] match Some(11) { - //~^ manual_filter + //~^ manual_filter // Lint, statement is preserved by `.filter` Some(x) => { if { @@ -193,7 +193,7 @@ fn main() { true } let _ = match Some(14) { - //~^ manual_filter + //~^ manual_filter Some(x) => { if unsafe { f(x) } { Some(x) @@ -204,7 +204,7 @@ fn main() { None => None, }; let _ = match Some(15) { - //~^ manual_filter + //~^ manual_filter Some(x) => unsafe { if f(x) { Some(x) } else { None } }, None => None, }; @@ -213,7 +213,7 @@ fn main() { if let Some(_) = Some(16) { Some(16) } else if let Some(x) = Some(16) { - //~^ manual_filter + //~^ manual_filter // Lint starting from here if x % 2 == 0 { Some(x) } else { None } } else { diff --git a/tests/ui/manual_filter_map.rs b/tests/ui/manual_filter_map.rs index 75e15d3b5a5a6..013c88da6b36f 100644 --- a/tests/ui/manual_filter_map.rs +++ b/tests/ui/manual_filter_map.rs @@ -171,7 +171,7 @@ fn issue8010() { let iter = [Enum::A(123), Enum::B].into_iter(); let _x = iter.clone().filter(|x| matches!(x, Enum::A(_))).map(|x| match x { - //~^ manual_filter_map + //~^ manual_filter_map Enum::A(s) => s, _ => unreachable!(), }); diff --git a/tests/ui/manual_find.rs b/tests/ui/manual_find.rs index d3c24d0b88491..20b557f21d141 100644 --- a/tests/ui/manual_find.rs +++ b/tests/ui/manual_find.rs @@ -3,8 +3,7 @@ //@no-rustfix fn vec_string(strings: Vec) -> Option { for s in strings { - //~^ manual_find - + //~^ manual_find if s == String::new() { return Some(s); @@ -15,8 +14,7 @@ fn vec_string(strings: Vec) -> Option { fn tuple(arr: Vec<(String, i32)>) -> Option { for (s, _) in arr { - //~^ manual_find - + //~^ manual_find if s == String::new() { return Some(s); diff --git a/tests/ui/manual_find.stderr b/tests/ui/manual_find.stderr index 2dbe0b16b75a9..a4e7878a247c1 100644 --- a/tests/ui/manual_find.stderr +++ b/tests/ui/manual_find.stderr @@ -2,6 +2,9 @@ error: manual implementation of `Iterator::find` --> tests/ui/manual_find.rs:5:5 | LL | / for s in strings { +LL | | +LL | | +LL | | if s == String::new() { ... | LL | | None | |________^ help: replace with an iterator: `strings.into_iter().find(|s| s == String::new())` @@ -11,9 +14,12 @@ LL | | None = help: to override `-D warnings` add `#[allow(clippy::manual_find)]` error: manual implementation of `Iterator::find` - --> tests/ui/manual_find.rs:17:5 + --> tests/ui/manual_find.rs:16:5 | LL | / for (s, _) in arr { +LL | | +LL | | +LL | | if s == String::new() { ... | LL | | None | |________^ help: replace with an iterator: `arr.into_iter().map(|(s, _)| s).find(|s| s == String::new())` diff --git a/tests/ui/manual_find_fixable.rs b/tests/ui/manual_find_fixable.rs index 3966d8df89b96..08a7dd2c6eeef 100644 --- a/tests/ui/manual_find_fixable.rs +++ b/tests/ui/manual_find_fixable.rs @@ -8,7 +8,7 @@ const ARRAY: &[u32; 5] = &[2, 7, 1, 9, 3]; fn lookup(n: u32) -> Option { for &v in ARRAY { - //~^ manual_find + //~^ manual_find if v == n { return Some(v); } @@ -18,7 +18,7 @@ fn lookup(n: u32) -> Option { fn with_pat(arr: Vec<(u32, u32)>) -> Option { for (a, _) in arr { - //~^ manual_find + //~^ manual_find if a % 2 == 0 { return Some(a); } @@ -32,7 +32,7 @@ struct Data { } fn with_struct(arr: Vec) -> Option { for el in arr { - //~^ manual_find + //~^ manual_find if el.name.len() == 10 { return Some(el); } @@ -43,7 +43,7 @@ fn with_struct(arr: Vec) -> Option { struct Tuple(usize, usize); fn with_tuple_struct(arr: Vec) -> Option { for Tuple(a, _) in arr { - //~^ manual_find + //~^ manual_find if a >= 3 { return Some(a); } @@ -59,7 +59,7 @@ impl A { } fn with_method_call(arr: Vec) -> Option { for el in arr { - //~^ manual_find + //~^ manual_find if el.should_keep() { return Some(el); } @@ -70,7 +70,7 @@ fn with_method_call(arr: Vec) -> Option { fn with_closure(arr: Vec) -> Option { let f = |el: u32| -> u32 { el + 10 }; for el in arr { - //~^ manual_find + //~^ manual_find if f(el) == 20 { return Some(el); } @@ -81,7 +81,7 @@ fn with_closure(arr: Vec) -> Option { fn with_closure2(arr: HashMap) -> Option { let f = |el: i32| -> bool { el == 10 }; for &el in arr.values() { - //~^ manual_find + //~^ manual_find if f(el) { return Some(el); } @@ -91,7 +91,7 @@ fn with_closure2(arr: HashMap) -> Option { fn with_bool(arr: Vec) -> Option { for el in arr { - //~^ manual_find + //~^ manual_find if el.is_true { return Some(el); } @@ -122,7 +122,7 @@ fn with_else(arr: Vec) -> Option { fn tuple_with_ref(v: [(u8, &u8); 3]) -> Option { for (_, &x) in v { - //~^ manual_find + //~^ manual_find if x > 10 { return Some(x); } @@ -132,7 +132,7 @@ fn tuple_with_ref(v: [(u8, &u8); 3]) -> Option { fn ref_to_tuple_with_ref(v: &[(u8, &u8)]) -> Option { for &(_, &x) in v { - //~^ manual_find + //~^ manual_find if x > 10 { return Some(x); } @@ -142,7 +142,7 @@ fn ref_to_tuple_with_ref(v: &[(u8, &u8)]) -> Option { fn explicit_ret(arr: Vec) -> Option { for x in arr { - //~^ manual_find + //~^ manual_find if x >= 5 { return Some(x); } diff --git a/tests/ui/manual_flatten.rs b/tests/ui/manual_flatten.rs index e22025c6f1a86..97f35c36e24cc 100644 --- a/tests/ui/manual_flatten.rs +++ b/tests/ui/manual_flatten.rs @@ -5,7 +5,7 @@ fn main() { // Test for loop over implicitly adjusted `Iterator` with `if let` expression let x = vec![Some(1), Some(2), Some(3)]; for n in x { - //~^ manual_flatten + //~^ manual_flatten if let Some(y) = n { println!("{}", y); @@ -15,7 +15,7 @@ fn main() { // Test for loop over implicitly adjusted `Iterator` with `if let` statement let y: Vec> = vec![]; for n in y.clone() { - //~^ manual_flatten + //~^ manual_flatten if let Ok(n) = n { println!("{}", n); @@ -24,7 +24,7 @@ fn main() { // Test for loop over by reference for n in &y { - //~^ manual_flatten + //~^ manual_flatten if let Ok(n) = n { println!("{}", n); @@ -34,7 +34,7 @@ fn main() { // Test for loop over an implicit reference let z = &y; for n in z { - //~^ manual_flatten + //~^ manual_flatten if let Ok(n) = n { println!("{}", n); @@ -45,7 +45,7 @@ fn main() { let z = vec![Some(1), Some(2), Some(3)]; let z = z.iter(); for n in z { - //~^ manual_flatten + //~^ manual_flatten if let Some(m) = n { println!("{}", m); @@ -80,7 +80,7 @@ fn main() { let vec_of_ref = vec![&Some(1)]; for n in &vec_of_ref { - //~^ manual_flatten + //~^ manual_flatten if let Some(n) = n { println!("{:?}", n); @@ -89,7 +89,7 @@ fn main() { let vec_of_ref = &vec_of_ref; for n in vec_of_ref { - //~^ manual_flatten + //~^ manual_flatten if let Some(n) = n { println!("{:?}", n); @@ -98,7 +98,7 @@ fn main() { let slice_of_ref = &[&Some(1)]; for n in slice_of_ref { - //~^ manual_flatten + //~^ manual_flatten if let Some(n) = n { println!("{:?}", n); diff --git a/tests/ui/manual_ignore_case_cmp.fixed b/tests/ui/manual_ignore_case_cmp.fixed index a75b0702a5ff9..c1c929585cfd3 100644 --- a/tests/ui/manual_ignore_case_cmp.fixed +++ b/tests/ui/manual_ignore_case_cmp.fixed @@ -7,11 +7,11 @@ fn main() {} fn variants(a: &str, b: &str) { if a.eq_ignore_ascii_case(b) { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } if a.eq_ignore_ascii_case(b) { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } let r = a.eq_ignore_ascii_case(b); @@ -22,11 +22,11 @@ fn variants(a: &str, b: &str) { //~^ manual_ignore_case_cmp // != if !a.eq_ignore_ascii_case(b) { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } if !a.eq_ignore_ascii_case(b) { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } let r = !a.eq_ignore_ascii_case(b); diff --git a/tests/ui/manual_ignore_case_cmp.rs b/tests/ui/manual_ignore_case_cmp.rs index 822f171a45064..ca401e595fe97 100644 --- a/tests/ui/manual_ignore_case_cmp.rs +++ b/tests/ui/manual_ignore_case_cmp.rs @@ -7,11 +7,11 @@ fn main() {} fn variants(a: &str, b: &str) { if a.to_ascii_lowercase() == b.to_ascii_lowercase() { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } if a.to_ascii_uppercase() == b.to_ascii_uppercase() { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } let r = a.to_ascii_lowercase() == b.to_ascii_lowercase(); @@ -22,11 +22,11 @@ fn variants(a: &str, b: &str) { //~^ manual_ignore_case_cmp // != if a.to_ascii_lowercase() != b.to_ascii_lowercase() { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } if a.to_ascii_uppercase() != b.to_ascii_uppercase() { - //~^ manual_ignore_case_cmp + //~^ manual_ignore_case_cmp return; } let r = a.to_ascii_lowercase() != b.to_ascii_lowercase(); diff --git a/tests/ui/manual_inspect.fixed b/tests/ui/manual_inspect.fixed index 8512da0bdf625..44f15d61f8563 100644 --- a/tests/ui/manual_inspect.fixed +++ b/tests/ui/manual_inspect.fixed @@ -3,29 +3,29 @@ fn main() { let _ = Some(0).inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); }); let _ = Some(0).inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect println!("{x}"); }); let _ = Some(0).inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x * 5 + 1); }); let _ = Some(0).inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect if x == 0 { panic!(); } }); let _ = Some(0).inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect if &x == &0 { let _y = x; panic!(); @@ -76,7 +76,7 @@ fn main() { } let _ = Some((String::new(), 0u32)).inspect(|x| { - //~^ manual_inspect + //~^ manual_inspect if x.1 == 0 { let _x = x.1; panic!(); @@ -102,7 +102,7 @@ fn main() { }); let _ = Some(String::new()).inspect(|x| { - //~^ manual_inspect + //~^ manual_inspect if x.is_empty() { let _ = || { let _x = x; @@ -113,7 +113,7 @@ fn main() { }); let _ = Some(0).inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect if x == 0 { let _ = || { let _x = x; @@ -128,7 +128,7 @@ fn main() { struct Cell2(core::cell::Cell); let _ = Some(Cell2(Cell::new(0u32))).inspect(|x| { - //~^ manual_inspect + //~^ manual_inspect x.0.set(1); }); @@ -144,20 +144,20 @@ fn main() { } let _: Result<_, ()> = Ok(0).inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); }); let _: Result<(), _> = Err(0).inspect_err(|&x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); }); let _ = [0] - //~^ suspicious_map + //~^ suspicious_map .into_iter() .inspect(|&x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); }) .count(); diff --git a/tests/ui/manual_inspect.rs b/tests/ui/manual_inspect.rs index 7f07394d4b221..d34f2abce6ae1 100644 --- a/tests/ui/manual_inspect.rs +++ b/tests/ui/manual_inspect.rs @@ -3,25 +3,25 @@ fn main() { let _ = Some(0).map(|x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); x }); let _ = Some(0).map(|x| { - //~^ manual_inspect + //~^ manual_inspect println!("{x}"); x }); let _ = Some(0).map(|x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x * 5 + 1); x }); let _ = Some(0).map(|x| { - //~^ manual_inspect + //~^ manual_inspect if x == 0 { panic!(); } @@ -29,7 +29,7 @@ fn main() { }); let _ = Some(0).map(|x| { - //~^ manual_inspect + //~^ manual_inspect if &x == &0 { let _y = x; panic!(); @@ -81,7 +81,7 @@ fn main() { } let _ = Some((String::new(), 0u32)).map(|x| { - //~^ manual_inspect + //~^ manual_inspect if x.1 == 0 { let _x = x.1; panic!(); @@ -108,7 +108,7 @@ fn main() { }); let _ = Some(String::new()).map(|x| { - //~^ manual_inspect + //~^ manual_inspect if x.is_empty() { let _ = || { let _x = &x; @@ -120,7 +120,7 @@ fn main() { }); let _ = Some(0).map(|x| { - //~^ manual_inspect + //~^ manual_inspect if x == 0 { let _ = || { let _x = x; @@ -136,7 +136,7 @@ fn main() { struct Cell2(core::cell::Cell); let _ = Some(Cell2(Cell::new(0u32))).map(|x| { - //~^ manual_inspect + //~^ manual_inspect x.0.set(1); x }); @@ -153,22 +153,22 @@ fn main() { } let _: Result<_, ()> = Ok(0).map(|x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); x }); let _: Result<(), _> = Err(0).map_err(|x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); x }); let _ = [0] - //~^ suspicious_map + //~^ suspicious_map .into_iter() .map(|x| { - //~^ manual_inspect + //~^ manual_inspect println!("{}", x); x }) diff --git a/tests/ui/manual_let_else.rs b/tests/ui/manual_let_else.rs index e5ef55c0b8a88..d2350d97ed003 100644 --- a/tests/ui/manual_let_else.rs +++ b/tests/ui/manual_let_else.rs @@ -29,9 +29,8 @@ fn fire() { let v = if let Some(v_some) = g() { v_some } else { return }; //~^ manual_let_else - let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -39,7 +38,7 @@ fn fire() { }; let v = if let Some(v) = g() { - //~^ manual_let_else + //~^ manual_let_else // Blocks around the identity should have no impact { { v } } @@ -56,17 +55,15 @@ fn fire() { let v = if let Some(v_some) = g() { v_some } else { break }; //~^ manual_let_else - } // panic also diverges let v = if let Some(v_some) = g() { v_some } else { panic!() }; //~^ manual_let_else - // abort also diverges let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -75,7 +72,7 @@ fn fire() { // If whose two branches diverge also diverges let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -84,7 +81,7 @@ fn fire() { // Diverging after an if still makes the block diverge: let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -94,7 +91,7 @@ fn fire() { // The final expression will need to be turned into a statement. let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -104,7 +101,7 @@ fn fire() { // Even if the result is buried multiple expressions deep. let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -121,7 +118,7 @@ fn fire() { // Or if a break gives the value. let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -133,7 +130,7 @@ fn fire() { // Even if the break is in a weird position. let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -150,7 +147,7 @@ fn fire() { // A match diverges if all branches diverge: let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -162,7 +159,7 @@ fn fire() { // An if's expression can cause divergence: let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -171,7 +168,7 @@ fn fire() { // An expression of a match can cause divergence: let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -182,7 +179,7 @@ fn fire() { // Top level else if let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else if true { @@ -193,7 +190,7 @@ fn fire() { // All match arms diverge let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -212,7 +209,7 @@ fn fire() { // Tuples supported for the declared variables let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) { - //~^ manual_let_else + //~^ manual_let_else v_some } else { @@ -221,7 +218,7 @@ fn fire() { // Tuples supported with multiple bindings let (w, S { v }) = if let (Some(v_some), w_some) = (g().map(|_| S { v: 0 }), 0) { - //~^ manual_let_else + //~^ manual_let_else (w_some, v_some) } else { @@ -244,16 +241,14 @@ fn fire() { let v = if let Variant::A(a, 0) = e() { a } else { return }; //~^ manual_let_else - // `mut v` is inserted into the pattern let mut v = if let Variant::B(b) = e() { b } else { return }; //~^ manual_let_else - // Nesting works let nested = Ok(Some(e())); let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested { - //~^ manual_let_else + //~^ manual_let_else b } else { @@ -263,15 +258,13 @@ fn fire() { let v = if let Variant::A(.., a) = e() { a } else { return }; //~^ manual_let_else - // () is preserved: a bit of an edge case but make sure it stays around let w = if let (Some(v), ()) = (g(), ()) { v } else { return }; //~^ manual_let_else - // Tuple structs work let w = if let Some(S { v: x }) = Some(S { v: 0 }) { - //~^ manual_let_else + //~^ manual_let_else x } else { @@ -280,7 +273,7 @@ fn fire() { // Field init shorthand is suggested let v = if let Some(S { v: x }) = Some(S { v: 0 }) { - //~^ manual_let_else + //~^ manual_let_else x } else { @@ -289,7 +282,7 @@ fn fire() { // Multi-field structs also work let (x, S { v }, w) = if let Some(U { v, w, x }) = None::>> { - //~^ manual_let_else + //~^ manual_let_else (x, v, w) } else { @@ -407,8 +400,7 @@ fn not_fire() { let ff = Some(1); let _ = match ff { - //~^ manual_let_else - + //~^ manual_let_else Some(value) => value, _ => macro_call!(), }; diff --git a/tests/ui/manual_let_else.stderr b/tests/ui/manual_let_else.stderr index 8982a1c567bf3..8f5cba64d545c 100644 --- a/tests/ui/manual_let_else.stderr +++ b/tests/ui/manual_let_else.stderr @@ -8,7 +8,7 @@ LL | let v = if let Some(v_some) = g() { v_some } else { return }; = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:33:5 + --> tests/ui/manual_let_else.rs:32:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -27,7 +27,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:41:5 + --> tests/ui/manual_let_else.rs:40:5 | LL | / let v = if let Some(v) = g() { ... | @@ -45,25 +45,25 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:54:9 + --> tests/ui/manual_let_else.rs:53:9 | LL | let v = if let Some(v_some) = g() { v_some } else { continue }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { continue };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:57:9 + --> tests/ui/manual_let_else.rs:56:9 | LL | let v = if let Some(v_some) = g() { v_some } else { break }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { break };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:63:5 + --> tests/ui/manual_let_else.rs:61:5 | LL | let v = if let Some(v_some) = g() { v_some } else { panic!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { panic!() };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:68:5 + --> tests/ui/manual_let_else.rs:65:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -82,7 +82,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:77:5 + --> tests/ui/manual_let_else.rs:74:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -101,7 +101,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:86:5 + --> tests/ui/manual_let_else.rs:83:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -121,7 +121,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:96:5 + --> tests/ui/manual_let_else.rs:93:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -141,7 +141,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:106:5 + --> tests/ui/manual_let_else.rs:103:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -167,7 +167,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:123:5 + --> tests/ui/manual_let_else.rs:120:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -188,7 +188,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:135:5 + --> tests/ui/manual_let_else.rs:132:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -214,7 +214,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:152:5 + --> tests/ui/manual_let_else.rs:149:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -236,7 +236,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:164:5 + --> tests/ui/manual_let_else.rs:161:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -255,7 +255,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:173:5 + --> tests/ui/manual_let_else.rs:170:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -276,7 +276,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:184:5 + --> tests/ui/manual_let_else.rs:181:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -297,7 +297,7 @@ LL + } }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:195:5 + --> tests/ui/manual_let_else.rs:192:5 | LL | / let v = if let Some(v_some) = g() { LL | | @@ -325,7 +325,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:214:5 + --> tests/ui/manual_let_else.rs:211:5 | LL | / let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) { LL | | @@ -344,7 +344,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:223:5 + --> tests/ui/manual_let_else.rs:220:5 | LL | / let (w, S { v }) = if let (Some(v_some), w_some) = (g().map(|_| S { v: 0 }), 0) { LL | | @@ -363,7 +363,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:234:13 + --> tests/ui/manual_let_else.rs:231:13 | LL | let $n = if let Some(v) = $e { v } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some($n) = g() else { return };` @@ -374,19 +374,19 @@ LL | create_binding_if_some!(w, g()); = note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info) error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:244:5 + --> tests/ui/manual_let_else.rs:241:5 | LL | let v = if let Variant::A(a, 0) = e() { a } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(v, 0) = e() else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:249:5 + --> tests/ui/manual_let_else.rs:245:5 | LL | let mut v = if let Variant::B(b) = e() { b } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::B(mut v) = e() else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:255:5 + --> tests/ui/manual_let_else.rs:250:5 | LL | / let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested { LL | | @@ -405,19 +405,19 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:263:5 + --> tests/ui/manual_let_else.rs:258:5 | LL | let v = if let Variant::A(.., a) = e() { a } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(.., v) = e() else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:268:5 + --> tests/ui/manual_let_else.rs:262:5 | LL | let w = if let (Some(v), ()) = (g(), ()) { v } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let (Some(w), ()) = (g(), ()) else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:273:5 + --> tests/ui/manual_let_else.rs:266:5 | LL | / let w = if let Some(S { v: x }) = Some(S { v: 0 }) { LL | | @@ -436,7 +436,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:282:5 + --> tests/ui/manual_let_else.rs:275:5 | LL | / let v = if let Some(S { v: x }) = Some(S { v: 0 }) { LL | | @@ -455,7 +455,7 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:291:5 + --> tests/ui/manual_let_else.rs:284:5 | LL | / let (x, S { v }, w) = if let Some(U { v, w, x }) = None::>> { LL | | @@ -474,18 +474,17 @@ LL + }; | error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:409:5 + --> tests/ui/manual_let_else.rs:402:5 | LL | / let _ = match ff { LL | | -LL | | LL | | Some(value) => value, LL | | _ => macro_call!(), LL | | }; | |______^ help: consider writing: `let Some(_) = ff else { macro_call!() };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else.rs:487:9 + --> tests/ui/manual_let_else.rs:479:9 | LL | let v = if let Some(v_some) = g() { v_some } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };` diff --git a/tests/ui/manual_let_else_match.rs b/tests/ui/manual_let_else_match.rs index cdb4070301111..6416753bac107 100644 --- a/tests/ui/manual_let_else_match.rs +++ b/tests/ui/manual_let_else_match.rs @@ -34,16 +34,13 @@ fn main() {} fn fire() { let v = match g() { - //~^ manual_let_else - - + //~^ manual_let_else Some(v_some) => v_some, None => return, }; let v = match g() { - //~^ manual_let_else - + //~^ manual_let_else Some(v_some) => v_some, _ => return, }; @@ -51,15 +48,13 @@ fn fire() { loop { // More complex pattern for the identity arm and diverging arm let v = match h() { - //~^ manual_let_else - + //~^ manual_let_else (Some(v), None) | (None, Some(v)) => v, (Some(_), Some(_)) | (None, None) => continue, }; // Custom enums are supported as long as the "else" arm is a simple _ let v = match build_enum() { - //~^ manual_let_else - + //~^ manual_let_else Variant::Bar(v) | Variant::Baz(v) => v, _ => continue, }; @@ -68,16 +63,14 @@ fn fire() { // There is a _ in the diverging arm // TODO also support unused bindings aka _v let v = match f() { - //~^ manual_let_else - + //~^ manual_let_else Ok(v) => v, Err(_) => return, }; // Err(()) is an allowed pattern let v = match f().map_err(|_| ()) { - //~^ manual_let_else - + //~^ manual_let_else Ok(v) => v, Err(()) => return, }; @@ -85,23 +78,20 @@ fn fire() { let f = Variant::Bar(1); let _value = match f { - //~^ manual_let_else - + //~^ manual_let_else Variant::Bar(v) | Variant::Baz(v) => v, _ => return, }; let _value = match Some(build_enum()) { - //~^ manual_let_else - + //~^ manual_let_else Some(Variant::Bar(v) | Variant::Baz(v)) => v, _ => return, }; let data = [1_u8, 2, 3, 4, 0, 0, 0, 0]; let data = match data.as_slice() { - //~^ manual_let_else - + //~^ manual_let_else [data @ .., 0, 0, 0, 0] | [data @ .., 0, 0] | [data @ .., 0] => data, _ => return, }; @@ -182,8 +172,7 @@ fn not_fire() { fn issue11579() { let msg = match Some("hi") { - //~^ manual_let_else - + //~^ manual_let_else Some(m) => m, _ => unreachable!("can't happen"), }; diff --git a/tests/ui/manual_let_else_match.stderr b/tests/ui/manual_let_else_match.stderr index 6a65186d6b537..393562c629bac 100644 --- a/tests/ui/manual_let_else_match.stderr +++ b/tests/ui/manual_let_else_match.stderr @@ -2,7 +2,8 @@ error: this could be rewritten as `let...else` --> tests/ui/manual_let_else_match.rs:36:5 | LL | / let v = match g() { -... | +LL | | +LL | | Some(v_some) => v_some, LL | | None => return, LL | | }; | |______^ help: consider writing: `let Some(v) = g() else { return };` @@ -11,99 +12,90 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:44:5 + --> tests/ui/manual_let_else_match.rs:42:5 | LL | / let v = match g() { LL | | -LL | | LL | | Some(v_some) => v_some, LL | | _ => return, LL | | }; | |______^ help: consider writing: `let Some(v) = g() else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:53:9 + --> tests/ui/manual_let_else_match.rs:50:9 | LL | / let v = match h() { LL | | -LL | | LL | | (Some(v), None) | (None, Some(v)) => v, LL | | (Some(_), Some(_)) | (None, None) => continue, LL | | }; | |__________^ help: consider writing: `let ((Some(v), None) | (None, Some(v))) = h() else { continue };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:60:9 + --> tests/ui/manual_let_else_match.rs:56:9 | LL | / let v = match build_enum() { LL | | -LL | | LL | | Variant::Bar(v) | Variant::Baz(v) => v, LL | | _ => continue, LL | | }; | |__________^ help: consider writing: `let (Variant::Bar(v) | Variant::Baz(v)) = build_enum() else { continue };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:70:5 + --> tests/ui/manual_let_else_match.rs:65:5 | LL | / let v = match f() { LL | | -LL | | LL | | Ok(v) => v, LL | | Err(_) => return, LL | | }; | |______^ help: consider writing: `let Ok(v) = f() else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:78:5 + --> tests/ui/manual_let_else_match.rs:72:5 | LL | / let v = match f().map_err(|_| ()) { LL | | -LL | | LL | | Ok(v) => v, LL | | Err(()) => return, LL | | }; | |______^ help: consider writing: `let Ok(v) = f().map_err(|_| ()) else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:87:5 + --> tests/ui/manual_let_else_match.rs:80:5 | LL | / let _value = match f { LL | | -LL | | LL | | Variant::Bar(v) | Variant::Baz(v) => v, LL | | _ => return, LL | | }; | |______^ help: consider writing: `let (Variant::Bar(_value) | Variant::Baz(_value)) = f else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:94:5 + --> tests/ui/manual_let_else_match.rs:86:5 | LL | / let _value = match Some(build_enum()) { LL | | -LL | | LL | | Some(Variant::Bar(v) | Variant::Baz(v)) => v, LL | | _ => return, LL | | }; | |______^ help: consider writing: `let Some(Variant::Bar(_value) | Variant::Baz(_value)) = Some(build_enum()) else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:102:5 + --> tests/ui/manual_let_else_match.rs:93:5 | LL | / let data = match data.as_slice() { LL | | -LL | | LL | | [data @ .., 0, 0, 0, 0] | [data @ .., 0, 0] | [data @ .., 0] => data, LL | | _ => return, LL | | }; | |______^ help: consider writing: `let ([data @ .., 0, 0, 0, 0] | [data @ .., 0, 0] | [data @ .., 0]) = data.as_slice() else { return };` error: this could be rewritten as `let...else` - --> tests/ui/manual_let_else_match.rs:184:5 + --> tests/ui/manual_let_else_match.rs:174:5 | LL | / let msg = match Some("hi") { LL | | -LL | | LL | | Some(m) => m, LL | | _ => unreachable!("can't happen"), LL | | }; diff --git a/tests/ui/manual_let_else_question_mark.rs b/tests/ui/manual_let_else_question_mark.rs index a07801ce0681d..8b43d59816f9c 100644 --- a/tests/ui/manual_let_else_question_mark.rs +++ b/tests/ui/manual_let_else_question_mark.rs @@ -43,7 +43,7 @@ fn foo() -> Option<()> { // Do fire manual_let_else in this instance: question mark cannot be used here due to the return // body. let v = if let Some(v_some) = g() { - //~^ manual_let_else + //~^ manual_let_else v_some } else { return Some(()); @@ -55,7 +55,7 @@ fn foo() -> Option<()> { #[allow(clippy::question_mark)] { let v = match g() { - //~^ manual_let_else + //~^ manual_let_else Some(v_some) => v_some, _ => return None, }; diff --git a/tests/ui/manual_map_option.rs b/tests/ui/manual_map_option.rs index 9d7cf754f4b86..9477d0d795d2d 100644 --- a/tests/ui/manual_map_option.rs +++ b/tests/ui/manual_map_option.rs @@ -12,25 +12,25 @@ fn main() { match Some(0) { - //~^ manual_map + //~^ manual_map Some(_) => Some(2), None:: => None, }; match Some(0) { - //~^ manual_map + //~^ manual_map Some(x) => Some(x + 1), _ => None, }; match Some("") { - //~^ manual_map + //~^ manual_map Some(x) => Some(x.is_empty()), None => None, }; if let Some(x) = Some(0) { - //~^ manual_map + //~^ manual_map Some(!x) } else { None @@ -44,7 +44,7 @@ fn main() { }; match Some(&String::new()) { - //~^ manual_map + //~^ manual_map Some(x) => Some(str::len(x)), None => None, }; @@ -55,31 +55,31 @@ fn main() { }; match &Some([0, 1]) { - //~^ manual_map + //~^ manual_map Some(x) => Some(x[0]), &None => None, }; match &Some(0) { - //~^ manual_map + //~^ manual_map &Some(x) => Some(x * 2), None => None, }; match Some(String::new()) { - //~^ manual_map + //~^ manual_map Some(ref x) => Some(x.is_empty()), _ => None, }; match &&Some(String::new()) { - //~^ manual_map + //~^ manual_map Some(x) => Some(x.len()), _ => None, }; match &&Some(0) { - //~^ manual_map + //~^ manual_map &&Some(x) => Some(x + x), &&_ => None, }; @@ -93,38 +93,38 @@ fn main() { #[allow(clippy::option_map_unit_fn)] { match &mut Some(String::new()) { - //~^ manual_map + //~^ manual_map Some(x) => Some(x.push_str("")), None => None, }; } match &mut Some(String::new()) { - //~^ manual_map + //~^ manual_map Some(ref x) => Some(x.len()), None => None, }; match &mut &Some(String::new()) { - //~^ manual_map + //~^ manual_map Some(x) => Some(x.is_empty()), &mut _ => None, }; match Some((0, 1, 2)) { - //~^ manual_map + //~^ manual_map Some((x, y, z)) => Some(x + y + z), None => None, }; match Some([1, 2, 3]) { - //~^ manual_map + //~^ manual_map Some([first, ..]) => Some(first), None => None, }; match &Some((String::new(), "test")) { - //~^ manual_map + //~^ manual_map Some((x, y)) => Some((y, x)), None => None, }; @@ -194,7 +194,7 @@ fn main() { }; match option_env!("") { - //~^ manual_map + //~^ manual_map Some(x) => Some(String::from(x)), None => None, }; @@ -215,7 +215,7 @@ fn main() { if let Some(_) = Some(0) { Some(0) } else if let Some(x) = Some(0) { - //~^ manual_map + //~^ manual_map Some(x + 1) } else { None @@ -224,7 +224,7 @@ fn main() { if true { Some(0) } else if let Some(x) = Some(0) { - //~^ manual_map + //~^ manual_map Some(x + 1) } else { None diff --git a/tests/ui/manual_map_option_2.rs b/tests/ui/manual_map_option_2.rs index 9f45349d5c89f..069c2381f6db1 100644 --- a/tests/ui/manual_map_option_2.rs +++ b/tests/ui/manual_map_option_2.rs @@ -4,7 +4,7 @@ fn main() { // Lint. `y` is declared within the arm, so it isn't captured by the map closure let _ = match Some(0) { - //~^ manual_map + //~^ manual_map Some(x) => Some({ let y = (String::new(), String::new()); (x, y.0) @@ -47,7 +47,7 @@ fn main() { let s = Some(String::new()); // Lint. `s` is captured by reference, so no lifetime issues. let _ = match &s { - //~^ manual_map + //~^ manual_map Some(x) => Some({ if let Some(ref s) = s { (x.clone(), s) } else { panic!() } }), None => None, }; @@ -63,18 +63,18 @@ fn main() { } unsafe { let _ = match Some(0) { - //~^ manual_map + //~^ manual_map Some(x) => Some(f(x)), None => None, }; } let _ = match Some(0) { - //~^ manual_map + //~^ manual_map Some(x) => unsafe { Some(f(x)) }, None => None, }; let _ = match Some(0) { - //~^ manual_map + //~^ manual_map Some(x) => Some(unsafe { f(x) }), None => None, }; @@ -111,7 +111,7 @@ mod with_type_coercion { }; let _ = match Some(0) { - //~^ manual_map + //~^ manual_map Some(_) => Some(match f() { Ok(res) => Ok(Box::new(res)), _ => Err(()), @@ -134,7 +134,7 @@ mod with_type_coercion { }); let _: Option> = match Some(0) { - //~^ manual_map + //~^ manual_map Some(_) => Some(g(x)), None => None, }; diff --git a/tests/ui/manual_memcpy/with_loop_counters.rs b/tests/ui/manual_memcpy/with_loop_counters.rs index eee6c8235daa3..c83a26cab21ab 100644 --- a/tests/ui/manual_memcpy/with_loop_counters.rs +++ b/tests/ui/manual_memcpy/with_loop_counters.rs @@ -3,8 +3,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { let mut count = 0; for i in 3..src.len() { - //~^ manual_memcpy - + //~^ manual_memcpy dst[i] = src[count]; count += 1; @@ -12,7 +11,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 0; for i in 3..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[count] = src[i]; count += 1; @@ -20,7 +19,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 3; for i in 0..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[count] = src[i]; count += 1; @@ -28,7 +27,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 3; for i in 0..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[count]; count += 1; @@ -36,7 +35,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 0; for i in 3..(3 + src.len()) { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[count]; count += 1; @@ -44,7 +43,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 3; for i in 5..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[count - 2]; count += 1; @@ -52,7 +51,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 2; for i in 0..dst.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[count]; count += 1; @@ -60,7 +59,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 5; for i in 3..10 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[count]; count += 1; @@ -69,7 +68,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) let mut count = 3; let mut count2 = 30; for i in 0..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[count] = src[i]; dst2[count2] = src[i]; @@ -81,7 +80,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) // arithmetic ones let mut count = 0 << 1; for i in 0..1 << 1 { - //~^ manual_memcpy + //~^ manual_memcpy dst[count] = src[i + 2]; count += 1; @@ -90,7 +89,7 @@ pub fn manual_copy_with_counters(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) // make sure incrementing expressions without semicolons at the end of loops are handled correctly. let mut count = 0; for i in 3..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[count]; count += 1 diff --git a/tests/ui/manual_memcpy/with_loop_counters.stderr b/tests/ui/manual_memcpy/with_loop_counters.stderr index fe42842b969b7..70da8309f3987 100644 --- a/tests/ui/manual_memcpy/with_loop_counters.stderr +++ b/tests/ui/manual_memcpy/with_loop_counters.stderr @@ -2,7 +2,9 @@ error: it looks like you're manually copying between slices --> tests/ui/manual_memcpy/with_loop_counters.rs:5:5 | LL | / for i in 3..src.len() { -... | +LL | | +LL | | +LL | | dst[i] = src[count]; LL | | count += 1; LL | | } | |_____^ help: try replacing the loop by: `dst[3..src.len()].copy_from_slice(&src[..(src.len() - 3)]);` @@ -11,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:14:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:13:5 | LL | / for i in 3..src.len() { LL | | @@ -22,7 +24,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..(src.len() - 3)].copy_from_slice(&src[3..]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:22:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:21:5 | LL | / for i in 0..src.len() { LL | | @@ -33,7 +35,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(src.len() + 3)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:30:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:29:5 | LL | / for i in 0..src.len() { LL | | @@ -44,7 +46,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[3..(src.len() + 3)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:38:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:37:5 | LL | / for i in 3..(3 + src.len()) { LL | | @@ -55,7 +57,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..(3 + src.len())].copy_from_slice(&src[..(3 + src.len() - 3)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:46:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:45:5 | LL | / for i in 5..src.len() { LL | | @@ -66,7 +68,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[5..src.len()].copy_from_slice(&src[(3 - 2)..((src.len() - 2) + 3 - 5)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:54:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:53:5 | LL | / for i in 0..dst.len() { LL | | @@ -77,7 +79,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[2..(dst.len() + 2)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:62:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:61:5 | LL | / for i in 3..10 { LL | | @@ -88,7 +90,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[3..10].copy_from_slice(&src[5..(10 + 5 - 3)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:71:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:70:5 | LL | / for i in 0..src.len() { LL | | @@ -106,7 +108,7 @@ LL + dst2[30..(src.len() + 30)].copy_from_slice(&src[..]); | error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:83:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:82:5 | LL | / for i in 0..1 << 1 { LL | | @@ -117,7 +119,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(0 << 1)..((1 << 1) + (0 << 1))].copy_from_slice(&src[2..((1 << 1) + 2)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/with_loop_counters.rs:92:5 + --> tests/ui/manual_memcpy/with_loop_counters.rs:91:5 | LL | / for i in 3..src.len() { LL | | diff --git a/tests/ui/manual_memcpy/without_loop_counters.rs b/tests/ui/manual_memcpy/without_loop_counters.rs index 65254df0aab4a..a3b8763812d72 100644 --- a/tests/ui/manual_memcpy/without_loop_counters.rs +++ b/tests/ui/manual_memcpy/without_loop_counters.rs @@ -12,36 +12,35 @@ const LOOP_OFFSET: usize = 5000; pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { // plain manual memcpy for i in 0..src.len() { - //~^ manual_memcpy - + //~^ manual_memcpy dst[i] = src[i]; } // dst offset memcpy for i in 0..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i + 10] = src[i]; } // src offset memcpy for i in 0..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i + 10]; } // src offset memcpy for i in 11..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i - 10]; } // overwrite entire dst for i in 0..dst.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i]; } @@ -56,7 +55,7 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { // multiple copies - suggest two memcpy statements for i in 10..256 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i - 5]; dst2[i + 500] = src[i] @@ -70,7 +69,7 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { let some_var = 5; // Offset in variable for i in 10..LOOP_OFFSET { - //~^ manual_memcpy + //~^ manual_memcpy dst[i + LOOP_OFFSET] = src[i - some_var]; } @@ -85,7 +84,7 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { // make sure vectors are supported for i in 0..src_vec.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst_vec[i] = src_vec[i]; } @@ -116,27 +115,27 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { let from = 1; for i in from..from + src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i - from]; } for i in from..from + 3 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i - from]; } #[allow(clippy::identity_op)] for i in 0..5 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i - 0] = src[i]; } #[allow(clippy::reversed_empty_ranges)] for i in 0..0 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i]; } @@ -161,21 +160,21 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { let src = [0, 1, 2, 3, 4]; let mut dst = [0; 4]; for i in 0..4 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i]; } let mut dst = [0; 6]; for i in 0..5 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i]; } let mut dst = [0; 5]; for i in 0..5 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i]; } @@ -223,14 +222,14 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { let src = [[0; 5]; 5]; let mut dst = [0; 5]; for i in 0..5 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[0][i]; } let src = [[[0; 5]; 5]; 5]; for i in 0..5 { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[0][1][i]; } @@ -239,7 +238,7 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) { #[warn(clippy::needless_range_loop, clippy::manual_memcpy)] pub fn manual_clone(src: &[String], dst: &mut [String]) { for i in 0..src.len() { - //~^ manual_memcpy + //~^ manual_memcpy dst[i] = src[i].clone(); } diff --git a/tests/ui/manual_memcpy/without_loop_counters.stderr b/tests/ui/manual_memcpy/without_loop_counters.stderr index 2599bc02c3caf..0e656dcbc63a4 100644 --- a/tests/ui/manual_memcpy/without_loop_counters.stderr +++ b/tests/ui/manual_memcpy/without_loop_counters.stderr @@ -2,7 +2,9 @@ error: it looks like you're manually copying between slices --> tests/ui/manual_memcpy/without_loop_counters.rs:14:5 | LL | / for i in 0..src.len() { -... | +LL | | +LL | | +LL | | dst[i] = src[i]; LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[..]);` | @@ -10,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:22:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:21:5 | LL | / for i in 0..src.len() { LL | | @@ -20,7 +22,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[10..(src.len() + 10)].copy_from_slice(&src[..]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:29:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:28:5 | LL | / for i in 0..src.len() { LL | | @@ -30,7 +32,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[10..(src.len() + 10)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:36:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:35:5 | LL | / for i in 11..src.len() { LL | | @@ -40,7 +42,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[11..src.len()].copy_from_slice(&src[(11 - 10)..(src.len() - 10)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:43:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:42:5 | LL | / for i in 0..dst.len() { LL | | @@ -50,7 +52,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..dst.len()]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:58:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:57:5 | LL | / for i in 10..256 { LL | | @@ -67,7 +69,7 @@ LL + dst2[(10 + 500)..(256 + 500)].copy_from_slice(&src[10..256]); | error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:72:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:71:5 | LL | / for i in 10..LOOP_OFFSET { LL | | @@ -77,7 +79,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].copy_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:87:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:86:5 | LL | / for i in 0..src_vec.len() { LL | | @@ -87,7 +89,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst_vec[..src_vec.len()].copy_from_slice(&src_vec[..]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:118:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:117:5 | LL | / for i in from..from + src.len() { LL | | @@ -97,7 +99,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + src.len())].copy_from_slice(&src[..(from + src.len() - from)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:124:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:123:5 | LL | / for i in from..from + 3 { LL | | @@ -107,7 +109,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[from..(from + 3)].copy_from_slice(&src[..(from + 3 - from)]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:131:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:130:5 | LL | / for i in 0..5 { LL | | @@ -117,7 +119,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:138:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:137:5 | LL | / for i in 0..0 { LL | | @@ -127,7 +129,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..0].copy_from_slice(&src[..0]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:163:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:162:5 | LL | / for i in 0..4 { LL | | @@ -137,7 +139,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..4]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:170:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:169:5 | LL | / for i in 0..5 { LL | | @@ -147,7 +149,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:177:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:176:5 | LL | / for i in 0..5 { LL | | @@ -157,7 +159,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:225:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:224:5 | LL | / for i in 0..5 { LL | | @@ -167,7 +169,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[0]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:232:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:231:5 | LL | / for i in 0..5 { LL | | @@ -177,7 +179,7 @@ LL | | } | |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[0][1]);` error: it looks like you're manually copying between slices - --> tests/ui/manual_memcpy/without_loop_counters.rs:241:5 + --> tests/ui/manual_memcpy/without_loop_counters.rs:240:5 | LL | / for i in 0..src.len() { LL | | diff --git a/tests/ui/manual_non_exhaustive_enum.rs b/tests/ui/manual_non_exhaustive_enum.rs index aaa5b549e7347..bb22165d478f5 100644 --- a/tests/ui/manual_non_exhaustive_enum.rs +++ b/tests/ui/manual_non_exhaustive_enum.rs @@ -2,7 +2,7 @@ #![allow(unused)] //@no-rustfix pub enum E { -//~^ manual_non_exhaustive + //~^ manual_non_exhaustive A, B, #[doc(hidden)] @@ -27,7 +27,7 @@ pub enum NoDocHidden { // name of variant with doc hidden does not start with underscore pub enum NoUnderscore { -//~^ manual_non_exhaustive + //~^ manual_non_exhaustive A, B, #[doc(hidden)] diff --git a/tests/ui/manual_ok_err.rs b/tests/ui/manual_ok_err.rs index 976311604a38b..77300b7af5396 100644 --- a/tests/ui/manual_ok_err.rs +++ b/tests/ui/manual_ok_err.rs @@ -6,35 +6,31 @@ fn funcall() -> Result { fn main() { let _ = match funcall() { - //~^ manual_ok_err - + //~^ manual_ok_err Ok(v) => Some(v), Err(_) => None, }; let _ = match funcall() { - //~^ manual_ok_err - + //~^ manual_ok_err Ok(v) => Some(v), _v => None, }; let _ = match funcall() { - //~^ manual_ok_err - + //~^ manual_ok_err Err(v) => Some(v), Ok(_) => None, }; let _ = match funcall() { - //~^ manual_ok_err - + //~^ manual_ok_err Err(v) => Some(v), _v => None, }; let _ = if let Ok(v) = funcall() { - //~^ manual_ok_err + //~^ manual_ok_err Some(v) } else { @@ -42,7 +38,7 @@ fn main() { }; let _ = if let Err(v) = funcall() { - //~^ manual_ok_err + //~^ manual_ok_err Some(v) } else { @@ -51,8 +47,7 @@ fn main() { #[allow(clippy::redundant_pattern)] let _ = match funcall() { - //~^ manual_ok_err - + //~^ manual_ok_err Ok(v) => Some(v), _v @ _ => None, }; @@ -69,8 +64,7 @@ fn main() { // Suggestion should be properly parenthesized let _ = match -S { - //~^ manual_ok_err - + //~^ manual_ok_err Ok(v) => Some(v), _ => None, }; diff --git a/tests/ui/manual_ok_err.stderr b/tests/ui/manual_ok_err.stderr index ea430dd3eb454..f10f52cc4c97e 100644 --- a/tests/ui/manual_ok_err.stderr +++ b/tests/ui/manual_ok_err.stderr @@ -4,7 +4,6 @@ error: manual implementation of `ok` LL | let _ = match funcall() { | _____________^ LL | | -LL | | LL | | Ok(v) => Some(v), LL | | Err(_) => None, LL | | }; @@ -14,43 +13,40 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_ok_err)]` error: manual implementation of `ok` - --> tests/ui/manual_ok_err.rs:15:13 + --> tests/ui/manual_ok_err.rs:14:13 | LL | let _ = match funcall() { | _____________^ LL | | -LL | | LL | | Ok(v) => Some(v), LL | | _v => None, LL | | }; | |_____^ help: replace with: `funcall().ok()` error: manual implementation of `err` - --> tests/ui/manual_ok_err.rs:22:13 + --> tests/ui/manual_ok_err.rs:20:13 | LL | let _ = match funcall() { | _____________^ LL | | -LL | | LL | | Err(v) => Some(v), LL | | Ok(_) => None, LL | | }; | |_____^ help: replace with: `funcall().err()` error: manual implementation of `err` - --> tests/ui/manual_ok_err.rs:29:13 + --> tests/ui/manual_ok_err.rs:26:13 | LL | let _ = match funcall() { | _____________^ LL | | -LL | | LL | | Err(v) => Some(v), LL | | _v => None, LL | | }; | |_____^ help: replace with: `funcall().err()` error: manual implementation of `ok` - --> tests/ui/manual_ok_err.rs:36:13 + --> tests/ui/manual_ok_err.rs:32:13 | LL | let _ = if let Ok(v) = funcall() { | _____________^ @@ -63,7 +59,7 @@ LL | | }; | |_____^ help: replace with: `funcall().ok()` error: manual implementation of `err` - --> tests/ui/manual_ok_err.rs:44:13 + --> tests/ui/manual_ok_err.rs:40:13 | LL | let _ = if let Err(v) = funcall() { | _____________^ @@ -76,24 +72,22 @@ LL | | }; | |_____^ help: replace with: `funcall().err()` error: manual implementation of `ok` - --> tests/ui/manual_ok_err.rs:53:13 + --> tests/ui/manual_ok_err.rs:49:13 | LL | let _ = match funcall() { | _____________^ LL | | -LL | | LL | | Ok(v) => Some(v), LL | | _v @ _ => None, LL | | }; | |_____^ help: replace with: `funcall().ok()` error: manual implementation of `ok` - --> tests/ui/manual_ok_err.rs:71:13 + --> tests/ui/manual_ok_err.rs:66:13 | LL | let _ = match -S { | _____________^ LL | | -LL | | LL | | Ok(v) => Some(v), LL | | _ => None, LL | | }; diff --git a/tests/ui/manual_option_as_slice.fixed b/tests/ui/manual_option_as_slice.fixed index 17a412017a434..48337d7654dea 100644 --- a/tests/ui/manual_option_as_slice.fixed +++ b/tests/ui/manual_option_as_slice.fixed @@ -9,24 +9,19 @@ fn check(x: Option) { _ = x.as_slice(); //~^ manual_option_as_slice - _ = x.as_slice(); //~^ manual_option_as_slice - _ = x.as_slice(); //~^ manual_option_as_slice - _ = x.as_slice(); //~^ manual_option_as_slice - { use std::slice::from_ref; _ = x.as_slice(); //~^ manual_option_as_slice - } // possible false positives diff --git a/tests/ui/manual_option_as_slice.rs b/tests/ui/manual_option_as_slice.rs index 71166399cbeac..e1a97a6b27115 100644 --- a/tests/ui/manual_option_as_slice.rs +++ b/tests/ui/manual_option_as_slice.rs @@ -3,14 +3,13 @@ fn check(x: Option) { _ = match x.as_ref() { - //~^ manual_option_as_slice - + //~^ manual_option_as_slice Some(f) => std::slice::from_ref(f), None => &[], }; _ = if let Some(f) = x.as_ref() { - //~^ manual_option_as_slice + //~^ manual_option_as_slice std::slice::from_ref(f) } else { @@ -20,24 +19,19 @@ fn check(x: Option) { _ = x.as_ref().map_or(&[][..], std::slice::from_ref); //~^ manual_option_as_slice - _ = x.as_ref().map_or_else(Default::default, std::slice::from_ref); //~^ manual_option_as_slice - _ = x.as_ref().map(std::slice::from_ref).unwrap_or_default(); //~^ manual_option_as_slice - _ = x.as_ref().map_or_else(|| &[42][..0], std::slice::from_ref); //~^ manual_option_as_slice - { use std::slice::from_ref; _ = x.as_ref().map_or_else(<&[_]>::default, from_ref); //~^ manual_option_as_slice - } // possible false positives diff --git a/tests/ui/manual_option_as_slice.stderr b/tests/ui/manual_option_as_slice.stderr index 3a07c6a02dae4..e240ae8eb7d90 100644 --- a/tests/ui/manual_option_as_slice.stderr +++ b/tests/ui/manual_option_as_slice.stderr @@ -4,7 +4,6 @@ error: use `Option::as_slice` LL | _ = match x.as_ref() { | _________^ LL | | -LL | | LL | | Some(f) => std::slice::from_ref(f), LL | | None => &[], LL | | }; @@ -14,7 +13,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_option_as_slice)]` error: use `Option::as_slice` - --> tests/ui/manual_option_as_slice.rs:12:9 + --> tests/ui/manual_option_as_slice.rs:11:9 | LL | _ = if let Some(f) = x.as_ref() { | _________^ @@ -27,31 +26,31 @@ LL | | }; | |_____^ help: use: `x.as_slice()` error: use `Option::as_slice` - --> tests/ui/manual_option_as_slice.rs:20:9 + --> tests/ui/manual_option_as_slice.rs:19:9 | LL | _ = x.as_ref().map_or(&[][..], std::slice::from_ref); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()` error: use `Option::as_slice` - --> tests/ui/manual_option_as_slice.rs:24:9 + --> tests/ui/manual_option_as_slice.rs:22:9 | LL | _ = x.as_ref().map_or_else(Default::default, std::slice::from_ref); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()` error: use `Option::as_slice` - --> tests/ui/manual_option_as_slice.rs:28:9 + --> tests/ui/manual_option_as_slice.rs:25:9 | LL | _ = x.as_ref().map(std::slice::from_ref).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()` error: use `Option::as_slice` - --> tests/ui/manual_option_as_slice.rs:32:9 + --> tests/ui/manual_option_as_slice.rs:28:9 | LL | _ = x.as_ref().map_or_else(|| &[42][..0], std::slice::from_ref); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()` error: use `Option::as_slice` - --> tests/ui/manual_option_as_slice.rs:38:13 + --> tests/ui/manual_option_as_slice.rs:33:13 | LL | _ = x.as_ref().map_or_else(<&[_]>::default, from_ref); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `x.as_slice()` diff --git a/tests/ui/manual_retain.rs b/tests/ui/manual_retain.rs index 61e2d73b544ff..cd05a41f3f25a 100644 --- a/tests/ui/manual_retain.rs +++ b/tests/ui/manual_retain.rs @@ -69,7 +69,7 @@ fn btree_map_retain() { btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); //~^ manual_retain btree_map = btree_map - //~^ manual_retain + //~^ manual_retain .into_iter() .filter(|(k, v)| (k % 2 == 0) && (v % 2 == 0)) .collect(); @@ -141,7 +141,7 @@ fn hash_map_retain() { hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect(); //~^ manual_retain hash_map = hash_map - //~^ manual_retain + //~^ manual_retain .into_iter() .filter(|(k, v)| (k % 2 == 0) && (v % 2 == 0)) .collect(); diff --git a/tests/ui/manual_saturating_arithmetic.rs b/tests/ui/manual_saturating_arithmetic.rs index c0d7f26916ee8..98246a5cd96ca 100644 --- a/tests/ui/manual_saturating_arithmetic.rs +++ b/tests/ui/manual_saturating_arithmetic.rs @@ -10,7 +10,7 @@ fn main() { let _ = 1u8.checked_add(1).unwrap_or(255); //~^ manual_saturating_arithmetic let _ = 1u128 - //~^ manual_saturating_arithmetic + //~^ manual_saturating_arithmetic .checked_add(1) .unwrap_or(340_282_366_920_938_463_463_374_607_431_768_211_455); let _ = 1u32.checked_add(1).unwrap_or(1234); // ok @@ -34,7 +34,7 @@ fn main() { let _ = 1i8.checked_add(1).unwrap_or(127); //~^ manual_saturating_arithmetic let _ = 1i128 - //~^ manual_saturating_arithmetic + //~^ manual_saturating_arithmetic .checked_add(1) .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727); let _ = 1i32.checked_add(-1).unwrap_or(i32::min_value()); @@ -44,7 +44,7 @@ fn main() { let _ = 1i8.checked_add(-1).unwrap_or(-128); //~^ manual_saturating_arithmetic let _ = 1i128 - //~^ manual_saturating_arithmetic + //~^ manual_saturating_arithmetic .checked_add(-1) .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); let _ = 1i32.checked_add(1).unwrap_or(1234); // ok @@ -58,7 +58,7 @@ fn main() { let _ = 1i8.checked_sub(1).unwrap_or(-128); //~^ manual_saturating_arithmetic let _ = 1i128 - //~^ manual_saturating_arithmetic + //~^ manual_saturating_arithmetic .checked_sub(1) .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728); let _ = 1i32.checked_sub(-1).unwrap_or(i32::max_value()); @@ -68,7 +68,7 @@ fn main() { let _ = 1i8.checked_sub(-1).unwrap_or(127); //~^ manual_saturating_arithmetic let _ = 1i128 - //~^ manual_saturating_arithmetic + //~^ manual_saturating_arithmetic .checked_sub(-1) .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727); let _ = 1i32.checked_sub(1).unwrap_or(1234); // ok diff --git a/tests/ui/manual_slice_fill.rs b/tests/ui/manual_slice_fill.rs index cd62a476d174c..f758f47bbcb0c 100644 --- a/tests/ui/manual_slice_fill.rs +++ b/tests/ui/manual_slice_fill.rs @@ -23,25 +23,25 @@ fn should_lint() { let mut some_slice = [1, 2, 3, 4, 5]; for i in 0..some_slice.len() { - //~^ manual_slice_fill + //~^ manual_slice_fill some_slice[i] = 0; } let x = 5; for i in 0..some_slice.len() { - //~^ manual_slice_fill + //~^ manual_slice_fill some_slice[i] = x; } for i in &mut some_slice { - //~^ manual_slice_fill + //~^ manual_slice_fill *i = 0; } // This should trigger `manual_slice_fill`, but the applicability is `MaybeIncorrect` since comments // within the loop might be purely informational. for i in 0..some_slice.len() { - //~^ manual_slice_fill + //~^ manual_slice_fill some_slice[i] = 0; // foo } diff --git a/tests/ui/manual_strip.rs b/tests/ui/manual_strip.rs index d3dbf301d9c01..ce53c99e6b507 100644 --- a/tests/ui/manual_strip.rs +++ b/tests/ui/manual_strip.rs @@ -36,7 +36,6 @@ fn main() { if s.starts_with(prefix) { str::to_string(&s[prefix.len()..]); //~^ manual_strip - } // Constant prefix @@ -53,7 +52,6 @@ fn main() { if TARGET.starts_with(prefix) { str::to_string(&TARGET[prefix.len()..]); //~^ manual_strip - } // String target - not mutated. @@ -61,7 +59,6 @@ fn main() { if s1.starts_with("ab") { s1[2..].to_uppercase(); //~^ manual_strip - } // String target - mutated. (Don't lint.) @@ -93,6 +90,5 @@ fn msrv_1_45() { if s.starts_with('a') { s[1..].to_string(); //~^ manual_strip - } } diff --git a/tests/ui/manual_strip.stderr b/tests/ui/manual_strip.stderr index 78967e521baa6..41d15da610c4e 100644 --- a/tests/ui/manual_strip.stderr +++ b/tests/ui/manual_strip.stderr @@ -84,13 +84,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> tests/ui/manual_strip.rs:45:24 + --> tests/ui/manual_strip.rs:44:24 | LL | str::to_string(&s[PREFIX.len()..]); | ^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> tests/ui/manual_strip.rs:44:5 + --> tests/ui/manual_strip.rs:43:5 | LL | if s.starts_with(PREFIX) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,13 +104,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> tests/ui/manual_strip.rs:54:24 + --> tests/ui/manual_strip.rs:53:24 | LL | str::to_string(&TARGET[prefix.len()..]); | ^^^^^^^^^^^^^^^^^^^^^^^ | note: the prefix was tested here - --> tests/ui/manual_strip.rs:53:5 + --> tests/ui/manual_strip.rs:52:5 | LL | if TARGET.starts_with(prefix) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,13 +121,13 @@ LL ~ str::to_string(); | error: stripping a prefix manually - --> tests/ui/manual_strip.rs:62:9 + --> tests/ui/manual_strip.rs:60:9 | LL | s1[2..].to_uppercase(); | ^^^^^^^ | note: the prefix was tested here - --> tests/ui/manual_strip.rs:61:5 + --> tests/ui/manual_strip.rs:59:5 | LL | if s1.starts_with("ab") { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,13 +138,13 @@ LL ~ .to_uppercase(); | error: stripping a prefix manually - --> tests/ui/manual_strip.rs:94:9 + --> tests/ui/manual_strip.rs:91:9 | LL | s[1..].to_string(); | ^^^^^^ | note: the prefix was tested here - --> tests/ui/manual_strip.rs:93:5 + --> tests/ui/manual_strip.rs:90:5 | LL | if s.starts_with('a') { | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/manual_try_fold.rs b/tests/ui/manual_try_fold.rs index 749fc7c7b6831..c91ea41bb84c5 100644 --- a/tests/ui/manual_try_fold.rs +++ b/tests/ui/manual_try_fold.rs @@ -62,11 +62,11 @@ fn main() { [1, 2, 3] .iter() .fold(NotOption(0i32, 0i32), |sum, i| NotOption(0i32, 0i32)); - //~^ manual_try_fold + //~^ manual_try_fold [1, 2, 3] .iter() .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32)); - //~^ manual_try_fold + //~^ manual_try_fold // Do not lint [1, 2, 3].iter().try_fold(0i32, |sum, i| sum.checked_add(*i)).unwrap(); [1, 2, 3].iter().fold(0i32, |sum, i| sum + i); diff --git a/tests/ui/manual_unwrap_or.rs b/tests/ui/manual_unwrap_or.rs index 80a677d726efc..c88b6f95da68e 100644 --- a/tests/ui/manual_unwrap_or.rs +++ b/tests/ui/manual_unwrap_or.rs @@ -9,21 +9,21 @@ fn option_unwrap_or() { // int case match Some(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Some(i) => i, None => 42, }; // int case reversed match Some(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or None => 42, Some(i) => i, }; // richer none expr match Some(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Some(i) => i, None => 1 + 42, }; @@ -42,7 +42,7 @@ fn option_unwrap_or() { // string case match Some("Bob") { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Some(i) => i, None => "Alice", }; @@ -90,7 +90,7 @@ fn option_unwrap_or() { }; if let Some(x) = Some(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or x } else { 42 @@ -124,7 +124,7 @@ fn option_unwrap_or() { fn result_unwrap_or() { // int case match Ok::(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Ok(i) => i, Err(_) => 42, }; @@ -132,14 +132,14 @@ fn result_unwrap_or() { // int case, scrutinee is a binding let a = Ok::(1); match a { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Ok(i) => i, Err(_) => 42, }; // int case, suggestion must surround Result expr with parentheses match Ok(1) as Result { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Ok(i) => i, Err(_) => 42, }; @@ -153,21 +153,21 @@ fn result_unwrap_or() { } let s = S {}; match s.method() { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Some(i) => i, None => 42, }; // int case reversed match Ok::(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Err(_) => 42, Ok(i) => i, }; // richer none expr match Ok::(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Ok(i) => i, Err(_) => 1 + 42, }; @@ -186,7 +186,7 @@ fn result_unwrap_or() { // string case match Ok::<&str, &str>("Bob") { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Ok(i) => i, Err(_) => "Alice", }; @@ -223,7 +223,7 @@ fn result_unwrap_or() { }; if let Ok(x) = Ok::(1) { - //~^ manual_unwrap_or + //~^ manual_unwrap_or x } else { 42 @@ -278,7 +278,7 @@ mod issue6965 { fn test() { let _ = match some_macro!() { - //~^ manual_unwrap_or + //~^ manual_unwrap_or Some(val) => val, None => 0, }; diff --git a/tests/ui/manual_unwrap_or_default.rs b/tests/ui/manual_unwrap_or_default.rs index 1ef07cf84bde9..bedb3f0af0f3e 100644 --- a/tests/ui/manual_unwrap_or_default.rs +++ b/tests/ui/manual_unwrap_or_default.rs @@ -4,39 +4,35 @@ fn main() { let x: Option> = None; match x { - //~^ manual_unwrap_or_default - + //~^ manual_unwrap_or_default Some(v) => v, None => Vec::default(), }; let x: Option> = None; match x { - //~^ manual_unwrap_or_default - + //~^ manual_unwrap_or_default Some(v) => v, _ => Vec::default(), }; let x: Option = None; match x { - //~^ manual_unwrap_or_default - + //~^ manual_unwrap_or_default Some(v) => v, None => String::new(), }; let x: Option> = None; match x { - //~^ manual_unwrap_or_default - + //~^ manual_unwrap_or_default None => Vec::default(), Some(v) => v, }; let x: Option> = None; if let Some(v) = x { - //~^ manual_unwrap_or_default + //~^ manual_unwrap_or_default v } else { @@ -55,15 +51,14 @@ fn main() { let x: Result = Ok(String::new()); match x { - //~^ manual_unwrap_or_default - + //~^ manual_unwrap_or_default Ok(v) => v, Err(_) => String::new(), }; let x: Result = Ok(String::new()); if let Ok(v) = x { - //~^ manual_unwrap_or_default + //~^ manual_unwrap_or_default v } else { @@ -76,7 +71,7 @@ unsafe fn no_deref_ptr(a: Option, b: *const Option) -> i32 { match a { // `*b` being correct depends on `a == Some(_)` Some(_) => match *b { - //~^ manual_unwrap_or_default + //~^ manual_unwrap_or_default Some(v) => v, _ => 0, }, diff --git a/tests/ui/manual_unwrap_or_default.stderr b/tests/ui/manual_unwrap_or_default.stderr index ff388ba85d517..ca9aa159152e3 100644 --- a/tests/ui/manual_unwrap_or_default.stderr +++ b/tests/ui/manual_unwrap_or_default.stderr @@ -3,7 +3,6 @@ error: match can be simplified with `.unwrap_or_default()` | LL | / match x { LL | | -LL | | LL | | Some(v) => v, LL | | None => Vec::default(), LL | | }; @@ -13,40 +12,37 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or_default)]` error: match can be simplified with `.unwrap_or_default()` - --> tests/ui/manual_unwrap_or_default.rs:14:5 + --> tests/ui/manual_unwrap_or_default.rs:13:5 | LL | / match x { LL | | -LL | | LL | | Some(v) => v, LL | | _ => Vec::default(), LL | | }; | |_____^ help: replace it with: `x.unwrap_or_default()` error: match can be simplified with `.unwrap_or_default()` - --> tests/ui/manual_unwrap_or_default.rs:22:5 + --> tests/ui/manual_unwrap_or_default.rs:20:5 | LL | / match x { LL | | -LL | | LL | | Some(v) => v, LL | | None => String::new(), LL | | }; | |_____^ help: replace it with: `x.unwrap_or_default()` error: match can be simplified with `.unwrap_or_default()` - --> tests/ui/manual_unwrap_or_default.rs:30:5 + --> tests/ui/manual_unwrap_or_default.rs:27:5 | LL | / match x { LL | | -LL | | LL | | None => Vec::default(), LL | | Some(v) => v, LL | | }; | |_____^ help: replace it with: `x.unwrap_or_default()` error: if let can be simplified with `.unwrap_or_default()` - --> tests/ui/manual_unwrap_or_default.rs:38:5 + --> tests/ui/manual_unwrap_or_default.rs:34:5 | LL | / if let Some(v) = x { LL | | @@ -58,18 +54,17 @@ LL | | }; | |_____^ help: replace it with: `x.unwrap_or_default()` error: match can be simplified with `.unwrap_or_default()` - --> tests/ui/manual_unwrap_or_default.rs:57:5 + --> tests/ui/manual_unwrap_or_default.rs:53:5 | LL | / match x { LL | | -LL | | LL | | Ok(v) => v, LL | | Err(_) => String::new(), LL | | }; | |_____^ help: replace it with: `x.unwrap_or_default()` error: if let can be simplified with `.unwrap_or_default()` - --> tests/ui/manual_unwrap_or_default.rs:65:5 + --> tests/ui/manual_unwrap_or_default.rs:60:5 | LL | / if let Ok(v) = x { LL | | @@ -81,7 +76,7 @@ LL | | }; | |_____^ help: replace it with: `x.unwrap_or_default()` error: match can be simplified with `.unwrap_or_default()` - --> tests/ui/manual_unwrap_or_default.rs:78:20 + --> tests/ui/manual_unwrap_or_default.rs:73:20 | LL | Some(_) => match *b { | ____________________^ diff --git a/tests/ui/manual_unwrap_or_default_unfixable.rs b/tests/ui/manual_unwrap_or_default_unfixable.rs index fb61d639f9c00..c48a4d5ee5152 100644 --- a/tests/ui/manual_unwrap_or_default_unfixable.rs +++ b/tests/ui/manual_unwrap_or_default_unfixable.rs @@ -3,7 +3,7 @@ fn issue_12670() { // no auto: type not found #[allow(clippy::match_result_ok)] let _ = if let Some(x) = "1".parse().ok() { - //~^ manual_unwrap_or_default + //~^ manual_unwrap_or_default x } else { i32::default() diff --git a/tests/ui/many_single_char_names.rs b/tests/ui/many_single_char_names.rs index 6e662e2460618..b601092248554 100644 --- a/tests/ui/many_single_char_names.rs +++ b/tests/ui/many_single_char_names.rs @@ -7,9 +7,6 @@ fn bla() { //~| many_single_char_names //~| many_single_char_names - - - let (b, c, d): (i32, i64, i16); { { @@ -37,11 +34,9 @@ fn bla() { fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} //~^ many_single_char_names - fn bindings2() { let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!(); //~^ many_single_char_names - } fn shadowing() { diff --git a/tests/ui/many_single_char_names.stderr b/tests/ui/many_single_char_names.stderr index ad45f9a34fd4c..131836ef7c882 100644 --- a/tests/ui/many_single_char_names.stderr +++ b/tests/ui/many_single_char_names.stderr @@ -40,13 +40,13 @@ LL | e => panic!(), | ^ error: 8 bindings with single-character names in scope - --> tests/ui/many_single_char_names.rs:37:13 + --> tests/ui/many_single_char_names.rs:34:13 | LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {} | ^ ^ ^ ^ ^ ^ ^ ^ error: 8 bindings with single-character names in scope - --> tests/ui/many_single_char_names.rs:42:10 + --> tests/ui/many_single_char_names.rs:38:10 | LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!(); | ^ ^ ^ ^ ^ ^ ^ ^ diff --git a/tests/ui/map_all_any_identity.fixed b/tests/ui/map_all_any_identity.fixed index 436b94bde0fc0..35543d239752f 100644 --- a/tests/ui/map_all_any_identity.fixed +++ b/tests/ui/map_all_any_identity.fixed @@ -7,7 +7,6 @@ fn main() { let _ = ["foo"].into_iter().all(|s| s == "foo"); //~^ map_all_any_identity - // // Do not lint // diff --git a/tests/ui/map_all_any_identity.rs b/tests/ui/map_all_any_identity.rs index 68fe7b77f5c6a..704eb821aaaa1 100644 --- a/tests/ui/map_all_any_identity.rs +++ b/tests/ui/map_all_any_identity.rs @@ -7,7 +7,6 @@ fn main() { let _ = ["foo"].into_iter().map(|s| s == "foo").all(std::convert::identity); //~^ map_all_any_identity - // // Do not lint // diff --git a/tests/ui/map_clone.fixed b/tests/ui/map_clone.fixed index 5e2c31bb31df1..8db4b21be684b 100644 --- a/tests/ui/map_clone.fixed +++ b/tests/ui/map_clone.fixed @@ -78,23 +78,17 @@ fn main() { let y = x.cloned(); //~^ map_clone - let y = x.cloned(); //~^ map_clone - - let x: Option = Some(0); let x = x.as_ref(); // We do this to prevent triggering the `useless_asref` lint. let y = x.copied(); //~^ map_clone - let y = x.copied(); //~^ map_clone - - // Should not suggest `copied` or `cloned` here since `T` is not a reference. let x: Option = Some(0); let y = x.map(|x| u32::clone(&x)); @@ -106,23 +100,17 @@ fn main() { let y = x.cloned(); //~^ map_clone - let y = x.cloned(); //~^ map_clone - - let x: Result = Ok(0); let x = x.as_ref(); // We do this to prevent triggering the `useless_asref` lint. let y = x.copied(); //~^ map_clone - let y = x.copied(); //~^ map_clone - - // Should not suggest `copied` or `cloned` here since `T` is not a reference. let x: Result = Ok(0); let y = x.map(|x| u32::clone(&x)); diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index f15889d64c52b..a726e35616345 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -78,23 +78,17 @@ fn main() { let y = x.map(Clone::clone); //~^ map_clone - let y = x.map(String::clone); //~^ map_clone - - let x: Option = Some(0); let x = x.as_ref(); // We do this to prevent triggering the `useless_asref` lint. let y = x.map(|x| u32::clone(x)); //~^ map_clone - let y = x.map(|x| Clone::clone(x)); //~^ map_clone - - // Should not suggest `copied` or `cloned` here since `T` is not a reference. let x: Option = Some(0); let y = x.map(|x| u32::clone(&x)); @@ -106,23 +100,17 @@ fn main() { let y = x.map(|x| String::clone(x)); //~^ map_clone - let y = x.map(|x| Clone::clone(x)); //~^ map_clone - - let x: Result = Ok(0); let x = x.as_ref(); // We do this to prevent triggering the `useless_asref` lint. let y = x.map(|x| u32::clone(x)); //~^ map_clone - let y = x.map(|x| Clone::clone(x)); //~^ map_clone - - // Should not suggest `copied` or `cloned` here since `T` is not a reference. let x: Result = Ok(0); let y = x.map(|x| u32::clone(&x)); diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index 5c88ec5793289..8bf54e4e8aee1 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -50,43 +50,43 @@ LL | let y = x.map(Clone::clone); | ^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> tests/ui/map_clone.rs:82:13 + --> tests/ui/map_clone.rs:81:13 | LL | let y = x.map(String::clone); | ^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> tests/ui/map_clone.rs:89:13 + --> tests/ui/map_clone.rs:86:13 | LL | let y = x.map(|x| u32::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> tests/ui/map_clone.rs:93:13 + --> tests/ui/map_clone.rs:89:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> tests/ui/map_clone.rs:106:13 + --> tests/ui/map_clone.rs:100:13 | LL | let y = x.map(|x| String::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> tests/ui/map_clone.rs:110:13 + --> tests/ui/map_clone.rs:103:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.cloned()` error: you are explicitly cloning with `.map()` - --> tests/ui/map_clone.rs:117:13 + --> tests/ui/map_clone.rs:108:13 | LL | let y = x.map(|x| u32::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` error: you are explicitly cloning with `.map()` - --> tests/ui/map_clone.rs:121:13 + --> tests/ui/map_clone.rs:111:13 | LL | let y = x.map(|x| Clone::clone(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `x.copied()` diff --git a/tests/ui/map_err.rs b/tests/ui/map_err.rs index 43f6ea0b3ae09..0f0c8f6c71cf8 100644 --- a/tests/ui/map_err.rs +++ b/tests/ui/map_err.rs @@ -22,7 +22,6 @@ fn main() -> Result<(), Errors> { println!("{:?}", x.map_err(|_| Errors::Ignored)); //~^ map_err_ignore - // Should not warn you because you explicitly ignore the parameter // using a named wildcard value println!("{:?}", x.map_err(|_foo| Errors::Ignored)); diff --git a/tests/ui/map_flatten.rs b/tests/ui/map_flatten.rs index e16a11f83ed58..d7e9c9d9900d9 100644 --- a/tests/ui/map_flatten.rs +++ b/tests/ui/map_flatten.rs @@ -67,7 +67,6 @@ fn no_suggestion_if_comments_present() { // a lovely comment explaining the code in very detail .map(|x| x.iter()) //~^ map_flatten - // the answer to life, the universe and everything could be here .flatten(); } diff --git a/tests/ui/map_flatten_fixable.fixed b/tests/ui/map_flatten_fixable.fixed index a5dc17cc06ca8..948fec970d869 100644 --- a/tests/ui/map_flatten_fixable.fixed +++ b/tests/ui/map_flatten_fixable.fixed @@ -42,7 +42,7 @@ fn issue8734() { let _ = [0u8, 1, 2, 3] .into_iter() .flat_map(|n| match n { - //~^ map_flatten + //~^ map_flatten 1 => [n .saturating_add(1) .saturating_add(1) diff --git a/tests/ui/map_flatten_fixable.rs b/tests/ui/map_flatten_fixable.rs index 57b8e7943f41e..67a91ab94147e 100644 --- a/tests/ui/map_flatten_fixable.rs +++ b/tests/ui/map_flatten_fixable.rs @@ -42,7 +42,7 @@ fn issue8734() { let _ = [0u8, 1, 2, 3] .into_iter() .map(|n| match n { - //~^ map_flatten + //~^ map_flatten 1 => [n .saturating_add(1) .saturating_add(1) diff --git a/tests/ui/map_identity.rs b/tests/ui/map_identity.rs index 7c891dda79ce9..e839c551364be 100644 --- a/tests/ui/map_identity.rs +++ b/tests/ui/map_identity.rs @@ -12,7 +12,7 @@ fn main() { let _: Option = Some(3).map(|x| x); //~^ map_identity let _: Result = Ok(-3).map(|x| { - //~^ map_identity + //~^ map_identity return x; }); // should not lint @@ -36,7 +36,7 @@ fn issue7189() { let _ = x.clone().map(|(x, y)| (x, y)); //~^ map_identity let _ = x.clone().map(|(x, y)| { - //~^ map_identity + //~^ map_identity return (x, y); }); let _ = x.clone().map(|(x, y)| return (x, y)); diff --git a/tests/ui/map_with_unused_argument_over_ranges.fixed b/tests/ui/map_with_unused_argument_over_ranges.fixed index 08bc1c7a62835..254c46ecae389 100644 --- a/tests/ui/map_with_unused_argument_over_ranges.fixed +++ b/tests/ui/map_with_unused_argument_over_ranges.fixed @@ -35,7 +35,7 @@ fn main() { std::iter::repeat_n(3, 10); //~^ map_with_unused_argument_over_ranges std::iter::repeat_with(|| { - //~^ map_with_unused_argument_over_ranges + //~^ map_with_unused_argument_over_ranges let x = 3; x + 2 }).take(10); diff --git a/tests/ui/map_with_unused_argument_over_ranges.rs b/tests/ui/map_with_unused_argument_over_ranges.rs index 151ebdf97e5d6..05c8d64f8012b 100644 --- a/tests/ui/map_with_unused_argument_over_ranges.rs +++ b/tests/ui/map_with_unused_argument_over_ranges.rs @@ -35,7 +35,7 @@ fn main() { (0..10).map(|_| 3); //~^ map_with_unused_argument_over_ranges (0..10).map(|_| { - //~^ map_with_unused_argument_over_ranges + //~^ map_with_unused_argument_over_ranges let x = 3; x + 2 }); diff --git a/tests/ui/match_as_ref.rs b/tests/ui/match_as_ref.rs index 7eaabcdc3d0ea..3a5b1227331e7 100644 --- a/tests/ui/match_as_ref.rs +++ b/tests/ui/match_as_ref.rs @@ -4,14 +4,14 @@ fn match_as_ref() { let owned: Option<()> = None; let borrowed: Option<&()> = match owned { - //~^ match_as_ref + //~^ match_as_ref None => None, Some(ref v) => Some(v), }; let mut mut_owned: Option<()> = None; let borrow_mut: Option<&mut ()> = match mut_owned { - //~^ match_as_ref + //~^ match_as_ref None => None, Some(ref mut v) => Some(v), }; @@ -30,7 +30,7 @@ mod issue4437 { impl Error for E { fn source(&self) -> Option<&(dyn Error + 'static)> { match self.source { - //~^ match_as_ref + //~^ match_as_ref Some(ref s) => Some(s), None => None, } diff --git a/tests/ui/match_bool.rs b/tests/ui/match_bool.rs index 7d4afd3f2890f..719b4e51eb6d9 100644 --- a/tests/ui/match_bool.rs +++ b/tests/ui/match_bool.rs @@ -5,23 +5,20 @@ fn match_bool() { let test: bool = true; match test { - //~^ match_bool - + //~^ match_bool true => 0, false => 42, }; let option = 1; match option == 1 { - //~^ match_bool - + //~^ match_bool true => 1, false => 0, }; match test { - //~^ match_bool - + //~^ match_bool true => (), false => { println!("Noooo!"); @@ -29,8 +26,7 @@ fn match_bool() { }; match test { - //~^ match_bool - + //~^ match_bool false => { println!("Noooo!"); }, @@ -38,8 +34,7 @@ fn match_bool() { }; match test && test { - //~^ match_bool - + //~^ match_bool false => { println!("Noooo!"); }, @@ -47,8 +42,7 @@ fn match_bool() { }; match test { - //~^ match_bool - + //~^ match_bool false => { println!("Noooo!"); }, @@ -73,43 +67,37 @@ fn match_bool() { }; let _ = match test { - //~^ match_bool - + //~^ match_bool true if option == 5 => 10, _ => 1, }; let _ = match test { - //~^ match_bool - + //~^ match_bool false if option == 5 => 10, _ => 1, }; match test { - //~^ match_bool - + //~^ match_bool true if option == 5 => println!("Hello"), _ => (), }; match test { - //~^ match_bool - + //~^ match_bool true if option == 5 => (), _ => println!("Hello"), }; match test { - //~^ match_bool - + //~^ match_bool false if option == 5 => println!("Hello"), _ => (), }; match test { - //~^ match_bool - + //~^ match_bool false if option == 5 => (), _ => println!("Hello"), }; @@ -117,8 +105,7 @@ fn match_bool() { fn issue14099() { match true { - //~^ match_bool - + //~^ match_bool true => 'a: { break 'a; }, diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index c25aad27cef2a..c05742e56339a 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -3,7 +3,6 @@ error: `match` on a boolean expression | LL | / match test { LL | | -LL | | LL | | true => 0, LL | | false => 42, LL | | }; @@ -16,24 +15,23 @@ LL | #![deny(clippy::match_bool)] | ^^^^^^^^^^^^^^^^^^ error: `match` on a boolean expression - --> tests/ui/match_bool.rs:15:5 + --> tests/ui/match_bool.rs:14:5 | LL | / match option == 1 { LL | | -LL | | LL | | true => 1, LL | | false => 0, LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if option == 1 { 1 } else { 0 }` error: `match` on a boolean expression - --> tests/ui/match_bool.rs:22:5 + --> tests/ui/match_bool.rs:20:5 | LL | / match test { LL | | -LL | | LL | | true => (), -... | +LL | | false => { +LL | | println!("Noooo!"); LL | | }, LL | | }; | |_____^ @@ -46,13 +44,13 @@ LL ~ }; | error: `match` on a boolean expression - --> tests/ui/match_bool.rs:31:5 + --> tests/ui/match_bool.rs:28:5 | LL | / match test { LL | | -LL | | LL | | false => { -... | +LL | | println!("Noooo!"); +LL | | }, LL | | _ => (), LL | | }; | |_____^ @@ -65,13 +63,13 @@ LL ~ }; | error: `match` on a boolean expression - --> tests/ui/match_bool.rs:40:5 + --> tests/ui/match_bool.rs:36:5 | LL | / match test && test { LL | | -LL | | LL | | false => { -... | +LL | | println!("Noooo!"); +LL | | }, LL | | _ => (), LL | | }; | |_____^ @@ -84,12 +82,12 @@ LL ~ }; | error: `match` on a boolean expression - --> tests/ui/match_bool.rs:49:5 + --> tests/ui/match_bool.rs:44:5 | LL | / match test { LL | | -LL | | LL | | false => { +LL | | println!("Noooo!"); ... | LL | | }, LL | | }; @@ -105,81 +103,75 @@ LL ~ }; | error: `match` on a boolean expression - --> tests/ui/match_bool.rs:75:13 + --> tests/ui/match_bool.rs:69:13 | LL | let _ = match test { | _____________^ LL | | -LL | | LL | | true if option == 5 => 10, LL | | _ => 1, LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if test && option == 5 { 10 } else { 1 }` error: `match` on a boolean expression - --> tests/ui/match_bool.rs:82:13 + --> tests/ui/match_bool.rs:75:13 | LL | let _ = match test { | _____________^ LL | | -LL | | LL | | false if option == 5 => 10, LL | | _ => 1, LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if !test && option == 5 { 10 } else { 1 }` error: `match` on a boolean expression - --> tests/ui/match_bool.rs:89:5 + --> tests/ui/match_bool.rs:81:5 | LL | / match test { LL | | -LL | | LL | | true if option == 5 => println!("Hello"), LL | | _ => (), LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if test && option == 5 { println!("Hello") }` error: `match` on a boolean expression - --> tests/ui/match_bool.rs:96:5 + --> tests/ui/match_bool.rs:87:5 | LL | / match test { LL | | -LL | | LL | | true if option == 5 => (), LL | | _ => println!("Hello"), LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if !(test && option == 5) { println!("Hello") }` error: `match` on a boolean expression - --> tests/ui/match_bool.rs:103:5 + --> tests/ui/match_bool.rs:93:5 | LL | / match test { LL | | -LL | | LL | | false if option == 5 => println!("Hello"), LL | | _ => (), LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if !test && option == 5 { println!("Hello") }` error: `match` on a boolean expression - --> tests/ui/match_bool.rs:110:5 + --> tests/ui/match_bool.rs:99:5 | LL | / match test { LL | | -LL | | LL | | false if option == 5 => (), LL | | _ => println!("Hello"), LL | | }; | |_____^ help: consider using an `if`/`else` expression: `if !(!test && option == 5) { println!("Hello") }` error: `match` on a boolean expression - --> tests/ui/match_bool.rs:119:5 + --> tests/ui/match_bool.rs:107:5 | LL | / match true { LL | | -LL | | LL | | true => 'a: { -... | +LL | | break 'a; +LL | | }, LL | | _ => (), LL | | } | |_____^ diff --git a/tests/ui/match_on_vec_items.rs b/tests/ui/match_on_vec_items.rs index 1b7ce69f3ae73..f3174ec9734df 100644 --- a/tests/ui/match_on_vec_items.rs +++ b/tests/ui/match_on_vec_items.rs @@ -8,9 +8,7 @@ fn match_with_wildcard() { // Lint, may panic match arr[idx] { - //~^ match_on_vec_items - - + //~^ match_on_vec_items 0 => println!("0"), 1 => println!("1"), _ => {}, @@ -18,8 +16,7 @@ fn match_with_wildcard() { // Lint, may panic match arr[range] { - //~^ match_on_vec_items - + //~^ match_on_vec_items [0, 1] => println!("0 1"), [1, 2] => println!("1 2"), _ => {}, @@ -33,8 +30,7 @@ fn match_without_wildcard() { // Lint, may panic match arr[idx] { - //~^ match_on_vec_items - + //~^ match_on_vec_items 0 => println!("0"), 1 => println!("1"), num => {}, @@ -42,8 +38,7 @@ fn match_without_wildcard() { // Lint, may panic match arr[range] { - //~^ match_on_vec_items - + //~^ match_on_vec_items [0, 1] => println!("0 1"), [1, 2] => println!("1 2"), [ref sub @ ..] => {}, @@ -57,8 +52,7 @@ fn match_wildcard_and_action() { // Lint, may panic match arr[idx] { - //~^ match_on_vec_items - + //~^ match_on_vec_items 0 => println!("0"), 1 => println!("1"), _ => println!("Hello, World!"), @@ -66,8 +60,7 @@ fn match_wildcard_and_action() { // Lint, may panic match arr[range] { - //~^ match_on_vec_items - + //~^ match_on_vec_items [0, 1] => println!("0 1"), [1, 2] => println!("1 2"), _ => println!("Hello, World!"), @@ -81,8 +74,7 @@ fn match_vec_ref() { // Lint, may panic match arr[idx] { - //~^ match_on_vec_items - + //~^ match_on_vec_items 0 => println!("0"), 1 => println!("1"), _ => {}, @@ -90,8 +82,7 @@ fn match_vec_ref() { // Lint, may panic match arr[range] { - //~^ match_on_vec_items - + //~^ match_on_vec_items [0, 1] => println!("0 1"), [1, 2] => println!("1 2"), _ => {}, diff --git a/tests/ui/match_on_vec_items.stderr b/tests/ui/match_on_vec_items.stderr index b00b2cb662a05..ae79e1305f7fd 100644 --- a/tests/ui/match_on_vec_items.stderr +++ b/tests/ui/match_on_vec_items.stderr @@ -8,43 +8,43 @@ LL | match arr[idx] { = help: to override `-D warnings` add `#[allow(clippy::match_on_vec_items)]` error: indexing into a vector may panic - --> tests/ui/match_on_vec_items.rs:20:11 + --> tests/ui/match_on_vec_items.rs:18:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> tests/ui/match_on_vec_items.rs:35:11 + --> tests/ui/match_on_vec_items.rs:32:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> tests/ui/match_on_vec_items.rs:44:11 + --> tests/ui/match_on_vec_items.rs:40:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> tests/ui/match_on_vec_items.rs:59:11 + --> tests/ui/match_on_vec_items.rs:54:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> tests/ui/match_on_vec_items.rs:68:11 + --> tests/ui/match_on_vec_items.rs:62:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` error: indexing into a vector may panic - --> tests/ui/match_on_vec_items.rs:83:11 + --> tests/ui/match_on_vec_items.rs:76:11 | LL | match arr[idx] { | ^^^^^^^^ help: try: `arr.get(idx)` error: indexing into a vector may panic - --> tests/ui/match_on_vec_items.rs:92:11 + --> tests/ui/match_on_vec_items.rs:84:11 | LL | match arr[range] { | ^^^^^^^^^^ help: try: `arr.get(range)` diff --git a/tests/ui/match_overlapping_arm.rs b/tests/ui/match_overlapping_arm.rs index 3885731264f7e..176287e3d2e0c 100644 --- a/tests/ui/match_overlapping_arm.rs +++ b/tests/ui/match_overlapping_arm.rs @@ -8,7 +8,6 @@ fn overlapping() { match 42 { 0..=10 => println!("0..=10"), //~^ match_overlapping_arm - 0..=11 => println!("0..=11"), _ => (), } @@ -16,7 +15,6 @@ fn overlapping() { match 42 { 0..=5 => println!("0..=5"), //~^ match_overlapping_arm - 6..=7 => println!("6..=7"), FOO..=11 => println!("FOO..=11"), _ => (), @@ -55,7 +53,6 @@ fn overlapping() { match 42 { 0..11 => println!("0..11"), //~^ match_overlapping_arm - 0..=11 => println!("0..=11"), _ => (), } @@ -82,14 +79,12 @@ fn overlapping() { 5..14 => println!("5..14"), 0..=10 => println!("0..=10"), //~^ match_overlapping_arm - _ => (), } match 42 { 0..7 => println!("0..7"), //~^ match_overlapping_arm - 0..=10 => println!("0..=10"), _ => (), } @@ -103,7 +98,6 @@ fn overlapping() { match 42 { ..=23 => println!("..=23"), //~^ match_overlapping_arm - ..26 => println!("..26"), _ => (), } @@ -114,7 +108,6 @@ fn overlapping() { 0..=20 => (), 21..=30 => (), //~^ match_overlapping_arm - 21..=40 => (), _ => (), } @@ -130,7 +123,6 @@ fn overlapping() { match 42u128 { 0..=0x0000_0000_0000_00ff => (), //~^ match_overlapping_arm - 0..=0x0000_0000_0000_ffff => (), 0..=0x0000_0000_ffff_ffff => (), 0..=0xffff_ffff_ffff_ffff => (), diff --git a/tests/ui/match_overlapping_arm.stderr b/tests/ui/match_overlapping_arm.stderr index cc928b4066a98..a60a09a079907 100644 --- a/tests/ui/match_overlapping_arm.stderr +++ b/tests/ui/match_overlapping_arm.stderr @@ -5,7 +5,7 @@ LL | 0..=10 => println!("0..=10"), | ^^^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:12:9 + --> tests/ui/match_overlapping_arm.rs:11:9 | LL | 0..=11 => println!("0..=11"), | ^^^^^^ @@ -13,85 +13,85 @@ LL | 0..=11 => println!("0..=11"), = help: to override `-D warnings` add `#[allow(clippy::match_overlapping_arm)]` error: some ranges overlap - --> tests/ui/match_overlapping_arm.rs:17:9 + --> tests/ui/match_overlapping_arm.rs:16:9 | LL | 0..=5 => println!("0..=5"), | ^^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:21:9 + --> tests/ui/match_overlapping_arm.rs:19:9 | LL | FOO..=11 => println!("FOO..=11"), | ^^^^^^^^ error: some ranges overlap - --> tests/ui/match_overlapping_arm.rs:56:9 + --> tests/ui/match_overlapping_arm.rs:54:9 | LL | 0..11 => println!("0..11"), | ^^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:59:9 + --> tests/ui/match_overlapping_arm.rs:56:9 | LL | 0..=11 => println!("0..=11"), | ^^^^^^ error: some ranges overlap - --> tests/ui/match_overlapping_arm.rs:83:9 + --> tests/ui/match_overlapping_arm.rs:80:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:82:9 + --> tests/ui/match_overlapping_arm.rs:79:9 | LL | 5..14 => println!("5..14"), | ^^^^^ error: some ranges overlap - --> tests/ui/match_overlapping_arm.rs:90:9 + --> tests/ui/match_overlapping_arm.rs:86:9 | LL | 0..7 => println!("0..7"), | ^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:93:9 + --> tests/ui/match_overlapping_arm.rs:88:9 | LL | 0..=10 => println!("0..=10"), | ^^^^^^ error: some ranges overlap - --> tests/ui/match_overlapping_arm.rs:104:9 + --> tests/ui/match_overlapping_arm.rs:99:9 | LL | ..=23 => println!("..=23"), | ^^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:107:9 + --> tests/ui/match_overlapping_arm.rs:101:9 | LL | ..26 => println!("..26"), | ^^^^ error: some ranges overlap - --> tests/ui/match_overlapping_arm.rs:115:9 + --> tests/ui/match_overlapping_arm.rs:109:9 | LL | 21..=30 => (), | ^^^^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:118:9 + --> tests/ui/match_overlapping_arm.rs:111:9 | LL | 21..=40 => (), | ^^^^^^^ error: some ranges overlap - --> tests/ui/match_overlapping_arm.rs:131:9 + --> tests/ui/match_overlapping_arm.rs:124:9 | LL | 0..=0x0000_0000_0000_00ff => (), | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: overlaps with this - --> tests/ui/match_overlapping_arm.rs:134:9 + --> tests/ui/match_overlapping_arm.rs:126:9 | LL | 0..=0x0000_0000_0000_ffff => (), | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_ref_pats.fixed b/tests/ui/match_ref_pats.fixed index 8ada289851982..8add3da0c99f0 100644 --- a/tests/ui/match_ref_pats.fixed +++ b/tests/ui/match_ref_pats.fixed @@ -6,7 +6,7 @@ fn ref_pats() { { let v = &Some(0); match *v { - //~^ match_ref_pats + //~^ match_ref_pats Some(v) => println!("{:?}", v), None => println!("none"), } @@ -24,7 +24,7 @@ fn ref_pats() { // Special case: using `&` both in expr and pats. let w = Some(0); match w { - //~^ match_ref_pats + //~^ match_ref_pats Some(v) => println!("{:?}", v), None => println!("none"), } @@ -37,13 +37,13 @@ fn ref_pats() { let a = &Some(0); if a.is_none() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching println!("none"); } let b = Some(0); if b.is_none() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching println!("none"); } } @@ -104,7 +104,7 @@ mod issue_7740 { fn issue_7740() { // Issue #7740 match *foobar_variant!(0) { - //~^ match_ref_pats + //~^ match_ref_pats FooBar::Foo => println!("Foo"), FooBar::Bar => println!("Bar"), FooBar::FooBar => println!("FooBar"), diff --git a/tests/ui/match_ref_pats.rs b/tests/ui/match_ref_pats.rs index cac6240bde314..07889b0dfc243 100644 --- a/tests/ui/match_ref_pats.rs +++ b/tests/ui/match_ref_pats.rs @@ -6,7 +6,7 @@ fn ref_pats() { { let v = &Some(0); match v { - //~^ match_ref_pats + //~^ match_ref_pats &Some(v) => println!("{:?}", v), &None => println!("none"), } @@ -24,7 +24,7 @@ fn ref_pats() { // Special case: using `&` both in expr and pats. let w = Some(0); match &w { - //~^ match_ref_pats + //~^ match_ref_pats &Some(v) => println!("{:?}", v), &None => println!("none"), } @@ -37,13 +37,13 @@ fn ref_pats() { let a = &Some(0); if let &None = a { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching println!("none"); } let b = Some(0); if let &None = &b { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching println!("none"); } } @@ -104,7 +104,7 @@ mod issue_7740 { fn issue_7740() { // Issue #7740 match foobar_variant!(0) { - //~^ match_ref_pats + //~^ match_ref_pats &FooBar::Foo => println!("Foo"), &FooBar::Bar => println!("Bar"), &FooBar::FooBar => println!("FooBar"), diff --git a/tests/ui/match_result_ok.fixed b/tests/ui/match_result_ok.fixed index 2032394f0e928..0e630e6a29045 100644 --- a/tests/ui/match_result_ok.fixed +++ b/tests/ui/match_result_ok.fixed @@ -49,7 +49,7 @@ impl Wat { fn base_1(x: i32) { let mut wat = Wat { counter: x }; while let Ok(a) = wat.next() { - //~^ match_result_ok + //~^ match_result_ok println!("{}", a); } } diff --git a/tests/ui/match_result_ok.rs b/tests/ui/match_result_ok.rs index c15e32d112d4f..63bf6e8ab5087 100644 --- a/tests/ui/match_result_ok.rs +++ b/tests/ui/match_result_ok.rs @@ -49,7 +49,7 @@ impl Wat { fn base_1(x: i32) { let mut wat = Wat { counter: x }; while let Some(a) = wat.next().ok() { - //~^ match_result_ok + //~^ match_result_ok println!("{}", a); } } diff --git a/tests/ui/match_same_arms.rs b/tests/ui/match_same_arms.rs index 073c66930357e..55441948e91b6 100644 --- a/tests/ui/match_same_arms.rs +++ b/tests/ui/match_same_arms.rs @@ -9,37 +9,36 @@ pub enum Abc { fn match_same_arms() { let _ = match Abc::A { -Abc::A => 0, -//~^ match_same_arms + Abc::A => 0, + //~^ match_same_arms Abc::B => 1, _ => 0, }; match (1, 2, 3) { -(1, .., 3) => 42, -//~^ match_same_arms + (1, .., 3) => 42, + //~^ match_same_arms (.., 3) => 42, _ => 0, }; let _ = match 42 { 42 => 1, -51 => 1, -//~^ match_same_arms -41 => 2, -//~^ match_same_arms + 51 => 1, + //~^ match_same_arms + 41 => 2, + //~^ match_same_arms 52 => 2, _ => 0, }; let _ = match 42 { 1 => 2, -2 => 2, -//~^ match_same_arms -//~| match_same_arms - -3 => 2, -//~^ match_same_arms + 2 => 2, + //~^ match_same_arms + //~| match_same_arms + 3 => 2, + //~^ match_same_arms 4 => 3, _ => 0, }; @@ -58,7 +57,6 @@ mod issue4244 { CommandInfo::BuiltIn { name, .. } => name.to_string(), CommandInfo::External { name, .. } => name.to_string(), //~^ match_same_arms - } } } diff --git a/tests/ui/match_same_arms.stderr b/tests/ui/match_same_arms.stderr index a269c4f392676..3744b83d89cc8 100644 --- a/tests/ui/match_same_arms.stderr +++ b/tests/ui/match_same_arms.stderr @@ -1,9 +1,9 @@ error: this match arm has an identical body to the `_` wildcard arm - --> tests/ui/match_same_arms.rs:12:1 + --> tests/ui/match_same_arms.rs:12:9 | -LL | / Abc::A => 0, +LL | / Abc::A => 0, LL | | - | |_^ help: try removing the arm + | |________^ help: try removing the arm | = help: or try changing either arm body note: `_` wildcard arm here @@ -15,66 +15,66 @@ LL | _ => 0, = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms.rs:19:1 + --> tests/ui/match_same_arms.rs:19:9 | -LL | (1, .., 3) => 42, - | ^^^^^^^^^^^^^^^^ +LL | (1, .., 3) => 42, + | ^^^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | -LL ~ (1, .., 3) | (.., 3) => 42, +LL ~ (1, .., 3) | (.., 3) => 42, LL | LL ~ _ => 0, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms.rs:27:1 + --> tests/ui/match_same_arms.rs:27:9 | -LL | 51 => 1, - | ^^^^^^^ +LL | 51 => 1, + | ^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL - 42 => 1, -LL - 51 => 1, +LL - 51 => 1, LL + 51 | 42 => 1, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms.rs:29:1 + --> tests/ui/match_same_arms.rs:29:9 | -LL | 41 => 2, - | ^^^^^^^ +LL | 41 => 2, + | ^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | -LL ~ 41 | 52 => 2, +LL ~ 41 | 52 => 2, LL | LL ~ _ => 0, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms.rs:37:1 + --> tests/ui/match_same_arms.rs:37:9 | -LL | 2 => 2, - | ^^^^^^ +LL | 2 => 2, + | ^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL - 1 => 2, -LL - 2 => 2, +LL - 2 => 2, LL + 2 | 1 => 2, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms.rs:41:1 + --> tests/ui/match_same_arms.rs:40:9 | -LL | 3 => 2, - | ^^^^^^ +LL | 3 => 2, + | ^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm @@ -82,24 +82,26 @@ help: or try merging the arm patterns and removing the obsolete arm LL ~ 2 => 2, LL | LL | -LL | -LL ~ 3 | 1 => 2, +LL ~ 3 | 1 => 2, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms.rs:37:1 + --> tests/ui/match_same_arms.rs:37:9 | -LL | 2 => 2, - | ^^^^^^ +LL | 2 => 2, + | ^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | -LL ~ 2 | 3 => 2, +LL ~ 2 | 3 => 2, +LL | +LL | +LL ~ | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms.rs:59:17 + --> tests/ui/match_same_arms.rs:58:17 | LL | CommandInfo::External { name, .. } => name.to_string(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms2.fixed b/tests/ui/match_same_arms2.fixed index 855c3287532c8..0d93e2c728d75 100644 --- a/tests/ui/match_same_arms2.fixed +++ b/tests/ui/match_same_arms2.fixed @@ -26,16 +26,15 @@ fn match_same_arms() { }, }; - let _ = match 42 { 51 | 42 => foo(), -//~^ match_same_arms + //~^ match_same_arms _ => true, }; let _ = match Some(42) { None | Some(_) => 24, -//~^ match_same_arms + //~^ match_same_arms }; let _ = match Some(42) { @@ -57,7 +56,7 @@ fn match_same_arms() { match (Some(42), Some(42)) { (None, Some(a)) | (Some(a), None) => bar(a), -//~^ match_same_arms + //~^ match_same_arms _ => (), } @@ -71,13 +70,13 @@ fn match_same_arms() { let _ = match (Some(42), Some(42)) { (None, Some(a)) | (Some(a), None) if a == 42 => a, -//~^ match_same_arms + //~^ match_same_arms _ => 0, }; match (Some(42), Some(42)) { -(Some(a), ..) | (.., Some(a)) => bar(a), -//~^ match_same_arms + (Some(a), ..) | (.., Some(a)) => bar(a), + //~^ match_same_arms _ => (), } @@ -110,8 +109,8 @@ fn match_same_arms() { } match (x, Some(1i32)) { -(Ok(x), Some(_)) | (Ok(_), Some(x)) => println!("ok {}", x), -//~^ match_same_arms + (Ok(x), Some(_)) | (Ok(_), Some(x)) => println!("ok {}", x), + //~^ match_same_arms _ => println!("err"), } @@ -126,7 +125,7 @@ fn match_same_arms() { match x { Ok(_tmp) => println!("ok"), Ok(_) | Ok(3) => println!("ok"), -//~^ match_same_arms + //~^ match_same_arms Err(_) => { unreachable!(); }, @@ -159,7 +158,6 @@ fn match_same_arms() { }, } - match_expr_like_matches_macro_priority(); } @@ -202,8 +200,8 @@ fn main() { // Suggest moving `Foo::Z(_)` up. let _ = match Foo::X(0) { -Foo::X(0) | Foo::Z(_) => 1, -//~^ match_same_arms + Foo::X(0) | Foo::Z(_) => 1, + //~^ match_same_arms Foo::X(_) | Foo::Y(_) => 2, _ => 0, }; @@ -211,8 +209,8 @@ Foo::X(0) | Foo::Z(_) => 1, // Suggest moving `Foo::X(0)` down. let _ = match Foo::X(0) { Foo::Y(_) | Foo::Z(0) => 2, -Foo::Z(_) | Foo::X(0) => 1, -//~^ match_same_arms + Foo::Z(_) | Foo::X(0) => 1, + //~^ match_same_arms _ => 0, }; @@ -234,8 +232,8 @@ Foo::Z(_) | Foo::X(0) => 1, let _ = match None { Some(Bar { y: 10, z: 0, .. }) => 2, None => 50, -Some(Bar { y: 0, x: 5, .. }) | Some(Bar { x: 0, y: 5, .. }) => 1, -//~^ match_same_arms + Some(Bar { y: 0, x: 5, .. }) | Some(Bar { x: 0, y: 5, .. }) => 1, + //~^ match_same_arms _ => 200, }; @@ -266,7 +264,6 @@ mod with_lifetime { match *self { MaybeStaticStr::Borrowed(s) | MaybeStaticStr::Static(s) => s, //~^ match_same_arms - } } } diff --git a/tests/ui/match_same_arms2.rs b/tests/ui/match_same_arms2.rs index 73a4fd432551f..b0ebc4784f331 100644 --- a/tests/ui/match_same_arms2.rs +++ b/tests/ui/match_same_arms2.rs @@ -35,18 +35,17 @@ fn match_same_arms() { }, }; - let _ = match 42 { 42 => foo(), -51 => foo(), -//~^ match_same_arms + 51 => foo(), + //~^ match_same_arms _ => true, }; let _ = match Some(42) { Some(_) => 24, -None => 24, -//~^ match_same_arms + None => 24, + //~^ match_same_arms }; let _ = match Some(42) { @@ -68,8 +67,8 @@ None => 24, match (Some(42), Some(42)) { (Some(a), None) => bar(a), -(None, Some(a)) => bar(a), -//~^ match_same_arms + (None, Some(a)) => bar(a), + //~^ match_same_arms _ => (), } @@ -83,14 +82,14 @@ None => 24, let _ = match (Some(42), Some(42)) { (Some(a), None) if a == 42 => a, -(None, Some(a)) if a == 42 => a, -//~^ match_same_arms + (None, Some(a)) if a == 42 => a, + //~^ match_same_arms _ => 0, }; match (Some(42), Some(42)) { -(Some(a), ..) => bar(a), -//~^ match_same_arms + (Some(a), ..) => bar(a), + //~^ match_same_arms (.., Some(a)) => bar(a), _ => (), } @@ -124,8 +123,8 @@ None => 24, } match (x, Some(1i32)) { -(Ok(x), Some(_)) => println!("ok {}", x), -//~^ match_same_arms + (Ok(x), Some(_)) => println!("ok {}", x), + //~^ match_same_arms (Ok(_), Some(x)) => println!("ok {}", x), _ => println!("err"), } @@ -141,8 +140,8 @@ None => 24, match x { Ok(_tmp) => println!("ok"), Ok(3) => println!("ok"), -Ok(_) => println!("ok"), -//~^ match_same_arms + Ok(_) => println!("ok"), + //~^ match_same_arms Err(_) => { unreachable!(); }, @@ -178,7 +177,6 @@ Ok(_) => println!("ok"), }, } - match_expr_like_matches_macro_priority(); } @@ -221,8 +219,8 @@ fn main() { // Suggest moving `Foo::Z(_)` up. let _ = match Foo::X(0) { -Foo::X(0) => 1, -//~^ match_same_arms + Foo::X(0) => 1, + //~^ match_same_arms Foo::X(_) | Foo::Y(_) => 2, Foo::Z(_) => 1, _ => 0, @@ -232,8 +230,8 @@ Foo::X(0) => 1, let _ = match Foo::X(0) { Foo::X(0) => 1, Foo::Y(_) | Foo::Z(0) => 2, -Foo::Z(_) => 1, -//~^ match_same_arms + Foo::Z(_) => 1, + //~^ match_same_arms _ => 0, }; @@ -256,8 +254,8 @@ Foo::Z(_) => 1, Some(Bar { x: 0, y: 5, .. }) => 1, Some(Bar { y: 10, z: 0, .. }) => 2, None => 50, -Some(Bar { y: 0, x: 5, .. }) => 1, -//~^ match_same_arms + Some(Bar { y: 0, x: 5, .. }) => 1, + //~^ match_same_arms _ => 200, }; @@ -290,7 +288,6 @@ mod with_lifetime { MaybeStaticStr::Static(s) => s, MaybeStaticStr::Borrowed(s) => s, //~^ match_same_arms - } } } diff --git a/tests/ui/match_same_arms2.stderr b/tests/ui/match_same_arms2.stderr index c67ac5475aaef..21a8743cc3242 100644 --- a/tests/ui/match_same_arms2.stderr +++ b/tests/ui/match_same_arms2.stderr @@ -26,105 +26,105 @@ LL | | }, = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:41:1 + --> tests/ui/match_same_arms2.rs:40:9 | -LL | 51 => foo(), - | ^^^^^^^^^^^ +LL | 51 => foo(), + | ^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL - 42 => foo(), -LL - 51 => foo(), +LL - 51 => foo(), LL + 51 | 42 => foo(), | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:48:1 + --> tests/ui/match_same_arms2.rs:47:9 | -LL | None => 24, - | ^^^^^^^^^^ +LL | None => 24, + | ^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL - Some(_) => 24, -LL - None => 24, +LL - None => 24, LL + None | Some(_) => 24, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:71:1 + --> tests/ui/match_same_arms2.rs:70:9 | -LL | (None, Some(a)) => bar(a), - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | (None, Some(a)) => bar(a), + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL - (Some(a), None) => bar(a), -LL - (None, Some(a)) => bar(a), +LL - (None, Some(a)) => bar(a), LL + (None, Some(a)) | (Some(a), None) => bar(a), | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:86:1 + --> tests/ui/match_same_arms2.rs:85:9 | -LL | (None, Some(a)) if a == 42 => a, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | (None, Some(a)) if a == 42 => a, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL - (Some(a), None) if a == 42 => a, -LL - (None, Some(a)) if a == 42 => a, +LL - (None, Some(a)) if a == 42 => a, LL + (None, Some(a)) | (Some(a), None) if a == 42 => a, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:92:1 + --> tests/ui/match_same_arms2.rs:91:9 | -LL | (Some(a), ..) => bar(a), - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | (Some(a), ..) => bar(a), + | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | -LL ~ (Some(a), ..) | (.., Some(a)) => bar(a), +LL ~ (Some(a), ..) | (.., Some(a)) => bar(a), LL | LL ~ _ => (), | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:127:1 + --> tests/ui/match_same_arms2.rs:126:9 | -LL | (Ok(x), Some(_)) => println!("ok {}", x), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | (Ok(x), Some(_)) => println!("ok {}", x), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | -LL ~ (Ok(x), Some(_)) | (Ok(_), Some(x)) => println!("ok {}", x), +LL ~ (Ok(x), Some(_)) | (Ok(_), Some(x)) => println!("ok {}", x), LL | LL ~ _ => println!("err"), | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:144:1 + --> tests/ui/match_same_arms2.rs:143:9 | -LL | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL - Ok(3) => println!("ok"), -LL - Ok(_) => println!("ok"), +LL - Ok(_) => println!("ok"), LL + Ok(_) | Ok(3) => println!("ok"), | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:172:9 + --> tests/ui/match_same_arms2.rs:171:9 | LL | / 1 => { LL | | empty!(0); @@ -142,49 +142,49 @@ LL + 1 | 0 => { | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:224:1 + --> tests/ui/match_same_arms2.rs:222:9 | -LL | Foo::X(0) => 1, - | ^^^^^^^^^^^^^^ +LL | Foo::X(0) => 1, + | ^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | -LL ~ Foo::X(0) | Foo::Z(_) => 1, +LL ~ Foo::X(0) | Foo::Z(_) => 1, LL | LL | Foo::X(_) | Foo::Y(_) => 2, LL ~ _ => 0, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:235:1 + --> tests/ui/match_same_arms2.rs:233:9 | -LL | Foo::Z(_) => 1, - | ^^^^^^^^^^^^^^ +LL | Foo::Z(_) => 1, + | ^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL ~ Foo::Y(_) | Foo::Z(0) => 2, -LL ~ Foo::Z(_) | Foo::X(0) => 1, +LL ~ Foo::Z(_) | Foo::X(0) => 1, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:259:1 + --> tests/ui/match_same_arms2.rs:257:9 | -LL | Some(Bar { y: 0, x: 5, .. }) => 1, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | Some(Bar { y: 0, x: 5, .. }) => 1, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try changing either arm body help: or try merging the arm patterns and removing the obsolete arm | LL ~ Some(Bar { y: 10, z: 0, .. }) => 2, LL | None => 50, -LL ~ Some(Bar { y: 0, x: 5, .. }) | Some(Bar { x: 0, y: 5, .. }) => 1, +LL ~ Some(Bar { y: 0, x: 5, .. }) | Some(Bar { x: 0, y: 5, .. }) => 1, | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:274:9 + --> tests/ui/match_same_arms2.rs:272:9 | LL | 1 => cfg!(not_enable), | ^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +198,7 @@ LL + 1 | 0 => cfg!(not_enable), | error: this match arm has an identical body to another arm - --> tests/ui/match_same_arms2.rs:291:17 + --> tests/ui/match_same_arms2.rs:289:17 | LL | MaybeStaticStr::Borrowed(s) => s, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/match_same_arms_non_exhaustive.fixed b/tests/ui/match_same_arms_non_exhaustive.fixed index 71041cff8d0a8..0c9398933b80e 100644 --- a/tests/ui/match_same_arms_non_exhaustive.fixed +++ b/tests/ui/match_same_arms_non_exhaustive.fixed @@ -42,7 +42,6 @@ pub fn g(x: Ordering) { Ordering::Release => println!("release"), Ordering::Acquire => println!("acquire"), //~^ match_same_arms - _ => repeat(), } } @@ -56,7 +55,6 @@ mod g { Ordering::Release => println!("release"), Ordering::Acquire => println!("acquire"), //~^ match_same_arms - _ => repeat(), } } diff --git a/tests/ui/match_same_arms_non_exhaustive.rs b/tests/ui/match_same_arms_non_exhaustive.rs index 45dc5d78883b4..304a9e5c28e76 100644 --- a/tests/ui/match_same_arms_non_exhaustive.rs +++ b/tests/ui/match_same_arms_non_exhaustive.rs @@ -43,7 +43,6 @@ pub fn g(x: Ordering) { Ordering::Acquire => println!("acquire"), Ordering::AcqRel | Ordering::SeqCst => repeat(), //~^ match_same_arms - _ => repeat(), } } @@ -58,7 +57,6 @@ mod g { Ordering::Acquire => println!("acquire"), Ordering::AcqRel | Ordering::SeqCst => repeat(), //~^ match_same_arms - _ => repeat(), } } diff --git a/tests/ui/match_same_arms_non_exhaustive.stderr b/tests/ui/match_same_arms_non_exhaustive.stderr index 1033203c72372..aa7f8c95dce84 100644 --- a/tests/ui/match_same_arms_non_exhaustive.stderr +++ b/tests/ui/match_same_arms_non_exhaustive.stderr @@ -7,7 +7,7 @@ LL | | | = help: or try changing either arm body note: `_` wildcard arm here - --> tests/ui/match_same_arms_non_exhaustive.rs:47:9 + --> tests/ui/match_same_arms_non_exhaustive.rs:46:9 | LL | _ => repeat(), | ^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | _ => repeat(), = help: to override `-D warnings` add `#[allow(clippy::match_same_arms)]` error: this match arm has an identical body to the `_` wildcard arm - --> tests/ui/match_same_arms_non_exhaustive.rs:59:13 + --> tests/ui/match_same_arms_non_exhaustive.rs:58:13 | LL | / Ordering::AcqRel | Ordering::SeqCst => repeat(), LL | | @@ -23,7 +23,7 @@ LL | | | = help: or try changing either arm body note: `_` wildcard arm here - --> tests/ui/match_same_arms_non_exhaustive.rs:62:13 + --> tests/ui/match_same_arms_non_exhaustive.rs:60:13 | LL | _ => repeat(), | ^^^^^^^^^^^^^ diff --git a/tests/ui/match_single_binding.rs b/tests/ui/match_single_binding.rs index 27fd7d601abf9..ada51254c6cdf 100644 --- a/tests/ui/match_single_binding.rs +++ b/tests/ui/match_single_binding.rs @@ -31,14 +31,14 @@ fn main() { let c = 3; // Lint match (a, b, c) { - //~^ match_single_binding + //~^ match_single_binding (x, y, z) => { println!("{} {} {}", x, y, z); }, } // Lint match (a, b, c) { - //~^ match_single_binding + //~^ match_single_binding (x, y, z) => println!("{} {} {}", x, y, z), } // Ok @@ -56,12 +56,12 @@ fn main() { } // Lint match a { - //~^ match_single_binding + //~^ match_single_binding _ => println!("whatever"), } // Lint match a { - //~^ match_single_binding + //~^ match_single_binding _ => { let x = 29; println!("x has a value of {}", x); @@ -69,7 +69,7 @@ fn main() { } // Lint match a { - //~^ match_single_binding + //~^ match_single_binding _ => { let e = 5 * a; if e >= 5 { @@ -80,29 +80,29 @@ fn main() { // Lint let p = Point { x: 0, y: 7 }; match p { - //~^ match_single_binding + //~^ match_single_binding Point { x, y } => println!("Coords: ({}, {})", x, y), } // Lint match p { - //~^ match_single_binding + //~^ match_single_binding Point { x: x1, y: y1 } => println!("Coords: ({}, {})", x1, y1), } // Lint let x = 5; match x { - //~^ match_single_binding + //~^ match_single_binding ref r => println!("Got a reference to {}", r), } // Lint let mut x = 5; match x { - //~^ match_single_binding + //~^ match_single_binding ref mut mr => println!("Got a mutable reference to {}", mr), } // Lint let product = match coords() { - //~^ match_single_binding + //~^ match_single_binding Point { x, y } => x * y, }; // Lint @@ -111,7 +111,7 @@ fn main() { let _ = v .iter() .map(|i| match i.unwrap() { - //~^ match_single_binding + //~^ match_single_binding unwrapped => unwrapped, }) .collect::>(); @@ -138,7 +138,7 @@ fn main() { // Lint let x = 1; match x { - //~^ match_single_binding + //~^ match_single_binding // => _ => println!("Not an array index start"), } @@ -148,7 +148,7 @@ fn issue_8723() { let (mut val, idx) = ("a b", 1); val = match val.split_at(idx) { - //~^ match_single_binding + //~^ match_single_binding (pre, suf) => { println!("{}", pre); suf @@ -162,14 +162,14 @@ fn side_effects() {} fn issue_9575() { let _ = || match side_effects() { - //~^ match_single_binding + //~^ match_single_binding _ => println!("Needs curlies"), }; } fn issue_9725(r: Option) { match r { - //~^ match_single_binding + //~^ match_single_binding x => match x { Some(_) => { println!("Some"); @@ -183,46 +183,46 @@ fn issue_9725(r: Option) { fn issue_10447() -> usize { match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => (), } let a = match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => (), }; match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => side_effects(), } let b = match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => side_effects(), }; match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => println!("1"), } let c = match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => println!("1"), }; let in_expr = [ match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => (), }, match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => side_effects(), }, match 1 { - //~^ match_single_binding + //~^ match_single_binding _ => println!("1"), }, ]; diff --git a/tests/ui/match_single_binding2.fixed b/tests/ui/match_single_binding2.fixed index 1d34f179ea4a6..988121f50d0fa 100644 --- a/tests/ui/match_single_binding2.fixed +++ b/tests/ui/match_single_binding2.fixed @@ -45,7 +45,7 @@ fn main() { // issue #7094 let x = 1; match x { - //~^ match_single_binding + //~^ match_single_binding 0 => 1, _ => 2, }; diff --git a/tests/ui/match_single_binding2.rs b/tests/ui/match_single_binding2.rs index 8c18d7c133c15..a4fb2bd6f3817 100644 --- a/tests/ui/match_single_binding2.rs +++ b/tests/ui/match_single_binding2.rs @@ -15,7 +15,7 @@ fn main() { fn size_hint(iter: &AppendIter) -> (usize, Option) { match &iter.inner { Some((iter, _item)) => match iter.size_hint() { - //~^ match_single_binding + //~^ match_single_binding (min, max) => (min.saturating_add(1), max.and_then(|max| max.checked_add(1))), }, None => (0, Some(0)), @@ -41,7 +41,7 @@ fn main() { // Lint (scrutinee has side effects) // issue #7094 match side_effects() { - //~^ match_single_binding + //~^ match_single_binding _ => println!("Side effects"), } @@ -49,7 +49,7 @@ fn main() { // issue #7094 let x = 1; match match x { - //~^ match_single_binding + //~^ match_single_binding 0 => 1, _ => 2, } { diff --git a/tests/ui/match_wild_err_arm.rs b/tests/ui/match_wild_err_arm.rs index f7f7c398d6472..d18d4047e2a64 100644 --- a/tests/ui/match_wild_err_arm.rs +++ b/tests/ui/match_wild_err_arm.rs @@ -22,8 +22,6 @@ fn match_wild_err_arm() { Ok(_) => println!("ok"), Err(_) => panic!("err"), //~^ match_wild_err_arm - - } match x { @@ -31,16 +29,13 @@ fn match_wild_err_arm() { Ok(_) => println!("ok"), Err(_) => panic!(), //~^ match_wild_err_arm - - } match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), Err(_) => { - //~^ match_wild_err_arm - + //~^ match_wild_err_arm panic!(); }, @@ -51,8 +46,6 @@ fn match_wild_err_arm() { Ok(_) => println!("ok"), Err(_e) => panic!(), //~^ match_wild_err_arm - - } // Allowed when used in `panic!`. diff --git a/tests/ui/match_wild_err_arm.stderr b/tests/ui/match_wild_err_arm.stderr index ec0ca602f5f97..fc65924f0873c 100644 --- a/tests/ui/match_wild_err_arm.stderr +++ b/tests/ui/match_wild_err_arm.stderr @@ -9,7 +9,7 @@ LL | Err(_) => panic!("err"), = help: to override `-D warnings` add `#[allow(clippy::match_wild_err_arm)]` error: `Err(_)` matches all errors - --> tests/ui/match_wild_err_arm.rs:32:9 + --> tests/ui/match_wild_err_arm.rs:30:9 | LL | Err(_) => panic!(), | ^^^^^^ @@ -17,7 +17,7 @@ LL | Err(_) => panic!(), = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable error: `Err(_)` matches all errors - --> tests/ui/match_wild_err_arm.rs:41:9 + --> tests/ui/match_wild_err_arm.rs:37:9 | LL | Err(_) => { | ^^^^^^ @@ -25,7 +25,7 @@ LL | Err(_) => { = note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable error: `Err(_e)` matches all errors - --> tests/ui/match_wild_err_arm.rs:52:9 + --> tests/ui/match_wild_err_arm.rs:47:9 | LL | Err(_e) => panic!(), | ^^^^^^^ diff --git a/tests/ui/mem_forget.rs b/tests/ui/mem_forget.rs index ad9bd079b98d0..b510af8ac6f16 100644 --- a/tests/ui/mem_forget.rs +++ b/tests/ui/mem_forget.rs @@ -14,25 +14,17 @@ fn main() { memstuff::forget(six); //~^ mem_forget - - let seven: Rc = Rc::new(7); std::mem::forget(seven); //~^ mem_forget - - let eight: Vec = vec![8]; forgetSomething(eight); //~^ mem_forget - - let string = String::new(); std::mem::forget(string); //~^ mem_forget - - std::mem::forget(7); } diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 4dd1efc1a2400..049db54a04b0e 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -9,7 +9,7 @@ LL | memstuff::forget(six); = help: to override `-D warnings` add `#[allow(clippy::mem_forget)]` error: usage of `mem::forget` on `Drop` type - --> tests/ui/mem_forget.rs:20:5 + --> tests/ui/mem_forget.rs:18:5 | LL | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | std::mem::forget(seven); = note: argument has type `std::rc::Rc` error: usage of `mem::forget` on `Drop` type - --> tests/ui/mem_forget.rs:26:5 + --> tests/ui/mem_forget.rs:22:5 | LL | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | forgetSomething(eight); = note: argument has type `std::vec::Vec` error: usage of `mem::forget` on type with `Drop` fields - --> tests/ui/mem_forget.rs:32:5 + --> tests/ui/mem_forget.rs:26:5 | LL | std::mem::forget(string); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index 98417df8c84be..fb4a367266d30 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -161,7 +161,7 @@ LL | let _ = std::mem::replace(&mut b.val, String::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut b.val)` error: replacing an `Option` with `Some(..)` - --> tests/ui/mem_replace.rs:138:20 + --> tests/ui/mem_replace.rs:164:20 | LL | let replaced = mem::replace(&mut an_option, Some(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::replace()` instead: `an_option.replace(1)` @@ -170,13 +170,13 @@ LL | let replaced = mem::replace(&mut an_option, Some(1)); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_option_with_some)]` error: replacing an `Option` with `Some(..)` - --> tests/ui/mem_replace.rs:142:20 + --> tests/ui/mem_replace.rs:168:20 | LL | let replaced = mem::replace(an_option, Some(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::replace()` instead: `an_option.replace(1)` error: replacing an `Option` with `Some(..)` - --> tests/ui/mem_replace.rs:147:20 + --> tests/ui/mem_replace.rs:173:20 | LL | let replaced = mem::replace(if b { &mut opt1 } else { &mut opt2 }, Some(1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::replace()` instead: `(if b { &mut opt1 } else { &mut opt2 }).replace(1)` diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index a7e37b2e8d233..85a4d59e5ca0a 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -101,7 +101,7 @@ struct BadNew; impl BadNew { fn new() -> i32 { - //~^ new_ret_no_self + //~^ new_ret_no_self 0 } } diff --git a/tests/ui/methods_unfixable.rs b/tests/ui/methods_unfixable.rs index a9881080d6f44..c19a769f79745 100644 --- a/tests/ui/methods_unfixable.rs +++ b/tests/ui/methods_unfixable.rs @@ -8,5 +8,4 @@ pub fn issue10029() { let iter = (0..10); let _ = iter.filter(|_| true).next(); //~^ filter_next - } diff --git a/tests/ui/min_ident_chars.rs b/tests/ui/min_ident_chars.rs index 5eae52d5c25c5..f473ac848a8ee 100644 --- a/tests/ui/min_ident_chars.rs +++ b/tests/ui/min_ident_chars.rs @@ -7,7 +7,7 @@ extern crate proc_macros; use proc_macros::{external, with_span}; struct A { -//~^ min_ident_chars + //~^ min_ident_chars a: u32, //~^ min_ident_chars i: u32, @@ -21,7 +21,7 @@ struct B(u32); //~^ min_ident_chars struct O { -//~^ min_ident_chars + //~^ min_ident_chars o: u32, //~^ min_ident_chars } @@ -29,7 +29,7 @@ struct O { struct i; enum C { -//~^ min_ident_chars + //~^ min_ident_chars D, //~^ min_ident_chars E, @@ -116,8 +116,8 @@ fn main() { fn b() {} //~^ min_ident_chars fn wrong_pythagoras(a: f32, b: f32) -> f32 { -//~^ min_ident_chars -//~| min_ident_chars + //~^ min_ident_chars + //~| min_ident_chars a * a + a * b } diff --git a/tests/ui/min_max.rs b/tests/ui/min_max.rs index 1b1a6a0eb10be..f3eeb85f20ed6 100644 --- a/tests/ui/min_max.rs +++ b/tests/ui/min_max.rs @@ -22,7 +22,6 @@ fn main() { min(1, max(3, x)); //~^ min_max - min(max(3, x), 1); //~^ min_max @@ -32,11 +31,9 @@ fn main() { max(3, min(x, 1)); //~^ min_max - my_max(3, my_min(x, 1)); //~^ min_max - min(3, max(1, x)); // ok, could be 1, 2 or 3 depending on x min(1, max(LARGE, x)); // no error, we don't lookup consts here @@ -51,7 +48,6 @@ fn main() { max(min(s, "Apple"), "Zoo"); //~^ min_max - max("Apple", min(s, "Zoo")); // ok let f = 3f32; @@ -64,7 +60,6 @@ fn main() { f.max(3f32).min(1f32); //~^ min_max - x.max(1).min(3); // ok x.min(3).max(1); // ok f.min(3f32).max(1f32); // ok @@ -80,7 +75,6 @@ fn main() { s.min("Apple").max("Zoo"); //~^ min_max - s.min("Zoo").max("Apple"); // ok let not_ord = NotOrd(1); diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index 91b3d722b3c68..84b4d37545529 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -8,73 +8,73 @@ LL | min(1, max(3, x)); = help: to override `-D warnings` add `#[allow(clippy::min_max)]` error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:26:5 + --> tests/ui/min_max.rs:25:5 | LL | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:29:5 + --> tests/ui/min_max.rs:28:5 | LL | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:32:5 + --> tests/ui/min_max.rs:31:5 | LL | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:36:5 + --> tests/ui/min_max.rs:34:5 | LL | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:48:5 + --> tests/ui/min_max.rs:45:5 | LL | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:51:5 + --> tests/ui/min_max.rs:48:5 | LL | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:58:5 + --> tests/ui/min_max.rs:54:5 | LL | x.min(1).max(3); | ^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:61:5 + --> tests/ui/min_max.rs:57:5 | LL | x.max(3).min(1); | ^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:64:5 + --> tests/ui/min_max.rs:60:5 | LL | f.max(3f32).min(1f32); | ^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:72:5 + --> tests/ui/min_max.rs:67:5 | LL | max(x.min(1), 3); | ^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:77:5 + --> tests/ui/min_max.rs:72:5 | LL | s.max("Zoo").min("Apple"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `min`/`max` combination leads to constant result - --> tests/ui/min_max.rs:80:5 + --> tests/ui/min_max.rs:75:5 | LL | s.min("Apple").max("Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/min_rust_version_attr.rs b/tests/ui/min_rust_version_attr.rs index 4793eb9726d67..4627bef28a29b 100644 --- a/tests/ui/min_rust_version_attr.rs +++ b/tests/ui/min_rust_version_attr.rs @@ -12,14 +12,12 @@ fn just_under_msrv() { fn meets_msrv() { let log2_10 = 3.321928094887362; //~^ approx_constant - } #[clippy::msrv = "1.44.0"] fn just_above_msrv() { let log2_10 = 3.321928094887362; //~^ approx_constant - } #[clippy::msrv = "1.42"] @@ -31,7 +29,6 @@ fn no_patch_under() { fn no_patch_meets() { let log2_10 = 3.321928094887362; //~^ approx_constant - } fn inner_attr_under() { @@ -43,7 +40,6 @@ fn inner_attr_meets() { #![clippy::msrv = "1.43"] let log2_10 = 3.321928094887362; //~^ approx_constant - } // https://github.com/rust-lang/rust-clippy/issues/6920 @@ -56,7 +52,6 @@ fn scoping() { let log2_10 = 3.321928094887362; //~^ approx_constant - mod a { #![clippy::msrv = "1.42.0"] @@ -64,7 +59,6 @@ fn scoping() { #![clippy::msrv = "1.43.0"] let log2_10 = 3.321928094887362; //~^ approx_constant - } fn should_not_warn() { diff --git a/tests/ui/min_rust_version_attr.stderr b/tests/ui/min_rust_version_attr.stderr index 6d4a8d9bd86e9..809b1cfe73bf0 100644 --- a/tests/ui/min_rust_version_attr.stderr +++ b/tests/ui/min_rust_version_attr.stderr @@ -8,7 +8,7 @@ LL | let log2_10 = 3.321928094887362; = note: `#[deny(clippy::approx_constant)]` on by default error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> tests/ui/min_rust_version_attr.rs:20:19 + --> tests/ui/min_rust_version_attr.rs:19:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> tests/ui/min_rust_version_attr.rs:32:19 + --> tests/ui/min_rust_version_attr.rs:30:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> tests/ui/min_rust_version_attr.rs:44:19 + --> tests/ui/min_rust_version_attr.rs:41:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> tests/ui/min_rust_version_attr.rs:56:19 + --> tests/ui/min_rust_version_attr.rs:52:19 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | let log2_10 = 3.321928094887362; = help: consider using the constant directly error: approximate value of `f{32, 64}::consts::LOG2_10` found - --> tests/ui/min_rust_version_attr.rs:65:27 + --> tests/ui/min_rust_version_attr.rs:60:27 | LL | let log2_10 = 3.321928094887362; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mismatching_type_param_order.rs b/tests/ui/mismatching_type_param_order.rs index 7e6044d0f5ff2..11ff865b583bf 100644 --- a/tests/ui/mismatching_type_param_order.rs +++ b/tests/ui/mismatching_type_param_order.rs @@ -12,13 +12,10 @@ fn main() { //~^ mismatching_type_param_order //~| mismatching_type_param_order - - // lint on the 2nd param impl Foo {} //~^ mismatching_type_param_order - // should not lint impl Foo {} @@ -32,8 +29,6 @@ fn main() { //~^ mismatching_type_param_order //~| mismatching_type_param_order - - struct Bar { x: i32, } @@ -53,9 +48,6 @@ fn main() { //~| mismatching_type_param_order //~| mismatching_type_param_order - - - // also works for unions union FooUnion where @@ -69,8 +61,6 @@ fn main() { //~^ mismatching_type_param_order //~| mismatching_type_param_order - - impl FooUnion where A: Copy, diff --git a/tests/ui/mismatching_type_param_order.stderr b/tests/ui/mismatching_type_param_order.stderr index 817ab8c997963..214d9d734d1bb 100644 --- a/tests/ui/mismatching_type_param_order.stderr +++ b/tests/ui/mismatching_type_param_order.stderr @@ -17,7 +17,7 @@ LL | impl Foo {} = help: try `B`, or a name that does not conflict with `Foo`'s generic params error: `Foo` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:18:23 + --> tests/ui/mismatching_type_param_order.rs:16:23 | LL | impl Foo {} | ^ @@ -25,7 +25,7 @@ LL | impl Foo {} = help: try `B`, or a name that does not conflict with `Foo`'s generic params error: `FooLifetime` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:31:44 + --> tests/ui/mismatching_type_param_order.rs:28:44 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | ^ @@ -33,7 +33,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} = help: try `A`, or a name that does not conflict with `FooLifetime`'s generic params error: `FooLifetime` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:31:47 + --> tests/ui/mismatching_type_param_order.rs:28:47 | LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} | ^ @@ -41,7 +41,7 @@ LL | impl<'m, 'l, B, A> FooLifetime<'m, 'l, B, A> {} = help: try `B`, or a name that does not conflict with `FooLifetime`'s generic params error: `FooEnum` has a similarly named generic type parameter `C` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:51:27 + --> tests/ui/mismatching_type_param_order.rs:46:27 | LL | impl FooEnum {} | ^ @@ -49,7 +49,7 @@ LL | impl FooEnum {} = help: try `A`, or a name that does not conflict with `FooEnum`'s generic params error: `FooEnum` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:51:30 + --> tests/ui/mismatching_type_param_order.rs:46:30 | LL | impl FooEnum {} | ^ @@ -57,7 +57,7 @@ LL | impl FooEnum {} = help: try `B`, or a name that does not conflict with `FooEnum`'s generic params error: `FooEnum` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:51:33 + --> tests/ui/mismatching_type_param_order.rs:46:33 | LL | impl FooEnum {} | ^ @@ -65,7 +65,7 @@ LL | impl FooEnum {} = help: try `C`, or a name that does not conflict with `FooEnum`'s generic params error: `FooUnion` has a similarly named generic type parameter `B` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:68:31 + --> tests/ui/mismatching_type_param_order.rs:60:31 | LL | impl FooUnion where A: Copy {} | ^ @@ -73,7 +73,7 @@ LL | impl FooUnion where A: Copy {} = help: try `A`, or a name that does not conflict with `FooUnion`'s generic params error: `FooUnion` has a similarly named generic type parameter `A` in its declaration, but in a different order - --> tests/ui/mismatching_type_param_order.rs:68:34 + --> tests/ui/mismatching_type_param_order.rs:60:34 | LL | impl FooUnion where A: Copy {} | ^ diff --git a/tests/ui/misnamed_getters.fixed b/tests/ui/misnamed_getters.fixed index 81af604e2e633..cada5307b1c8e 100644 --- a/tests/ui/misnamed_getters.fixed +++ b/tests/ui/misnamed_getters.fixed @@ -10,37 +10,36 @@ struct A { impl A { fn a(&self) -> &u8 { - //~^ misnamed_getters - + //~^ misnamed_getters &self.a } fn a_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } fn b(self) -> u8 { - //~^ misnamed_getters + //~^ misnamed_getters self.b } fn b_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } fn c(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.c } fn c_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.c } @@ -53,24 +52,24 @@ union B { impl B { unsafe fn a(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.a } unsafe fn a_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } unsafe fn b(self) -> u8 { - //~^ misnamed_getters + //~^ misnamed_getters self.b } unsafe fn b_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } @@ -84,24 +83,24 @@ impl B { } unsafe fn a_unchecked(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.a } unsafe fn a_unchecked_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } unsafe fn b_unchecked(self) -> u8 { - //~^ misnamed_getters + //~^ misnamed_getters self.b } unsafe fn b_unchecked_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } @@ -135,23 +134,23 @@ impl core::ops::DerefMut for D { impl D { fn a(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.a } fn a_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } fn d(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.d } fn d_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.d } diff --git a/tests/ui/misnamed_getters.rs b/tests/ui/misnamed_getters.rs index cb83ae02ccf15..f529c56b4717b 100644 --- a/tests/ui/misnamed_getters.rs +++ b/tests/ui/misnamed_getters.rs @@ -10,37 +10,36 @@ struct A { impl A { fn a(&self) -> &u8 { - //~^ misnamed_getters - + //~^ misnamed_getters &self.b } fn a_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } fn b(self) -> u8 { - //~^ misnamed_getters + //~^ misnamed_getters self.a } fn b_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } fn c(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.b } fn c_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } @@ -53,24 +52,24 @@ union B { impl B { unsafe fn a(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.b } unsafe fn a_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } unsafe fn b(self) -> u8 { - //~^ misnamed_getters + //~^ misnamed_getters self.a } unsafe fn b_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } @@ -84,24 +83,24 @@ impl B { } unsafe fn a_unchecked(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.b } unsafe fn a_unchecked_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } unsafe fn b_unchecked(self) -> u8 { - //~^ misnamed_getters + //~^ misnamed_getters self.a } unsafe fn b_unchecked_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.a } @@ -135,23 +134,23 @@ impl core::ops::DerefMut for D { impl D { fn a(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.b } fn a_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } fn d(&self) -> &u8 { - //~^ misnamed_getters + //~^ misnamed_getters &self.b } fn d_mut(&mut self) -> &mut u8 { - //~^ misnamed_getters + //~^ misnamed_getters &mut self.b } diff --git a/tests/ui/misnamed_getters.stderr b/tests/ui/misnamed_getters.stderr index e3ea40b7a94e0..5dd1d75bcf6f1 100644 --- a/tests/ui/misnamed_getters.stderr +++ b/tests/ui/misnamed_getters.stderr @@ -2,7 +2,8 @@ error: getter function appears to return the wrong field --> tests/ui/misnamed_getters.rs:12:5 | LL | / fn a(&self) -> &u8 { -... | +LL | | +LL | | LL | | &self.b | | ------- help: consider using: `&self.a` LL | | } @@ -12,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::misnamed_getters)]` error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:18:5 + --> tests/ui/misnamed_getters.rs:17:5 | LL | / fn a_mut(&mut self) -> &mut u8 { LL | | @@ -23,7 +24,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:24:5 + --> tests/ui/misnamed_getters.rs:23:5 | LL | / fn b(self) -> u8 { LL | | @@ -34,7 +35,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:30:5 + --> tests/ui/misnamed_getters.rs:29:5 | LL | / fn b_mut(&mut self) -> &mut u8 { LL | | @@ -45,7 +46,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:36:5 + --> tests/ui/misnamed_getters.rs:35:5 | LL | / fn c(&self) -> &u8 { LL | | @@ -56,7 +57,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:42:5 + --> tests/ui/misnamed_getters.rs:41:5 | LL | / fn c_mut(&mut self) -> &mut u8 { LL | | @@ -67,7 +68,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:55:5 + --> tests/ui/misnamed_getters.rs:54:5 | LL | / unsafe fn a(&self) -> &u8 { LL | | @@ -78,7 +79,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:60:5 + --> tests/ui/misnamed_getters.rs:59:5 | LL | / unsafe fn a_mut(&mut self) -> &mut u8 { LL | | @@ -89,7 +90,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:66:5 + --> tests/ui/misnamed_getters.rs:65:5 | LL | / unsafe fn b(self) -> u8 { LL | | @@ -100,7 +101,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:72:5 + --> tests/ui/misnamed_getters.rs:71:5 | LL | / unsafe fn b_mut(&mut self) -> &mut u8 { LL | | @@ -111,7 +112,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:86:5 + --> tests/ui/misnamed_getters.rs:85:5 | LL | / unsafe fn a_unchecked(&self) -> &u8 { LL | | @@ -122,7 +123,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:91:5 + --> tests/ui/misnamed_getters.rs:90:5 | LL | / unsafe fn a_unchecked_mut(&mut self) -> &mut u8 { LL | | @@ -133,7 +134,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:97:5 + --> tests/ui/misnamed_getters.rs:96:5 | LL | / unsafe fn b_unchecked(self) -> u8 { LL | | @@ -144,7 +145,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:103:5 + --> tests/ui/misnamed_getters.rs:102:5 | LL | / unsafe fn b_unchecked_mut(&mut self) -> &mut u8 { LL | | @@ -155,7 +156,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:137:5 + --> tests/ui/misnamed_getters.rs:136:5 | LL | / fn a(&self) -> &u8 { LL | | @@ -166,7 +167,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:142:5 + --> tests/ui/misnamed_getters.rs:141:5 | LL | / fn a_mut(&mut self) -> &mut u8 { LL | | @@ -177,7 +178,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:148:5 + --> tests/ui/misnamed_getters.rs:147:5 | LL | / fn d(&self) -> &u8 { LL | | @@ -188,7 +189,7 @@ LL | | } | |_____^ error: getter function appears to return the wrong field - --> tests/ui/misnamed_getters.rs:153:5 + --> tests/ui/misnamed_getters.rs:152:5 | LL | / fn d_mut(&mut self) -> &mut u8 { LL | | diff --git a/tests/ui/missing_asserts_for_indexing.fixed b/tests/ui/missing_asserts_for_indexing.fixed index ce23c45b52148..3bbafe0bba3fe 100644 --- a/tests/ui/missing_asserts_for_indexing.fixed +++ b/tests/ui/missing_asserts_for_indexing.fixed @@ -29,28 +29,24 @@ fn sum_with_assert_lt(v: &[u8]) -> u8 { assert!(v.len() > 4); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } fn sum_with_assert_le(v: &[u8]) -> u8 { assert!(v.len() > 4); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } fn sum_with_incorrect_assert_len(v: &[u8]) -> u8 { assert!(v.len() > 4); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } fn sum_with_incorrect_assert_len2(v: &[u8]) -> u8 { assert!(v.len() > 4); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } // ok, don't lint for single array access @@ -103,7 +99,6 @@ fn index_different_slices_wrong_len(v1: &[u8], v2: &[u8]) { let _ = v2[5] + v2[15]; //~^ missing_asserts_for_indexing - } fn index_different_slices_one_wrong_len(v1: &[u8], v2: &[u8]) { assert!(v1.len() > 12); diff --git a/tests/ui/missing_asserts_for_indexing.rs b/tests/ui/missing_asserts_for_indexing.rs index 2d129c6b7e2c8..f8ea0173c13fc 100644 --- a/tests/ui/missing_asserts_for_indexing.rs +++ b/tests/ui/missing_asserts_for_indexing.rs @@ -29,28 +29,24 @@ fn sum_with_assert_lt(v: &[u8]) -> u8 { assert!(v.len() < 5); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } fn sum_with_assert_le(v: &[u8]) -> u8 { assert!(v.len() <= 5); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } fn sum_with_incorrect_assert_len(v: &[u8]) -> u8 { assert!(v.len() > 3); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } fn sum_with_incorrect_assert_len2(v: &[u8]) -> u8 { assert!(v.len() >= 4); v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } // ok, don't lint for single array access @@ -103,7 +99,6 @@ fn index_different_slices_wrong_len(v1: &[u8], v2: &[u8]) { let _ = v2[5] + v2[15]; //~^ missing_asserts_for_indexing - } fn index_different_slices_one_wrong_len(v1: &[u8], v2: &[u8]) { assert!(v1.len() >= 12); diff --git a/tests/ui/missing_asserts_for_indexing.stderr b/tests/ui/missing_asserts_for_indexing.stderr index a1559d21150b7..5d30920ccf521 100644 --- a/tests/ui/missing_asserts_for_indexing.stderr +++ b/tests/ui/missing_asserts_for_indexing.stderr @@ -36,7 +36,7 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:37:5 + --> tests/ui/missing_asserts_for_indexing.rs:36:5 | LL | assert!(v.len() <= 5); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -44,34 +44,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:37:5 + --> tests/ui/missing_asserts_for_indexing.rs:36:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:37:12 + --> tests/ui/missing_asserts_for_indexing.rs:36:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:37:19 + --> tests/ui/missing_asserts_for_indexing.rs:36:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:37:26 + --> tests/ui/missing_asserts_for_indexing.rs:36:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:37:33 + --> tests/ui/missing_asserts_for_indexing.rs:36:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:44:5 + --> tests/ui/missing_asserts_for_indexing.rs:42:5 | LL | assert!(v.len() > 3); | -------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -79,34 +79,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:44:5 + --> tests/ui/missing_asserts_for_indexing.rs:42:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:44:12 + --> tests/ui/missing_asserts_for_indexing.rs:42:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:44:19 + --> tests/ui/missing_asserts_for_indexing.rs:42:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:44:26 + --> tests/ui/missing_asserts_for_indexing.rs:42:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:44:33 + --> tests/ui/missing_asserts_for_indexing.rs:42:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:51:5 + --> tests/ui/missing_asserts_for_indexing.rs:48:5 | LL | assert!(v.len() >= 4); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -114,34 +114,34 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:51:5 + --> tests/ui/missing_asserts_for_indexing.rs:48:5 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:51:12 + --> tests/ui/missing_asserts_for_indexing.rs:48:12 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:51:19 + --> tests/ui/missing_asserts_for_indexing.rs:48:19 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:51:26 + --> tests/ui/missing_asserts_for_indexing.rs:48:26 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:51:33 + --> tests/ui/missing_asserts_for_indexing.rs:48:33 | LL | v[0] + v[1] + v[2] + v[3] + v[4] | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:70:13 + --> tests/ui/missing_asserts_for_indexing.rs:66:13 | LL | assert!(v.len() >= 3); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 3)` @@ -152,19 +152,19 @@ LL | | let _ = v[1..4]; | |___________________^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:70:13 + --> tests/ui/missing_asserts_for_indexing.rs:66:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:73:13 + --> tests/ui/missing_asserts_for_indexing.rs:69:13 | LL | let _ = v[1..4]; | ^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:85:13 + --> tests/ui/missing_asserts_for_indexing.rs:81:13 | LL | assert!(v.len() >= 4); | --------------------- help: provide the highest index that is indexed with: `assert!(v.len() > 4)` @@ -175,19 +175,19 @@ LL | | let _ = v[1..=4]; | |____________________^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:85:13 + --> tests/ui/missing_asserts_for_indexing.rs:81:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:88:13 + --> tests/ui/missing_asserts_for_indexing.rs:84:13 | LL | let _ = v[1..=4]; | ^^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:101:13 + --> tests/ui/missing_asserts_for_indexing.rs:97:13 | LL | assert!(v1.len() >= 12); | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` @@ -196,19 +196,19 @@ LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:101:13 + --> tests/ui/missing_asserts_for_indexing.rs:97:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:101:21 + --> tests/ui/missing_asserts_for_indexing.rs:97:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:104:13 + --> tests/ui/missing_asserts_for_indexing.rs:100:13 | LL | assert!(v2.len() >= 15); | ----------------------- help: provide the highest index that is indexed with: `assert!(v2.len() > 15)` @@ -217,19 +217,19 @@ LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:104:13 + --> tests/ui/missing_asserts_for_indexing.rs:100:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:104:21 + --> tests/ui/missing_asserts_for_indexing.rs:100:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:111:13 + --> tests/ui/missing_asserts_for_indexing.rs:106:13 | LL | assert!(v1.len() >= 12); | ----------------------- help: provide the highest index that is indexed with: `assert!(v1.len() > 12)` @@ -238,19 +238,19 @@ LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:111:13 + --> tests/ui/missing_asserts_for_indexing.rs:106:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:111:21 + --> tests/ui/missing_asserts_for_indexing.rs:106:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:136:13 + --> tests/ui/missing_asserts_for_indexing.rs:131:13 | LL | assert!(v1.len() == 2); | ---------------------- help: provide the highest index that is indexed with: `assert!(v1.len() == 3)` @@ -259,24 +259,24 @@ LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:136:13 + --> tests/ui/missing_asserts_for_indexing.rs:131:13 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:136:21 + --> tests/ui/missing_asserts_for_indexing.rs:131:21 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:136:29 + --> tests/ui/missing_asserts_for_indexing.rs:131:29 | LL | let _ = v1[0] + v1[1] + v1[2]; | ^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times with an `assert` that does not cover the highest index - --> tests/ui/missing_asserts_for_indexing.rs:141:13 + --> tests/ui/missing_asserts_for_indexing.rs:136:13 | LL | assert!(2 == v3.len()); | ---------------------- help: provide the highest index that is indexed with: `assert!(v3.len() == 3)` @@ -285,17 +285,17 @@ LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^^^^^^^^^^^^^^^^^ | note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:141:13 + --> tests/ui/missing_asserts_for_indexing.rs:136:13 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:141:21 + --> tests/ui/missing_asserts_for_indexing.rs:136:21 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing.rs:141:29 + --> tests/ui/missing_asserts_for_indexing.rs:136:29 | LL | let _ = v3[0] + v3[1] + v3[2]; | ^^^^^ diff --git a/tests/ui/missing_asserts_for_indexing_unfixable.rs b/tests/ui/missing_asserts_for_indexing_unfixable.rs index c2083a90a19a1..a520151a2dd94 100644 --- a/tests/ui/missing_asserts_for_indexing_unfixable.rs +++ b/tests/ui/missing_asserts_for_indexing_unfixable.rs @@ -4,7 +4,6 @@ fn sum(v: &[u8]) -> u8 { v[0] + v[1] + v[2] + v[3] + v[4] //~^ missing_asserts_for_indexing - } fn subslice(v: &[u8]) { @@ -45,7 +44,6 @@ struct Foo<'a> { fn index_struct_field(f: &Foo<'_>) { let _ = f.v[0] + f.v[1]; //~^ missing_asserts_for_indexing - } fn index_struct_different_fields(f: &Foo<'_>) { @@ -60,7 +58,6 @@ fn shadowing() { let x: &[i32] = &[1]; let _ = x[0] + x[1]; //~^ missing_asserts_for_indexing - } pub fn issue11856(values: &[i32]) -> usize { diff --git a/tests/ui/missing_asserts_for_indexing_unfixable.stderr b/tests/ui/missing_asserts_for_indexing_unfixable.stderr index f6557fb2e50f2..24109b052a8af 100644 --- a/tests/ui/missing_asserts_for_indexing_unfixable.stderr +++ b/tests/ui/missing_asserts_for_indexing_unfixable.stderr @@ -35,7 +35,7 @@ LL | v[0] + v[1] + v[2] + v[3] + v[4] = help: to override `-D warnings` add `#[allow(clippy::missing_asserts_for_indexing)]` error: indexing into a slice multiple times without an `assert` - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:11:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 | LL | let _ = v[0]; | _____________^ @@ -45,19 +45,19 @@ LL | | let _ = v[1..4]; | = help: consider asserting the length before indexing: `assert!(v.len() > 3);` note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:11:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:10:13 | LL | let _ = v[0]; | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:14:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:13:13 | LL | let _ = v[1..4]; | ^^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:18:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:17:13 | LL | let a = v[0]; | _____________^ @@ -69,112 +69,112 @@ LL | | let c = v[2]; | = help: consider asserting the length before indexing: `assert!(v.len() > 2);` note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:18:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:17:13 | LL | let a = v[0]; | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:21:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:20:13 | LL | let b = v[1]; | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:22:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:21:13 | LL | let c = v[2]; | ^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:27:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:26:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v1.len() > 12);` note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:27:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:26:13 | LL | let _ = v1[0] + v1[12]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:27:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:26:21 | LL | let _ = v1[0] + v1[12]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:29:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:28:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:29:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:28:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:29:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:28:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:36:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:35:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(v2.len() > 15);` note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:36:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:35:13 | LL | let _ = v2[5] + v2[15]; | ^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:36:21 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:35:21 | LL | let _ = v2[5] + v2[15]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:46:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:45:13 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(f.v.len() > 1);` note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:46:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:45:13 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:46:22 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:45:22 | LL | let _ = f.v[0] + f.v[1]; | ^^^^^^ = note: asserting the length before indexing will elide bounds checks error: indexing into a slice multiple times without an `assert` - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:61:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:59:13 | LL | let _ = x[0] + x[1]; | ^^^^^^^^^^^ | = help: consider asserting the length before indexing: `assert!(x.len() > 1);` note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:61:13 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:59:13 | LL | let _ = x[0] + x[1]; | ^^^^ note: slice indexed here - --> tests/ui/missing_asserts_for_indexing_unfixable.rs:61:20 + --> tests/ui/missing_asserts_for_indexing_unfixable.rs:59:20 | LL | let _ = x[0] + x[1]; | ^^^^ diff --git a/tests/ui/missing_const_for_fn/could_be_const.fixed b/tests/ui/missing_const_for_fn/could_be_const.fixed index 592302c34ae60..10df44e73b85f 100644 --- a/tests/ui/missing_const_for_fn/could_be_const.fixed +++ b/tests/ui/missing_const_for_fn/could_be_const.fixed @@ -11,44 +11,44 @@ struct Game { impl Game { // Could be const pub const fn new() -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn Self { guess: 42 } } const fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { - //~^ missing_const_for_fn + //~^ missing_const_for_fn b } } // Could be const const fn one() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn 1 } // Could also be const const fn two() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn let abc = 2; abc } // Could be const (since Rust 1.39) const fn string() -> String { -//~^ missing_const_for_fn + //~^ missing_const_for_fn String::new() } // Could be const const unsafe fn four() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn 4 } // Could also be const const fn generic(t: T) -> T { -//~^ missing_const_for_fn + //~^ missing_const_for_fn t } @@ -57,7 +57,7 @@ fn sub(x: u32) -> usize { } const fn generic_arr(t: [T; 1]) -> T { -//~^ missing_const_for_fn + //~^ missing_const_for_fn t[0] } @@ -71,7 +71,7 @@ mod with_drop { impl B { // This can be const, because `a` is passed by reference pub const fn b(self, a: &A) -> B { - //~^ missing_const_for_fn + //~^ missing_const_for_fn B } } @@ -81,7 +81,7 @@ mod with_drop { mod const_fn_stabilized_before_msrv { // This could be const because `u8::is_ascii_digit` is a stable const function in 1.47. const fn const_fn_stabilized_before_msrv(byte: u8) { - //~^ missing_const_for_fn + //~^ missing_const_for_fn byte.is_ascii_digit(); } } @@ -93,7 +93,7 @@ fn msrv_1_45() -> i32 { #[clippy::msrv = "1.46"] const fn msrv_1_46() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn 46 } @@ -121,12 +121,12 @@ mod msrv { impl Foo { #[clippy::msrv = "1.58"] const fn deref_ptr_can_be_const(self) -> usize { - //~^ missing_const_for_fn + //~^ missing_const_for_fn unsafe { *self.0 as usize } } const fn deref_copied_val(self) -> usize { - //~^ missing_const_for_fn + //~^ missing_const_for_fn *self.1 as usize } } @@ -137,7 +137,7 @@ mod msrv { #[clippy::msrv = "1.56"] const fn union_access_can_be_const() { - //~^ missing_const_for_fn + //~^ missing_const_for_fn let bar = Bar { val: 1 }; let _ = unsafe { bar.val }; } @@ -167,13 +167,13 @@ mod issue12677 { impl Wrapper { #[must_use] pub const fn new(strings: Vec) -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn Self { strings } } #[must_use] pub const fn empty() -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn Self { strings: Vec::new() } } } @@ -185,7 +185,7 @@ mod issue12677 { impl Other { pub const fn new(text: String) -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn let vec = Vec::new(); Self { text, vec } } @@ -218,6 +218,6 @@ mod extern_fn { } const fn mut_add(x: &mut i32) { -//~^ missing_const_for_fn + //~^ missing_const_for_fn *x += 1; } diff --git a/tests/ui/missing_const_for_fn/could_be_const.rs b/tests/ui/missing_const_for_fn/could_be_const.rs index f689f9bb7f92d..bc44b34daef7e 100644 --- a/tests/ui/missing_const_for_fn/could_be_const.rs +++ b/tests/ui/missing_const_for_fn/could_be_const.rs @@ -11,44 +11,44 @@ struct Game { impl Game { // Could be const pub fn new() -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn Self { guess: 42 } } fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { - //~^ missing_const_for_fn + //~^ missing_const_for_fn b } } // Could be const fn one() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn 1 } // Could also be const fn two() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn let abc = 2; abc } // Could be const (since Rust 1.39) fn string() -> String { -//~^ missing_const_for_fn + //~^ missing_const_for_fn String::new() } // Could be const unsafe fn four() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn 4 } // Could also be const fn generic(t: T) -> T { -//~^ missing_const_for_fn + //~^ missing_const_for_fn t } @@ -57,7 +57,7 @@ fn sub(x: u32) -> usize { } fn generic_arr(t: [T; 1]) -> T { -//~^ missing_const_for_fn + //~^ missing_const_for_fn t[0] } @@ -71,7 +71,7 @@ mod with_drop { impl B { // This can be const, because `a` is passed by reference pub fn b(self, a: &A) -> B { - //~^ missing_const_for_fn + //~^ missing_const_for_fn B } } @@ -81,7 +81,7 @@ mod with_drop { mod const_fn_stabilized_before_msrv { // This could be const because `u8::is_ascii_digit` is a stable const function in 1.47. fn const_fn_stabilized_before_msrv(byte: u8) { - //~^ missing_const_for_fn + //~^ missing_const_for_fn byte.is_ascii_digit(); } } @@ -93,7 +93,7 @@ fn msrv_1_45() -> i32 { #[clippy::msrv = "1.46"] fn msrv_1_46() -> i32 { -//~^ missing_const_for_fn + //~^ missing_const_for_fn 46 } @@ -121,12 +121,12 @@ mod msrv { impl Foo { #[clippy::msrv = "1.58"] fn deref_ptr_can_be_const(self) -> usize { - //~^ missing_const_for_fn + //~^ missing_const_for_fn unsafe { *self.0 as usize } } fn deref_copied_val(self) -> usize { - //~^ missing_const_for_fn + //~^ missing_const_for_fn *self.1 as usize } } @@ -137,7 +137,7 @@ mod msrv { #[clippy::msrv = "1.56"] fn union_access_can_be_const() { - //~^ missing_const_for_fn + //~^ missing_const_for_fn let bar = Bar { val: 1 }; let _ = unsafe { bar.val }; } @@ -167,13 +167,13 @@ mod issue12677 { impl Wrapper { #[must_use] pub fn new(strings: Vec) -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn Self { strings } } #[must_use] pub fn empty() -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn Self { strings: Vec::new() } } } @@ -185,7 +185,7 @@ mod issue12677 { impl Other { pub fn new(text: String) -> Self { - //~^ missing_const_for_fn + //~^ missing_const_for_fn let vec = Vec::new(); Self { text, vec } } @@ -218,6 +218,6 @@ mod extern_fn { } fn mut_add(x: &mut i32) { -//~^ missing_const_for_fn + //~^ missing_const_for_fn *x += 1; } diff --git a/tests/ui/missing_const_for_thread_local.fixed b/tests/ui/missing_const_for_thread_local.fixed index 281d7a6c9da36..2efe10c153da3 100644 --- a/tests/ui/missing_const_for_thread_local.fixed +++ b/tests/ui/missing_const_for_thread_local.fixed @@ -9,7 +9,6 @@ fn main() { //~^ missing_const_for_thread_local } - // don't lint thread_local! { static BUF_2: RefCell = const { RefCell::new(String::new()) }; @@ -20,7 +19,6 @@ fn main() { //~^ missing_const_for_thread_local } - // lint and suggest const for all non const items thread_local! { static BUF_3_CAN_BE_MADE_CONST: RefCell = const { RefCell::new(String::new()) }; @@ -30,8 +28,6 @@ fn main() { //~^ missing_const_for_thread_local } - - thread_local! { static PEEL_ME: i32 = const { 1 }; //~^ missing_const_for_thread_local diff --git a/tests/ui/missing_const_for_thread_local.rs b/tests/ui/missing_const_for_thread_local.rs index 07239e5fa617e..119cc5a99fa05 100644 --- a/tests/ui/missing_const_for_thread_local.rs +++ b/tests/ui/missing_const_for_thread_local.rs @@ -9,7 +9,6 @@ fn main() { //~^ missing_const_for_thread_local } - // don't lint thread_local! { static BUF_2: RefCell = const { RefCell::new(String::new()) }; @@ -20,7 +19,6 @@ fn main() { //~^ missing_const_for_thread_local } - // lint and suggest const for all non const items thread_local! { static BUF_3_CAN_BE_MADE_CONST: RefCell = RefCell::new(String::new()); @@ -30,8 +28,6 @@ fn main() { //~^ missing_const_for_thread_local } - - thread_local! { static PEEL_ME: i32 = { 1 }; //~^ missing_const_for_thread_local diff --git a/tests/ui/missing_const_for_thread_local.stderr b/tests/ui/missing_const_for_thread_local.stderr index 76104a3761eb4..4e90c10c92f8f 100644 --- a/tests/ui/missing_const_for_thread_local.stderr +++ b/tests/ui/missing_const_for_thread_local.stderr @@ -8,31 +8,31 @@ LL | static BUF_1: RefCell = RefCell::new(String::new()); = help: to override `-D warnings` add `#[allow(clippy::missing_const_for_thread_local)]` error: initializer for `thread_local` value can be made `const` - --> tests/ui/missing_const_for_thread_local.rs:19:29 + --> tests/ui/missing_const_for_thread_local.rs:18:29 | LL | static SIMPLE:i32 = 1; | ^ help: replace with: `const { 1 }` error: initializer for `thread_local` value can be made `const` - --> tests/ui/missing_const_for_thread_local.rs:26:59 + --> tests/ui/missing_const_for_thread_local.rs:24:59 | LL | static BUF_3_CAN_BE_MADE_CONST: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` error: initializer for `thread_local` value can be made `const` - --> tests/ui/missing_const_for_thread_local.rs:29:59 + --> tests/ui/missing_const_for_thread_local.rs:27:59 | LL | static BUF_4_CAN_BE_MADE_CONST: RefCell = RefCell::new(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }` error: initializer for `thread_local` value can be made `const` - --> tests/ui/missing_const_for_thread_local.rs:36:31 + --> tests/ui/missing_const_for_thread_local.rs:32:31 | LL | static PEEL_ME: i32 = { 1 }; | ^^^^^ help: replace with: `const { 1 }` error: initializer for `thread_local` value can be made `const` - --> tests/ui/missing_const_for_thread_local.rs:39:36 + --> tests/ui/missing_const_for_thread_local.rs:35:36 | LL | static PEEL_ME_MANY: i32 = { let x = 1; x * x }; | ^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { { let x = 1; x * x } }` diff --git a/tests/ui/missing_doc.rs b/tests/ui/missing_doc.rs index 301c46e0f1b9e..705de959cb7da 100644 --- a/tests/ui/missing_doc.rs +++ b/tests/ui/missing_doc.rs @@ -43,7 +43,7 @@ mod a { } enum Baz { -//~^ missing_docs_in_private_items + //~^ missing_docs_in_private_items BazA { a: isize, b: isize }, //~^ missing_docs_in_private_items //~| missing_docs_in_private_items @@ -94,7 +94,7 @@ pub static BAR3: u32 = 0; pub static BAR4: u32 = 0; mod internal_impl { -//~^ missing_docs_in_private_items + //~^ missing_docs_in_private_items /// dox pub fn documented() {} pub fn undocumented1() {} @@ -133,7 +133,7 @@ with_span!(span pub const FOO2_PM: u32 = 0;); const _: () = (); fn issue13298() { -//~^ missing_docs_in_private_items + //~^ missing_docs_in_private_items // Rustdoc doesn't generate documentation for items within other items like fns or consts const MSG: &str = "Hello, world!"; } diff --git a/tests/ui/missing_doc_crate_missing.rs b/tests/ui/missing_doc_crate_missing.rs index 70e96f4dd5474..f55d8b67cb847 100644 --- a/tests/ui/missing_doc_crate_missing.rs +++ b/tests/ui/missing_doc_crate_missing.rs @@ -1,6 +1,4 @@ #![warn(clippy::missing_docs_in_private_items)] //~^ missing_docs_in_private_items - - fn main() {} diff --git a/tests/ui/missing_doc_impl.rs b/tests/ui/missing_doc_impl.rs index e2d268c4e3bdf..034ce31dfe768 100644 --- a/tests/ui/missing_doc_impl.rs +++ b/tests/ui/missing_doc_impl.rs @@ -11,7 +11,7 @@ extern crate proc_macros; use proc_macros::with_span; struct Foo { -//~^ missing_docs_in_private_items + //~^ missing_docs_in_private_items a: isize, //~^ missing_docs_in_private_items b: isize, @@ -69,7 +69,7 @@ pub trait E: Sized { impl Foo { pub fn new() -> Self { - //~^ missing_docs_in_private_items + //~^ missing_docs_in_private_items Foo { a: 0, b: 0 } } fn bar() {} @@ -82,7 +82,7 @@ impl PubFoo { pub fn foo1() {} #[must_use = "yep"] fn foo2() -> u32 { - //~^ missing_docs_in_private_items + //~^ missing_docs_in_private_items 1 } #[allow(clippy::missing_docs_in_private_items)] diff --git a/tests/ui/missing_fields_in_debug.rs b/tests/ui/missing_fields_in_debug.rs index bf69eae051698..14803b5485a11 100644 --- a/tests/ui/missing_fields_in_debug.rs +++ b/tests/ui/missing_fields_in_debug.rs @@ -12,7 +12,7 @@ struct NamedStruct1Ignored { } impl fmt::Debug for NamedStruct1Ignored { -//~^ missing_fields_in_debug + //~^ missing_fields_in_debug // unused field: hidden fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -32,7 +32,7 @@ struct NamedStructMultipleIgnored { } impl fmt::Debug for NamedStructMultipleIgnored { -//~^ missing_fields_in_debug + //~^ missing_fields_in_debug // unused fields: hidden, hidden2, hidden4 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -95,7 +95,7 @@ struct MultiExprDebugImpl { // ok impl fmt::Debug for MultiExprDebugImpl { -//~^ missing_fields_in_debug + //~^ missing_fields_in_debug fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let mut f = formatter.debug_struct("MultiExprDebugImpl"); diff --git a/tests/ui/missing_inline.rs b/tests/ui/missing_inline.rs index ec21de4ca41ca..c1801005b777a 100644 --- a/tests/ui/missing_inline.rs +++ b/tests/ui/missing_inline.rs @@ -20,7 +20,6 @@ fn foo() {} pub fn pub_foo() {} //~^ missing_inline_in_public_items - #[inline] pub fn pub_foo_inline() {} // ok #[inline(always)] @@ -64,7 +63,6 @@ impl PubBar for PubFoo { // missing #[inline] fn PubBar_c() {} //~^ missing_inline_in_public_items - } // do not need inline because Foo is not exported @@ -77,7 +75,6 @@ impl PubFoo { // missing #[inline] pub fn PubFooImpl() {} //~^ missing_inline_in_public_items - } // do not lint this since users cannot control the external code diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index 2ce335a696ce5..99ee828e805ca 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -8,31 +8,31 @@ LL | pub fn pub_foo() {} = help: to override `-D warnings` add `#[allow(clippy::missing_inline_in_public_items)]` error: missing `#[inline]` for a default trait method - --> tests/ui/missing_inline.rs:40:5 + --> tests/ui/missing_inline.rs:39:5 | LL | fn PubBar_b() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> tests/ui/missing_inline.rs:57:5 + --> tests/ui/missing_inline.rs:56:5 | LL | fn PubBar_a() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> tests/ui/missing_inline.rs:61:5 + --> tests/ui/missing_inline.rs:60:5 | LL | fn PubBar_b() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> tests/ui/missing_inline.rs:65:5 + --> tests/ui/missing_inline.rs:64:5 | LL | fn PubBar_c() {} | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> tests/ui/missing_inline.rs:78:5 + --> tests/ui/missing_inline.rs:76:5 | LL | pub fn PubFooImpl() {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/missing_panics_doc.rs b/tests/ui/missing_panics_doc.rs index f8aeffb3d041d..95e361c5d5556 100644 --- a/tests/ui/missing_panics_doc.rs +++ b/tests/ui/missing_panics_doc.rs @@ -11,20 +11,20 @@ fn main() {} /// This needs to be documented pub fn unwrap() { -//~^ missing_panics_doc + //~^ missing_panics_doc let result = Err("Hi"); result.unwrap() } /// This needs to be documented pub fn panic() { -//~^ missing_panics_doc + //~^ missing_panics_doc panic!("This function panics") } /// This needs to be documented pub fn inner_body(opt: Option) { -//~^ missing_panics_doc + //~^ missing_panics_doc opt.map(|x| { if x == 10 { panic!() @@ -34,20 +34,20 @@ pub fn inner_body(opt: Option) { /// This needs to be documented pub fn unreachable_and_panic() { -//~^ missing_panics_doc + //~^ missing_panics_doc if true { unreachable!() } else { panic!() } } /// This needs to be documented pub fn assert_eq() { -//~^ missing_panics_doc + //~^ missing_panics_doc let x = 0; assert_eq!(x, 0); } /// This needs to be documented pub fn assert_ne() { -//~^ missing_panics_doc + //~^ missing_panics_doc let x = 0; assert_ne!(x, 0); } @@ -155,36 +155,36 @@ pub fn debug_assertions() { // `pub` is required, because the lint does not consider unreachable items pub mod issue10240 { pub fn option_unwrap(v: &[T]) -> &T { - //~^ missing_panics_doc + //~^ missing_panics_doc let o: Option<&T> = v.last(); o.unwrap() } pub fn option_expect(v: &[T]) -> &T { - //~^ missing_panics_doc + //~^ missing_panics_doc let o: Option<&T> = v.last(); o.expect("passed an empty thing") } pub fn result_unwrap(v: &[T]) -> &T { - //~^ missing_panics_doc + //~^ missing_panics_doc let res: Result<&T, &str> = v.last().ok_or("oh noes"); res.unwrap() } pub fn result_expect(v: &[T]) -> &T { - //~^ missing_panics_doc + //~^ missing_panics_doc let res: Result<&T, &str> = v.last().ok_or("oh noes"); res.expect("passed an empty thing") } pub fn last_unwrap(v: &[u32]) -> u32 { - //~^ missing_panics_doc + //~^ missing_panics_doc *v.last().unwrap() } pub fn last_expect(v: &[u32]) -> u32 { - //~^ missing_panics_doc + //~^ missing_panics_doc *v.last().expect("passed an empty thing") } } diff --git a/tests/ui/missing_trait_methods.rs b/tests/ui/missing_trait_methods.rs index bcca5e1ae5bd0..7af186ba33220 100644 --- a/tests/ui/missing_trait_methods.rs +++ b/tests/ui/missing_trait_methods.rs @@ -22,9 +22,8 @@ struct Partial; impl A for Partial {} //~^ missing_trait_methods - impl B for Partial { -//~^ missing_trait_methods + //~^ missing_trait_methods fn required() {} diff --git a/tests/ui/missing_trait_methods.stderr b/tests/ui/missing_trait_methods.stderr index 4af7b9ae1ea95..d9fb8951ab3db 100644 --- a/tests/ui/missing_trait_methods.stderr +++ b/tests/ui/missing_trait_methods.stderr @@ -13,7 +13,7 @@ LL | fn provided() {} = help: to override `-D warnings` add `#[allow(clippy::missing_trait_methods)]` error: missing trait method provided by default: `b` - --> tests/ui/missing_trait_methods.rs:26:1 + --> tests/ui/missing_trait_methods.rs:25:1 | LL | impl B for Partial { | ^^^^^^^^^^^^^^^^^^ @@ -25,37 +25,37 @@ LL | fn b<'a, T: AsRef<[u8]>>(a: &'a T) -> &'a [u8] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing trait method provided by default: `one` - --> tests/ui/missing_trait_methods.rs:60:1 + --> tests/ui/missing_trait_methods.rs:59:1 | LL | impl MissingMultiple for Partial {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: implement the method - --> tests/ui/missing_trait_methods.rs:55:5 + --> tests/ui/missing_trait_methods.rs:54:5 | LL | fn one() {} | ^^^^^^^^ error: missing trait method provided by default: `two` - --> tests/ui/missing_trait_methods.rs:60:1 + --> tests/ui/missing_trait_methods.rs:59:1 | LL | impl MissingMultiple for Partial {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: implement the method - --> tests/ui/missing_trait_methods.rs:56:5 + --> tests/ui/missing_trait_methods.rs:55:5 | LL | fn two() {} | ^^^^^^^^ error: missing trait method provided by default: `three` - --> tests/ui/missing_trait_methods.rs:60:1 + --> tests/ui/missing_trait_methods.rs:59:1 | LL | impl MissingMultiple for Partial {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: implement the method - --> tests/ui/missing_trait_methods.rs:57:5 + --> tests/ui/missing_trait_methods.rs:56:5 | LL | fn three() {} | ^^^^^^^^^^ diff --git a/tests/ui/mixed_read_write_in_expression.rs b/tests/ui/mixed_read_write_in_expression.rs index cff7996243bb2..2ead166bf8011 100644 --- a/tests/ui/mixed_read_write_in_expression.rs +++ b/tests/ui/mixed_read_write_in_expression.rs @@ -14,10 +14,9 @@ fn main() { } + x; //~^ mixed_read_write_in_expression - // Example from iss#277 x += { - //~^ mixed_read_write_in_expression + //~^ mixed_read_write_in_expression x = 20; 2 @@ -33,7 +32,6 @@ fn main() { let foo = Foo { a: x, //~^ mixed_read_write_in_expression - ..{ x = 6; base @@ -43,7 +41,7 @@ fn main() { let closure = || { let mut x = 0; x += { - //~^ mixed_read_write_in_expression + //~^ mixed_read_write_in_expression x = 20; 2 diff --git a/tests/ui/mixed_read_write_in_expression.stderr b/tests/ui/mixed_read_write_in_expression.stderr index ebb3e691e6b7d..e34dce2bb132c 100644 --- a/tests/ui/mixed_read_write_in_expression.stderr +++ b/tests/ui/mixed_read_write_in_expression.stderr @@ -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` - --> tests/ui/mixed_read_write_in_expression.rs:19:5 + --> tests/ui/mixed_read_write_in_expression.rs:18:5 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> tests/ui/mixed_read_write_in_expression.rs:22:9 + --> tests/ui/mixed_read_write_in_expression.rs:21:9 | LL | x = 20; | ^^^^^^ error: unsequenced read of `x` - --> tests/ui/mixed_read_write_in_expression.rs:34:12 + --> tests/ui/mixed_read_write_in_expression.rs:33:12 | LL | a: x, | ^ | note: whether read occurs before this write depends on evaluation order - --> tests/ui/mixed_read_write_in_expression.rs:38:13 + --> tests/ui/mixed_read_write_in_expression.rs:36:13 | LL | x = 6; | ^^^^^ error: unsequenced read of `x` - --> tests/ui/mixed_read_write_in_expression.rs:45:9 + --> tests/ui/mixed_read_write_in_expression.rs:43:9 | LL | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> tests/ui/mixed_read_write_in_expression.rs:48:13 + --> tests/ui/mixed_read_write_in_expression.rs:46:13 | LL | x = 20; | ^^^^^^ diff --git a/tests/ui/module_inception.rs b/tests/ui/module_inception.rs index f04f0c5eeebac..15b7fb8777700 100644 --- a/tests/ui/module_inception.rs +++ b/tests/ui/module_inception.rs @@ -3,15 +3,14 @@ pub mod foo2 { pub mod bar2 { pub mod bar2 { - //~^ module_inception - + //~^ module_inception pub mod foo2 {} } pub mod foo2 {} } pub mod foo2 { - //~^ module_inception + //~^ module_inception pub mod bar2 {} } @@ -20,14 +19,14 @@ pub mod foo2 { mod foo { mod bar { mod bar { - //~^ module_inception + //~^ module_inception mod foo {} } mod foo {} } mod foo { - //~^ module_inception + //~^ module_inception mod bar {} } diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index 3aaf304ac0e55..8e7d555cebc67 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -2,7 +2,9 @@ error: module has the same name as its containing module --> tests/ui/module_inception.rs:5:9 | LL | / pub mod bar2 { -... | +LL | | +LL | | +LL | | pub mod foo2 {} LL | | } | |_________^ | @@ -10,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::module_inception)]` error: module has the same name as its containing module - --> tests/ui/module_inception.rs:13:5 + --> tests/ui/module_inception.rs:12:5 | LL | / pub mod foo2 { LL | | @@ -20,7 +22,7 @@ LL | | } | |_____^ error: module has the same name as its containing module - --> tests/ui/module_inception.rs:22:9 + --> tests/ui/module_inception.rs:21:9 | LL | / mod bar { LL | | @@ -30,7 +32,7 @@ LL | | } | |_________^ error: module has the same name as its containing module - --> tests/ui/module_inception.rs:29:5 + --> tests/ui/module_inception.rs:28:5 | LL | / mod foo { LL | | diff --git a/tests/ui/module_name_repetitions.rs b/tests/ui/module_name_repetitions.rs index b45120a8d10cc..2fde98d7927c2 100644 --- a/tests/ui/module_name_repetitions.rs +++ b/tests/ui/module_name_repetitions.rs @@ -8,7 +8,6 @@ pub mod foo { pub fn foo_bar() {} //~^ module_name_repetitions - pub fn bar_foo() {} //~^ module_name_repetitions @@ -21,7 +20,6 @@ pub mod foo { pub struct Foo7Bar; //~^ module_name_repetitions - // Should not warn pub struct Foobar; @@ -35,7 +33,6 @@ pub mod foo { pub use error::FooError; //~^ module_name_repetitions - // FIXME: This should also warn because it creates the public path `foo::FooIter`. mod iter { pub struct FooIter; diff --git a/tests/ui/module_name_repetitions.stderr b/tests/ui/module_name_repetitions.stderr index 664a816ae5d10..9000c44a3902e 100644 --- a/tests/ui/module_name_repetitions.stderr +++ b/tests/ui/module_name_repetitions.stderr @@ -8,31 +8,31 @@ LL | pub fn foo_bar() {} = help: to override `-D warnings` add `#[allow(clippy::module_name_repetitions)]` error: item name ends with its containing module's name - --> tests/ui/module_name_repetitions.rs:12:12 + --> tests/ui/module_name_repetitions.rs:11:12 | LL | pub fn bar_foo() {} | ^^^^^^^ error: item name starts with its containing module's name - --> tests/ui/module_name_repetitions.rs:15:16 + --> tests/ui/module_name_repetitions.rs:14:16 | LL | pub struct FooCake; | ^^^^^^^ error: item name ends with its containing module's name - --> tests/ui/module_name_repetitions.rs:18:14 + --> tests/ui/module_name_repetitions.rs:17:14 | LL | pub enum CakeFoo {} | ^^^^^^^ error: item name starts with its containing module's name - --> tests/ui/module_name_repetitions.rs:21:16 + --> tests/ui/module_name_repetitions.rs:20:16 | LL | pub struct Foo7Bar; | ^^^^^^^ error: item name starts with its containing module's name - --> tests/ui/module_name_repetitions.rs:35:20 + --> tests/ui/module_name_repetitions.rs:33:20 | LL | pub use error::FooError; | ^^^^^^^^ diff --git a/tests/ui/modulo_arithmetic_float.rs b/tests/ui/modulo_arithmetic_float.rs index 1b622151bcc2e..0e08174f686eb 100644 --- a/tests/ui/modulo_arithmetic_float.rs +++ b/tests/ui/modulo_arithmetic_float.rs @@ -8,82 +8,61 @@ fn main() { -1.6 % 2.1; //~^ modulo_arithmetic - 1.6 % -2.1; //~^ modulo_arithmetic - (1.1 - 2.3) % (1.1 + 2.3); //~^ modulo_arithmetic - (1.1 + 2.3) % (1.1 - 2.3); //~^ modulo_arithmetic - - // Lint on floating point numbers let a_f16: f16 = -1.6; let mut b_f16: f16 = 2.1; a_f16 % b_f16; //~^ modulo_arithmetic - b_f16 % a_f16; //~^ modulo_arithmetic - b_f16 %= a_f16; //~^ modulo_arithmetic - - // Lint on floating point numbers let a_f32: f32 = -1.6; let mut b_f32: f32 = 2.1; a_f32 % b_f32; //~^ modulo_arithmetic - b_f32 % a_f32; //~^ modulo_arithmetic - b_f32 %= a_f32; //~^ modulo_arithmetic - - let a_f64: f64 = -1.6; let mut b_f64: f64 = 2.1; a_f64 % b_f64; //~^ modulo_arithmetic - b_f64 % a_f64; //~^ modulo_arithmetic - b_f64 %= a_f64; //~^ modulo_arithmetic - - let a_f128: f128 = -1.6; let mut b_f128: f128 = 2.1; a_f128 % b_f128; //~^ modulo_arithmetic - b_f128 % a_f128; //~^ modulo_arithmetic - b_f128 %= a_f128; //~^ modulo_arithmetic - - // No lint when both sides are const and of the same sign 1.6 % 2.1; -1.6 % -2.1; diff --git a/tests/ui/modulo_arithmetic_float.stderr b/tests/ui/modulo_arithmetic_float.stderr index 9eb9a328664b9..91b5c80ce9f4e 100644 --- a/tests/ui/modulo_arithmetic_float.stderr +++ b/tests/ui/modulo_arithmetic_float.stderr @@ -9,7 +9,7 @@ LL | -1.6 % 2.1; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on constants with different signs: `1.600 % -2.100` - --> tests/ui/modulo_arithmetic_float.rs:12:5 + --> tests/ui/modulo_arithmetic_float.rs:11:5 | LL | 1.6 % -2.1; | ^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | 1.6 % -2.1; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on constants with different signs: `-1.200 % 3.400` - --> tests/ui/modulo_arithmetic_float.rs:16:5 + --> tests/ui/modulo_arithmetic_float.rs:14:5 | LL | (1.1 - 2.3) % (1.1 + 2.3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | (1.1 - 2.3) % (1.1 + 2.3); = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on constants with different signs: `3.400 % -1.200` - --> tests/ui/modulo_arithmetic_float.rs:20:5 + --> tests/ui/modulo_arithmetic_float.rs:17:5 | LL | (1.1 + 2.3) % (1.1 - 2.3); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | (1.1 + 2.3) % (1.1 - 2.3); = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:28:5 + --> tests/ui/modulo_arithmetic_float.rs:23:5 | LL | a_f16 % b_f16; | ^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | a_f16 % b_f16; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:32:5 + --> tests/ui/modulo_arithmetic_float.rs:26:5 | LL | b_f16 % a_f16; | ^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | b_f16 % a_f16; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:36:5 + --> tests/ui/modulo_arithmetic_float.rs:29:5 | LL | b_f16 %= a_f16; | ^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | b_f16 %= a_f16; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:44:5 + --> tests/ui/modulo_arithmetic_float.rs:35:5 | LL | a_f32 % b_f32; | ^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | a_f32 % b_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:48:5 + --> tests/ui/modulo_arithmetic_float.rs:38:5 | LL | b_f32 % a_f32; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | b_f32 % a_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:52:5 + --> tests/ui/modulo_arithmetic_float.rs:41:5 | LL | b_f32 %= a_f32; | ^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | b_f32 %= a_f32; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:59:5 + --> tests/ui/modulo_arithmetic_float.rs:46:5 | LL | a_f64 % b_f64; | ^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | a_f64 % b_f64; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:63:5 + --> tests/ui/modulo_arithmetic_float.rs:49:5 | LL | b_f64 % a_f64; | ^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | b_f64 % a_f64; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:67:5 + --> tests/ui/modulo_arithmetic_float.rs:52:5 | LL | b_f64 %= a_f64; | ^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | b_f64 %= a_f64; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:74:5 + --> tests/ui/modulo_arithmetic_float.rs:57:5 | LL | a_f128 % b_f128; | ^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | a_f128 % b_f128; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:78:5 + --> tests/ui/modulo_arithmetic_float.rs:60:5 | LL | b_f128 % a_f128; | ^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | b_f128 % a_f128; = note: double check for expected result especially when interoperating with different languages error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_float.rs:82:5 + --> tests/ui/modulo_arithmetic_float.rs:63:5 | LL | b_f128 %= a_f128; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/modulo_arithmetic_integral.rs b/tests/ui/modulo_arithmetic_integral.rs index e3a6df7c88f36..d7cd910e43cb7 100644 --- a/tests/ui/modulo_arithmetic_integral.rs +++ b/tests/ui/modulo_arithmetic_integral.rs @@ -8,93 +8,68 @@ fn main() { a % b; //~^ modulo_arithmetic - b % a; //~^ modulo_arithmetic - b %= a; //~^ modulo_arithmetic - - let a_i8: i8 = 1; let mut b_i8: i8 = 2; a_i8 % b_i8; //~^ modulo_arithmetic - b_i8 %= a_i8; //~^ modulo_arithmetic - - let a_i16: i16 = 1; let mut b_i16: i16 = 2; a_i16 % b_i16; //~^ modulo_arithmetic - b_i16 %= a_i16; //~^ modulo_arithmetic - - let a_i32: i32 = 1; let mut b_i32: i32 = 2; a_i32 % b_i32; //~^ modulo_arithmetic - b_i32 %= a_i32; //~^ modulo_arithmetic - - let a_i64: i64 = 1; let mut b_i64: i64 = 2; a_i64 % b_i64; //~^ modulo_arithmetic - b_i64 %= a_i64; //~^ modulo_arithmetic - - let a_i128: i128 = 1; let mut b_i128: i128 = 2; a_i128 % b_i128; //~^ modulo_arithmetic - b_i128 %= a_i128; //~^ modulo_arithmetic - - let a_isize: isize = 1; let mut b_isize: isize = 2; a_isize % b_isize; //~^ modulo_arithmetic - b_isize %= a_isize; //~^ modulo_arithmetic - - let a = 1; let mut b = 2; a % b; //~^ modulo_arithmetic - b %= a; //~^ modulo_arithmetic - - // No lint on unsigned integral value let a_u8: u8 = 17; let b_u8: u8 = 3; diff --git a/tests/ui/modulo_arithmetic_integral.stderr b/tests/ui/modulo_arithmetic_integral.stderr index 32cf45240c1b9..d1b71cdab5e42 100644 --- a/tests/ui/modulo_arithmetic_integral.stderr +++ b/tests/ui/modulo_arithmetic_integral.stderr @@ -10,7 +10,7 @@ LL | a % b; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:12:5 + --> tests/ui/modulo_arithmetic_integral.rs:11:5 | LL | b % a; | ^^^^^ @@ -19,7 +19,7 @@ LL | b % a; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:16:5 + --> tests/ui/modulo_arithmetic_integral.rs:14:5 | LL | b %= a; | ^^^^^^ @@ -28,7 +28,7 @@ LL | b %= a; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:23:5 + --> tests/ui/modulo_arithmetic_integral.rs:19:5 | LL | a_i8 % b_i8; | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | a_i8 % b_i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:27:5 + --> tests/ui/modulo_arithmetic_integral.rs:22:5 | LL | b_i8 %= a_i8; | ^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | b_i8 %= a_i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:34:5 + --> tests/ui/modulo_arithmetic_integral.rs:27:5 | LL | a_i16 % b_i16; | ^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | a_i16 % b_i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:38:5 + --> tests/ui/modulo_arithmetic_integral.rs:30:5 | LL | b_i16 %= a_i16; | ^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | b_i16 %= a_i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:45:5 + --> tests/ui/modulo_arithmetic_integral.rs:35:5 | LL | a_i32 % b_i32; | ^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | a_i32 % b_i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:49:5 + --> tests/ui/modulo_arithmetic_integral.rs:38:5 | LL | b_i32 %= a_i32; | ^^^^^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | b_i32 %= a_i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:56:5 + --> tests/ui/modulo_arithmetic_integral.rs:43:5 | LL | a_i64 % b_i64; | ^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | a_i64 % b_i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:60:5 + --> tests/ui/modulo_arithmetic_integral.rs:46:5 | LL | b_i64 %= a_i64; | ^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | b_i64 %= a_i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:67:5 + --> tests/ui/modulo_arithmetic_integral.rs:51:5 | LL | a_i128 % b_i128; | ^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | a_i128 % b_i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:71:5 + --> tests/ui/modulo_arithmetic_integral.rs:54:5 | LL | b_i128 %= a_i128; | ^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | b_i128 %= a_i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:78:5 + --> tests/ui/modulo_arithmetic_integral.rs:59:5 | LL | a_isize % b_isize; | ^^^^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | a_isize % b_isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:82:5 + --> tests/ui/modulo_arithmetic_integral.rs:62:5 | LL | b_isize %= a_isize; | ^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | b_isize %= a_isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:89:5 + --> tests/ui/modulo_arithmetic_integral.rs:67:5 | LL | a % b; | ^^^^^ @@ -145,7 +145,7 @@ LL | a % b; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on types that might have different signs - --> tests/ui/modulo_arithmetic_integral.rs:93:5 + --> tests/ui/modulo_arithmetic_integral.rs:70:5 | LL | b %= a; | ^^^^^^ diff --git a/tests/ui/modulo_arithmetic_integral_const.rs b/tests/ui/modulo_arithmetic_integral_const.rs index ddcf4b219073e..9f5fb697df0ea 100644 --- a/tests/ui/modulo_arithmetic_integral_const.rs +++ b/tests/ui/modulo_arithmetic_integral_const.rs @@ -11,73 +11,54 @@ fn main() { -1 % 2; //~^ modulo_arithmetic - 1 % -2; //~^ modulo_arithmetic - (1 - 2) % (1 + 2); //~^ modulo_arithmetic - (1 + 2) % (1 - 2); //~^ modulo_arithmetic - 35 * (7 - 4 * 2) % (-500 * -600); //~^ modulo_arithmetic - - -1i8 % 2i8; //~^ modulo_arithmetic - 1i8 % -2i8; //~^ modulo_arithmetic - -1i16 % 2i16; //~^ modulo_arithmetic - 1i16 % -2i16; //~^ modulo_arithmetic - -1i32 % 2i32; //~^ modulo_arithmetic - 1i32 % -2i32; //~^ modulo_arithmetic - -1i64 % 2i64; //~^ modulo_arithmetic - 1i64 % -2i64; //~^ modulo_arithmetic - -1i128 % 2i128; //~^ modulo_arithmetic - 1i128 % -2i128; //~^ modulo_arithmetic - -1isize % 2isize; //~^ modulo_arithmetic - 1isize % -2isize; //~^ modulo_arithmetic - - // No lint when both sides are const and of the same sign 1 % 2; -1 % -2; diff --git a/tests/ui/modulo_arithmetic_integral_const.stderr b/tests/ui/modulo_arithmetic_integral_const.stderr index 49a5a2c6433a8..12edee8cf4255 100644 --- a/tests/ui/modulo_arithmetic_integral_const.stderr +++ b/tests/ui/modulo_arithmetic_integral_const.stderr @@ -10,7 +10,7 @@ LL | -1 % 2; = help: to override `-D warnings` add `#[allow(clippy::modulo_arithmetic)]` error: you are using modulo operator on constants with different signs: `1 % -2` - --> tests/ui/modulo_arithmetic_integral_const.rs:15:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:14:5 | LL | 1 % -2; | ^^^^^^ @@ -19,7 +19,7 @@ LL | 1 % -2; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 3` - --> tests/ui/modulo_arithmetic_integral_const.rs:19:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:17:5 | LL | (1 - 2) % (1 + 2); | ^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | (1 - 2) % (1 + 2); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `3 % -1` - --> tests/ui/modulo_arithmetic_integral_const.rs:23:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:20:5 | LL | (1 + 2) % (1 - 2); | ^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | (1 + 2) % (1 - 2); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-35 % 300000` - --> tests/ui/modulo_arithmetic_integral_const.rs:27:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:23:5 | LL | 35 * (7 - 4 * 2) % (-500 * -600); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | 35 * (7 - 4 * 2) % (-500 * -600); = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> tests/ui/modulo_arithmetic_integral_const.rs:32:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:26:5 | LL | -1i8 % 2i8; | ^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | -1i8 % 2i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> tests/ui/modulo_arithmetic_integral_const.rs:36:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:29:5 | LL | 1i8 % -2i8; | ^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | 1i8 % -2i8; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> tests/ui/modulo_arithmetic_integral_const.rs:40:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:32:5 | LL | -1i16 % 2i16; | ^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | -1i16 % 2i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> tests/ui/modulo_arithmetic_integral_const.rs:44:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:35:5 | LL | 1i16 % -2i16; | ^^^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | 1i16 % -2i16; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> tests/ui/modulo_arithmetic_integral_const.rs:48:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:38:5 | LL | -1i32 % 2i32; | ^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | -1i32 % 2i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> tests/ui/modulo_arithmetic_integral_const.rs:52:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:41:5 | LL | 1i32 % -2i32; | ^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | 1i32 % -2i32; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> tests/ui/modulo_arithmetic_integral_const.rs:56:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:44:5 | LL | -1i64 % 2i64; | ^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | -1i64 % 2i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> tests/ui/modulo_arithmetic_integral_const.rs:60:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:47:5 | LL | 1i64 % -2i64; | ^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | 1i64 % -2i64; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> tests/ui/modulo_arithmetic_integral_const.rs:64:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:50:5 | LL | -1i128 % 2i128; | ^^^^^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | -1i128 % 2i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> tests/ui/modulo_arithmetic_integral_const.rs:68:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:53:5 | LL | 1i128 % -2i128; | ^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | 1i128 % -2i128; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `-1 % 2` - --> tests/ui/modulo_arithmetic_integral_const.rs:72:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:56:5 | LL | -1isize % 2isize; | ^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | -1isize % 2isize; = note: or consider using `rem_euclid` or similar function error: you are using modulo operator on constants with different signs: `1 % -2` - --> tests/ui/modulo_arithmetic_integral_const.rs:76:5 + --> tests/ui/modulo_arithmetic_integral_const.rs:59:5 | LL | 1isize % -2isize; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/modulo_one.rs b/tests/ui/modulo_one.rs index 6ad038e60744f..63ae61059cb86 100644 --- a/tests/ui/modulo_one.rs +++ b/tests/ui/modulo_one.rs @@ -9,7 +9,6 @@ fn main() { 10 % 1; //~^ modulo_one - 10 % -1; //~^ modulo_one diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index 1eb886123d857..1c9c79d1c6214 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -8,31 +8,31 @@ LL | 10 % 1; = help: to override `-D warnings` add `#[allow(clippy::modulo_one)]` error: any number modulo -1 will panic/overflow or result in 0 - --> tests/ui/modulo_one.rs:13:5 + --> tests/ui/modulo_one.rs:12:5 | LL | 10 % -1; | ^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> tests/ui/modulo_one.rs:18:5 + --> tests/ui/modulo_one.rs:17:5 | LL | i32::MIN % (-1); | ^^^^^^^^^^^^^^^ error: any number modulo 1 will be 0 - --> tests/ui/modulo_one.rs:25:5 + --> tests/ui/modulo_one.rs:24:5 | LL | 2 % ONE; | ^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> tests/ui/modulo_one.rs:30:5 + --> tests/ui/modulo_one.rs:29:5 | LL | 2 % NEG_ONE; | ^^^^^^^^^^^ error: any number modulo -1 will panic/overflow or result in 0 - --> tests/ui/modulo_one.rs:36:5 + --> tests/ui/modulo_one.rs:35:5 | LL | INT_MIN % NEG_ONE; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/multi_assignments.rs b/tests/ui/multi_assignments.rs index 651cdc5773de9..5a0d9a7aa37cb 100644 --- a/tests/ui/multi_assignments.rs +++ b/tests/ui/multi_assignments.rs @@ -4,12 +4,10 @@ fn main() { a = b = c; //~^ multi_assignments - a = b = c = d; //~^ multi_assignments //~| multi_assignments - a = b = { c }; //~^ multi_assignments @@ -18,5 +16,4 @@ fn main() { a = (b = c); //~^ multi_assignments - } diff --git a/tests/ui/multi_assignments.stderr b/tests/ui/multi_assignments.stderr index 3c5bbcdea5f3d..f56489c0b4b72 100644 --- a/tests/ui/multi_assignments.stderr +++ b/tests/ui/multi_assignments.stderr @@ -8,31 +8,31 @@ LL | a = b = c; = help: to override `-D warnings` add `#[allow(clippy::multi_assignments)]` error: assignments don't nest intuitively - --> tests/ui/multi_assignments.rs:8:5 + --> tests/ui/multi_assignments.rs:7:5 | LL | a = b = c = d; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> tests/ui/multi_assignments.rs:8:9 + --> tests/ui/multi_assignments.rs:7:9 | LL | a = b = c = d; | ^^^^^^^^^ error: assignments don't nest intuitively - --> tests/ui/multi_assignments.rs:13:5 + --> tests/ui/multi_assignments.rs:11:5 | LL | a = b = { c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> tests/ui/multi_assignments.rs:16:5 + --> tests/ui/multi_assignments.rs:14:5 | LL | a = { b = c }; | ^^^^^^^^^^^^^ error: assignments don't nest intuitively - --> tests/ui/multi_assignments.rs:19:5 + --> tests/ui/multi_assignments.rs:17:5 | LL | a = (b = c); | ^^^^^^^^^^^ diff --git a/tests/ui/multiple_bound_locations.rs b/tests/ui/multiple_bound_locations.rs index 45524c90b7f29..95b269d8935df 100644 --- a/tests/ui/multiple_bound_locations.rs +++ b/tests/ui/multiple_bound_locations.rs @@ -2,7 +2,6 @@ fn ty(a: F) //~^ multiple_bound_locations - where F: Sized, { @@ -10,7 +9,6 @@ where fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) //~^ multiple_bound_locations - where 'b: 'c, { @@ -18,7 +16,6 @@ where fn ty_pred() //~^ multiple_bound_locations - where for<'a> F: Send + 'a, { @@ -29,7 +26,6 @@ struct B; impl B { fn ty(a: F) //~^ multiple_bound_locations - where F: Sized, { @@ -37,7 +33,6 @@ impl B { fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) //~^ multiple_bound_locations - where 'b: 'c, { @@ -45,7 +40,6 @@ impl B { fn ty_pred() //~^ multiple_bound_locations - where for<'a> F: Send + 'a, { diff --git a/tests/ui/multiple_bound_locations.stderr b/tests/ui/multiple_bound_locations.stderr index bccc57fe70547..22dd2e0a55249 100644 --- a/tests/ui/multiple_bound_locations.stderr +++ b/tests/ui/multiple_bound_locations.stderr @@ -11,7 +11,7 @@ LL | F: Sized, = help: to override `-D warnings` add `#[allow(clippy::multiple_bound_locations)]` error: bound is defined in more than one place - --> tests/ui/multiple_bound_locations.rs:11:17 + --> tests/ui/multiple_bound_locations.rs:10:17 | LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) | ^^ @@ -20,7 +20,7 @@ LL | 'b: 'c, | ^^ error: bound is defined in more than one place - --> tests/ui/multiple_bound_locations.rs:19:12 + --> tests/ui/multiple_bound_locations.rs:17:12 | LL | fn ty_pred() | ^ @@ -29,7 +29,7 @@ LL | for<'a> F: Send + 'a, | ^ error: bound is defined in more than one place - --> tests/ui/multiple_bound_locations.rs:30:11 + --> tests/ui/multiple_bound_locations.rs:27:11 | LL | fn ty(a: F) | ^ @@ -38,7 +38,7 @@ LL | F: Sized, | ^ error: bound is defined in more than one place - --> tests/ui/multiple_bound_locations.rs:38:21 + --> tests/ui/multiple_bound_locations.rs:34:21 | LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) | ^^ @@ -47,7 +47,7 @@ LL | 'b: 'c, | ^^ error: bound is defined in more than one place - --> tests/ui/multiple_bound_locations.rs:46:16 + --> tests/ui/multiple_bound_locations.rs:41:16 | LL | fn ty_pred() | ^ diff --git a/tests/ui/multiple_unsafe_ops_per_block.rs b/tests/ui/multiple_unsafe_ops_per_block.rs index cc5d455f78cff..016fd89a7b7ac 100644 --- a/tests/ui/multiple_unsafe_ops_per_block.rs +++ b/tests/ui/multiple_unsafe_ops_per_block.rs @@ -36,7 +36,7 @@ static mut STATIC: i32 = 0; fn test1() { unsafe { - //~^ multiple_unsafe_ops_per_block + //~^ multiple_unsafe_ops_per_block STATIC += 1; not_very_safe(); } @@ -46,7 +46,7 @@ fn test2() { let u = U { i: 0 }; unsafe { - //~^ multiple_unsafe_ops_per_block + //~^ multiple_unsafe_ops_per_block drop(u.u); *raw_ptr(); } @@ -54,7 +54,7 @@ fn test2() { fn test3() { unsafe { - //~^ multiple_unsafe_ops_per_block + //~^ multiple_unsafe_ops_per_block asm!("nop"); sample.not_very_safe(); STATIC = 0; @@ -64,7 +64,7 @@ fn test3() { fn test_all() { let u = U { i: 0 }; unsafe { - //~^ multiple_unsafe_ops_per_block + //~^ multiple_unsafe_ops_per_block drop(u.u); drop(STATIC); sample.not_very_safe(); @@ -128,7 +128,7 @@ fn issue10259() { fn _fn_ptr(x: unsafe fn()) { unsafe { - //~^ multiple_unsafe_ops_per_block + //~^ multiple_unsafe_ops_per_block x(); x(); } @@ -140,7 +140,7 @@ fn _assoc_const() { } fn _f() { unsafe { - //~^ multiple_unsafe_ops_per_block + //~^ multiple_unsafe_ops_per_block T::X(); T::X(); } @@ -151,7 +151,7 @@ fn _field_fn_ptr(x: unsafe fn()) { struct X(unsafe fn()); let x = X(x); unsafe { - //~^ multiple_unsafe_ops_per_block + //~^ multiple_unsafe_ops_per_block x.0(); x.0(); } diff --git a/tests/ui/must_use_candidates.fixed b/tests/ui/must_use_candidates.fixed index 7c70c7f6399f1..b5d356a502170 100644 --- a/tests/ui/must_use_candidates.fixed +++ b/tests/ui/must_use_candidates.fixed @@ -14,13 +14,13 @@ pub struct MyAtomic(AtomicBool); pub struct MyPure; #[must_use] pub fn pure(i: u8) -> u8 { -//~^ must_use_candidate + //~^ must_use_candidate i } impl MyPure { #[must_use] pub fn inherent_pure(&self) -> u8 { - //~^ must_use_candidate + //~^ must_use_candidate 0 } } @@ -52,7 +52,7 @@ pub fn with_callback bool>(f: &F) -> bool { } #[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { -//~^ must_use_candidate + //~^ must_use_candidate true } @@ -65,7 +65,7 @@ pub fn atomics(b: &AtomicBool) -> bool { } #[must_use] pub fn rcd(_x: Rc) -> bool { -//~^ must_use_candidate + //~^ must_use_candidate true } @@ -74,7 +74,7 @@ pub fn rcmut(_x: Rc<&mut u32>) -> bool { } #[must_use] pub fn arcd(_x: Arc) -> bool { -//~^ must_use_candidate + //~^ must_use_candidate false } diff --git a/tests/ui/must_use_candidates.rs b/tests/ui/must_use_candidates.rs index a422e952dbcd9..14ea16662fdb4 100644 --- a/tests/ui/must_use_candidates.rs +++ b/tests/ui/must_use_candidates.rs @@ -14,13 +14,13 @@ pub struct MyAtomic(AtomicBool); pub struct MyPure; pub fn pure(i: u8) -> u8 { -//~^ must_use_candidate + //~^ must_use_candidate i } impl MyPure { pub fn inherent_pure(&self) -> u8 { - //~^ must_use_candidate + //~^ must_use_candidate 0 } } @@ -52,7 +52,7 @@ pub fn with_callback bool>(f: &F) -> bool { } pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { -//~^ must_use_candidate + //~^ must_use_candidate true } @@ -65,7 +65,7 @@ pub fn atomics(b: &AtomicBool) -> bool { } pub fn rcd(_x: Rc) -> bool { -//~^ must_use_candidate + //~^ must_use_candidate true } @@ -74,7 +74,7 @@ pub fn rcmut(_x: Rc<&mut u32>) -> bool { } pub fn arcd(_x: Arc) -> bool { -//~^ must_use_candidate + //~^ must_use_candidate false } diff --git a/tests/ui/mut_from_ref.rs b/tests/ui/mut_from_ref.rs index d2d82135d6416..b8c10f3eeb8f9 100644 --- a/tests/ui/mut_from_ref.rs +++ b/tests/ui/mut_from_ref.rs @@ -5,7 +5,7 @@ struct Foo; impl Foo { fn this_wont_hurt_a_bit(&self) -> &mut Foo { - //~^ mut_from_ref + //~^ mut_from_ref unsafe { unimplemented!() } } @@ -14,7 +14,6 @@ impl Foo { trait Ouch { fn ouch(x: &Foo) -> &mut Foo; //~^ mut_from_ref - } impl Ouch for Foo { @@ -24,19 +23,19 @@ impl Ouch for Foo { } fn fail(x: &u32) -> &mut u16 { -//~^ mut_from_ref + //~^ mut_from_ref unsafe { unimplemented!() } } fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { -//~^ mut_from_ref + //~^ mut_from_ref unsafe { unimplemented!() } } fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { -//~^ mut_from_ref + //~^ mut_from_ref unsafe { unimplemented!() } } @@ -52,7 +51,7 @@ fn also_works<'a>(x: &'a u32, y: &'a mut u32) -> &'a mut u32 { } unsafe fn also_broken(x: &u32) -> &mut u32 { -//~^ mut_from_ref + //~^ mut_from_ref unimplemented!() } diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index 593e7acdaed84..8c3c8e0c3d851 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -25,49 +25,49 @@ LL | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ error: mutable borrow from immutable input(s) - --> tests/ui/mut_from_ref.rs:26:21 + --> tests/ui/mut_from_ref.rs:25:21 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^^^^^ | note: immutable borrow here - --> tests/ui/mut_from_ref.rs:26:12 + --> tests/ui/mut_from_ref.rs:25:12 | LL | fn fail(x: &u32) -> &mut u16 { | ^^^^ error: mutable borrow from immutable input(s) - --> tests/ui/mut_from_ref.rs:32:50 + --> tests/ui/mut_from_ref.rs:31:50 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> tests/ui/mut_from_ref.rs:32:25 + --> tests/ui/mut_from_ref.rs:31:25 | LL | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^ error: mutable borrow from immutable input(s) - --> tests/ui/mut_from_ref.rs:38:67 + --> tests/ui/mut_from_ref.rs:37:67 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> tests/ui/mut_from_ref.rs:38:27 + --> tests/ui/mut_from_ref.rs:37:27 | LL | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ error: mutable borrow from immutable input(s) - --> tests/ui/mut_from_ref.rs:54:35 + --> tests/ui/mut_from_ref.rs:53:35 | LL | unsafe fn also_broken(x: &u32) -> &mut u32 { | ^^^^^^^^ | note: immutable borrow here - --> tests/ui/mut_from_ref.rs:54:26 + --> tests/ui/mut_from_ref.rs:53:26 | LL | unsafe fn also_broken(x: &u32) -> &mut u32 { | ^^^^ diff --git a/tests/ui/mut_key.rs b/tests/ui/mut_key.rs index 55b7fe2bcca03..29dc2d020132f 100644 --- a/tests/ui/mut_key.rs +++ b/tests/ui/mut_key.rs @@ -29,10 +29,8 @@ impl Hash for Key { } fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> HashSet { -//~^ mutable_key_type -//~| mutable_key_type - - + //~^ mutable_key_type + //~| mutable_key_type let _other: HashMap = HashMap::new(); //~^ mutable_key_type @@ -66,7 +64,6 @@ fn tuples(_m: &mut HashMap<((), U), ()>) {} fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} //~^ mutable_key_type - fn main() { let _ = should_not_take_this_arg(&mut HashMap::new(), 1); this_is_ok(&mut HashMap::new()); @@ -112,7 +109,6 @@ fn main() { let _map = HashMap::>, usize>::new(); //~^ mutable_key_type - // Not interior mutability let _map = HashMap::<&mut usize, usize>::new(); let _map = HashMap::, usize>::new(); diff --git a/tests/ui/mut_key.stderr b/tests/ui/mut_key.stderr index 1887604b080a1..0d504584fbae8 100644 --- a/tests/ui/mut_key.stderr +++ b/tests/ui/mut_key.stderr @@ -21,7 +21,7 @@ LL | fn should_not_take_this_arg(m: &mut HashMap, _n: usize) -> Hash = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:37:5 + --> tests/ui/mut_key.rs:35:5 | LL | let _other: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | let _other: HashMap = HashMap::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:66:22 + --> tests/ui/mut_key.rs:64:22 | LL | fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | fn tuples_bad(_m: &mut HashMap<(Key, U), bool>) {} = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:80:5 + --> tests/ui/mut_key.rs:77:5 | LL | let _map = HashMap::, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | let _map = HashMap::, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:83:5 + --> tests/ui/mut_key.rs:80:5 | LL | let _map = HashMap::<&mut Cell, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | let _map = HashMap::<&mut Cell, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:87:5 + --> tests/ui/mut_key.rs:84:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL | let _map = HashMap::>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:90:5 + --> tests/ui/mut_key.rs:87:5 | LL | let _map = HashMap::, ()>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | let _map = HashMap::, ()>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:93:5 + --> tests/ui/mut_key.rs:90:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | let _map = HashMap::>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:96:5 + --> tests/ui/mut_key.rs:93:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ LL | let _map = HashMap::>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:99:5 + --> tests/ui/mut_key.rs:96:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | let _map = HashMap::>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:102:5 + --> tests/ui/mut_key.rs:99:5 | LL | let _map = HashMap::>>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | let _map = HashMap::>>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:106:5 + --> tests/ui/mut_key.rs:103:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ LL | let _map = HashMap::>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:109:5 + --> tests/ui/mut_key.rs:106:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | let _map = HashMap::>, usize>::new(); = note: ... because it contains `UnsafeCell`, which has interior mutability error: mutable key type - --> tests/ui/mut_key.rs:112:5 + --> tests/ui/mut_key.rs:109:5 | LL | let _map = HashMap::>, usize>::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mut_mut.rs b/tests/ui/mut_mut.rs index 47f52621794b7..bbcdbc89b6a4b 100644 --- a/tests/ui/mut_mut.rs +++ b/tests/ui/mut_mut.rs @@ -13,7 +13,7 @@ extern crate proc_macros; use proc_macros::{external, inline_macros}; fn fun(x: &mut &mut u32) -> bool { -//~^ mut_mut + //~^ mut_mut **x > 0 } diff --git a/tests/ui/mut_range_bound.rs b/tests/ui/mut_range_bound.rs index 326afb42ccb20..107a6229b86d8 100644 --- a/tests/ui/mut_range_bound.rs +++ b/tests/ui/mut_range_bound.rs @@ -7,8 +7,6 @@ fn mut_range_bound_upper() { for i in 0..m { m = 5; //~^ mut_range_bound - - } } @@ -17,8 +15,6 @@ fn mut_range_bound_lower() { for i in m..10 { m *= 2; //~^ mut_range_bound - - } } @@ -29,11 +25,8 @@ fn mut_range_bound_both() { m = 5; //~^ mut_range_bound - n = 7; //~^ mut_range_bound - - } } @@ -50,7 +43,6 @@ fn mut_borrow_range_bound() { let n = &mut m; //~^ mut_range_bound - *n += 1; } } @@ -86,7 +78,6 @@ fn mut_range_bound_no_immediate_break() { m = 2; //~^ mut_range_bound - if m == 4 { break; } @@ -99,7 +90,6 @@ fn mut_range_bound_no_immediate_break() { n = 1; //~^ mut_range_bound - let _ = 2; break; } diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index 3dbc70f87f0fe..3aae6e2dca6d0 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -9,7 +9,7 @@ LL | m = 5; = help: to override `-D warnings` add `#[allow(clippy::mut_range_bound)]` error: attempt to mutate range bound within loop - --> tests/ui/mut_range_bound.rs:18:9 + --> tests/ui/mut_range_bound.rs:16:9 | LL | m *= 2; | ^ @@ -17,7 +17,7 @@ LL | m *= 2; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> tests/ui/mut_range_bound.rs:29:9 + --> tests/ui/mut_range_bound.rs:25:9 | LL | m = 5; | ^ @@ -25,7 +25,7 @@ LL | m = 5; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> tests/ui/mut_range_bound.rs:33:9 + --> tests/ui/mut_range_bound.rs:28:9 | LL | n = 7; | ^ @@ -33,7 +33,7 @@ LL | n = 7; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> tests/ui/mut_range_bound.rs:50:22 + --> tests/ui/mut_range_bound.rs:43:22 | LL | let n = &mut m; | ^ @@ -41,7 +41,7 @@ LL | let n = &mut m; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> tests/ui/mut_range_bound.rs:86:9 + --> tests/ui/mut_range_bound.rs:78:9 | LL | m = 2; | ^ @@ -49,7 +49,7 @@ LL | m = 2; = note: the range of the loop is unchanged error: attempt to mutate range bound within loop - --> tests/ui/mut_range_bound.rs:99:13 + --> tests/ui/mut_range_bound.rs:90:13 | LL | n = 1; | ^ diff --git a/tests/ui/mut_reference.rs b/tests/ui/mut_reference.rs index 4ae57940cf2d1..f664c373cdc3a 100644 --- a/tests/ui/mut_reference.rs +++ b/tests/ui/mut_reference.rs @@ -30,18 +30,15 @@ fn main() { takes_an_immutable_reference(&mut 42); //~^ unnecessary_mut_passed - let as_ptr: fn(&i32) = takes_an_immutable_reference; as_ptr(&mut 42); //~^ unnecessary_mut_passed - // Methods let my_struct = MyStruct; my_struct.takes_an_immutable_reference(&mut 42); //~^ unnecessary_mut_passed - // No error // Functions diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index fb489360a1a36..474221329c258 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -8,13 +8,13 @@ LL | takes_an_immutable_reference(&mut 42); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_mut_passed)]` error: the function `as_ptr` doesn't need a mutable reference - --> tests/ui/mut_reference.rs:35:12 + --> tests/ui/mut_reference.rs:34:12 | LL | as_ptr(&mut 42); | ^^^^^^^ error: the method `takes_an_immutable_reference` doesn't need a mutable reference - --> tests/ui/mut_reference.rs:41:44 + --> tests/ui/mut_reference.rs:39:44 | LL | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ diff --git a/tests/ui/mutex_atomic.rs b/tests/ui/mutex_atomic.rs index 993ea880d66b3..80a712a9286a4 100644 --- a/tests/ui/mutex_atomic.rs +++ b/tests/ui/mutex_atomic.rs @@ -8,7 +8,6 @@ fn main() { Mutex::new(true); //~^ mutex_atomic - Mutex::new(5usize); //~^ mutex_atomic @@ -25,7 +24,6 @@ fn main() { Mutex::new(0u32); //~^ mutex_integer - Mutex::new(0i32); //~^ mutex_integer @@ -43,7 +41,6 @@ fn main() { Mutex::new(X); //~^ mutex_integer - // there are no 128 atomics, so these two should not lint { Mutex::new(0u128); diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index 83be2ef995ce4..838fc1d7c36ee 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -8,31 +8,31 @@ LL | Mutex::new(true); = help: to override `-D warnings` add `#[allow(clippy::mutex_atomic)]` error: consider using an `AtomicUsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:12:5 + --> tests/ui/mutex_atomic.rs:11:5 | LL | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicIsize` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:15:5 + --> tests/ui/mutex_atomic.rs:14:5 | LL | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:19:5 + --> tests/ui/mutex_atomic.rs:18:5 | LL | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicPtr` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:22:5 + --> tests/ui/mutex_atomic.rs:21:5 | LL | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using an `AtomicU32` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:25:5 + --> tests/ui/mutex_atomic.rs:24:5 | LL | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ @@ -41,31 +41,31 @@ LL | Mutex::new(0u32); = help: to override `-D warnings` add `#[allow(clippy::mutex_integer)]` error: consider using an `AtomicI32` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:29:5 + --> tests/ui/mutex_atomic.rs:27:5 | LL | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ error: consider using an `AtomicU8` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:33:5 + --> tests/ui/mutex_atomic.rs:31:5 | LL | Mutex::new(0u8); | ^^^^^^^^^^^^^^^ error: consider using an `AtomicI16` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:36:5 + --> tests/ui/mutex_atomic.rs:34:5 | LL | Mutex::new(0i16); | ^^^^^^^^^^^^^^^^ error: consider using an `AtomicI8` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:39:25 + --> tests/ui/mutex_atomic.rs:37:25 | LL | let _x: Mutex = Mutex::new(0); | ^^^^^^^^^^^^^ error: consider using an `AtomicI64` instead of a `Mutex` here; if you just want the locking behavior and not the internal type, consider using `Mutex<()>` - --> tests/ui/mutex_atomic.rs:43:5 + --> tests/ui/mutex_atomic.rs:41:5 | LL | Mutex::new(X); | ^^^^^^^^^^^^^ diff --git a/tests/ui/needless_arbitrary_self_type.fixed b/tests/ui/needless_arbitrary_self_type.fixed index 22dd127f01f3b..adb9096c9f242 100644 --- a/tests/ui/needless_arbitrary_self_type.fixed +++ b/tests/ui/needless_arbitrary_self_type.fixed @@ -8,7 +8,7 @@ pub enum ValType { impl ValType { pub fn bad(self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -17,7 +17,7 @@ impl ValType { } pub fn mut_bad(mut self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -26,7 +26,7 @@ impl ValType { } pub fn ref_bad(&self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -35,7 +35,7 @@ impl ValType { } pub fn ref_bad_with_lifetime<'a>(&'a self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -44,7 +44,7 @@ impl ValType { } pub fn mut_ref_bad(&mut self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -53,7 +53,7 @@ impl ValType { } pub fn mut_ref_bad_with_lifetime<'a>(&'a mut self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } diff --git a/tests/ui/needless_arbitrary_self_type.rs b/tests/ui/needless_arbitrary_self_type.rs index 5b1702bfdf968..550546ed24fd7 100644 --- a/tests/ui/needless_arbitrary_self_type.rs +++ b/tests/ui/needless_arbitrary_self_type.rs @@ -8,7 +8,7 @@ pub enum ValType { impl ValType { pub fn bad(self: Self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -17,7 +17,7 @@ impl ValType { } pub fn mut_bad(mut self: Self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -26,7 +26,7 @@ impl ValType { } pub fn ref_bad(self: &Self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -35,7 +35,7 @@ impl ValType { } pub fn ref_bad_with_lifetime<'a>(self: &'a Self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -44,7 +44,7 @@ impl ValType { } pub fn mut_ref_bad(self: &mut Self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } @@ -53,7 +53,7 @@ impl ValType { } pub fn mut_ref_bad_with_lifetime<'a>(self: &'a mut Self) { - //~^ needless_arbitrary_self_type + //~^ needless_arbitrary_self_type unimplemented!(); } diff --git a/tests/ui/needless_as_bytes.fixed b/tests/ui/needless_as_bytes.fixed index 2f9e822188897..9cbc7b9c26519 100644 --- a/tests/ui/needless_as_bytes.fixed +++ b/tests/ui/needless_as_bytes.fixed @@ -15,34 +15,30 @@ impl S { fn main() { if "some string".is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", "some string".len()); //~^ needless_as_bytes - } if "some string".is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", "some string".len()); //~^ needless_as_bytes - } let s = String::from("yet another string"); if s.is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", s.len()); //~^ needless_as_bytes - } if s.is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", s.len()); //~^ needless_as_bytes - } // Do not lint diff --git a/tests/ui/needless_as_bytes.rs b/tests/ui/needless_as_bytes.rs index 2f0fc352d192a..7de699647e85f 100644 --- a/tests/ui/needless_as_bytes.rs +++ b/tests/ui/needless_as_bytes.rs @@ -15,34 +15,30 @@ impl S { fn main() { if "some string".as_bytes().is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", "some string".as_bytes().len()); //~^ needless_as_bytes - } if "some string".bytes().is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", "some string".bytes().len()); //~^ needless_as_bytes - } let s = String::from("yet another string"); if s.as_bytes().is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", s.as_bytes().len()); //~^ needless_as_bytes - } if s.bytes().is_empty() { - //~^ needless_as_bytes + //~^ needless_as_bytes println!("len = {}", s.bytes().len()); //~^ needless_as_bytes - } // Do not lint diff --git a/tests/ui/needless_as_bytes.stderr b/tests/ui/needless_as_bytes.stderr index 72746c05b8e26..0eead9815f8ab 100644 --- a/tests/ui/needless_as_bytes.stderr +++ b/tests/ui/needless_as_bytes.stderr @@ -14,37 +14,37 @@ LL | println!("len = {}", "some string".as_bytes().len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `"some string".len()` error: needless call to `bytes` - --> tests/ui/needless_as_bytes.rs:24:8 + --> tests/ui/needless_as_bytes.rs:23:8 | LL | if "some string".bytes().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `is_empty()` can be called directly on strings: `"some string".is_empty()` error: needless call to `bytes` - --> tests/ui/needless_as_bytes.rs:27:30 + --> tests/ui/needless_as_bytes.rs:26:30 | LL | println!("len = {}", "some string".bytes().len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `"some string".len()` error: needless call to `as_bytes` - --> tests/ui/needless_as_bytes.rs:33:8 + --> tests/ui/needless_as_bytes.rs:31:8 | LL | if s.as_bytes().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: `is_empty()` can be called directly on strings: `s.is_empty()` error: needless call to `as_bytes` - --> tests/ui/needless_as_bytes.rs:36:30 + --> tests/ui/needless_as_bytes.rs:34:30 | LL | println!("len = {}", s.as_bytes().len()); | ^^^^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `s.len()` error: needless call to `bytes` - --> tests/ui/needless_as_bytes.rs:40:8 + --> tests/ui/needless_as_bytes.rs:37:8 | LL | if s.bytes().is_empty() { | ^^^^^^^^^^^^^^^^^^^^ help: `is_empty()` can be called directly on strings: `s.is_empty()` error: needless call to `bytes` - --> tests/ui/needless_as_bytes.rs:43:30 + --> tests/ui/needless_as_bytes.rs:40:30 | LL | println!("len = {}", s.bytes().len()); | ^^^^^^^^^^^^^^^ help: `len()` can be called directly on strings: `s.len()` diff --git a/tests/ui/needless_bitwise_bool.fixed b/tests/ui/needless_bitwise_bool.fixed index 7fc36e0f94b49..89a3c1474f25d 100644 --- a/tests/ui/needless_bitwise_bool.fixed +++ b/tests/ui/needless_bitwise_bool.fixed @@ -21,7 +21,7 @@ fn main() { println!("true") } if y && !x { - //~^ needless_bitwise_bool + //~^ needless_bitwise_bool println!("true") } diff --git a/tests/ui/needless_bitwise_bool.rs b/tests/ui/needless_bitwise_bool.rs index dcbc08334a77c..f5aa7a9f3d9e3 100644 --- a/tests/ui/needless_bitwise_bool.rs +++ b/tests/ui/needless_bitwise_bool.rs @@ -21,7 +21,7 @@ fn main() { println!("true") } if y & !x { - //~^ needless_bitwise_bool + //~^ needless_bitwise_bool println!("true") } diff --git a/tests/ui/needless_borrow_pat.fixed b/tests/ui/needless_borrow_pat.fixed index d067f1c6016b2..fe966a716df71 100644 --- a/tests/ui/needless_borrow_pat.fixed +++ b/tests/ui/needless_borrow_pat.fixed @@ -58,8 +58,6 @@ fn main() { let _: &String = match Some(&x) { Some(x) => x, //~^ needless_borrow - - None => return, }; @@ -67,14 +65,13 @@ fn main() { let _: &String = match Some(&x) { Some(x) => x, //~^ needless_borrow - None => return, }; // Err, reference to a &String let _: &String = match Some(&x) { Some(x) => { - //~^ needless_borrow + //~^ needless_borrow f1(x); f1(x); @@ -87,13 +84,12 @@ fn main() { match Some(&x) { Some(x) => m1!(x), //~^ needless_borrow - None => return, }; // Err, reference to a &String let _ = |&x: &&String| { - //~^ needless_borrow + //~^ needless_borrow let _: &String = x; }; @@ -113,7 +109,6 @@ fn main() { let _: u32 = match Some(&x) { Some(x) => x.0, //~^ needless_borrow - None => return, }; @@ -125,7 +120,6 @@ fn main() { let _: &u32 = match E::A(&0) { E::A(x) | E::B(x) => x, //~^ needless_borrow - }; // Err, reference to &String. @@ -142,7 +136,7 @@ fn main() { // Err, reference to a &String fn f2<'a>(&x: &&'a String) -> &'a String { -//~^ needless_borrow + //~^ needless_borrow let _: &String = x; x @@ -151,7 +145,7 @@ fn f2<'a>(&x: &&'a String) -> &'a String { trait T1 { // Err, reference to a &String fn f(&x: &&String) { - //~^ needless_borrow + //~^ needless_borrow let _: &String = x; } @@ -161,7 +155,7 @@ struct S; impl T1 for S { // Err, reference to a &String fn f(&x: &&String) { - //~^ needless_borrow + //~^ needless_borrow let _: &String = x; } diff --git a/tests/ui/needless_borrow_pat.rs b/tests/ui/needless_borrow_pat.rs index 7c39183d79169..a6b43855cad10 100644 --- a/tests/ui/needless_borrow_pat.rs +++ b/tests/ui/needless_borrow_pat.rs @@ -58,8 +58,6 @@ fn main() { let _: &String = match Some(&x) { Some(ref x) => x, //~^ needless_borrow - - None => return, }; @@ -67,14 +65,13 @@ fn main() { let _: &String = match Some(&x) { Some(ref x) => *x, //~^ needless_borrow - None => return, }; // Err, reference to a &String let _: &String = match Some(&x) { Some(ref x) => { - //~^ needless_borrow + //~^ needless_borrow f1(x); f1(*x); @@ -87,13 +84,12 @@ fn main() { match Some(&x) { Some(ref x) => m1!(x), //~^ needless_borrow - None => return, }; // Err, reference to a &String let _ = |&ref x: &&String| { - //~^ needless_borrow + //~^ needless_borrow let _: &String = x; }; @@ -113,7 +109,6 @@ fn main() { let _: u32 = match Some(&x) { Some(ref x) => x.0, //~^ needless_borrow - None => return, }; @@ -125,7 +120,6 @@ fn main() { let _: &u32 = match E::A(&0) { E::A(ref x) | E::B(ref x) => *x, //~^ needless_borrow - }; // Err, reference to &String. @@ -142,7 +136,7 @@ fn main() { // Err, reference to a &String fn f2<'a>(&ref x: &&'a String) -> &'a String { -//~^ needless_borrow + //~^ needless_borrow let _: &String = x; *x @@ -151,7 +145,7 @@ fn f2<'a>(&ref x: &&'a String) -> &'a String { trait T1 { // Err, reference to a &String fn f(&ref x: &&String) { - //~^ needless_borrow + //~^ needless_borrow let _: &String = x; } @@ -161,7 +155,7 @@ struct S; impl T1 for S { // Err, reference to a &String fn f(&ref x: &&String) { - //~^ needless_borrow + //~^ needless_borrow let _: &String = *x; } diff --git a/tests/ui/needless_borrow_pat.stderr b/tests/ui/needless_borrow_pat.stderr index 7e1b3694e30fa..018e74a4f11d3 100644 --- a/tests/ui/needless_borrow_pat.stderr +++ b/tests/ui/needless_borrow_pat.stderr @@ -8,7 +8,7 @@ LL | Some(ref x) => x, = help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]` error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:68:14 + --> tests/ui/needless_borrow_pat.rs:66:14 | LL | Some(ref x) => *x, | ^^^^^ @@ -19,7 +19,7 @@ LL | Some(x) => x, | ~ ~ error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:76:14 + --> tests/ui/needless_borrow_pat.rs:73:14 | LL | Some(ref x) => { | ^^^^^ @@ -34,19 +34,19 @@ LL ~ f1(x); | error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:88:14 + --> tests/ui/needless_borrow_pat.rs:85:14 | LL | Some(ref x) => m1!(x), | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:95:15 + --> tests/ui/needless_borrow_pat.rs:91:15 | LL | let _ = |&ref x: &&String| { | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:102:10 + --> tests/ui/needless_borrow_pat.rs:98:10 | LL | let (ref y,) = (&x,); | ^^^^^ @@ -60,13 +60,13 @@ LL ~ let _: &String = y; | error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:114:14 + --> tests/ui/needless_borrow_pat.rs:110:14 | LL | Some(ref x) => x.0, | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:126:14 + --> tests/ui/needless_borrow_pat.rs:121:14 | LL | E::A(ref x) | E::B(ref x) => *x, | ^^^^^ ^^^^^ @@ -77,13 +77,13 @@ LL | E::A(x) | E::B(x) => x, | ~ ~ ~ error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:134:21 + --> tests/ui/needless_borrow_pat.rs:128:21 | LL | if let Some(ref x) = Some(&String::new()); | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:144:12 + --> tests/ui/needless_borrow_pat.rs:138:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { | ^^^^^ @@ -98,13 +98,13 @@ LL ~ x | error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:153:11 + --> tests/ui/needless_borrow_pat.rs:147:11 | LL | fn f(&ref x: &&String) { | ^^^^^ help: try: `x` error: this pattern creates a reference to a reference - --> tests/ui/needless_borrow_pat.rs:163:11 + --> tests/ui/needless_borrow_pat.rs:157:11 | LL | fn f(&ref x: &&String) { | ^^^^^ diff --git a/tests/ui/needless_borrowed_ref.fixed b/tests/ui/needless_borrowed_ref.fixed index 1cad115e96d1f..e4504bc2784cc 100644 --- a/tests/ui/needless_borrowed_ref.fixed +++ b/tests/ui/needless_borrowed_ref.fixed @@ -69,7 +69,7 @@ fn should_lint( //~^ needless_borrowed_reference if let Struct { - //~^ needless_borrowed_reference + //~^ needless_borrowed_reference a, b: b, c: renamed, diff --git a/tests/ui/needless_borrowed_ref.rs b/tests/ui/needless_borrowed_ref.rs index ae6377fd44217..7edfda60b9790 100644 --- a/tests/ui/needless_borrowed_ref.rs +++ b/tests/ui/needless_borrowed_ref.rs @@ -69,7 +69,7 @@ fn should_lint( //~^ needless_borrowed_reference if let &Struct { - //~^ needless_borrowed_reference + //~^ needless_borrowed_reference ref a, b: ref b, c: ref renamed, diff --git a/tests/ui/needless_character_iteration.fixed b/tests/ui/needless_character_iteration.fixed index 584b578fa8be8..e25db9bb590f7 100644 --- a/tests/ui/needless_character_iteration.fixed +++ b/tests/ui/needless_character_iteration.fixed @@ -27,7 +27,6 @@ fn main() { !"foo".is_ascii(); //~^ needless_character_iteration - let s = String::new(); s.is_ascii(); //~^ needless_character_iteration @@ -35,14 +34,12 @@ fn main() { !"foo".to_string().is_ascii(); //~^ needless_character_iteration - "foo".is_ascii(); !"foo".is_ascii(); S::default().field().is_ascii(); //~^ needless_character_iteration - // Should not lint! "foo".chars().all(|c| { let x = c; diff --git a/tests/ui/needless_character_iteration.rs b/tests/ui/needless_character_iteration.rs index 1ef5c3a79a3ef..9b184dab6bc82 100644 --- a/tests/ui/needless_character_iteration.rs +++ b/tests/ui/needless_character_iteration.rs @@ -27,7 +27,6 @@ fn main() { "foo".chars().any(|c| !char::is_ascii(&c)); //~^ needless_character_iteration - let s = String::new(); s.chars().all(|c| c.is_ascii()); //~^ needless_character_iteration @@ -35,15 +34,14 @@ fn main() { "foo".to_string().chars().any(|c| !c.is_ascii()); //~^ needless_character_iteration - "foo".chars().all(|c| { - //~^ needless_character_iteration + //~^ needless_character_iteration let x = c; x.is_ascii() }); "foo".chars().any(|c| { - //~^ needless_character_iteration + //~^ needless_character_iteration let x = c; !x.is_ascii() @@ -52,7 +50,6 @@ fn main() { S::default().field().chars().all(|x| x.is_ascii()); //~^ needless_character_iteration - // Should not lint! "foo".chars().all(|c| { let x = c; diff --git a/tests/ui/needless_character_iteration.stderr b/tests/ui/needless_character_iteration.stderr index 29e5a674e0c50..9954049966444 100644 --- a/tests/ui/needless_character_iteration.stderr +++ b/tests/ui/needless_character_iteration.stderr @@ -26,19 +26,19 @@ LL | "foo".chars().any(|c| !char::is_ascii(&c)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!"foo".is_ascii()` error: checking if a string is ascii using iterators - --> tests/ui/needless_character_iteration.rs:32:5 + --> tests/ui/needless_character_iteration.rs:31:5 | LL | s.chars().all(|c| c.is_ascii()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `s.is_ascii()` error: checking if a string is ascii using iterators - --> tests/ui/needless_character_iteration.rs:35:5 + --> tests/ui/needless_character_iteration.rs:34:5 | LL | "foo".to_string().chars().any(|c| !c.is_ascii()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!"foo".to_string().is_ascii()` error: checking if a string is ascii using iterators - --> tests/ui/needless_character_iteration.rs:39:5 + --> tests/ui/needless_character_iteration.rs:37:5 | LL | / "foo".chars().all(|c| { LL | | @@ -49,7 +49,7 @@ LL | | }); | |______^ help: try: `"foo".is_ascii()` error: checking if a string is ascii using iterators - --> tests/ui/needless_character_iteration.rs:45:5 + --> tests/ui/needless_character_iteration.rs:43:5 | LL | / "foo".chars().any(|c| { LL | | @@ -60,7 +60,7 @@ LL | | }); | |______^ help: try: `!"foo".is_ascii()` error: checking if a string is ascii using iterators - --> tests/ui/needless_character_iteration.rs:52:5 + --> tests/ui/needless_character_iteration.rs:50:5 | LL | S::default().field().chars().all(|x| x.is_ascii()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `S::default().field().is_ascii()` diff --git a/tests/ui/needless_collect.fixed b/tests/ui/needless_collect.fixed index c2267b84de42f..104941dc99373 100644 --- a/tests/ui/needless_collect.fixed +++ b/tests/ui/needless_collect.fixed @@ -9,7 +9,7 @@ fn main() { let len = sample.iter().count(); //~^ needless_collect if sample.iter().next().is_none() { - //~^ needless_collect + //~^ needless_collect // Empty } sample.iter().cloned().any(|x| x == 1); diff --git a/tests/ui/needless_collect.rs b/tests/ui/needless_collect.rs index 854bc3fff19d0..7f05f51b82e94 100644 --- a/tests/ui/needless_collect.rs +++ b/tests/ui/needless_collect.rs @@ -9,7 +9,7 @@ fn main() { let len = sample.iter().collect::>().len(); //~^ needless_collect if sample.iter().collect::>().is_empty() { - //~^ needless_collect + //~^ needless_collect // Empty } sample.iter().cloned().collect::>().contains(&1); diff --git a/tests/ui/needless_continue.rs b/tests/ui/needless_continue.rs index 0adef7e72ee45..e873db6dee14e 100644 --- a/tests/ui/needless_continue.rs +++ b/tests/ui/needless_continue.rs @@ -28,7 +28,7 @@ fn main() { let i = 0; println!("bar {} ", i); } else { - //~^ needless_continue + //~^ needless_continue continue; } @@ -45,7 +45,7 @@ fn main() { } if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 { - //~^ needless_continue + //~^ needless_continue continue; } else { @@ -61,7 +61,6 @@ fn simple_loop() { loop { continue; //~^ needless_continue - } } @@ -70,7 +69,6 @@ fn simple_loop2() { println!("bleh"); continue; //~^ needless_continue - } } @@ -98,7 +96,6 @@ fn simple_loop5() { println!("bleh"); { continue } //~^ needless_continue - } } @@ -149,7 +146,7 @@ mod issue_2329 { if condition() { println!("bar-3"); } else { - //~^ needless_continue + //~^ needless_continue continue 'inner; } @@ -157,7 +154,7 @@ mod issue_2329 { update_condition(); if condition() { - //~^ needless_continue + //~^ needless_continue continue; } else { @@ -182,7 +179,6 @@ fn issue_13641() { 'b: loop { continue 'b; //~^ needless_continue - } } } @@ -221,7 +217,7 @@ mod issue_4077 { loop { if true { } else { - //~^ needless_continue + //~^ needless_continue // redundant `else` continue; // redundant `continue` } @@ -229,7 +225,7 @@ mod issue_4077 { loop { if some_expr() { - //~^ needless_continue + //~^ needless_continue continue; } else { do_something(); diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 947e61cac12e6..878c1e731e32a 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -71,7 +71,7 @@ LL | continue; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:71:9 + --> tests/ui/needless_continue.rs:70:9 | LL | continue; | ^^^^^^^^ @@ -79,7 +79,7 @@ LL | continue; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:80:9 + --> tests/ui/needless_continue.rs:78:9 | LL | continue | ^^^^^^^^ @@ -87,7 +87,7 @@ LL | continue = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:90:9 + --> tests/ui/needless_continue.rs:88:9 | LL | continue | ^^^^^^^^ @@ -95,7 +95,7 @@ LL | continue = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:99:11 + --> tests/ui/needless_continue.rs:97:11 | LL | { continue } | ^^^^^^^^ @@ -103,7 +103,7 @@ LL | { continue } = help: consider dropping the `continue` expression error: this `else` block is redundant - --> tests/ui/needless_continue.rs:151:24 + --> tests/ui/needless_continue.rs:148:24 | LL | } else { | ________________________^ @@ -130,7 +130,7 @@ LL | | } } error: there is no need for an explicit `else` block for this `if` expression - --> tests/ui/needless_continue.rs:159:17 + --> tests/ui/needless_continue.rs:156:17 | LL | / if condition() { LL | | @@ -152,7 +152,7 @@ LL | | } } error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:183:13 + --> tests/ui/needless_continue.rs:180:13 | LL | continue 'b; | ^^^^^^^^^^^ @@ -160,7 +160,7 @@ LL | continue 'b; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:200:21 + --> tests/ui/needless_continue.rs:196:21 | LL | continue 'inner; | ^^^^^^^^^^^^^^^ @@ -168,7 +168,7 @@ LL | continue 'inner; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:204:21 + --> tests/ui/needless_continue.rs:200:21 | LL | continue 'inner; | ^^^^^^^^^^^^^^^ @@ -176,7 +176,7 @@ LL | continue 'inner; = help: consider dropping the `continue` expression error: this `continue` expression is redundant - --> tests/ui/needless_continue.rs:215:21 + --> tests/ui/needless_continue.rs:211:21 | LL | continue; | ^^^^^^^^ @@ -184,7 +184,7 @@ LL | continue; = help: consider dropping the `continue` expression error: this `else` block is redundant - --> tests/ui/needless_continue.rs:223:20 + --> tests/ui/needless_continue.rs:219:20 | LL | } else { | ____________________^ @@ -201,7 +201,7 @@ LL | | } } error: there is no need for an explicit `else` block for this `if` expression - --> tests/ui/needless_continue.rs:231:13 + --> tests/ui/needless_continue.rs:227:13 | LL | / if some_expr() { LL | | diff --git a/tests/ui/needless_for_each_fixable.fixed b/tests/ui/needless_for_each_fixable.fixed index 873bad552af1b..fa23e18318f19 100644 --- a/tests/ui/needless_for_each_fixable.fixed +++ b/tests/ui/needless_for_each_fixable.fixed @@ -13,34 +13,34 @@ fn should_lint() { let v: Vec = Vec::new(); let mut acc = 0; for elem in v.iter() { - //~^ needless_for_each + //~^ needless_for_each acc += elem; } for elem in v.into_iter() { - //~^ needless_for_each + //~^ needless_for_each acc += elem; } for elem in [1, 2, 3].iter() { - //~^ needless_for_each + //~^ needless_for_each acc += elem; } let mut hash_map: HashMap = HashMap::new(); for (k, v) in hash_map.iter() { - //~^ needless_for_each + //~^ needless_for_each acc += k + v; } for (k, v) in hash_map.iter_mut() { - //~^ needless_for_each + //~^ needless_for_each acc += *k + *v; } for k in hash_map.keys() { - //~^ needless_for_each + //~^ needless_for_each acc += k; } for v in hash_map.values() { - //~^ needless_for_each + //~^ needless_for_each acc += v; } @@ -48,7 +48,7 @@ fn should_lint() { Vec::new() } for elem in my_vec().iter() { - //~^ needless_for_each + //~^ needless_for_each acc += elem; } } diff --git a/tests/ui/needless_for_each_fixable.rs b/tests/ui/needless_for_each_fixable.rs index 5e650dfc06c19..2c7e68a6f5128 100644 --- a/tests/ui/needless_for_each_fixable.rs +++ b/tests/ui/needless_for_each_fixable.rs @@ -13,34 +13,34 @@ fn should_lint() { let v: Vec = Vec::new(); let mut acc = 0; v.iter().for_each(|elem| { - //~^ needless_for_each + //~^ needless_for_each acc += elem; }); v.into_iter().for_each(|elem| { - //~^ needless_for_each + //~^ needless_for_each acc += elem; }); [1, 2, 3].iter().for_each(|elem| { - //~^ needless_for_each + //~^ needless_for_each acc += elem; }); let mut hash_map: HashMap = HashMap::new(); hash_map.iter().for_each(|(k, v)| { - //~^ needless_for_each + //~^ needless_for_each acc += k + v; }); hash_map.iter_mut().for_each(|(k, v)| { - //~^ needless_for_each + //~^ needless_for_each acc += *k + *v; }); hash_map.keys().for_each(|k| { - //~^ needless_for_each + //~^ needless_for_each acc += k; }); hash_map.values().for_each(|v| { - //~^ needless_for_each + //~^ needless_for_each acc += v; }); @@ -48,7 +48,7 @@ fn should_lint() { Vec::new() } my_vec().iter().for_each(|elem| { - //~^ needless_for_each + //~^ needless_for_each acc += elem; }); } diff --git a/tests/ui/needless_for_each_unfixable.rs b/tests/ui/needless_for_each_unfixable.rs index 56faa471ed8c1..159cbe49828f6 100644 --- a/tests/ui/needless_for_each_unfixable.rs +++ b/tests/ui/needless_for_each_unfixable.rs @@ -6,8 +6,7 @@ fn main() { let v: Vec = Vec::new(); // This is unfixable because the closure includes `return`. v.iter().for_each(|v| { - //~^ needless_for_each - + //~^ needless_for_each if *v == 10 { return; diff --git a/tests/ui/needless_for_each_unfixable.stderr b/tests/ui/needless_for_each_unfixable.stderr index 37470a8a622ed..7e42bd133f069 100644 --- a/tests/ui/needless_for_each_unfixable.stderr +++ b/tests/ui/needless_for_each_unfixable.stderr @@ -2,6 +2,9 @@ error: needless use of `for_each` --> tests/ui/needless_for_each_unfixable.rs:8:5 | LL | / v.iter().for_each(|v| { +LL | | +LL | | +LL | | if *v == 10 { ... | LL | | }); | |_______^ @@ -13,7 +16,6 @@ help: try LL ~ for v in v.iter() { LL + LL + -LL + LL + if *v == 10 { LL + return; LL + } else { diff --git a/tests/ui/needless_if.fixed b/tests/ui/needless_if.fixed index 1e2842a27aa6e..6208ca19b82b4 100644 --- a/tests/ui/needless_if.fixed +++ b/tests/ui/needless_if.fixed @@ -34,7 +34,7 @@ fn main() { } else { } ({ - //~^ needless_if + //~^ needless_if return; }); // Do not lint if `else if` is present @@ -51,7 +51,7 @@ fn main() { {} // Can lint nested `if let`s ({ - //~^ needless_if + //~^ needless_if if let true = true && true { diff --git a/tests/ui/needless_if.rs b/tests/ui/needless_if.rs index a753c66da5a54..b459ff877be61 100644 --- a/tests/ui/needless_if.rs +++ b/tests/ui/needless_if.rs @@ -34,7 +34,7 @@ fn main() { } else { } if { - //~^ needless_if + //~^ needless_if return; } {} // Do not lint if `else if` is present @@ -51,7 +51,7 @@ fn main() { {} // Can lint nested `if let`s if { - //~^ needless_if + //~^ needless_if if let true = true && true { diff --git a/tests/ui/needless_lifetimes.fixed b/tests/ui/needless_lifetimes.fixed index 3cfbce84cd9ba..283635d42def8 100644 --- a/tests/ui/needless_lifetimes.fixed +++ b/tests/ui/needless_lifetimes.fixed @@ -31,7 +31,7 @@ fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) {} fn mut_and_static_input(_x: &mut u8, _y: &'static str) {} fn in_and_out(x: &u8, _y: u8) -> &u8 { -//~^ needless_lifetimes + //~^ needless_lifetimes x } @@ -44,7 +44,7 @@ fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 { // fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 // ^^^ fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 { -//~^ needless_lifetimes + //~^ needless_lifetimes x } @@ -52,7 +52,7 @@ fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 { // fn multiple_in_and_out_2b<'b>(_x: &u8, y: &'b u8) -> &'b u8 // ^^^ fn multiple_in_and_out_2b<'b>(_x: &u8, y: &'b u8) -> &'b u8 { -//~^ needless_lifetimes + //~^ needless_lifetimes y } @@ -70,7 +70,7 @@ fn in_static_and_out<'a>(x: &'a u8, _y: &'static u8) -> &'a u8 { // fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> // ^^^ fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> { -//~^ needless_lifetimes + //~^ needless_lifetimes Ok(x) } @@ -78,7 +78,7 @@ fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> { // fn deep_reference_1b<'b>(_x: &u8, y: &'b u8) -> Result<&'b u8, ()> // ^^^ fn deep_reference_1b<'b>(_x: &u8, y: &'b u8) -> Result<&'b u8, ()> { -//~^ needless_lifetimes + //~^ needless_lifetimes Ok(y) } @@ -88,7 +88,7 @@ fn deep_reference_2<'a>(x: Result<&'a u8, &'a u8>) -> &'a u8 { } fn deep_reference_3(x: &u8, _y: u8) -> Result<&u8, ()> { -//~^ needless_lifetimes + //~^ needless_lifetimes Ok(x) } @@ -163,7 +163,7 @@ struct X { impl X { fn self_and_out(&self) -> &u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes &self.x } @@ -171,7 +171,7 @@ impl X { // fn self_and_in_out_1<'s>(&'s self, _x: &u8) -> &'s u8 // ^^^ fn self_and_in_out_1<'s>(&'s self, _x: &u8) -> &'s u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes &self.x } @@ -179,7 +179,7 @@ impl X { // fn self_and_in_out_2<'t>(&self, x: &'t u8) -> &'t u8 // ^^^^^ fn self_and_in_out_2<'t>(&self, x: &'t u8) -> &'t u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes x } @@ -204,7 +204,7 @@ fn already_elided<'a>(_: &u8, _: &'a u8) -> &'a u8 { } fn struct_with_lt(_foo: Foo<'_>) -> &str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -223,7 +223,7 @@ fn struct_with_lt3<'a>(_foo: &Foo<'a>) -> &'a str { // fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str // ^^ fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -232,7 +232,7 @@ fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str { // fn struct_with_lt4b<'b>(_foo: &Foo<'b>) -> &'b str // ^^^^ fn struct_with_lt4b<'b>(_foo: &Foo<'b>) -> &'b str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -248,14 +248,14 @@ fn trait_obj_elided<'a>(_arg: &'a dyn WithLifetime) -> &'a str { // Should warn because there is no lifetime on `Drop`, so this would be // unambiguous if we elided the lifetime. fn trait_obj_elided2(_arg: &dyn Drop) -> &str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } type FooAlias<'a> = Foo<'a>; fn alias_with_lt(_foo: FooAlias<'_>) -> &str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -274,7 +274,7 @@ fn alias_with_lt3<'a>(_foo: &FooAlias<'a>) -> &'a str { // fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str // ^^ fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -283,12 +283,12 @@ fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str { // fn alias_with_lt4b<'b>(_foo: &FooAlias<'b>) -> &'b str // ^^^^^^^^^ fn alias_with_lt4b<'b>(_foo: &FooAlias<'b>) -> &'b str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } fn named_input_elided_output(_arg: &str) -> &str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -297,7 +297,7 @@ fn elided_input_named_output<'a>(_arg: &str) -> &'a str { } fn trait_bound_ok>(_: &u8, _: T) { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) { @@ -334,7 +334,7 @@ struct Cow<'a> { x: &'a str, } fn out_return_type_lts(e: &str) -> Cow<'_> { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -362,7 +362,7 @@ mod issue2944 { //~^ needless_lifetimes impl Bar { fn baz(&self) -> impl Foo + '_ { - //~^ needless_lifetimes + //~^ needless_lifetimes Baz { bar: self } } } @@ -395,7 +395,7 @@ mod nested_elision_sites { f(i) } fn impl_trait_elidable_nested_anonymous_lifetimes(i: &i32, f: impl Fn(&i32) -> &i32) -> &i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes f(i) } @@ -405,7 +405,7 @@ mod nested_elision_sites { } // lint fn generics_elidable &i32>(i: &i32, f: T) -> &i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes f(i) } @@ -434,7 +434,7 @@ mod nested_elision_sites { } // lint fn pointer_fn_elidable(i: &i32, f: fn(&i32) -> &i32) -> &i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes f(i) } @@ -448,11 +448,11 @@ mod nested_elision_sites { // lint fn nested_fn_pointer_3(_: &i32) -> fn(fn(&i32) -> &i32) -> i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes |f| 42 } fn nested_fn_pointer_4(_: &i32) -> impl Fn(fn(&i32)) { - //~^ needless_lifetimes + //~^ needless_lifetimes |f| () } } @@ -475,21 +475,21 @@ mod issue7296 { struct Foo; impl Foo { fn implicit(&self) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } fn implicit_mut(&mut self) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.81"] fn explicit(self: &Arc) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.81"] fn explicit_mut(self: &mut Rc) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.80"] @@ -502,7 +502,7 @@ mod issue7296 { } fn lifetime_elsewhere(self: Box, here: &()) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } } @@ -511,7 +511,7 @@ mod issue7296 { fn implicit(&self) -> &(); //~^ needless_lifetimes fn implicit_provided(&self) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } @@ -520,7 +520,7 @@ mod issue7296 { //~^ needless_lifetimes #[clippy::msrv = "1.81"] fn explicit_provided(self: &Arc) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.80"] @@ -533,7 +533,7 @@ mod issue7296 { fn lifetime_elsewhere(self: Box, here: &()) -> &(); //~^ needless_lifetimes fn lifetime_elsewhere_provided(self: Box, here: &()) -> &() { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } } @@ -554,13 +554,13 @@ mod pr_9743_output_lifetime_checks { // lint: only one input fn one_input(x: &u8) -> &u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } // lint: multiple inputs, output would not be elided fn multiple_inputs_output_not_elided<'b>(x: &u8, y: &'b u8, z: &'b u8) -> &'b u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -673,7 +673,7 @@ mod issue13923 { } impl<'t> ContentString<'t> { - //~^ needless_lifetimes + //~^ needless_lifetimes // `'py` can be elided because of `&self` fn map_content2(&self, f: impl FnOnce(&'t str) -> &'t str) -> Content<'t, '_> { match self { @@ -684,7 +684,7 @@ mod issue13923 { } impl<'t> ContentString<'t> { - //~^ needless_lifetimes + //~^ needless_lifetimes // `'py` can be elided because of `&'_ self` fn map_content3(&'_ self, f: impl FnOnce(&'t str) -> &'t str) -> Content<'t, '_> { match self { @@ -705,7 +705,7 @@ mod issue13923 { } impl<'t> ContentString<'t> { - //~^ needless_lifetimes + //~^ needless_lifetimes // `'py` can be elided because of `&Self` fn map_content5( self: std::pin::Pin<&Self>, diff --git a/tests/ui/needless_lifetimes.rs b/tests/ui/needless_lifetimes.rs index 612e7546d9625..2853870473db2 100644 --- a/tests/ui/needless_lifetimes.rs +++ b/tests/ui/needless_lifetimes.rs @@ -31,7 +31,7 @@ fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) {} fn mut_and_static_input(_x: &mut u8, _y: &'static str) {} fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { -//~^ needless_lifetimes + //~^ needless_lifetimes x } @@ -44,7 +44,7 @@ fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 { // fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 // ^^^ fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { -//~^ needless_lifetimes + //~^ needless_lifetimes x } @@ -52,7 +52,7 @@ fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { // fn multiple_in_and_out_2b<'b>(_x: &u8, y: &'b u8) -> &'b u8 // ^^^ fn multiple_in_and_out_2b<'a, 'b>(_x: &'a u8, y: &'b u8) -> &'b u8 { -//~^ needless_lifetimes + //~^ needless_lifetimes y } @@ -70,7 +70,7 @@ fn in_static_and_out<'a>(x: &'a u8, _y: &'static u8) -> &'a u8 { // fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> // ^^^ fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { -//~^ needless_lifetimes + //~^ needless_lifetimes Ok(x) } @@ -78,7 +78,7 @@ fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { // fn deep_reference_1b<'b>(_x: &u8, y: &'b u8) -> Result<&'b u8, ()> // ^^^ fn deep_reference_1b<'a, 'b>(_x: &'a u8, y: &'b u8) -> Result<&'b u8, ()> { -//~^ needless_lifetimes + //~^ needless_lifetimes Ok(y) } @@ -88,7 +88,7 @@ fn deep_reference_2<'a>(x: Result<&'a u8, &'a u8>) -> &'a u8 { } fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { -//~^ needless_lifetimes + //~^ needless_lifetimes Ok(x) } @@ -163,7 +163,7 @@ struct X { impl X { fn self_and_out<'s>(&'s self) -> &'s u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes &self.x } @@ -171,7 +171,7 @@ impl X { // fn self_and_in_out_1<'s>(&'s self, _x: &u8) -> &'s u8 // ^^^ fn self_and_in_out_1<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes &self.x } @@ -179,7 +179,7 @@ impl X { // fn self_and_in_out_2<'t>(&self, x: &'t u8) -> &'t u8 // ^^^^^ fn self_and_in_out_2<'s, 't>(&'s self, x: &'t u8) -> &'t u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes x } @@ -204,7 +204,7 @@ fn already_elided<'a>(_: &u8, _: &'a u8) -> &'a u8 { } fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -223,7 +223,7 @@ fn struct_with_lt3<'a>(_foo: &Foo<'a>) -> &'a str { // fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str // ^^ fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -232,7 +232,7 @@ fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str { // fn struct_with_lt4b<'b>(_foo: &Foo<'b>) -> &'b str // ^^^^ fn struct_with_lt4b<'a, 'b>(_foo: &'a Foo<'b>) -> &'b str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -248,14 +248,14 @@ fn trait_obj_elided<'a>(_arg: &'a dyn WithLifetime) -> &'a str { // Should warn because there is no lifetime on `Drop`, so this would be // unambiguous if we elided the lifetime. fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } type FooAlias<'a> = Foo<'a>; fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -274,7 +274,7 @@ fn alias_with_lt3<'a>(_foo: &FooAlias<'a>) -> &'a str { // fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str // ^^ fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -283,12 +283,12 @@ fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str { // fn alias_with_lt4b<'b>(_foo: &FooAlias<'b>) -> &'b str // ^^^^^^^^^ fn alias_with_lt4b<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'b str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } fn named_input_elided_output<'a>(_arg: &'a str) -> &str { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -297,7 +297,7 @@ fn elided_input_named_output<'a>(_arg: &str) -> &'a str { } fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) { @@ -334,7 +334,7 @@ struct Cow<'a> { x: &'a str, } fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { -//~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -362,7 +362,7 @@ mod issue2944 { //~^ needless_lifetimes impl Bar { fn baz<'a>(&'a self) -> impl Foo + 'a { - //~^ needless_lifetimes + //~^ needless_lifetimes Baz { bar: self } } } @@ -395,7 +395,7 @@ mod nested_elision_sites { f(i) } fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes f(i) } @@ -405,7 +405,7 @@ mod nested_elision_sites { } // lint fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes f(i) } @@ -434,7 +434,7 @@ mod nested_elision_sites { } // lint fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes f(i) } @@ -448,11 +448,11 @@ mod nested_elision_sites { // lint fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 { - //~^ needless_lifetimes + //~^ needless_lifetimes |f| 42 } fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) { - //~^ needless_lifetimes + //~^ needless_lifetimes |f| () } } @@ -475,21 +475,21 @@ mod issue7296 { struct Foo; impl Foo { fn implicit<'a>(&'a self) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } fn implicit_mut<'a>(&'a mut self) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.81"] fn explicit<'a>(self: &'a Arc) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.81"] fn explicit_mut<'a>(self: &'a mut Rc) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.80"] @@ -502,7 +502,7 @@ mod issue7296 { } fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } } @@ -511,7 +511,7 @@ mod issue7296 { fn implicit<'a>(&'a self) -> &'a (); //~^ needless_lifetimes fn implicit_provided<'a>(&'a self) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } @@ -520,7 +520,7 @@ mod issue7296 { //~^ needless_lifetimes #[clippy::msrv = "1.81"] fn explicit_provided<'a>(self: &'a Arc) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } #[clippy::msrv = "1.80"] @@ -533,7 +533,7 @@ mod issue7296 { fn lifetime_elsewhere<'a>(self: Box, here: &'a ()) -> &'a (); //~^ needless_lifetimes fn lifetime_elsewhere_provided<'a>(self: Box, here: &'a ()) -> &'a () { - //~^ needless_lifetimes + //~^ needless_lifetimes &() } } @@ -554,13 +554,13 @@ mod pr_9743_output_lifetime_checks { // lint: only one input fn one_input<'a>(x: &'a u8) -> &'a u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } // lint: multiple inputs, output would not be elided fn multiple_inputs_output_not_elided<'a, 'b>(x: &'a u8, y: &'b u8, z: &'b u8) -> &'b u8 { - //~^ needless_lifetimes + //~^ needless_lifetimes unimplemented!() } @@ -673,7 +673,7 @@ mod issue13923 { } impl<'t, 'py> ContentString<'t> { - //~^ needless_lifetimes + //~^ needless_lifetimes // `'py` can be elided because of `&self` fn map_content2(&self, f: impl FnOnce(&'t str) -> &'t str) -> Content<'t, 'py> { match self { @@ -684,7 +684,7 @@ mod issue13923 { } impl<'t, 'py> ContentString<'t> { - //~^ needless_lifetimes + //~^ needless_lifetimes // `'py` can be elided because of `&'_ self` fn map_content3(&'_ self, f: impl FnOnce(&'t str) -> &'t str) -> Content<'t, 'py> { match self { @@ -705,7 +705,7 @@ mod issue13923 { } impl<'t, 'py> ContentString<'t> { - //~^ needless_lifetimes + //~^ needless_lifetimes // `'py` can be elided because of `&Self` fn map_content5( self: std::pin::Pin<&Self>, diff --git a/tests/ui/needless_match.rs b/tests/ui/needless_match.rs index 848490d9b35ec..1cb670edc60fb 100644 --- a/tests/ui/needless_match.rs +++ b/tests/ui/needless_match.rs @@ -13,7 +13,7 @@ enum Simple { fn useless_match() { let i = 10; let _: i32 = match i { - //~^ needless_match + //~^ needless_match 0 => 0, 1 => 1, 2 => 2, @@ -21,7 +21,7 @@ fn useless_match() { }; let s = "test"; let _: &str = match s { - //~^ needless_match + //~^ needless_match "a" => "a", "b" => "b", s => s, @@ -31,7 +31,7 @@ fn useless_match() { fn custom_type_match() { let se = Simple::A; let _: Simple = match se { - //~^ needless_match + //~^ needless_match Simple::A => Simple::A, Simple::B => Simple::B, Simple::C => Simple::C, @@ -54,7 +54,7 @@ fn custom_type_match() { fn option_match(x: Option) { let _: Option = match x { - //~^ needless_match + //~^ needless_match Some(a) => Some(a), None => None, }; @@ -71,12 +71,12 @@ fn func_ret_err(err: T) -> Result { fn result_match() { let _: Result = match Ok(1) { - //~^ needless_match + //~^ needless_match Ok(a) => Ok(a), Err(err) => Err(err), }; let _: Result = match func_ret_err(0_i32) { - //~^ needless_match + //~^ needless_match Err(err) => Err(err), Ok(a) => Ok(a), }; @@ -136,7 +136,7 @@ fn if_let_result() { fn if_let_custom_enum(x: Simple) { let _: Simple = if let Simple::A = x { - //~^ needless_match + //~^ needless_match Simple::A } else if let Simple::B = x { Simple::B @@ -176,7 +176,7 @@ mod issue8542 { let bb = false; let _: Complex = match ce { - //~^ needless_match + //~^ needless_match Complex::A(a) => Complex::A(a), Complex::B(a, b) => Complex::B(a, b), Complex::C(a, b, c) => Complex::C(a, b, c), @@ -261,14 +261,14 @@ mod issue9084 { // should lint let _ = match e { - //~^ needless_match + //~^ needless_match _ if some_bool => e, _ => e, }; // should lint let _ = match e { - //~^ needless_match + //~^ needless_match Some(i) => Some(i), _ if some_bool => e, _ => e, @@ -350,7 +350,7 @@ pub fn issue13574() -> Option<()> { // Same const, should lint let _ = { if let Some(num) = A { - //~^ needless_match + //~^ needless_match Some(num) } else if let Some(num) = A { Some(num) diff --git a/tests/ui/needless_maybe_sized.fixed b/tests/ui/needless_maybe_sized.fixed index 68252ba54fd42..f8b1643969903 100644 --- a/tests/ui/needless_maybe_sized.fixed +++ b/tests/ui/needless_maybe_sized.fixed @@ -51,23 +51,23 @@ struct Struct(T); //~^ needless_maybe_sized impl Struct { -//~^ needless_maybe_sized + //~^ needless_maybe_sized fn method(&self) {} //~^ needless_maybe_sized } enum Enum { -//~^ needless_maybe_sized + //~^ needless_maybe_sized Variant(&'static T), } union Union<'a, T: Sized> { -//~^ needless_maybe_sized + //~^ needless_maybe_sized a: &'a T, } trait Trait { -//~^ needless_maybe_sized + //~^ needless_maybe_sized fn trait_method() {} //~^ needless_maybe_sized diff --git a/tests/ui/needless_maybe_sized.rs b/tests/ui/needless_maybe_sized.rs index 0cafc0d9ff6e9..e4312b40563f1 100644 --- a/tests/ui/needless_maybe_sized.rs +++ b/tests/ui/needless_maybe_sized.rs @@ -54,23 +54,23 @@ struct Struct(T); //~^ needless_maybe_sized impl Struct { -//~^ needless_maybe_sized + //~^ needless_maybe_sized fn method(&self) {} //~^ needless_maybe_sized } enum Enum { -//~^ needless_maybe_sized + //~^ needless_maybe_sized Variant(&'static T), } union Union<'a, T: Sized + ?Sized> { -//~^ needless_maybe_sized + //~^ needless_maybe_sized a: &'a T, } trait Trait { -//~^ needless_maybe_sized + //~^ needless_maybe_sized fn trait_method() {} //~^ needless_maybe_sized diff --git a/tests/ui/needless_option_take.fixed b/tests/ui/needless_option_take.fixed index ae2bfab0e06d5..a8bd50b79899b 100644 --- a/tests/ui/needless_option_take.fixed +++ b/tests/ui/needless_option_take.fixed @@ -23,7 +23,6 @@ fn main() { x.as_ref(); //~^ needless_option_take - println!("Testing non erroneous option_take_on_temporary"); let mut x = Some(3); let y = x.as_mut(); @@ -35,33 +34,26 @@ fn main() { let y = x.replace(289); //~^ needless_option_take - let y = Some(3).as_mut(); //~^ needless_option_take - let y = Option::as_mut(&mut x); //~^ needless_option_take - let x = return_option(); let x = return_option(); //~^ needless_option_take - let x = MyStruct::get_option(); let x = MyStruct::get_option(); //~^ needless_option_take - let mut my_vec = vec![1, 2, 3]; my_vec.push(4); let y = my_vec.first(); let y = my_vec.first(); //~^ needless_option_take - let y = my_vec.first(); //~^ needless_option_take - } diff --git a/tests/ui/needless_option_take.rs b/tests/ui/needless_option_take.rs index 723930f59a116..8141ee43db11f 100644 --- a/tests/ui/needless_option_take.rs +++ b/tests/ui/needless_option_take.rs @@ -23,7 +23,6 @@ fn main() { x.as_ref().take(); //~^ needless_option_take - println!("Testing non erroneous option_take_on_temporary"); let mut x = Some(3); let y = x.as_mut(); @@ -35,33 +34,26 @@ fn main() { let y = x.replace(289).take(); //~^ needless_option_take - let y = Some(3).as_mut().take(); //~^ needless_option_take - let y = Option::as_mut(&mut x).take(); //~^ needless_option_take - let x = return_option(); let x = return_option().take(); //~^ needless_option_take - let x = MyStruct::get_option(); let x = MyStruct::get_option().take(); //~^ needless_option_take - let mut my_vec = vec![1, 2, 3]; my_vec.push(4); let y = my_vec.first(); let y = my_vec.first().take(); //~^ needless_option_take - let y = my_vec.first().take(); //~^ needless_option_take - } diff --git a/tests/ui/needless_option_take.stderr b/tests/ui/needless_option_take.stderr index 271e1a0c79154..9054463c07cd2 100644 --- a/tests/ui/needless_option_take.stderr +++ b/tests/ui/needless_option_take.stderr @@ -11,7 +11,7 @@ LL | x.as_ref().take(); = help: to override `-D warnings` add `#[allow(clippy::needless_option_take)]` error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:32:13 + --> tests/ui/needless_option_take.rs:31:13 | LL | let y = x.as_mut().take(); | ^^^^^^^^^^------- @@ -21,7 +21,7 @@ LL | let y = x.as_mut().take(); = note: `as_mut` creates a temporary value, so calling take() has no effect error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:35:13 + --> tests/ui/needless_option_take.rs:34:13 | LL | let y = x.replace(289).take(); | ^^^^^^^^^^^^^^------- @@ -31,7 +31,7 @@ LL | let y = x.replace(289).take(); = note: `replace` creates a temporary value, so calling take() has no effect error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:39:13 + --> tests/ui/needless_option_take.rs:37:13 | LL | let y = Some(3).as_mut().take(); | ^^^^^^^^^^^^^^^^------- @@ -41,7 +41,7 @@ LL | let y = Some(3).as_mut().take(); = note: `as_mut` creates a temporary value, so calling take() has no effect error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:43:13 + --> tests/ui/needless_option_take.rs:40:13 | LL | let y = Option::as_mut(&mut x).take(); | ^^^^^^^^^^^^^^^^^^^^^^------- @@ -51,7 +51,7 @@ LL | let y = Option::as_mut(&mut x).take(); = note: `as_mut` creates a temporary value, so calling take() has no effect error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:48:13 + --> tests/ui/needless_option_take.rs:44:13 | LL | let x = return_option().take(); | ^^^^^^^^^^^^^^^------- @@ -61,7 +61,7 @@ LL | let x = return_option().take(); = note: `return_option` creates a temporary value, so calling take() has no effect error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:53:13 + --> tests/ui/needless_option_take.rs:48:13 | LL | let x = MyStruct::get_option().take(); | ^^^^^^^^^^^^^^^^^^^^^^------- @@ -71,7 +71,7 @@ LL | let x = MyStruct::get_option().take(); = note: `get_option` creates a temporary value, so calling take() has no effect error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:60:13 + --> tests/ui/needless_option_take.rs:54:13 | LL | let y = my_vec.first().take(); | ^^^^^^^^^^^^^^------- @@ -81,7 +81,7 @@ LL | let y = my_vec.first().take(); = note: `first` creates a temporary value, so calling take() has no effect error: called `Option::take()` on a temporary value - --> tests/ui/needless_option_take.rs:64:13 + --> tests/ui/needless_option_take.rs:57:13 | LL | let y = my_vec.first().take(); | ^^^^^^^^^^^^^^------- diff --git a/tests/ui/needless_pass_by_ref_mut.rs b/tests/ui/needless_pass_by_ref_mut.rs index 415a131638053..f0c5a716ac991 100644 --- a/tests/ui/needless_pass_by_ref_mut.rs +++ b/tests/ui/needless_pass_by_ref_mut.rs @@ -9,7 +9,7 @@ use std::ptr::NonNull; fn foo(s: &mut Vec, b: &u32, x: &mut u32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut *x += *b + s.len() as u32; } @@ -35,7 +35,7 @@ fn foo5(s: &mut Vec) { } fn foo6(s: &mut Vec) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut non_mut_ref(s); } @@ -48,9 +48,8 @@ impl Bar { fn bar(&mut self) {} //~^ needless_pass_by_ref_mut - fn mushroom(&self, vec: &mut Vec) -> usize { - //~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut vec.len() } @@ -128,43 +127,43 @@ async fn f7(x: &mut i32, y: i32, z: &mut i32, a: i32) { } async fn a1(x: &mut i32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut println!("{:?}", x); } async fn a2(x: &mut i32, y: String) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut println!("{:?}", x); } async fn a3(x: &mut i32, y: String, z: String) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut println!("{:?}", x); } async fn a4(x: &mut i32, y: i32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut println!("{:?}", x); } async fn a5(x: i32, y: &mut i32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut println!("{:?}", x); } async fn a6(x: i32, y: &mut i32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut println!("{:?}", x); } async fn a7(x: i32, y: i32, z: &mut i32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut println!("{:?}", z); } async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { -//~^ needless_pass_by_ref_mut -//~| needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut + //~| needless_pass_by_ref_mut println!("{:?}", z); } @@ -201,14 +200,10 @@ fn lint_attr(s: &mut u32) {} fn cfg_warn(s: &mut u32) {} //~^ needless_pass_by_ref_mut - - #[cfg(not(feature = "a"))] mod foo { fn cfg_warn(s: &mut u32) {} //~^ needless_pass_by_ref_mut - - } // Should not warn. @@ -221,7 +216,7 @@ async fn inner_async(x: &mut i32, y: &mut u32) { } async fn inner_async2(x: &mut i32, y: &mut u32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut async { *x += 1; @@ -230,7 +225,7 @@ async fn inner_async2(x: &mut i32, y: &mut u32) { } async fn inner_async3(x: &mut i32, y: &mut u32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut async { *y += 1; @@ -250,7 +245,7 @@ async fn async_vec2(b: &mut Vec) { fn non_mut(n: &str) {} //Should warn async fn call_in_closure1(n: &mut str) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut (|| non_mut(n))() } fn str_mut(str: &mut String) -> bool { @@ -270,7 +265,7 @@ async fn closure(n: &mut usize) -> impl '_ + FnMut() { // Should warn. fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut || *n + 1 } @@ -282,7 +277,7 @@ async fn closure3(n: &mut usize) { // Should warn. async fn closure4(n: &mut usize) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut (|| { let _x = *n + 1; @@ -340,9 +335,8 @@ impl MutSelf { //~^ needless_pass_by_ref_mut async fn foo(&mut self, u: &mut i32, v: &mut u32) { - //~^ needless_pass_by_ref_mut - //~| needless_pass_by_ref_mut - + //~^ needless_pass_by_ref_mut + //~| needless_pass_by_ref_mut async { *u += 1; @@ -350,7 +344,7 @@ impl MutSelf { .await; } async fn foo2(&mut self, u: &mut i32, v: &mut u32) { - //~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut async { self.a += 1; diff --git a/tests/ui/needless_pass_by_ref_mut.stderr b/tests/ui/needless_pass_by_ref_mut.stderr index 0492acf7cc086..6637a255b5f51 100644 --- a/tests/ui/needless_pass_by_ref_mut.stderr +++ b/tests/ui/needless_pass_by_ref_mut.stderr @@ -20,67 +20,67 @@ LL | fn bar(&mut self) {} | ^^^^^^^^^ help: consider changing to: `&self` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:52:29 + --> tests/ui/needless_pass_by_ref_mut.rs:51:29 | LL | fn mushroom(&self, vec: &mut Vec) -> usize { | ^^^^^^^^^^^^^ help: consider changing to: `&Vec` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:130:16 + --> tests/ui/needless_pass_by_ref_mut.rs:129:16 | LL | async fn a1(x: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:135:16 + --> tests/ui/needless_pass_by_ref_mut.rs:134:16 | LL | async fn a2(x: &mut i32, y: String) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:140:16 + --> tests/ui/needless_pass_by_ref_mut.rs:139:16 | LL | async fn a3(x: &mut i32, y: String, z: String) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:145:16 + --> tests/ui/needless_pass_by_ref_mut.rs:144:16 | LL | async fn a4(x: &mut i32, y: i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:150:24 + --> tests/ui/needless_pass_by_ref_mut.rs:149:24 | LL | async fn a5(x: i32, y: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:155:24 + --> tests/ui/needless_pass_by_ref_mut.rs:154:24 | LL | async fn a6(x: i32, y: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:160:32 + --> tests/ui/needless_pass_by_ref_mut.rs:159:32 | LL | async fn a7(x: i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:165:24 + --> tests/ui/needless_pass_by_ref_mut.rs:164:24 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:165:45 + --> tests/ui/needless_pass_by_ref_mut.rs:164:45 | LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:201:16 + --> tests/ui/needless_pass_by_ref_mut.rs:200:16 | LL | fn cfg_warn(s: &mut u32) {} | ^^^^^^^^ help: consider changing to: `&u32` @@ -88,7 +88,7 @@ LL | fn cfg_warn(s: &mut u32) {} = note: this is cfg-gated and may require further changes error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:208:20 + --> tests/ui/needless_pass_by_ref_mut.rs:205:20 | LL | fn cfg_warn(s: &mut u32) {} | ^^^^^^^^ help: consider changing to: `&u32` @@ -96,115 +96,115 @@ LL | fn cfg_warn(s: &mut u32) {} = note: this is cfg-gated and may require further changes error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:223:39 + --> tests/ui/needless_pass_by_ref_mut.rs:218:39 | LL | async fn inner_async2(x: &mut i32, y: &mut u32) { | ^^^^^^^^ help: consider changing to: `&u32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:232:26 + --> tests/ui/needless_pass_by_ref_mut.rs:227:26 | LL | async fn inner_async3(x: &mut i32, y: &mut u32) { | ^^^^^^^^ help: consider changing to: `&i32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:252:30 + --> tests/ui/needless_pass_by_ref_mut.rs:247:30 | LL | async fn call_in_closure1(n: &mut str) { | ^^^^^^^^ help: consider changing to: `&str` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:272:16 + --> tests/ui/needless_pass_by_ref_mut.rs:267:16 | LL | fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize { | ^^^^^^^^^^ help: consider changing to: `&usize` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:284:22 + --> tests/ui/needless_pass_by_ref_mut.rs:279:22 | LL | async fn closure4(n: &mut usize) { | ^^^^^^^^^^ help: consider changing to: `&usize` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:339:12 + --> tests/ui/needless_pass_by_ref_mut.rs:334:12 | LL | fn bar(&mut self) {} | ^^^^^^^^^ help: consider changing to: `&self` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:342:18 + --> tests/ui/needless_pass_by_ref_mut.rs:337:18 | LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { | ^^^^^^^^^ help: consider changing to: `&self` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:342:45 + --> tests/ui/needless_pass_by_ref_mut.rs:337:45 | LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) { | ^^^^^^^^ help: consider changing to: `&u32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:352:46 + --> tests/ui/needless_pass_by_ref_mut.rs:346:46 | LL | async fn foo2(&mut self, u: &mut i32, v: &mut u32) { | ^^^^^^^^ help: consider changing to: `&u32` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:369:18 + --> tests/ui/needless_pass_by_ref_mut.rs:363:18 | LL | fn _empty_tup(x: &mut (())) {} | ^^^^^^^^^ help: consider changing to: `&()` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:371:19 + --> tests/ui/needless_pass_by_ref_mut.rs:365:19 | LL | fn _single_tup(x: &mut ((i32,))) {} | ^^^^^^^^^^^^^ help: consider changing to: `&(i32,)` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:373:18 + --> tests/ui/needless_pass_by_ref_mut.rs:367:18 | LL | fn _multi_tup(x: &mut ((i32, u32))) {} | ^^^^^^^^^^^^^^^^^ help: consider changing to: `&(i32, u32)` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:375:11 + --> tests/ui/needless_pass_by_ref_mut.rs:369:11 | LL | fn _fn(x: &mut (fn())) {} | ^^^^^^^^^^^ help: consider changing to: `&fn()` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:378:23 + --> tests/ui/needless_pass_by_ref_mut.rs:372:23 | LL | fn _extern_rust_fn(x: &mut extern "Rust" fn()) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "Rust" fn()` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:380:20 + --> tests/ui/needless_pass_by_ref_mut.rs:374:20 | LL | fn _extern_c_fn(x: &mut extern "C" fn()) {} | ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "C" fn()` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:382:18 + --> tests/ui/needless_pass_by_ref_mut.rs:376:18 | LL | fn _unsafe_fn(x: &mut unsafe fn()) {} | ^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe fn()` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:384:25 + --> tests/ui/needless_pass_by_ref_mut.rs:378:25 | LL | fn _unsafe_extern_fn(x: &mut unsafe extern "C" fn()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn()` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:386:20 + --> tests/ui/needless_pass_by_ref_mut.rs:380:20 | LL | fn _fn_with_arg(x: &mut unsafe extern "C" fn(i32)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn(i32)` error: this argument is a mutable reference, but not used mutably - --> tests/ui/needless_pass_by_ref_mut.rs:388:20 + --> tests/ui/needless_pass_by_ref_mut.rs:382:20 | LL | fn _fn_with_ret(x: &mut unsafe extern "C" fn() -> (i32)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn() -> (i32)` diff --git a/tests/ui/needless_pass_by_ref_mut2.fixed b/tests/ui/needless_pass_by_ref_mut2.fixed index fc40f8c8ca302..0e2ac02023641 100644 --- a/tests/ui/needless_pass_by_ref_mut2.fixed +++ b/tests/ui/needless_pass_by_ref_mut2.fixed @@ -6,7 +6,7 @@ #![warn(clippy::needless_pass_by_ref_mut)] async fn inner_async3(x: &i32, y: &mut u32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut async { *y += 1; @@ -15,7 +15,7 @@ async fn inner_async3(x: &i32, y: &mut u32) { } async fn inner_async4(u: &mut i32, v: &u32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut async { *u += 1; diff --git a/tests/ui/needless_pass_by_ref_mut2.rs b/tests/ui/needless_pass_by_ref_mut2.rs index f921a76842363..9201d9a272984 100644 --- a/tests/ui/needless_pass_by_ref_mut2.rs +++ b/tests/ui/needless_pass_by_ref_mut2.rs @@ -6,7 +6,7 @@ #![warn(clippy::needless_pass_by_ref_mut)] async fn inner_async3(x: &mut i32, y: &mut u32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut async { *y += 1; @@ -15,7 +15,7 @@ async fn inner_async3(x: &mut i32, y: &mut u32) { } async fn inner_async4(u: &mut i32, v: &mut u32) { -//~^ needless_pass_by_ref_mut + //~^ needless_pass_by_ref_mut async { *u += 1; diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index faa68c8140cb0..885fb409417b1 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -17,8 +17,7 @@ use std::mem::MaybeUninit; // `v` should be warned // `w`, `x` and `y` are allowed (moved or mutated) fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { -//~^ needless_pass_by_value - + //~^ needless_pass_by_value assert_eq!(v.len(), 42); @@ -34,9 +33,8 @@ fn consume(_: T) {} struct Wrapper(String); fn bar(x: String, y: Wrapper) { -//~^ needless_pass_by_value -//~| needless_pass_by_value - + //~^ needless_pass_by_value + //~| needless_pass_by_value assert_eq!(x.len(), 42); assert_eq!(y.0.len(), 42); @@ -44,7 +42,7 @@ fn bar(x: String, y: Wrapper) { // V implements `Borrow`, but should be warned correctly fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { -//~^ needless_pass_by_value + //~^ needless_pass_by_value println!("{}", t.borrow()); println!("{}", u.as_ref()); @@ -58,7 +56,7 @@ fn test_fn i32>(f: F) { // x should be warned, but y is ok fn test_match(x: Option>, y: Option>) { -//~^ needless_pass_by_value + //~^ needless_pass_by_value match x { Some(Some(_)) => 1, // not moved @@ -73,9 +71,8 @@ fn test_match(x: Option>, y: Option>) { // x and y should be warned, but z is ok fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { -//~^ needless_pass_by_value -//~| needless_pass_by_value - + //~^ needless_pass_by_value + //~| needless_pass_by_value let Wrapper(s) = z; // moved let Wrapper(ref t) = y; // not moved @@ -95,15 +92,11 @@ impl Serialize for i32 {} fn test_blanket_ref(vals: T, serializable: S) {} //~^ needless_pass_by_value - fn issue_2114(s: String, t: String, u: Vec, v: Vec) { -//~^ needless_pass_by_value -//~| needless_pass_by_value -//~| needless_pass_by_value -//~| needless_pass_by_value - - - + //~^ needless_pass_by_value + //~| needless_pass_by_value + //~| needless_pass_by_value + //~| needless_pass_by_value s.capacity(); let _ = t.clone(); @@ -119,10 +112,8 @@ impl S { // taking `self` by value is always allowed s: String, //~^ needless_pass_by_value - t: String, //~^ needless_pass_by_value - ) -> usize { s.len() + t.capacity() } @@ -134,8 +125,6 @@ impl S { fn baz(&self, uu: U, ss: Self) {} //~^ needless_pass_by_value //~| needless_pass_by_value - - } trait FalsePositive { @@ -158,7 +147,7 @@ fn range>(range: T) { struct CopyWrapper(u32); fn bar_copy(x: u32, y: CopyWrapper) { -//~^ needless_pass_by_value + //~^ needless_pass_by_value assert_eq!(x, 42); assert_eq!(y.0, 42); @@ -166,11 +155,9 @@ fn bar_copy(x: u32, y: CopyWrapper) { // x and y should be warned, but z is ok fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { -//~^ needless_pass_by_value -//~| needless_pass_by_value -//~| needless_pass_by_value - - + //~^ needless_pass_by_value + //~| needless_pass_by_value + //~| needless_pass_by_value let CopyWrapper(s) = z; // moved let CopyWrapper(ref t) = y; // not moved @@ -186,14 +173,12 @@ impl<'b, T> Bar<'b, T> for T {} fn some_fun<'b, S: Bar<'b, ()>>(items: S) {} //~^ needless_pass_by_value - // Also this should not cause an ICE. See #2831 trait Club<'a, A> {} impl Club<'static, T> for T {} fn more_fun(items: impl Club<'static, i32>) {} //~^ needless_pass_by_value - fn is_sync(_: T) where T: Sync, diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 414ce347403a8..47e0086882150 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -8,55 +8,55 @@ LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec tests/ui/needless_pass_by_value.rs:36:11 + --> tests/ui/needless_pass_by_value.rs:35:11 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:36:22 + --> tests/ui/needless_pass_by_value.rs:35:22 | LL | fn bar(x: String, y: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:46:71 + --> tests/ui/needless_pass_by_value.rs:44:71 | LL | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { | ^ help: consider taking a reference instead: `&V` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:60:18 + --> tests/ui/needless_pass_by_value.rs:58:18 | LL | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option>` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:75:24 + --> tests/ui/needless_pass_by_value.rs:73:24 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:75:36 + --> tests/ui/needless_pass_by_value.rs:73:36 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead: `&Wrapper` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:95:49 + --> tests/ui/needless_pass_by_value.rs:92:49 | LL | fn test_blanket_ref(vals: T, serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:99:18 + --> tests/ui/needless_pass_by_value.rs:95:18 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:99:29 + --> tests/ui/needless_pass_by_value.rs:95:29 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ @@ -71,13 +71,13 @@ LL | let _ = t.to_string(); | ~~~~~~~~~~~~~ error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:99:40 + --> tests/ui/needless_pass_by_value.rs:95:40 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:99:53 + --> tests/ui/needless_pass_by_value.rs:95:53 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ @@ -92,85 +92,85 @@ LL | let _ = v.to_owned(); | ~~~~~~~~~~~~ error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:120:12 + --> tests/ui/needless_pass_by_value.rs:113:12 | LL | s: String, | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:123:12 + --> tests/ui/needless_pass_by_value.rs:115:12 | LL | t: String, | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:134:23 + --> tests/ui/needless_pass_by_value.rs:125:23 | LL | fn baz(&self, uu: U, ss: Self) {} | ^ help: consider taking a reference instead: `&U` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:134:30 + --> tests/ui/needless_pass_by_value.rs:125:30 | LL | fn baz(&self, uu: U, ss: Self) {} | ^^^^ help: consider taking a reference instead: `&Self` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:160:24 + --> tests/ui/needless_pass_by_value.rs:149:24 | LL | fn bar_copy(x: u32, y: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: or consider marking this type as `Copy` - --> tests/ui/needless_pass_by_value.rs:158:1 + --> tests/ui/needless_pass_by_value.rs:147:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:168:29 + --> tests/ui/needless_pass_by_value.rs:157:29 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: or consider marking this type as `Copy` - --> tests/ui/needless_pass_by_value.rs:158:1 + --> tests/ui/needless_pass_by_value.rs:147:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:168:45 + --> tests/ui/needless_pass_by_value.rs:157:45 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: or consider marking this type as `Copy` - --> tests/ui/needless_pass_by_value.rs:158:1 + --> tests/ui/needless_pass_by_value.rs:147:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:168:61 + --> tests/ui/needless_pass_by_value.rs:157:61 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper` | help: or consider marking this type as `Copy` - --> tests/ui/needless_pass_by_value.rs:158:1 + --> tests/ui/needless_pass_by_value.rs:147:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:186:40 + --> tests/ui/needless_pass_by_value.rs:173:40 | LL | fn some_fun<'b, S: Bar<'b, ()>>(items: S) {} | ^ help: consider taking a reference instead: `&S` error: this argument is passed by value, but not consumed in the function body - --> tests/ui/needless_pass_by_value.rs:193:20 + --> tests/ui/needless_pass_by_value.rs:179:20 | LL | fn more_fun(items: impl Club<'static, i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` diff --git a/tests/ui/needless_range_loop.rs b/tests/ui/needless_range_loop.rs index ff9699e35691c..8a1c1be289cf8 100644 --- a/tests/ui/needless_range_loop.rs +++ b/tests/ui/needless_range_loop.rs @@ -14,8 +14,7 @@ fn main() { let mut vec = vec![1, 2, 3, 4]; let vec2 = vec![1, 2, 3, 4]; for i in 0..vec.len() { - //~^ needless_range_loop - + //~^ needless_range_loop println!("{}", vec[i]); } @@ -26,26 +25,26 @@ fn main() { } for i in 0..vec.len() { - //~^ needless_range_loop + //~^ needless_range_loop let _ = vec[i]; } // ICE #746 for j in 0..4 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{:?}", STATIC[j]); } for j in 0..4 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{:?}", CONST[j]); } for i in 0..vec.len() { - //~^ needless_range_loop + //~^ needless_range_loop println!("{} {}", vec[i], i); } @@ -55,56 +54,56 @@ fn main() { } for i in 0..vec.len() { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", vec2[i]); } for i in 5..vec.len() { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", vec[i]); } for i in 0..MAX_LEN { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", vec[i]); } for i in 0..=MAX_LEN { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", vec[i]); } for i in 5..10 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", vec[i]); } for i in 5..=10 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", vec[i]); } for i in 5..vec.len() { - //~^ needless_range_loop + //~^ needless_range_loop println!("{} {}", vec[i], i); } for i in 5..10 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{} {}", vec[i], i); } // #2542 for i in 0..vec.len() { - //~^ needless_range_loop + //~^ needless_range_loop vec[i] = Some(1).unwrap_or_else(|| panic!("error on {}", i)); } diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index a15830d721b69..86c2b550b071b 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -12,7 +12,7 @@ LL | for in &vec { | ~~~~~~ ~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop.rs:28:14 + --> tests/ui/needless_range_loop.rs:27:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | for in &vec { | ~~~~~~ ~~~~ error: the loop variable `j` is only used to index `STATIC` - --> tests/ui/needless_range_loop.rs:35:14 + --> tests/ui/needless_range_loop.rs:34:14 | LL | for j in 0..4 { | ^^^^ @@ -34,7 +34,7 @@ LL | for in &STATIC { | ~~~~~~ ~~~~~~~ error: the loop variable `j` is only used to index `CONST` - --> tests/ui/needless_range_loop.rs:41:14 + --> tests/ui/needless_range_loop.rs:40:14 | LL | for j in 0..4 { | ^^^^ @@ -45,7 +45,7 @@ LL | for in &CONST { | ~~~~~~ ~~~~~~ error: the loop variable `i` is used to index `vec` - --> tests/ui/needless_range_loop.rs:47:14 + --> tests/ui/needless_range_loop.rs:46:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for (i, ) in vec.iter().enumerate() { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec2` - --> tests/ui/needless_range_loop.rs:57:14 + --> tests/ui/needless_range_loop.rs:56:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | for in vec2.iter().take(vec.len()) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop.rs:63:14 + --> tests/ui/needless_range_loop.rs:62:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | for in vec.iter().skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop.rs:69:14 + --> tests/ui/needless_range_loop.rs:68:14 | LL | for i in 0..MAX_LEN { | ^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | for in vec.iter().take(MAX_LEN) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop.rs:75:14 + --> tests/ui/needless_range_loop.rs:74:14 | LL | for i in 0..=MAX_LEN { | ^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | for in vec.iter().take(MAX_LEN + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop.rs:81:14 + --> tests/ui/needless_range_loop.rs:80:14 | LL | for i in 5..10 { | ^^^^^ @@ -111,7 +111,7 @@ LL | for in vec.iter().take(10).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop.rs:87:14 + --> tests/ui/needless_range_loop.rs:86:14 | LL | for i in 5..=10 { | ^^^^^^ @@ -122,7 +122,7 @@ LL | for in vec.iter().take(10 + 1).skip(5) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> tests/ui/needless_range_loop.rs:93:14 + --> tests/ui/needless_range_loop.rs:92:14 | LL | for i in 5..vec.len() { | ^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | for (i, ) in vec.iter().enumerate().skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> tests/ui/needless_range_loop.rs:99:14 + --> tests/ui/needless_range_loop.rs:98:14 | LL | for i in 5..10 { | ^^^^^ @@ -144,7 +144,7 @@ LL | for (i, ) in vec.iter().enumerate().take(10).skip(5) { | ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is used to index `vec` - --> tests/ui/needless_range_loop.rs:106:14 + --> tests/ui/needless_range_loop.rs:105:14 | LL | for i in 0..vec.len() { | ^^^^^^^^^^^^ diff --git a/tests/ui/needless_range_loop2.rs b/tests/ui/needless_range_loop2.rs index 8a591a4bddae7..68784a8df19d3 100644 --- a/tests/ui/needless_range_loop2.rs +++ b/tests/ui/needless_range_loop2.rs @@ -9,8 +9,7 @@ fn main() { let ns = vec![2, 3, 5, 7]; for i in 3..10 { - //~^ needless_range_loop - + //~^ needless_range_loop println!("{}", ns[i]); } @@ -33,7 +32,7 @@ fn main() { let mut ms = vec![1, 2, 3, 4, 5, 6]; for i in 0..ms.len() { - //~^ needless_range_loop + //~^ needless_range_loop ms[i] *= 2; } @@ -41,7 +40,7 @@ fn main() { let mut ms = vec![1, 2, 3, 4, 5, 6]; for i in 0..ms.len() { - //~^ needless_range_loop + //~^ needless_range_loop let x = &mut ms[i]; *x *= 2; @@ -67,7 +66,7 @@ fn main() { let mut vec = vec![0; 9]; for i in x..x + 4 { - //~^ needless_range_loop + //~^ needless_range_loop vec[i] += 1; } @@ -76,7 +75,7 @@ fn main() { let mut vec = vec![0; 10]; for i in x..=x + 4 { - //~^ needless_range_loop + //~^ needless_range_loop vec[i] += 1; } @@ -84,19 +83,19 @@ fn main() { let arr = [1, 2, 3]; for i in 0..3 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", arr[i]); } for i in 0..2 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", arr[i]); } for i in 1..3 { - //~^ needless_range_loop + //~^ needless_range_loop println!("{}", arr[i]); } diff --git a/tests/ui/needless_range_loop2.stderr b/tests/ui/needless_range_loop2.stderr index 34357c3db02f8..0531e8e8f856b 100644 --- a/tests/ui/needless_range_loop2.stderr +++ b/tests/ui/needless_range_loop2.stderr @@ -12,7 +12,7 @@ LL | for in ns.iter().take(10).skip(3) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `ms` - --> tests/ui/needless_range_loop2.rs:35:14 + --> tests/ui/needless_range_loop2.rs:34:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | for in &mut ms { | ~~~~~~ ~~~~~~~ error: the loop variable `i` is only used to index `ms` - --> tests/ui/needless_range_loop2.rs:43:14 + --> tests/ui/needless_range_loop2.rs:42:14 | LL | for i in 0..ms.len() { | ^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | for in &mut ms { | ~~~~~~ ~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop2.rs:69:14 + --> tests/ui/needless_range_loop2.rs:68:14 | LL | for i in x..x + 4 { | ^^^^^^^^ @@ -45,7 +45,7 @@ LL | for in vec.iter_mut().skip(x).take(4) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `vec` - --> tests/ui/needless_range_loop2.rs:78:14 + --> tests/ui/needless_range_loop2.rs:77:14 | LL | for i in x..=x + 4 { | ^^^^^^^^^ @@ -56,7 +56,7 @@ LL | for in vec.iter_mut().skip(x).take(4 + 1) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `arr` - --> tests/ui/needless_range_loop2.rs:86:14 + --> tests/ui/needless_range_loop2.rs:85:14 | LL | for i in 0..3 { | ^^^^ @@ -67,7 +67,7 @@ LL | for in &arr { | ~~~~~~ ~~~~ error: the loop variable `i` is only used to index `arr` - --> tests/ui/needless_range_loop2.rs:92:14 + --> tests/ui/needless_range_loop2.rs:91:14 | LL | for i in 0..2 { | ^^^^ @@ -78,7 +78,7 @@ LL | for in arr.iter().take(2) { | ~~~~~~ ~~~~~~~~~~~~~~~~~~ error: the loop variable `i` is only used to index `arr` - --> tests/ui/needless_range_loop2.rs:98:14 + --> tests/ui/needless_range_loop2.rs:97:14 | LL | for i in 1..3 { | ^^^^ diff --git a/tests/ui/needless_update.rs b/tests/ui/needless_update.rs index 6e91c957e8118..62e3492343193 100644 --- a/tests/ui/needless_update.rs +++ b/tests/ui/needless_update.rs @@ -19,8 +19,6 @@ fn main() { S { a: 1, b: 1, ..base }; //~^ needless_update - - let base = T { x: 0, y: 0 }; T { ..base }; // no error T { x: 1, ..base }; // no error diff --git a/tests/ui/neg_cmp_op_on_partial_ord.rs b/tests/ui/neg_cmp_op_on_partial_ord.rs index 7d24429b58677..27b51b4281705 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.rs +++ b/tests/ui/neg_cmp_op_on_partial_ord.rs @@ -16,23 +16,18 @@ fn main() { let _not_less = !(a_value < another_value); //~^ neg_cmp_op_on_partial_ord - - // Not Less or Equal but potentially Greater or Uncomparable. let _not_less_or_equal = !(a_value <= another_value); //~^ neg_cmp_op_on_partial_ord - // Not Greater but potentially Less, Equal or Uncomparable. let _not_greater = !(a_value > another_value); //~^ neg_cmp_op_on_partial_ord - // Not Greater or Equal but potentially Less or Uncomparable. let _not_greater_or_equal = !(a_value >= another_value); //~^ neg_cmp_op_on_partial_ord - // --- Good --- let _not_less = match a_value.partial_cmp(&another_value) { diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index f6347b7d56cd8..3c11d5b8826ab 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -8,19 +8,19 @@ LL | let _not_less = !(a_value < another_value); = help: to override `-D warnings` add `#[allow(clippy::neg_cmp_op_on_partial_ord)]` error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> tests/ui/neg_cmp_op_on_partial_ord.rs:22:30 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:20:30 | LL | let _not_less_or_equal = !(a_value <= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> tests/ui/neg_cmp_op_on_partial_ord.rs:27:24 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:24:24 | LL | let _not_greater = !(a_value > another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the use of negated comparison operators on partially ordered types produces code that is hard to read and refactor, please consider using the `partial_cmp` method instead, to make it clear that the two values could be incomparable - --> tests/ui/neg_cmp_op_on_partial_ord.rs:32:33 + --> tests/ui/neg_cmp_op_on_partial_ord.rs:28:33 | LL | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/never_loop.rs b/tests/ui/never_loop.rs index c366e7d863107..2d8e04c192e40 100644 --- a/tests/ui/never_loop.rs +++ b/tests/ui/never_loop.rs @@ -10,8 +10,7 @@ fn test1() { let mut x = 0; loop { - //~^ never_loop - + //~^ never_loop // clippy::never_loop x += 1; @@ -35,7 +34,7 @@ fn test2() { fn test3() { let mut x = 0; loop { - //~^ never_loop + //~^ never_loop // never loops x += 1; @@ -57,11 +56,11 @@ fn test4() { fn test5() { let i = 0; loop { - //~^ never_loop + //~^ never_loop // never loops while i == 0 { - //~^ never_loop + //~^ never_loop // never loops break; @@ -75,7 +74,7 @@ fn test6() { 'outer: loop { x += 1; loop { - //~^ never_loop + //~^ never_loop // never loops if x == 5 { @@ -113,7 +112,7 @@ fn test8() { fn test9() { let x = Some(1); while let Some(y) = x { - //~^ never_loop + //~^ never_loop // never loops return; @@ -122,7 +121,7 @@ fn test9() { fn test10() { for x in 0..10 { - //~^ never_loop + //~^ never_loop // never loops match x { @@ -172,7 +171,7 @@ pub fn test13() { pub fn test14() { let mut a = true; 'outer: while a { - //~^ never_loop + //~^ never_loop // never loops while a { @@ -189,7 +188,7 @@ pub fn test14() { pub fn test15() { 'label: loop { while false { - //~^ never_loop + //~^ never_loop break 'label; } @@ -242,7 +241,7 @@ pub fn test18() { }; // never loops let _ = loop { - //~^ never_loop + //~^ never_loop let Some(x) = x else { return; @@ -265,14 +264,12 @@ pub fn test19() { pub fn test20() { 'a: loop { - //~^ never_loop + //~^ never_loop 'b: { break 'b 'c: { break 'a; //~^ diverging_sub_expression - - }; } } @@ -304,7 +301,7 @@ pub fn test23() { for _ in 0..10 { 'block: { for _ in 0..20 { - //~^ never_loop + //~^ never_loop break 'block; } @@ -389,7 +386,7 @@ pub fn test31(b: bool) { 'a: loop { 'b: { 'c: loop { - //~^ never_loop + //~^ never_loop if b { break 'c } else { break 'b } } @@ -401,12 +398,12 @@ pub fn test31(b: bool) { pub fn test32() { loop { - //~^ never_loop + //~^ never_loop panic!("oh no"); } loop { - //~^ never_loop + //~^ never_loop unimplemented!("not yet"); } diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 6d492f8eb9dab..72bf8da51dfe3 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -10,7 +10,7 @@ LL | | } = note: `#[deny(clippy::never_loop)]` on by default error: this loop never actually loops - --> tests/ui/never_loop.rs:37:5 + --> tests/ui/never_loop.rs:36:5 | LL | / loop { ... | @@ -19,7 +19,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> tests/ui/never_loop.rs:59:5 + --> tests/ui/never_loop.rs:58:5 | LL | / loop { ... | @@ -28,7 +28,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> tests/ui/never_loop.rs:63:9 + --> tests/ui/never_loop.rs:62:9 | LL | / while i == 0 { ... | @@ -36,7 +36,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> tests/ui/never_loop.rs:77:9 + --> tests/ui/never_loop.rs:76:9 | LL | / loop { ... | @@ -45,7 +45,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> tests/ui/never_loop.rs:115:5 + --> tests/ui/never_loop.rs:114:5 | LL | / while let Some(y) = x { ... | @@ -53,7 +53,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> tests/ui/never_loop.rs:124:5 + --> tests/ui/never_loop.rs:123:5 | LL | / for x in 0..10 { ... | @@ -66,7 +66,7 @@ LL | if let Some(x) = (0..10).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: this loop never actually loops - --> tests/ui/never_loop.rs:174:5 + --> tests/ui/never_loop.rs:173:5 | LL | / 'outer: while a { ... | @@ -75,7 +75,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> tests/ui/never_loop.rs:191:9 + --> tests/ui/never_loop.rs:190:9 | LL | / while false { LL | | @@ -85,7 +85,7 @@ LL | | } | |_________^ error: this loop never actually loops - --> tests/ui/never_loop.rs:244:13 + --> tests/ui/never_loop.rs:243:13 | LL | let _ = loop { | _____________^ @@ -98,7 +98,7 @@ LL | | }; | |_____^ error: this loop never actually loops - --> tests/ui/never_loop.rs:267:5 + --> tests/ui/never_loop.rs:266:5 | LL | / 'a: loop { LL | | @@ -109,7 +109,7 @@ LL | | } | |_____^ error: sub-expression diverges - --> tests/ui/never_loop.rs:272:17 + --> tests/ui/never_loop.rs:271:17 | LL | break 'a; | ^^^^^^^^ @@ -118,7 +118,7 @@ LL | break 'a; = help: to override `-D warnings` add `#[allow(clippy::diverging_sub_expression)]` error: this loop never actually loops - --> tests/ui/never_loop.rs:306:13 + --> tests/ui/never_loop.rs:303:13 | LL | / for _ in 0..20 { LL | | @@ -133,7 +133,7 @@ LL | if let Some(_) = (0..20).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: this loop never actually loops - --> tests/ui/never_loop.rs:391:13 + --> tests/ui/never_loop.rs:388:13 | LL | / 'c: loop { LL | | @@ -143,7 +143,7 @@ LL | | } | |_____________^ error: this loop never actually loops - --> tests/ui/never_loop.rs:403:5 + --> tests/ui/never_loop.rs:400:5 | LL | / loop { LL | | @@ -153,7 +153,7 @@ LL | | } | |_____^ error: this loop never actually loops - --> tests/ui/never_loop.rs:408:5 + --> tests/ui/never_loop.rs:405:5 | LL | / loop { LL | | diff --git a/tests/ui/new_ret_no_self.rs b/tests/ui/new_ret_no_self.rs index fc7dea97e48a6..d61973f09b171 100644 --- a/tests/ui/new_ret_no_self.rs +++ b/tests/ui/new_ret_no_self.rs @@ -48,8 +48,7 @@ impl R for S3 { impl S3 { // should trigger the lint pub fn new(_: String) -> impl R { - //~^ new_ret_no_self - + //~^ new_ret_no_self S3 } @@ -83,7 +82,7 @@ struct U; impl U { // should trigger lint pub fn new() -> u32 { - //~^ new_ret_no_self + //~^ new_ret_no_self unimplemented!(); } @@ -94,7 +93,7 @@ struct V; impl V { // should trigger lint pub fn new(_: String) -> u32 { - //~^ new_ret_no_self + //~^ new_ret_no_self unimplemented!(); } @@ -132,7 +131,7 @@ struct TupleReturnerBad; impl TupleReturnerBad { // should trigger lint pub fn new() -> (u32, u32) { - //~^ new_ret_no_self + //~^ new_ret_no_self unimplemented!(); } @@ -161,7 +160,7 @@ struct MutPointerReturnerBad; impl MutPointerReturnerBad { // should trigger lint pub fn new() -> *mut V { - //~^ new_ret_no_self + //~^ new_ret_no_self unimplemented!(); } @@ -181,7 +180,7 @@ struct GenericReturnerBad; impl GenericReturnerBad { // should trigger lint pub fn new() -> Option { - //~^ new_ret_no_self + //~^ new_ret_no_self unimplemented!(); } @@ -237,7 +236,6 @@ mod issue5435 { // should trigger lint as we are in trait definition fn new() -> String; //~^ new_ret_no_self - } pub struct StructRet; impl TraitRet for StructRet { @@ -251,7 +249,6 @@ mod issue5435 { // should trigger lint fn new(_: String) -> String; //~^ new_ret_no_self - } trait TupleReturnerOk { @@ -287,7 +284,7 @@ mod issue5435 { trait TupleReturnerBad { // should trigger lint fn new() -> (u32, u32) { - //~^ new_ret_no_self + //~^ new_ret_no_self unimplemented!(); } @@ -316,7 +313,7 @@ mod issue5435 { trait MutPointerReturnerBad { // should trigger lint fn new() -> *mut V { - //~^ new_ret_no_self + //~^ new_ret_no_self unimplemented!(); } @@ -388,7 +385,7 @@ mod issue7344 { impl RetImplTraitNoSelf { // should trigger lint fn new(t: T) -> impl Into { - //~^ new_ret_no_self + //~^ new_ret_no_self 1 } @@ -409,8 +406,7 @@ mod issue7344 { impl RetImplTraitNoSelf2 { // should trigger lint fn new(t: T) -> impl Trait2<(), i32> { - //~^ new_ret_no_self - + //~^ new_ret_no_self } } diff --git a/tests/ui/new_ret_no_self.stderr b/tests/ui/new_ret_no_self.stderr index e31282c3fb7eb..a758c746f9184 100644 --- a/tests/ui/new_ret_no_self.stderr +++ b/tests/ui/new_ret_no_self.stderr @@ -2,7 +2,9 @@ error: methods called `new` usually return `Self` --> tests/ui/new_ret_no_self.rs:50:5 | LL | / pub fn new(_: String) -> impl R { -... | +LL | | +LL | | +LL | | S3 LL | | } | |_____^ | @@ -10,7 +12,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::new_ret_no_self)]` error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:85:5 + --> tests/ui/new_ret_no_self.rs:84:5 | LL | / pub fn new() -> u32 { LL | | @@ -20,7 +22,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:96:5 + --> tests/ui/new_ret_no_self.rs:95:5 | LL | / pub fn new(_: String) -> u32 { LL | | @@ -30,7 +32,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:134:5 + --> tests/ui/new_ret_no_self.rs:133:5 | LL | / pub fn new() -> (u32, u32) { LL | | @@ -40,7 +42,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:163:5 + --> tests/ui/new_ret_no_self.rs:162:5 | LL | / pub fn new() -> *mut V { LL | | @@ -50,7 +52,7 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:183:5 + --> tests/ui/new_ret_no_self.rs:182:5 | LL | / pub fn new() -> Option { LL | | @@ -60,19 +62,19 @@ LL | | } | |_____^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:238:9 + --> tests/ui/new_ret_no_self.rs:237:9 | LL | fn new() -> String; | ^^^^^^^^^^^^^^^^^^^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:252:9 + --> tests/ui/new_ret_no_self.rs:250:9 | LL | fn new(_: String) -> String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:289:9 + --> tests/ui/new_ret_no_self.rs:286:9 | LL | / fn new() -> (u32, u32) { LL | | @@ -82,7 +84,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:318:9 + --> tests/ui/new_ret_no_self.rs:315:9 | LL | / fn new() -> *mut V { LL | | @@ -92,7 +94,7 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:390:9 + --> tests/ui/new_ret_no_self.rs:387:9 | LL | / fn new(t: T) -> impl Into { LL | | @@ -102,10 +104,10 @@ LL | | } | |_________^ error: methods called `new` usually return `Self` - --> tests/ui/new_ret_no_self.rs:411:9 + --> tests/ui/new_ret_no_self.rs:408:9 | LL | / fn new(t: T) -> impl Trait2<(), i32> { -... | +LL | | LL | | } | |_________^ diff --git a/tests/ui/new_ret_no_self_overflow.rs b/tests/ui/new_ret_no_self_overflow.rs index db7ce9c4054e9..8a85c56622763 100644 --- a/tests/ui/new_ret_no_self_overflow.rs +++ b/tests/ui/new_ret_no_self_overflow.rs @@ -18,7 +18,7 @@ mod issue10041 { impl Bomb2 { pub fn new() -> X { - //~^ ERROR: overflow evaluating the requirement + //~^ ERROR: overflow evaluating the requirement 0i32 } } diff --git a/tests/ui/new_without_default.fixed b/tests/ui/new_without_default.fixed index 8fd7032008356..277c335cd8851 100644 --- a/tests/ui/new_without_default.fixed +++ b/tests/ui/new_without_default.fixed @@ -17,8 +17,7 @@ impl Default for Foo { impl Foo { pub fn new() -> Foo { - //~^ new_without_default - + //~^ new_without_default Foo } @@ -34,7 +33,7 @@ impl Default for Bar { impl Bar { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Bar } @@ -106,7 +105,7 @@ impl<'c> Default for LtKo<'c> { impl<'c> LtKo<'c> { pub fn new() -> LtKo<'c> { - //~^ new_without_default + //~^ new_without_default unimplemented!() } @@ -146,7 +145,7 @@ impl Default for Const { impl Const { pub const fn new() -> Const { - //~^ new_without_default + //~^ new_without_default Const } // While Default is not const, it can still call const functions, so we should lint this } @@ -213,7 +212,7 @@ impl Default for NewNotEqualToDerive { impl NewNotEqualToDerive { // This `new` implementation is not equal to a derived `Default`, so do not suggest deriving. pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default NewNotEqualToDerive { foo: 1 } } @@ -229,7 +228,7 @@ impl Default for FooGenerics { impl FooGenerics { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Self(Default::default()) } @@ -244,7 +243,7 @@ impl Default for BarGenerics { impl BarGenerics { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Self(Default::default()) } @@ -263,7 +262,7 @@ pub mod issue7220 { impl Foo { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default todo!() } @@ -319,7 +318,7 @@ where K: std::hash::Hash + Eq + PartialEq, { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Self { _kv: None } } } diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index 856f515e4abab..f2844897c93d9 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -11,8 +11,7 @@ pub struct Foo; impl Foo { pub fn new() -> Foo { - //~^ new_without_default - + //~^ new_without_default Foo } @@ -22,7 +21,7 @@ pub struct Bar; impl Bar { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Bar } @@ -88,7 +87,7 @@ pub struct LtKo<'a> { impl<'c> LtKo<'c> { pub fn new() -> LtKo<'c> { - //~^ new_without_default + //~^ new_without_default unimplemented!() } @@ -122,7 +121,7 @@ pub struct Const; impl Const { pub const fn new() -> Const { - //~^ new_without_default + //~^ new_without_default Const } // While Default is not const, it can still call const functions, so we should lint this } @@ -183,7 +182,7 @@ pub struct NewNotEqualToDerive { impl NewNotEqualToDerive { // This `new` implementation is not equal to a derived `Default`, so do not suggest deriving. pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default NewNotEqualToDerive { foo: 1 } } @@ -193,7 +192,7 @@ impl NewNotEqualToDerive { pub struct FooGenerics(std::marker::PhantomData); impl FooGenerics { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Self(Default::default()) } @@ -202,7 +201,7 @@ impl FooGenerics { pub struct BarGenerics(std::marker::PhantomData); impl BarGenerics { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Self(Default::default()) } @@ -215,7 +214,7 @@ pub mod issue7220 { impl Foo { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default todo!() } @@ -262,7 +261,7 @@ where K: std::hash::Hash + Eq + PartialEq, { pub fn new() -> Self { - //~^ new_without_default + //~^ new_without_default Self { _kv: None } } } diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index 1a122d341a089..70a65aba464b8 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -2,7 +2,9 @@ error: you should consider adding a `Default` implementation for `Foo` --> tests/ui/new_without_default.rs:13:5 | LL | / pub fn new() -> Foo { -... | +LL | | +LL | | +LL | | Foo LL | | } | |_____^ | @@ -18,7 +20,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Bar` - --> tests/ui/new_without_default.rs:24:5 + --> tests/ui/new_without_default.rs:23:5 | LL | / pub fn new() -> Self { LL | | @@ -37,7 +39,7 @@ LL + } | error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> tests/ui/new_without_default.rs:90:5 + --> tests/ui/new_without_default.rs:89:5 | LL | / pub fn new() -> LtKo<'c> { LL | | @@ -56,7 +58,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Const` - --> tests/ui/new_without_default.rs:124:5 + --> tests/ui/new_without_default.rs:123:5 | LL | / pub const fn new() -> Const { LL | | @@ -74,7 +76,7 @@ LL + } | error: you should consider adding a `Default` implementation for `NewNotEqualToDerive` - --> tests/ui/new_without_default.rs:185:5 + --> tests/ui/new_without_default.rs:184:5 | LL | / pub fn new() -> Self { LL | | @@ -93,7 +95,7 @@ LL + } | error: you should consider adding a `Default` implementation for `FooGenerics` - --> tests/ui/new_without_default.rs:195:5 + --> tests/ui/new_without_default.rs:194:5 | LL | / pub fn new() -> Self { LL | | @@ -112,7 +114,7 @@ LL + } | error: you should consider adding a `Default` implementation for `BarGenerics` - --> tests/ui/new_without_default.rs:204:5 + --> tests/ui/new_without_default.rs:203:5 | LL | / pub fn new() -> Self { LL | | @@ -131,7 +133,7 @@ LL + } | error: you should consider adding a `Default` implementation for `Foo` - --> tests/ui/new_without_default.rs:217:9 + --> tests/ui/new_without_default.rs:216:9 | LL | / pub fn new() -> Self { LL | | @@ -152,7 +154,7 @@ LL ~ impl Foo { | error: you should consider adding a `Default` implementation for `MyStruct` - --> tests/ui/new_without_default.rs:264:5 + --> tests/ui/new_without_default.rs:263:5 | LL | / pub fn new() -> Self { LL | | diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index cd992aed15e2d..703c2a3d98479 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -186,7 +186,6 @@ fn main() { let _unused = 1; //~^ no_effect_underscore_binding - let _penguin = || println!("Some helpful closure"); //~^ no_effect_underscore_binding diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 617a43aaf60d5..58a9380cbfdeb 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -149,19 +149,19 @@ LL | let _unused = 1; = help: to override `-D warnings` add `#[allow(clippy::no_effect_underscore_binding)]` error: binding to `_` prefixed variable with no side-effect - --> tests/ui/no_effect.rs:190:9 + --> tests/ui/no_effect.rs:189:9 | LL | let _penguin = || println!("Some helpful closure"); | ^^^^^^^^ error: binding to `_` prefixed variable with no side-effect - --> tests/ui/no_effect.rs:193:9 + --> tests/ui/no_effect.rs:192:9 | LL | let _duck = Struct { field: 0 }; | ^^^^^ error: binding to `_` prefixed variable with no side-effect - --> tests/ui/no_effect.rs:196:9 + --> tests/ui/no_effect.rs:195:9 | LL | let _cat = [2, 4, 6, 8][2]; | ^^^^ diff --git a/tests/ui/no_effect_async_fn.rs b/tests/ui/no_effect_async_fn.rs index 6fb3ccab8a087..a036a7e27bef6 100644 --- a/tests/ui/no_effect_async_fn.rs +++ b/tests/ui/no_effect_async_fn.rs @@ -13,7 +13,6 @@ impl AsyncTrait for Bar { let _a = 0; //~^ no_effect_underscore_binding - // Shouldn't lint `binding to `_` prefixed variable with no side-effect` let _b = num(); @@ -21,7 +20,6 @@ impl AsyncTrait for Bar { let _c = 0; //~^ no_effect_underscore_binding - // Shouldn't lint `binding to `_` prefixed variable with no side-effect` let _d = num(); } @@ -34,7 +32,6 @@ async fn foo(_i: u64) { let _a = 0; //~^ no_effect_underscore_binding - // Shouldn't lint `binding to `_` prefixed variable with no side-effect` let _b = num(); @@ -42,7 +39,6 @@ async fn foo(_i: u64) { let _c = 0; //~^ no_effect_underscore_binding - // Shouldn't lint `binding to `_` prefixed variable with no side-effect` let _d = num(); } diff --git a/tests/ui/no_effect_async_fn.stderr b/tests/ui/no_effect_async_fn.stderr index 96ad7b9d6075e..2325eb9aae592 100644 --- a/tests/ui/no_effect_async_fn.stderr +++ b/tests/ui/no_effect_async_fn.stderr @@ -1,5 +1,5 @@ error: binding to `_` prefixed variable with no side-effect - --> tests/ui/no_effect_async_fn.rs:21:17 + --> tests/ui/no_effect_async_fn.rs:20:17 | LL | let _c = 0; | ^^ @@ -14,13 +14,13 @@ LL | let _a = 0; | ^^ error: binding to `_` prefixed variable with no side-effect - --> tests/ui/no_effect_async_fn.rs:42:13 + --> tests/ui/no_effect_async_fn.rs:39:13 | LL | let _c = 0; | ^^ error: binding to `_` prefixed variable with no side-effect - --> tests/ui/no_effect_async_fn.rs:34:9 + --> tests/ui/no_effect_async_fn.rs:32:9 | LL | let _a = 0; | ^^ diff --git a/tests/ui/no_effect_replace.rs b/tests/ui/no_effect_replace.rs index dc8e66f69ff5c..245898f50740c 100644 --- a/tests/ui/no_effect_replace.rs +++ b/tests/ui/no_effect_replace.rs @@ -4,14 +4,12 @@ fn main() { let _ = "12345".replace('1', "1"); //~^ no_effect_replace - let _ = "12345".replace("12", "12"); //~^ no_effect_replace let _ = String::new().replace("12", "12"); //~^ no_effect_replace - let _ = "12345".replacen('1', "1", 1); //~^ no_effect_replace @@ -21,7 +19,6 @@ fn main() { let _ = String::new().replacen("12", "12", 1); //~^ no_effect_replace - let _ = "12345".replace("12", "22"); let _ = "12345".replacen("12", "22", 1); diff --git a/tests/ui/no_effect_replace.stderr b/tests/ui/no_effect_replace.stderr index 3861d042e6f5f..33d13b1d72e81 100644 --- a/tests/ui/no_effect_replace.stderr +++ b/tests/ui/no_effect_replace.stderr @@ -8,43 +8,43 @@ LL | let _ = "12345".replace('1', "1"); = help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]` error: replacing text with itself - --> tests/ui/no_effect_replace.rs:8:13 + --> tests/ui/no_effect_replace.rs:7:13 | LL | let _ = "12345".replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> tests/ui/no_effect_replace.rs:11:13 + --> tests/ui/no_effect_replace.rs:10:13 | LL | let _ = String::new().replace("12", "12"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> tests/ui/no_effect_replace.rs:15:13 + --> tests/ui/no_effect_replace.rs:13:13 | LL | let _ = "12345".replacen('1', "1", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> tests/ui/no_effect_replace.rs:18:13 + --> tests/ui/no_effect_replace.rs:16:13 | LL | let _ = "12345".replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> tests/ui/no_effect_replace.rs:21:13 + --> tests/ui/no_effect_replace.rs:19:13 | LL | let _ = String::new().replacen("12", "12", 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> tests/ui/no_effect_replace.rs:29:13 + --> tests/ui/no_effect_replace.rs:26:13 | LL | let _ = "hello".replace(&x.f(), &x.f()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: replacing text with itself - --> tests/ui/no_effect_replace.rs:34:13 + --> tests/ui/no_effect_replace.rs:31:13 | LL | let _ = "hello".replace(&y(), &y()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/no_effect_return.rs b/tests/ui/no_effect_return.rs index 8bfd8367f1041..4ba2fe07785d0 100644 --- a/tests/ui/no_effect_return.rs +++ b/tests/ui/no_effect_return.rs @@ -8,8 +8,6 @@ fn a() -> u32 { { 0u32; //~^ no_effect - - } 0 } @@ -18,7 +16,6 @@ async fn b() -> u32 { { 0u32; //~^ no_effect - } 0 } @@ -28,7 +25,6 @@ async fn c() -> C { { 0i32 as C; //~^ no_effect - } 0 } @@ -49,7 +45,6 @@ fn e() -> u32 { // mismatched types 0u16; //~^ no_effect - } 0 } @@ -58,7 +53,6 @@ fn f() -> [u16; 1] { { [1u16]; //~^ no_effect - } [1] } @@ -67,7 +61,6 @@ fn g() -> ControlFlow<()> { { ControlFlow::Break::<()>(()); //~^ no_effect - } ControlFlow::Continue(()) } @@ -86,7 +79,6 @@ fn i() -> () { // does not suggest on function with explicit unit return type (); //~^ no_effect - } () } @@ -96,7 +88,6 @@ fn j() { // does not suggest on function without explicit return type (); //~^ no_effect - } () } diff --git a/tests/ui/no_effect_return.stderr b/tests/ui/no_effect_return.stderr index f6ff2ded33e01..e7bf7e4cd4f43 100644 --- a/tests/ui/no_effect_return.stderr +++ b/tests/ui/no_effect_return.stderr @@ -10,7 +10,7 @@ LL | 0u32; = help: to override `-D warnings` add `#[allow(clippy::no_effect)]` error: statement with no effect - --> tests/ui/no_effect_return.rs:19:9 + --> tests/ui/no_effect_return.rs:17:9 | LL | 0u32; | -^^^^ @@ -18,7 +18,7 @@ LL | 0u32; | help: did you mean to return it?: `return` error: statement with no effect - --> tests/ui/no_effect_return.rs:29:9 + --> tests/ui/no_effect_return.rs:26:9 | LL | 0i32 as C; | -^^^^^^^^^ @@ -26,19 +26,19 @@ LL | 0i32 as C; | help: did you mean to return it?: `return` error: statement with no effect - --> tests/ui/no_effect_return.rs:39:9 + --> tests/ui/no_effect_return.rs:35:9 | LL | 0u128; | ^^^^^^ error: statement with no effect - --> tests/ui/no_effect_return.rs:50:9 + --> tests/ui/no_effect_return.rs:46:9 | LL | 0u16; | ^^^^^ error: statement with no effect - --> tests/ui/no_effect_return.rs:59:9 + --> tests/ui/no_effect_return.rs:54:9 | LL | [1u16]; | -^^^^^^ @@ -46,7 +46,7 @@ LL | [1u16]; | help: did you mean to return it?: `return` error: statement with no effect - --> tests/ui/no_effect_return.rs:68:9 + --> tests/ui/no_effect_return.rs:62:9 | LL | ControlFlow::Break::<()>(()); | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | ControlFlow::Break::<()>(()); | help: did you mean to return it?: `return` error: statement with no effect - --> tests/ui/no_effect_return.rs:87:9 + --> tests/ui/no_effect_return.rs:80:9 | LL | (); | ^^^ error: statement with no effect - --> tests/ui/no_effect_return.rs:97:9 + --> tests/ui/no_effect_return.rs:89:9 | LL | (); | ^^^ diff --git a/tests/ui/no_mangle_with_rust_abi.rs b/tests/ui/no_mangle_with_rust_abi.rs index 99b731d4a5977..0d09b3ceecde7 100644 --- a/tests/ui/no_mangle_with_rust_abi.rs +++ b/tests/ui/no_mangle_with_rust_abi.rs @@ -24,7 +24,7 @@ unsafe fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {} #[unsafe(no_mangle)] fn rust_abi_multiline_function_really_long_name_to_overflow_args_to_multiple_lines( -//~^ no_mangle_with_rust_abi + //~^ no_mangle_with_rust_abi arg_one: u32, arg_two: usize, ) -> u32 { diff --git a/tests/ui/no_mangle_with_rust_abi_2021.rs b/tests/ui/no_mangle_with_rust_abi_2021.rs index eba6538890640..3d5c70cad2f3e 100644 --- a/tests/ui/no_mangle_with_rust_abi_2021.rs +++ b/tests/ui/no_mangle_with_rust_abi_2021.rs @@ -28,7 +28,7 @@ unsafe fn rust_abi_fn_four(arg_one: u32, arg_two: usize) {} #[no_mangle] fn rust_abi_multiline_function_really_long_name_to_overflow_args_to_multiple_lines( -//~^ no_mangle_with_rust_abi + //~^ no_mangle_with_rust_abi arg_one: u32, arg_two: usize, ) -> u32 { diff --git a/tests/ui/non_canonical_clone_impl.rs b/tests/ui/non_canonical_clone_impl.rs index d735122e18451..7d101915517fe 100644 --- a/tests/ui/non_canonical_clone_impl.rs +++ b/tests/ui/non_canonical_clone_impl.rs @@ -12,12 +12,12 @@ struct A(u32); impl Clone for A { fn clone(&self) -> Self { - //~^ non_canonical_clone_impl + //~^ non_canonical_clone_impl Self(self.0) } fn clone_from(&mut self, source: &Self) { - //~^ non_canonical_clone_impl + //~^ non_canonical_clone_impl source.clone(); *self = source.clone(); } @@ -85,12 +85,12 @@ struct F(u32); impl Clone for F { fn clone(&self) -> Self { - //~^ non_canonical_clone_impl + //~^ non_canonical_clone_impl Self(self.0) } fn clone_from(&mut self, source: &Self) { - //~^ non_canonical_clone_impl + //~^ non_canonical_clone_impl source.clone(); *self = source.clone(); } diff --git a/tests/ui/non_canonical_partial_ord_impl.fixed b/tests/ui/non_canonical_partial_ord_impl.fixed index 7d1211522f181..8774c666db11f 100644 --- a/tests/ui/non_canonical_partial_ord_impl.fixed +++ b/tests/ui/non_canonical_partial_ord_impl.fixed @@ -14,7 +14,7 @@ impl Ord for A { } impl PartialOrd for A { -//~^ non_canonical_partial_ord_impl + //~^ non_canonical_partial_ord_impl fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } @@ -47,7 +47,7 @@ impl Ord for C { } impl PartialOrd for C { -//~^ non_canonical_partial_ord_impl + //~^ non_canonical_partial_ord_impl fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } diff --git a/tests/ui/non_canonical_partial_ord_impl.rs b/tests/ui/non_canonical_partial_ord_impl.rs index 4f3310557992e..568b97c8fff7b 100644 --- a/tests/ui/non_canonical_partial_ord_impl.rs +++ b/tests/ui/non_canonical_partial_ord_impl.rs @@ -14,7 +14,7 @@ impl Ord for A { } impl PartialOrd for A { -//~^ non_canonical_partial_ord_impl + //~^ non_canonical_partial_ord_impl fn partial_cmp(&self, other: &Self) -> Option { todo!(); } @@ -49,7 +49,7 @@ impl Ord for C { } impl PartialOrd for C { -//~^ non_canonical_partial_ord_impl + //~^ non_canonical_partial_ord_impl fn partial_cmp(&self, _: &Self) -> Option { todo!(); } diff --git a/tests/ui/non_canonical_partial_ord_impl_fully_qual.rs b/tests/ui/non_canonical_partial_ord_impl_fully_qual.rs index cbd1ae57be4a9..99cd7ebac60cd 100644 --- a/tests/ui/non_canonical_partial_ord_impl_fully_qual.rs +++ b/tests/ui/non_canonical_partial_ord_impl_fully_qual.rs @@ -21,7 +21,7 @@ impl cmp::Ord for A { } impl PartialOrd for A { -//~^ non_canonical_partial_ord_impl + //~^ non_canonical_partial_ord_impl fn partial_cmp(&self, other: &Self) -> Option { // NOTE: This suggestion is wrong, as `Ord` is not in scope. But this should be fine as it isn't // automatically applied @@ -45,7 +45,7 @@ impl cmp::Ord for B { } impl PartialOrd for B { -//~^ non_canonical_partial_ord_impl + //~^ non_canonical_partial_ord_impl fn partial_cmp(&self, other: &Self) -> Option { // This calls `B.cmp`, not `Ord::cmp`! Some(self.cmp(other)) diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 69e90c3d670bc..b772c754f8b76 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -25,12 +25,12 @@ impl MaybeInst { } fn underscores_and_numbers() { -let _1 = 1; -//~^ just_underscores_and_digits -let ____1 = 1; -//~^ just_underscores_and_digits -let __1___2 = 12; -//~^ just_underscores_and_digits + let _1 = 1; + //~^ just_underscores_and_digits + let ____1 = 1; + //~^ just_underscores_and_digits + let __1___2 = 12; + //~^ just_underscores_and_digits let _1_ok = 1; } @@ -51,12 +51,12 @@ struct Bar; impl Bar { fn bar() { -let _1 = 1; -//~^ just_underscores_and_digits -let ____1 = 1; -//~^ just_underscores_and_digits -let __1___2 = 12; -//~^ just_underscores_and_digits + let _1 = 1; + //~^ just_underscores_and_digits + let ____1 = 1; + //~^ just_underscores_and_digits + let __1___2 = 12; + //~^ just_underscores_and_digits let _1_ok = 1; } } diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 7aa67e1ca4158..3bd77a730fe78 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,41 +1,41 @@ error: consider choosing a more descriptive name - --> tests/ui/non_expressive_names.rs:28:5 + --> tests/ui/non_expressive_names.rs:28:9 | -LL | let _1 = 1; - | ^^ +LL | let _1 = 1; + | ^^ | = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::just_underscores_and_digits)]` error: consider choosing a more descriptive name - --> tests/ui/non_expressive_names.rs:30:5 + --> tests/ui/non_expressive_names.rs:30:9 | -LL | let ____1 = 1; - | ^^^^^ +LL | let ____1 = 1; + | ^^^^^ error: consider choosing a more descriptive name - --> tests/ui/non_expressive_names.rs:32:5 + --> tests/ui/non_expressive_names.rs:32:9 | -LL | let __1___2 = 12; - | ^^^^^^^ +LL | let __1___2 = 12; + | ^^^^^^^ error: consider choosing a more descriptive name - --> tests/ui/non_expressive_names.rs:54:5 + --> tests/ui/non_expressive_names.rs:54:13 | -LL | let _1 = 1; - | ^^ +LL | let _1 = 1; + | ^^ error: consider choosing a more descriptive name - --> tests/ui/non_expressive_names.rs:56:5 + --> tests/ui/non_expressive_names.rs:56:13 | -LL | let ____1 = 1; - | ^^^^^ +LL | let ____1 = 1; + | ^^^^^ error: consider choosing a more descriptive name - --> tests/ui/non_expressive_names.rs:58:5 + --> tests/ui/non_expressive_names.rs:58:13 | -LL | let __1___2 = 12; - | ^^^^^^^ +LL | let __1___2 = 12; + | ^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/non_zero_suggestions.fixed b/tests/ui/non_zero_suggestions.fixed index 1459832be75ee..4573896ecd673 100644 --- a/tests/ui/non_zero_suggestions.fixed +++ b/tests/ui/non_zero_suggestions.fixed @@ -9,22 +9,18 @@ fn main() { let r1 = x / NonZeroU64::from(y); //~^ non_zero_suggestions - let r2 = x % NonZeroU64::from(y); //~^ non_zero_suggestions - // U16 -> U32 let a: u32 = 50; let b = NonZeroU16::new(5).unwrap(); let r3 = a / NonZeroU32::from(b); //~^ non_zero_suggestions - let x = NonZeroU64::from(NonZeroU32::new(5).unwrap()); //~^ non_zero_suggestions - /// Negative test cases (lint should not trigger) // Left hand side expressions should not be triggered let c: u32 = 50; @@ -55,7 +51,6 @@ fn main() { fn divide_numbers(x: u64, y: NonZeroU32) -> u64 { x / NonZeroU64::from(y) //~^ non_zero_suggestions - } struct Calculator { @@ -66,6 +61,5 @@ impl Calculator { fn divide(&self, divisor: NonZeroU32) -> u64 { self.value / NonZeroU64::from(divisor) //~^ non_zero_suggestions - } } diff --git a/tests/ui/non_zero_suggestions.rs b/tests/ui/non_zero_suggestions.rs index 72a38131a132c..3e7081e0c1c0c 100644 --- a/tests/ui/non_zero_suggestions.rs +++ b/tests/ui/non_zero_suggestions.rs @@ -9,22 +9,18 @@ fn main() { let r1 = x / u64::from(y.get()); //~^ non_zero_suggestions - let r2 = x % u64::from(y.get()); //~^ non_zero_suggestions - // U16 -> U32 let a: u32 = 50; let b = NonZeroU16::new(5).unwrap(); let r3 = a / u32::from(b.get()); //~^ non_zero_suggestions - let x = u64::from(NonZeroU32::new(5).unwrap().get()); //~^ non_zero_suggestions - /// Negative test cases (lint should not trigger) // Left hand side expressions should not be triggered let c: u32 = 50; @@ -55,7 +51,6 @@ fn main() { fn divide_numbers(x: u64, y: NonZeroU32) -> u64 { x / u64::from(y.get()) //~^ non_zero_suggestions - } struct Calculator { @@ -66,6 +61,5 @@ impl Calculator { fn divide(&self, divisor: NonZeroU32) -> u64 { self.value / u64::from(divisor.get()) //~^ non_zero_suggestions - } } diff --git a/tests/ui/non_zero_suggestions.stderr b/tests/ui/non_zero_suggestions.stderr index f7ed71dcf56c1..7a57f7983be74 100644 --- a/tests/ui/non_zero_suggestions.stderr +++ b/tests/ui/non_zero_suggestions.stderr @@ -8,31 +8,31 @@ LL | let r1 = x / u64::from(y.get()); = help: to override `-D warnings` add `#[allow(clippy::non_zero_suggestions)]` error: consider using `NonZeroU64::from()` for more efficient and type-safe conversion - --> tests/ui/non_zero_suggestions.rs:13:18 + --> tests/ui/non_zero_suggestions.rs:12:18 | LL | let r2 = x % u64::from(y.get()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(y)` error: consider using `NonZeroU32::from()` for more efficient and type-safe conversion - --> tests/ui/non_zero_suggestions.rs:20:18 + --> tests/ui/non_zero_suggestions.rs:18:18 | LL | let r3 = a / u32::from(b.get()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU32::from(b)` error: consider using `NonZeroU64::from()` for more efficient and type-safe conversion - --> tests/ui/non_zero_suggestions.rs:24:13 + --> tests/ui/non_zero_suggestions.rs:21:13 | LL | let x = u64::from(NonZeroU32::new(5).unwrap().get()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(NonZeroU32::new(5).unwrap())` error: consider using `NonZeroU64::from()` for more efficient and type-safe conversion - --> tests/ui/non_zero_suggestions.rs:56:9 + --> tests/ui/non_zero_suggestions.rs:52:9 | LL | x / u64::from(y.get()) | ^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(y)` error: consider using `NonZeroU64::from()` for more efficient and type-safe conversion - --> tests/ui/non_zero_suggestions.rs:67:22 + --> tests/ui/non_zero_suggestions.rs:62:22 | LL | self.value / u64::from(divisor.get()) | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(divisor)` diff --git a/tests/ui/non_zero_suggestions_unfixable.rs b/tests/ui/non_zero_suggestions_unfixable.rs index 4adbdf7bcc748..1224356236c71 100644 --- a/tests/ui/non_zero_suggestions_unfixable.rs +++ b/tests/ui/non_zero_suggestions_unfixable.rs @@ -6,7 +6,6 @@ fn main() { let x: u64 = u64::from(NonZeroU32::new(5).unwrap().get()); //~^ non_zero_suggestions - let n = NonZeroU32::new(20).unwrap(); let y = u64::from(n.get()); //~^ non_zero_suggestions @@ -20,7 +19,6 @@ fn main() { fn return_non_zero(x: u64, y: NonZeroU32) -> u64 { u64::from(y.get()) //~^ non_zero_suggestions - } fn some_fn_that_only_takes_u64(_: u64) {} diff --git a/tests/ui/non_zero_suggestions_unfixable.stderr b/tests/ui/non_zero_suggestions_unfixable.stderr index dff70dada26d3..d2ac983d4f7f0 100644 --- a/tests/ui/non_zero_suggestions_unfixable.stderr +++ b/tests/ui/non_zero_suggestions_unfixable.stderr @@ -8,13 +8,13 @@ LL | let x: u64 = u64::from(NonZeroU32::new(5).unwrap().get()); = help: to override `-D warnings` add `#[allow(clippy::non_zero_suggestions)]` error: consider using `NonZeroU64::from()` for more efficient and type-safe conversion - --> tests/ui/non_zero_suggestions_unfixable.rs:11:13 + --> tests/ui/non_zero_suggestions_unfixable.rs:10:13 | LL | let y = u64::from(n.get()); | ^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(n)` error: consider using `NonZeroU64::from()` for more efficient and type-safe conversion - --> tests/ui/non_zero_suggestions_unfixable.rs:21:5 + --> tests/ui/non_zero_suggestions_unfixable.rs:20:5 | LL | u64::from(y.get()) | ^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(y)` diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs index 1d41b2b9a84c7..a155ff3508be0 100644 --- a/tests/ui/nonminimal_bool.rs +++ b/tests/ui/nonminimal_bool.rs @@ -17,7 +17,6 @@ fn main() { let _ = !true; //~^ nonminimal_bool - let _ = !false; //~^ nonminimal_bool @@ -38,7 +37,6 @@ fn main() { let _ = !a && !(b && c); //~^ nonminimal_bool - } fn equality_stuff() { @@ -60,7 +58,6 @@ fn equality_stuff() { let _ = a != b && !(a != b && c == d); //~^ nonminimal_bool - } fn issue3847(a: u32, b: u32) -> bool { @@ -91,7 +88,7 @@ fn check_expect() { fn issue9428() { if matches!(true, true) && true { - //~^ nonminimal_bool + //~^ nonminimal_bool println!("foo"); } @@ -171,35 +168,35 @@ fn issue11932() { fn issue_5794() { let a = 0; -if !(12 == a) {} -//~^ nonminimal_bool -if !(a == 12) {} -//~^ nonminimal_bool -if !(12 != a) {} -//~^ nonminimal_bool -if !(a != 12) {} -//~^ nonminimal_bool + if !(12 == a) {} + //~^ nonminimal_bool + if !(a == 12) {} + //~^ nonminimal_bool + if !(12 != a) {} + //~^ nonminimal_bool + if !(a != 12) {} + //~^ nonminimal_bool let b = true; let c = false; -if !b == true {} -//~^ nonminimal_bool -//~| bool_comparison -//~| bool_comparison -if !b != true {} -//~^ nonminimal_bool -//~| bool_comparison -if true == !b {} -//~^ nonminimal_bool -//~| bool_comparison -//~| bool_comparison -if true != !b {} -//~^ nonminimal_bool -//~| bool_comparison -if !b == !c {} -//~^ nonminimal_bool -if !b != !c {} -//~^ nonminimal_bool + if !b == true {} + //~^ nonminimal_bool + //~| bool_comparison + //~| bool_comparison + if !b != true {} + //~^ nonminimal_bool + //~| bool_comparison + if true == !b {} + //~^ nonminimal_bool + //~| bool_comparison + //~| bool_comparison + if true != !b {} + //~^ nonminimal_bool + //~| bool_comparison + if !b == !c {} + //~^ nonminimal_bool + if !b != !c {} + //~^ nonminimal_bool } fn issue_12371(x: usize) -> bool { @@ -215,7 +212,7 @@ fn many_ops(a: bool, b: bool, c: bool, d: bool, e: bool, f: bool) -> bool { fn issue14184(a: f32, b: bool) { if !(a < 2.0 && !b) { - //~^ nonminimal_bool + //~^ nonminimal_bool println!("Hi"); } } diff --git a/tests/ui/nonminimal_bool.stderr b/tests/ui/nonminimal_bool.stderr index ca2c7ab8232aa..06d3615c6e26f 100644 --- a/tests/ui/nonminimal_bool.stderr +++ b/tests/ui/nonminimal_bool.stderr @@ -8,43 +8,43 @@ LL | let _ = !true; = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:21:13 + --> tests/ui/nonminimal_bool.rs:20:13 | LL | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:24:13 + --> tests/ui/nonminimal_bool.rs:23:13 | LL | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:27:13 + --> tests/ui/nonminimal_bool.rs:26:13 | LL | let _ = false || a; | ^^^^^^^^^^ help: try: `a` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:33:13 + --> tests/ui/nonminimal_bool.rs:32:13 | LL | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `a || !b` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:36:13 + --> tests/ui/nonminimal_bool.rs:35:13 | LL | let _ = !(!a || b); | ^^^^^^^^^^ help: try: `a && !b` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:39:13 + --> tests/ui/nonminimal_bool.rs:38:13 | LL | let _ = !a && !(b && c); | ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:49:13 + --> tests/ui/nonminimal_bool.rs:47:13 | LL | let _ = a == b && c == 5 && a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:52:13 + --> tests/ui/nonminimal_bool.rs:50:13 | LL | let _ = a == b || c == 5 || a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | let _ = a == b || c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:55:13 + --> tests/ui/nonminimal_bool.rs:53:13 | LL | let _ = a == b && c == 5 && b == a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL | let _ = a == b && c == 5; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:58:13 + --> tests/ui/nonminimal_bool.rs:56:13 | LL | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,7 +96,7 @@ LL | let _ = a != b || c != d; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:61:13 + --> tests/ui/nonminimal_bool.rs:59:13 | LL | let _ = a != b && !(a != b && c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,112 +109,112 @@ LL | let _ = a != b && c != d; | ~~~~~~~~~~~~~~~~ error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:93:8 + --> tests/ui/nonminimal_bool.rs:90:8 | LL | if matches!(true, true) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:174:4 + --> tests/ui/nonminimal_bool.rs:171:8 | -LL | if !(12 == a) {} - | ^^^^^^^^^^ help: try: `(12 != a)` +LL | if !(12 == a) {} + | ^^^^^^^^^^ help: try: `(12 != a)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:176:4 + --> tests/ui/nonminimal_bool.rs:173:8 | -LL | if !(a == 12) {} - | ^^^^^^^^^^ help: try: `(a != 12)` +LL | if !(a == 12) {} + | ^^^^^^^^^^ help: try: `(a != 12)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:178:4 + --> tests/ui/nonminimal_bool.rs:175:8 | -LL | if !(12 != a) {} - | ^^^^^^^^^^ help: try: `(12 == a)` +LL | if !(12 != a) {} + | ^^^^^^^^^^ help: try: `(12 == a)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:180:4 + --> tests/ui/nonminimal_bool.rs:177:8 | -LL | if !(a != 12) {} - | ^^^^^^^^^^ help: try: `(a == 12)` +LL | if !(a != 12) {} + | ^^^^^^^^^^ help: try: `(a == 12)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:185:4 + --> tests/ui/nonminimal_bool.rs:182:8 | -LL | if !b == true {} - | ^^^^^^^^^^ help: try: `b != true` +LL | if !b == true {} + | ^^^^^^^^^^ help: try: `b != true` error: this comparison might be written more concisely - --> tests/ui/nonminimal_bool.rs:185:4 + --> tests/ui/nonminimal_bool.rs:182:8 | -LL | if !b == true {} - | ^^^^^^^^^^ help: try simplifying it as shown: `b != true` +LL | if !b == true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `b != true` | = note: `-D clippy::bool-comparison` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]` error: equality checks against true are unnecessary - --> tests/ui/nonminimal_bool.rs:185:4 + --> tests/ui/nonminimal_bool.rs:182:8 | -LL | if !b == true {} - | ^^^^^^^^^^ help: try simplifying it as shown: `!b` +LL | if !b == true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!b` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:189:4 + --> tests/ui/nonminimal_bool.rs:186:8 | -LL | if !b != true {} - | ^^^^^^^^^^ help: try: `b == true` +LL | if !b != true {} + | ^^^^^^^^^^ help: try: `b == true` error: inequality checks against true can be replaced by a negation - --> tests/ui/nonminimal_bool.rs:189:4 + --> tests/ui/nonminimal_bool.rs:186:8 | -LL | if !b != true {} - | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` +LL | if !b != true {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:192:4 + --> tests/ui/nonminimal_bool.rs:189:8 | -LL | if true == !b {} - | ^^^^^^^^^^ help: try: `true != b` +LL | if true == !b {} + | ^^^^^^^^^^ help: try: `true != b` error: this comparison might be written more concisely - --> tests/ui/nonminimal_bool.rs:192:4 + --> tests/ui/nonminimal_bool.rs:189:8 | -LL | if true == !b {} - | ^^^^^^^^^^ help: try simplifying it as shown: `true != b` +LL | if true == !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `true != b` error: equality checks against true are unnecessary - --> tests/ui/nonminimal_bool.rs:192:4 + --> tests/ui/nonminimal_bool.rs:189:8 | -LL | if true == !b {} - | ^^^^^^^^^^ help: try simplifying it as shown: `!b` +LL | if true == !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!b` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:196:4 + --> tests/ui/nonminimal_bool.rs:193:8 | -LL | if true != !b {} - | ^^^^^^^^^^ help: try: `true == b` +LL | if true != !b {} + | ^^^^^^^^^^ help: try: `true == b` error: inequality checks against true can be replaced by a negation - --> tests/ui/nonminimal_bool.rs:196:4 + --> tests/ui/nonminimal_bool.rs:193:8 | -LL | if true != !b {} - | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` +LL | if true != !b {} + | ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:199:4 + --> tests/ui/nonminimal_bool.rs:196:8 | -LL | if !b == !c {} - | ^^^^^^^^ help: try: `b == c` +LL | if !b == !c {} + | ^^^^^^^^ help: try: `b == c` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:201:4 + --> tests/ui/nonminimal_bool.rs:198:8 | -LL | if !b != !c {} - | ^^^^^^^^ help: try: `b != c` +LL | if !b != !c {} + | ^^^^^^^^ help: try: `b != c` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool.rs:217:8 + --> tests/ui/nonminimal_bool.rs:214:8 | LL | if !(a < 2.0 && !b) { | ^^^^^^^^^^^^^^^^ help: try: `!(a < 2.0) || b` diff --git a/tests/ui/nonminimal_bool_methods.fixed b/tests/ui/nonminimal_bool_methods.fixed index 4b11dc2b5dda6..c2377491f25b1 100644 --- a/tests/ui/nonminimal_bool_methods.fixed +++ b/tests/ui/nonminimal_bool_methods.fixed @@ -123,34 +123,34 @@ fn dont_warn_for_negated_partial_ord_comparison() { fn issue_12625() { let a = 0; let b = 0; -if ((a as u64) < b) {} -//~^ nonminimal_bool -if ((a as u64) < b) {} -//~^ nonminimal_bool -if (a as u64 > b) {} -//~^ nonminimal_bool + if ((a as u64) < b) {} + //~^ nonminimal_bool + if ((a as u64) < b) {} + //~^ nonminimal_bool + if (a as u64 > b) {} + //~^ nonminimal_bool } fn issue_12761() { let a = 0; let b = 0; let c = 0; -if (a < b) as i32 == c {} -//~^ nonminimal_bool -if (a < b) | (a > c) {} -//~^ nonminimal_bool -//~| nonminimal_bool + if (a < b) as i32 == c {} + //~^ nonminimal_bool + if (a < b) | (a > c) {} + //~^ nonminimal_bool + //~| nonminimal_bool let opt: Option = Some(1); let res: Result = Ok(1); -if res.is_err() as i32 == c {} -//~^ nonminimal_bool -if res.is_err() | opt.is_some() {} -//~^ nonminimal_bool -//~| nonminimal_bool + if res.is_err() as i32 == c {} + //~^ nonminimal_bool + if res.is_err() | opt.is_some() {} + //~^ nonminimal_bool + //~| nonminimal_bool fn a(a: bool) -> bool { -(4 <= 3).b() -//~^ nonminimal_bool + (4 <= 3).b() + //~^ nonminimal_bool } trait B { @@ -175,18 +175,18 @@ fn issue_13436() { _ = opt.is_some_and(|x| x == 1000); _ = opt.is_some_and(|x| x != 1000); _ = opt.is_some_and(not_zero); -_ = opt.is_none_or(|x| x >= 1000); -//~^ nonminimal_bool -_ = opt.is_none_or(|x| x > 1000); -//~^ nonminimal_bool -_ = opt.is_none_or(|x| x <= 1000); -//~^ nonminimal_bool -_ = opt.is_none_or(|x| x < 1000); -//~^ nonminimal_bool -_ = opt.is_none_or(|x| x != 1000); -//~^ nonminimal_bool -_ = opt.is_none_or(|x| x == 1000); -//~^ nonminimal_bool + _ = opt.is_none_or(|x| x >= 1000); + //~^ nonminimal_bool + _ = opt.is_none_or(|x| x > 1000); + //~^ nonminimal_bool + _ = opt.is_none_or(|x| x <= 1000); + //~^ nonminimal_bool + _ = opt.is_none_or(|x| x < 1000); + //~^ nonminimal_bool + _ = opt.is_none_or(|x| x != 1000); + //~^ nonminimal_bool + _ = opt.is_none_or(|x| x == 1000); + //~^ nonminimal_bool _ = !opt.is_some_and(not_zero); _ = opt.is_none_or(|x| x < 1000); _ = opt.is_none_or(|x| x <= 1000); @@ -195,45 +195,45 @@ _ = opt.is_none_or(|x| x == 1000); _ = opt.is_none_or(|x| x == 1000); _ = opt.is_none_or(|x| x != 1000); _ = opt.is_none_or(not_zero); -_ = opt.is_some_and(|x| x >= 1000); -//~^ nonminimal_bool -_ = opt.is_some_and(|x| x > 1000); -//~^ nonminimal_bool -_ = opt.is_some_and(|x| x <= 1000); -//~^ nonminimal_bool -_ = opt.is_some_and(|x| x < 1000); -//~^ nonminimal_bool -_ = opt.is_some_and(|x| x != 1000); -//~^ nonminimal_bool -_ = opt.is_some_and(|x| x == 1000); -//~^ nonminimal_bool + _ = opt.is_some_and(|x| x >= 1000); + //~^ nonminimal_bool + _ = opt.is_some_and(|x| x > 1000); + //~^ nonminimal_bool + _ = opt.is_some_and(|x| x <= 1000); + //~^ nonminimal_bool + _ = opt.is_some_and(|x| x < 1000); + //~^ nonminimal_bool + _ = opt.is_some_and(|x| x != 1000); + //~^ nonminimal_bool + _ = opt.is_some_and(|x| x == 1000); + //~^ nonminimal_bool _ = !opt.is_none_or(not_zero); let opt = Some(true); _ = opt.is_some_and(|x| x); _ = opt.is_some_and(|x| !x); _ = !opt.is_some_and(|x| x); -_ = opt.is_none_or(|x| x); -//~^ nonminimal_bool + _ = opt.is_none_or(|x| x); + //~^ nonminimal_bool _ = opt.is_none_or(|x| x); _ = opt.is_none_or(|x| !x); _ = !opt.is_none_or(|x| x); -_ = opt.is_some_and(|x| x); -//~^ nonminimal_bool + _ = opt.is_some_and(|x| x); + //~^ nonminimal_bool let opt: Option> = Some(Ok(123)); _ = opt.is_some_and(|x| x.is_ok()); _ = opt.is_some_and(|x| x.is_err()); _ = opt.is_none_or(|x| x.is_ok()); _ = opt.is_none_or(|x| x.is_err()); -_ = opt.is_none_or(|x| x.is_err()); -//~^ nonminimal_bool -_ = opt.is_none_or(|x| x.is_ok()); -//~^ nonminimal_bool -_ = opt.is_some_and(|x| x.is_err()); -//~^ nonminimal_bool -_ = opt.is_some_and(|x| x.is_ok()); -//~^ nonminimal_bool + _ = opt.is_none_or(|x| x.is_err()); + //~^ nonminimal_bool + _ = opt.is_none_or(|x| x.is_ok()); + //~^ nonminimal_bool + _ = opt.is_some_and(|x| x.is_err()); + //~^ nonminimal_bool + _ = opt.is_some_and(|x| x.is_ok()); + //~^ nonminimal_bool #[clippy::msrv = "1.81"] fn before_stabilization() { diff --git a/tests/ui/nonminimal_bool_methods.rs b/tests/ui/nonminimal_bool_methods.rs index 3e574de2d1568..1ae0f0064c6b6 100644 --- a/tests/ui/nonminimal_bool_methods.rs +++ b/tests/ui/nonminimal_bool_methods.rs @@ -123,34 +123,34 @@ fn dont_warn_for_negated_partial_ord_comparison() { fn issue_12625() { let a = 0; let b = 0; -if !(a as u64 >= b) {} -//~^ nonminimal_bool -if !((a as u64) >= b) {} -//~^ nonminimal_bool -if !(a as u64 <= b) {} -//~^ nonminimal_bool + if !(a as u64 >= b) {} + //~^ nonminimal_bool + if !((a as u64) >= b) {} + //~^ nonminimal_bool + if !(a as u64 <= b) {} + //~^ nonminimal_bool } fn issue_12761() { let a = 0; let b = 0; let c = 0; -if !(a >= b) as i32 == c {} -//~^ nonminimal_bool -if !(a >= b) | !(a <= c) {} -//~^ nonminimal_bool -//~| nonminimal_bool + if !(a >= b) as i32 == c {} + //~^ nonminimal_bool + if !(a >= b) | !(a <= c) {} + //~^ nonminimal_bool + //~| nonminimal_bool let opt: Option = Some(1); let res: Result = Ok(1); -if !res.is_ok() as i32 == c {} -//~^ nonminimal_bool -if !res.is_ok() | !opt.is_none() {} -//~^ nonminimal_bool -//~| nonminimal_bool + if !res.is_ok() as i32 == c {} + //~^ nonminimal_bool + if !res.is_ok() | !opt.is_none() {} + //~^ nonminimal_bool + //~| nonminimal_bool fn a(a: bool) -> bool { -(!(4 > 3)).b() -//~^ nonminimal_bool + (!(4 > 3)).b() + //~^ nonminimal_bool } trait B { @@ -175,18 +175,18 @@ fn issue_13436() { _ = opt.is_some_and(|x| x == 1000); _ = opt.is_some_and(|x| x != 1000); _ = opt.is_some_and(not_zero); -_ = !opt.is_some_and(|x| x < 1000); -//~^ nonminimal_bool -_ = !opt.is_some_and(|x| x <= 1000); -//~^ nonminimal_bool -_ = !opt.is_some_and(|x| x > 1000); -//~^ nonminimal_bool -_ = !opt.is_some_and(|x| x >= 1000); -//~^ nonminimal_bool -_ = !opt.is_some_and(|x| x == 1000); -//~^ nonminimal_bool -_ = !opt.is_some_and(|x| x != 1000); -//~^ nonminimal_bool + _ = !opt.is_some_and(|x| x < 1000); + //~^ nonminimal_bool + _ = !opt.is_some_and(|x| x <= 1000); + //~^ nonminimal_bool + _ = !opt.is_some_and(|x| x > 1000); + //~^ nonminimal_bool + _ = !opt.is_some_and(|x| x >= 1000); + //~^ nonminimal_bool + _ = !opt.is_some_and(|x| x == 1000); + //~^ nonminimal_bool + _ = !opt.is_some_and(|x| x != 1000); + //~^ nonminimal_bool _ = !opt.is_some_and(not_zero); _ = opt.is_none_or(|x| x < 1000); _ = opt.is_none_or(|x| x <= 1000); @@ -195,45 +195,45 @@ _ = !opt.is_some_and(|x| x != 1000); _ = opt.is_none_or(|x| x == 1000); _ = opt.is_none_or(|x| x != 1000); _ = opt.is_none_or(not_zero); -_ = !opt.is_none_or(|x| x < 1000); -//~^ nonminimal_bool -_ = !opt.is_none_or(|x| x <= 1000); -//~^ nonminimal_bool -_ = !opt.is_none_or(|x| x > 1000); -//~^ nonminimal_bool -_ = !opt.is_none_or(|x| x >= 1000); -//~^ nonminimal_bool -_ = !opt.is_none_or(|x| x == 1000); -//~^ nonminimal_bool -_ = !opt.is_none_or(|x| x != 1000); -//~^ nonminimal_bool + _ = !opt.is_none_or(|x| x < 1000); + //~^ nonminimal_bool + _ = !opt.is_none_or(|x| x <= 1000); + //~^ nonminimal_bool + _ = !opt.is_none_or(|x| x > 1000); + //~^ nonminimal_bool + _ = !opt.is_none_or(|x| x >= 1000); + //~^ nonminimal_bool + _ = !opt.is_none_or(|x| x == 1000); + //~^ nonminimal_bool + _ = !opt.is_none_or(|x| x != 1000); + //~^ nonminimal_bool _ = !opt.is_none_or(not_zero); let opt = Some(true); _ = opt.is_some_and(|x| x); _ = opt.is_some_and(|x| !x); _ = !opt.is_some_and(|x| x); -_ = !opt.is_some_and(|x| !x); -//~^ nonminimal_bool + _ = !opt.is_some_and(|x| !x); + //~^ nonminimal_bool _ = opt.is_none_or(|x| x); _ = opt.is_none_or(|x| !x); _ = !opt.is_none_or(|x| x); -_ = !opt.is_none_or(|x| !x); -//~^ nonminimal_bool + _ = !opt.is_none_or(|x| !x); + //~^ nonminimal_bool let opt: Option> = Some(Ok(123)); _ = opt.is_some_and(|x| x.is_ok()); _ = opt.is_some_and(|x| x.is_err()); _ = opt.is_none_or(|x| x.is_ok()); _ = opt.is_none_or(|x| x.is_err()); -_ = !opt.is_some_and(|x| x.is_ok()); -//~^ nonminimal_bool -_ = !opt.is_some_and(|x| x.is_err()); -//~^ nonminimal_bool -_ = !opt.is_none_or(|x| x.is_ok()); -//~^ nonminimal_bool -_ = !opt.is_none_or(|x| x.is_err()); -//~^ nonminimal_bool + _ = !opt.is_some_and(|x| x.is_ok()); + //~^ nonminimal_bool + _ = !opt.is_some_and(|x| x.is_err()); + //~^ nonminimal_bool + _ = !opt.is_none_or(|x| x.is_ok()); + //~^ nonminimal_bool + _ = !opt.is_none_or(|x| x.is_err()); + //~^ nonminimal_bool #[clippy::msrv = "1.81"] fn before_stabilization() { diff --git a/tests/ui/nonminimal_bool_methods.stderr b/tests/ui/nonminimal_bool_methods.stderr index 3f03b86135964..b5155b3b16968 100644 --- a/tests/ui/nonminimal_bool_methods.stderr +++ b/tests/ui/nonminimal_bool_methods.stderr @@ -80,172 +80,172 @@ LL | if !res.is_none() {} | ^^^^^^^^^^^^^^ help: try: `res.is_some()` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:126:4 + --> tests/ui/nonminimal_bool_methods.rs:126:8 | -LL | if !(a as u64 >= b) {} - | ^^^^^^^^^^^^^^^^ help: try: `((a as u64) < b)` +LL | if !(a as u64 >= b) {} + | ^^^^^^^^^^^^^^^^ help: try: `((a as u64) < b)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:128:4 + --> tests/ui/nonminimal_bool_methods.rs:128:8 | -LL | if !((a as u64) >= b) {} - | ^^^^^^^^^^^^^^^^^^ help: try: `((a as u64) < b)` +LL | if !((a as u64) >= b) {} + | ^^^^^^^^^^^^^^^^^^ help: try: `((a as u64) < b)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:130:4 + --> tests/ui/nonminimal_bool_methods.rs:130:8 | -LL | if !(a as u64 <= b) {} - | ^^^^^^^^^^^^^^^^ help: try: `(a as u64 > b)` +LL | if !(a as u64 <= b) {} + | ^^^^^^^^^^^^^^^^ help: try: `(a as u64 > b)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:138:4 + --> tests/ui/nonminimal_bool_methods.rs:138:8 | -LL | if !(a >= b) as i32 == c {} - | ^^^^^^^^^ help: try: `(a < b)` +LL | if !(a >= b) as i32 == c {} + | ^^^^^^^^^ help: try: `(a < b)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:140:4 + --> tests/ui/nonminimal_bool_methods.rs:140:8 | -LL | if !(a >= b) | !(a <= c) {} - | ^^^^^^^^^ help: try: `(a < b)` +LL | if !(a >= b) | !(a <= c) {} + | ^^^^^^^^^ help: try: `(a < b)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:140:16 + --> tests/ui/nonminimal_bool_methods.rs:140:20 | -LL | if !(a >= b) | !(a <= c) {} - | ^^^^^^^^^ help: try: `(a > c)` +LL | if !(a >= b) | !(a <= c) {} + | ^^^^^^^^^ help: try: `(a > c)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:145:4 + --> tests/ui/nonminimal_bool_methods.rs:145:8 | -LL | if !res.is_ok() as i32 == c {} - | ^^^^^^^^^^^^ help: try: `res.is_err()` +LL | if !res.is_ok() as i32 == c {} + | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:147:4 + --> tests/ui/nonminimal_bool_methods.rs:147:8 | -LL | if !res.is_ok() | !opt.is_none() {} - | ^^^^^^^^^^^^ help: try: `res.is_err()` +LL | if !res.is_ok() | !opt.is_none() {} + | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:147:19 + --> tests/ui/nonminimal_bool_methods.rs:147:23 | -LL | if !res.is_ok() | !opt.is_none() {} - | ^^^^^^^^^^^^^^ help: try: `opt.is_some()` +LL | if !res.is_ok() | !opt.is_none() {} + | ^^^^^^^^^^^^^^ help: try: `opt.is_some()` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:152:1 + --> tests/ui/nonminimal_bool_methods.rs:152:9 | -LL | (!(4 > 3)).b() - | ^^^^^^^^^^ help: try: `(4 <= 3)` +LL | (!(4 > 3)).b() + | ^^^^^^^^^^ help: try: `(4 <= 3)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:178:5 + --> tests/ui/nonminimal_bool_methods.rs:178:9 | -LL | _ = !opt.is_some_and(|x| x < 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x >= 1000)` +LL | _ = !opt.is_some_and(|x| x < 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x >= 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:180:5 + --> tests/ui/nonminimal_bool_methods.rs:180:9 | -LL | _ = !opt.is_some_and(|x| x <= 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x > 1000)` +LL | _ = !opt.is_some_and(|x| x <= 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x > 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:182:5 + --> tests/ui/nonminimal_bool_methods.rs:182:9 | -LL | _ = !opt.is_some_and(|x| x > 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x <= 1000)` +LL | _ = !opt.is_some_and(|x| x > 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x <= 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:184:5 + --> tests/ui/nonminimal_bool_methods.rs:184:9 | -LL | _ = !opt.is_some_and(|x| x >= 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x < 1000)` +LL | _ = !opt.is_some_and(|x| x >= 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x < 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:186:5 + --> tests/ui/nonminimal_bool_methods.rs:186:9 | -LL | _ = !opt.is_some_and(|x| x == 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x != 1000)` +LL | _ = !opt.is_some_and(|x| x == 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x != 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:188:5 + --> tests/ui/nonminimal_bool_methods.rs:188:9 | -LL | _ = !opt.is_some_and(|x| x != 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x == 1000)` +LL | _ = !opt.is_some_and(|x| x != 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x == 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:198:5 + --> tests/ui/nonminimal_bool_methods.rs:198:9 | -LL | _ = !opt.is_none_or(|x| x < 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x >= 1000)` +LL | _ = !opt.is_none_or(|x| x < 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x >= 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:200:5 + --> tests/ui/nonminimal_bool_methods.rs:200:9 | -LL | _ = !opt.is_none_or(|x| x <= 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x > 1000)` +LL | _ = !opt.is_none_or(|x| x <= 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x > 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:202:5 + --> tests/ui/nonminimal_bool_methods.rs:202:9 | -LL | _ = !opt.is_none_or(|x| x > 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x <= 1000)` +LL | _ = !opt.is_none_or(|x| x > 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x <= 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:204:5 + --> tests/ui/nonminimal_bool_methods.rs:204:9 | -LL | _ = !opt.is_none_or(|x| x >= 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x < 1000)` +LL | _ = !opt.is_none_or(|x| x >= 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x < 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:206:5 + --> tests/ui/nonminimal_bool_methods.rs:206:9 | -LL | _ = !opt.is_none_or(|x| x == 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x != 1000)` +LL | _ = !opt.is_none_or(|x| x == 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x != 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:208:5 + --> tests/ui/nonminimal_bool_methods.rs:208:9 | -LL | _ = !opt.is_none_or(|x| x != 1000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x == 1000)` +LL | _ = !opt.is_none_or(|x| x != 1000); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x == 1000)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:216:5 + --> tests/ui/nonminimal_bool_methods.rs:216:9 | -LL | _ = !opt.is_some_and(|x| !x); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x)` +LL | _ = !opt.is_some_and(|x| !x); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:221:5 + --> tests/ui/nonminimal_bool_methods.rs:221:9 | -LL | _ = !opt.is_none_or(|x| !x); - | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x)` +LL | _ = !opt.is_none_or(|x| !x); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x)` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:229:5 + --> tests/ui/nonminimal_bool_methods.rs:229:9 | -LL | _ = !opt.is_some_and(|x| x.is_ok()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x.is_err())` +LL | _ = !opt.is_some_and(|x| x.is_ok()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x.is_err())` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:231:5 + --> tests/ui/nonminimal_bool_methods.rs:231:9 | -LL | _ = !opt.is_some_and(|x| x.is_err()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x.is_ok())` +LL | _ = !opt.is_some_and(|x| x.is_err()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_none_or(|x| x.is_ok())` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:233:5 + --> tests/ui/nonminimal_bool_methods.rs:233:9 | -LL | _ = !opt.is_none_or(|x| x.is_ok()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x.is_err())` +LL | _ = !opt.is_none_or(|x| x.is_ok()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x.is_err())` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods.rs:235:5 + --> tests/ui/nonminimal_bool_methods.rs:235:9 | -LL | _ = !opt.is_none_or(|x| x.is_err()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x.is_ok())` +LL | _ = !opt.is_none_or(|x| x.is_err()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.is_some_and(|x| x.is_ok())` error: aborting due to 41 previous errors diff --git a/tests/ui/nonminimal_bool_methods_unfixable.rs b/tests/ui/nonminimal_bool_methods_unfixable.rs index aba156ac8ea9d..850eba4851b8f 100644 --- a/tests/ui/nonminimal_bool_methods_unfixable.rs +++ b/tests/ui/nonminimal_bool_methods_unfixable.rs @@ -3,9 +3,9 @@ fn issue_13436() { let opt_opt = Some(Some(500)); -_ = !opt_opt.is_some_and(|x| !x.is_some_and(|y| y != 1000)); -//~^ nonminimal_bool -//~| nonminimal_bool + _ = !opt_opt.is_some_and(|x| !x.is_some_and(|y| y != 1000)); + //~^ nonminimal_bool + //~| nonminimal_bool } fn main() {} diff --git a/tests/ui/nonminimal_bool_methods_unfixable.stderr b/tests/ui/nonminimal_bool_methods_unfixable.stderr index c228bafad325e..5a90155844cd3 100644 --- a/tests/ui/nonminimal_bool_methods_unfixable.stderr +++ b/tests/ui/nonminimal_bool_methods_unfixable.stderr @@ -1,17 +1,17 @@ error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods_unfixable.rs:6:5 + --> tests/ui/nonminimal_bool_methods_unfixable.rs:6:9 | -LL | _ = !opt_opt.is_some_and(|x| !x.is_some_and(|y| y != 1000)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt_opt.is_none_or(|x| x.is_some_and(|y| y != 1000))` +LL | _ = !opt_opt.is_some_and(|x| !x.is_some_and(|y| y != 1000)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt_opt.is_none_or(|x| x.is_some_and(|y| y != 1000))` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]` error: this boolean expression can be simplified - --> tests/ui/nonminimal_bool_methods_unfixable.rs:6:30 + --> tests/ui/nonminimal_bool_methods_unfixable.rs:6:34 | -LL | _ = !opt_opt.is_some_and(|x| !x.is_some_and(|y| y != 1000)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.is_none_or(|y| y == 1000)` +LL | _ = !opt_opt.is_some_and(|x| !x.is_some_and(|y| y != 1000)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.is_none_or(|y| y == 1000)` error: aborting due to 2 previous errors diff --git a/tests/ui/obfuscated_if_else.fixed b/tests/ui/obfuscated_if_else.fixed index 61a8fdddcd7d6..b7a9cc8364759 100644 --- a/tests/ui/obfuscated_if_else.fixed +++ b/tests/ui/obfuscated_if_else.fixed @@ -8,7 +8,6 @@ fn main() { if true { "a" } else { "b" }; //~^ obfuscated_if_else - let a = 1; if a == 1 { "a" } else { "b" }; //~^ obfuscated_if_else @@ -16,7 +15,6 @@ fn main() { if a == 1 { "a" } else { "b" }; //~^ obfuscated_if_else - let partial = (a == 1).then_some("a"); partial.unwrap_or("b"); // not lint @@ -26,7 +24,6 @@ fn main() { if true { () } else { a += 2 }; //~^ obfuscated_if_else - } fn issue11141() { @@ -34,31 +31,25 @@ fn issue11141() { let _ = (if true { 40 } else { 17 }) | 2; //~^ obfuscated_if_else - // Parentheses are required only for the leftmost expression let _ = (if true { 30 } else { 17 }) | if true { 2 } else { 3 } | if true { 10 } else { 1 }; //~^ obfuscated_if_else //~| obfuscated_if_else //~| obfuscated_if_else - // Parentheses are not required around the right side of a binary expression let _ = 2 | if true { 40 } else { 17 }; //~^ obfuscated_if_else - // Parentheses are not required for a cast let _ = if true { 42 } else { 17 } as u8; //~^ obfuscated_if_else - // Parentheses are not required for a deref let _ = *if true { &42 } else { &17 }; //~^ obfuscated_if_else - // Parentheses are not required for a deref followed by a cast let _ = *if true { &42 } else { &17 } as u8; //~^ obfuscated_if_else - } diff --git a/tests/ui/obfuscated_if_else.rs b/tests/ui/obfuscated_if_else.rs index 0eaafe8b66ad4..a6470fedd5c66 100644 --- a/tests/ui/obfuscated_if_else.rs +++ b/tests/ui/obfuscated_if_else.rs @@ -8,7 +8,6 @@ fn main() { true.then(|| "a").unwrap_or("b"); //~^ obfuscated_if_else - let a = 1; (a == 1).then_some("a").unwrap_or("b"); //~^ obfuscated_if_else @@ -16,7 +15,6 @@ fn main() { (a == 1).then(|| "a").unwrap_or("b"); //~^ obfuscated_if_else - let partial = (a == 1).then_some("a"); partial.unwrap_or("b"); // not lint @@ -26,7 +24,6 @@ fn main() { true.then_some(()).unwrap_or(a += 2); //~^ obfuscated_if_else - } fn issue11141() { @@ -34,31 +31,25 @@ fn issue11141() { let _ = true.then_some(40).unwrap_or(17) | 2; //~^ obfuscated_if_else - // Parentheses are required only for the leftmost expression let _ = true.then_some(30).unwrap_or(17) | true.then_some(2).unwrap_or(3) | true.then_some(10).unwrap_or(1); //~^ obfuscated_if_else //~| obfuscated_if_else //~| obfuscated_if_else - // Parentheses are not required around the right side of a binary expression let _ = 2 | true.then_some(40).unwrap_or(17); //~^ obfuscated_if_else - // Parentheses are not required for a cast let _ = true.then_some(42).unwrap_or(17) as u8; //~^ obfuscated_if_else - // Parentheses are not required for a deref let _ = *true.then_some(&42).unwrap_or(&17); //~^ obfuscated_if_else - // Parentheses are not required for a deref followed by a cast let _ = *true.then_some(&42).unwrap_or(&17) as u8; //~^ obfuscated_if_else - } diff --git a/tests/ui/obfuscated_if_else.stderr b/tests/ui/obfuscated_if_else.stderr index 2d635871950f8..84caa848ece6e 100644 --- a/tests/ui/obfuscated_if_else.stderr +++ b/tests/ui/obfuscated_if_else.stderr @@ -14,73 +14,73 @@ LL | true.then(|| "a").unwrap_or("b"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:13:5 + --> tests/ui/obfuscated_if_else.rs:12:5 | LL | (a == 1).then_some("a").unwrap_or("b"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if a == 1 { "a" } else { "b" }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:16:5 + --> tests/ui/obfuscated_if_else.rs:15:5 | LL | (a == 1).then(|| "a").unwrap_or("b"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if a == 1 { "a" } else { "b" }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:24:5 + --> tests/ui/obfuscated_if_else.rs:22:5 | LL | true.then_some(a += 1).unwrap_or(()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { a += 1 } else { () }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:27:5 + --> tests/ui/obfuscated_if_else.rs:25:5 | LL | true.then_some(()).unwrap_or(a += 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { () } else { a += 2 }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:34:13 + --> tests/ui/obfuscated_if_else.rs:31:13 | LL | let _ = true.then_some(40).unwrap_or(17) | 2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(if true { 40 } else { 17 })` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:39:13 + --> tests/ui/obfuscated_if_else.rs:35:13 | LL | let _ = true.then_some(30).unwrap_or(17) | true.then_some(2).unwrap_or(3) | true.then_some(10).unwrap_or(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(if true { 30 } else { 17 })` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:39:48 + --> tests/ui/obfuscated_if_else.rs:35:48 | LL | let _ = true.then_some(30).unwrap_or(17) | true.then_some(2).unwrap_or(3) | true.then_some(10).unwrap_or(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 2 } else { 3 }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:39:81 + --> tests/ui/obfuscated_if_else.rs:35:81 | LL | let _ = true.then_some(30).unwrap_or(17) | true.then_some(2).unwrap_or(3) | true.then_some(10).unwrap_or(1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 10 } else { 1 }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:46:17 + --> tests/ui/obfuscated_if_else.rs:41:17 | LL | let _ = 2 | true.then_some(40).unwrap_or(17); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 40 } else { 17 }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:51:13 + --> tests/ui/obfuscated_if_else.rs:45:13 | LL | let _ = true.then_some(42).unwrap_or(17) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 42 } else { 17 }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:56:14 + --> tests/ui/obfuscated_if_else.rs:49:14 | LL | let _ = *true.then_some(&42).unwrap_or(&17); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { &42 } else { &17 }` error: this method chain can be written more clearly with `if .. else ..` - --> tests/ui/obfuscated_if_else.rs:61:14 + --> tests/ui/obfuscated_if_else.rs:53:14 | LL | let _ = *true.then_some(&42).unwrap_or(&17) as u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { &42 } else { &17 }` diff --git a/tests/ui/octal_escapes.rs b/tests/ui/octal_escapes.rs index 08e0316d11240..d91d6c1d7beec 100644 --- a/tests/ui/octal_escapes.rs +++ b/tests/ui/octal_escapes.rs @@ -2,31 +2,29 @@ #![warn(clippy::octal_escapes)] fn main() { -let _bad1 = "\033[0m"; -//~^ octal_escapes -let _bad2 = b"\033[0m"; -//~^ octal_escapes -let _bad3 = "\\\033[0m"; -//~^ octal_escapes + let _bad1 = "\033[0m"; + //~^ octal_escapes + let _bad2 = b"\033[0m"; + //~^ octal_escapes + let _bad3 = "\\\033[0m"; + //~^ octal_escapes // maximum 3 digits (\012 is the escape) -let _bad4 = "\01234567"; -//~^ octal_escapes -let _bad5 = "\0\03"; -//~^ octal_escapes + let _bad4 = "\01234567"; + //~^ octal_escapes + let _bad5 = "\0\03"; + //~^ octal_escapes let _bad6 = "Text-\055\077-MoreText"; //~^ octal_escapes //~| octal_escapes - let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; //~^ octal_escapes //~| octal_escapes - -let _bad8 = "锈\01锈"; -//~^ octal_escapes -let _bad9 = "锈\011锈"; -//~^ octal_escapes + let _bad8 = "锈\01锈"; + //~^ octal_escapes + let _bad9 = "锈\011锈"; + //~^ octal_escapes let _good1 = "\\033[0m"; let _good2 = "\0\\0"; diff --git a/tests/ui/octal_escapes.stderr b/tests/ui/octal_escapes.stderr index 2f838a84dd48f..024308cbf429d 100644 --- a/tests/ui/octal_escapes.stderr +++ b/tests/ui/octal_escapes.stderr @@ -1,80 +1,80 @@ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:5:14 + --> tests/ui/octal_escapes.rs:5:18 | -LL | let _bad1 = "\033[0m"; - | ^^^^ +LL | let _bad1 = "\033[0m"; + | ^^^^ | = help: octal escapes are not supported, `\0` is always null = note: `-D clippy::octal-escapes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::octal_escapes)]` help: if an octal escape is intended, use a hex escape instead | -LL | let _bad1 = "\x1b[0m"; - | ~~~~ +LL | let _bad1 = "\x1b[0m"; + | ~~~~ help: if a null escape is intended, disambiguate using | -LL | let _bad1 = "\x0033[0m"; - | ~~~~~~ +LL | let _bad1 = "\x0033[0m"; + | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:7:15 + --> tests/ui/octal_escapes.rs:7:19 | -LL | let _bad2 = b"\033[0m"; - | ^^^^ +LL | let _bad2 = b"\033[0m"; + | ^^^^ | help: if an octal escape is intended, use a hex escape instead | -LL | let _bad2 = b"\x1b[0m"; - | ~~~~ +LL | let _bad2 = b"\x1b[0m"; + | ~~~~ help: if a null escape is intended, disambiguate using | -LL | let _bad2 = b"\x0033[0m"; - | ~~~~~~ +LL | let _bad2 = b"\x0033[0m"; + | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:9:16 + --> tests/ui/octal_escapes.rs:9:20 | -LL | let _bad3 = "\\\033[0m"; - | ^^^^ +LL | let _bad3 = "\\\033[0m"; + | ^^^^ | help: if an octal escape is intended, use a hex escape instead | -LL | let _bad3 = "\\\x1b[0m"; - | ~~~~ +LL | let _bad3 = "\\\x1b[0m"; + | ~~~~ help: if a null escape is intended, disambiguate using | -LL | let _bad3 = "\\\x0033[0m"; - | ~~~~~~ +LL | let _bad3 = "\\\x0033[0m"; + | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:12:14 + --> tests/ui/octal_escapes.rs:12:18 | -LL | let _bad4 = "\01234567"; - | ^^^^ +LL | let _bad4 = "\01234567"; + | ^^^^ | help: if an octal escape is intended, use a hex escape instead | -LL | let _bad4 = "\x0a34567"; - | ~~~~ +LL | let _bad4 = "\x0a34567"; + | ~~~~ help: if a null escape is intended, disambiguate using | -LL | let _bad4 = "\x001234567"; - | ~~~~~~ +LL | let _bad4 = "\x001234567"; + | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:14:16 + --> tests/ui/octal_escapes.rs:14:20 | -LL | let _bad5 = "\0\03"; - | ^^^ +LL | let _bad5 = "\0\03"; + | ^^^ | help: if an octal escape is intended, use a hex escape instead | -LL | let _bad5 = "\0\x03"; - | ~~~~ +LL | let _bad5 = "\0\x03"; + | ~~~~ help: if a null escape is intended, disambiguate using | -LL | let _bad5 = "\0\x0003"; - | ~~~~~~ +LL | let _bad5 = "\0\x0003"; + | ~~~~~~ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:16:23 @@ -107,7 +107,7 @@ LL | let _bad6 = "Text-\055\x0077-MoreText"; | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:21:31 + --> tests/ui/octal_escapes.rs:20:31 | LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; | ^^^ @@ -122,7 +122,7 @@ LL | let _bad7 = "EvenMoreText-\x0001\02-ShortEscapes"; | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:21:34 + --> tests/ui/octal_escapes.rs:20:34 | LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; | ^^^ @@ -137,34 +137,34 @@ LL | let _bad7 = "EvenMoreText-\01\x0002-ShortEscapes"; | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:26:15 + --> tests/ui/octal_escapes.rs:24:19 | -LL | let _bad8 = "锈\01锈"; - | ^^^ +LL | let _bad8 = "锈\01锈"; + | ^^^ | help: if an octal escape is intended, use a hex escape instead | -LL | let _bad8 = "锈\x01锈"; - | ~~~~ +LL | let _bad8 = "锈\x01锈"; + | ~~~~ help: if a null escape is intended, disambiguate using | -LL | let _bad8 = "锈\x0001锈"; - | ~~~~~~ +LL | let _bad8 = "锈\x0001锈"; + | ~~~~~~ error: octal-looking escape in a literal - --> tests/ui/octal_escapes.rs:28:15 + --> tests/ui/octal_escapes.rs:26:19 | -LL | let _bad9 = "锈\011锈"; - | ^^^^ +LL | let _bad9 = "锈\011锈"; + | ^^^^ | help: if an octal escape is intended, use a hex escape instead | -LL | let _bad9 = "锈\x09锈"; - | ~~~~ +LL | let _bad9 = "锈\x09锈"; + | ~~~~ help: if a null escape is intended, disambiguate using | -LL | let _bad9 = "锈\x0011锈"; - | ~~~~~~ +LL | let _bad9 = "锈\x0011锈"; + | ~~~~~~ error: aborting due to 11 previous errors diff --git a/tests/ui/ok_expect.rs b/tests/ui/ok_expect.rs index 33702878ddb72..efb56f242a746 100644 --- a/tests/ui/ok_expect.rs +++ b/tests/ui/ok_expect.rs @@ -35,5 +35,4 @@ fn main() { let res6: Result = Ok(0); res6.ok().expect("meh"); //~^ ok_expect - } diff --git a/tests/ui/only_used_in_recursion.rs b/tests/ui/only_used_in_recursion.rs index cf872920a6e2a..7d6075ba9ea47 100644 --- a/tests/ui/only_used_in_recursion.rs +++ b/tests/ui/only_used_in_recursion.rs @@ -9,21 +9,20 @@ fn _simple2(x: u32) -> u32 { } fn _one_unused(flag: u32, a: usize) -> usize { -//~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { _one_unused(flag - 1, a) } } fn _two_unused(flag: u32, a: u32, b: i32) -> usize { -//~^ only_used_in_recursion -//~| only_used_in_recursion - + //~^ only_used_in_recursion + //~| only_used_in_recursion if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } } fn _with_calc(flag: u32, a: i64) -> usize { -//~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 @@ -38,9 +37,8 @@ fn _used_with_flag(flag: u32, a: u32) -> usize { } fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { -//~^ only_used_in_recursion -//~| only_used_in_recursion - + //~^ only_used_in_recursion + //~| only_used_in_recursion if flag == 0 { 0 @@ -50,9 +48,8 @@ fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { } fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { -//~^ only_used_in_recursion -//~| only_used_in_recursion - + //~^ only_used_in_recursion + //~| only_used_in_recursion if flag == 0 { 0 @@ -62,7 +59,7 @@ fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { } fn _not_primitive(flag: u32, b: String) -> usize { -//~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { _not_primitive(flag - 1, b) } } @@ -71,15 +68,14 @@ struct A; impl A { fn _method(flag: usize, a: usize) -> usize { - //~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { Self::_method(flag - 1, a) } } fn _method_self(&self, flag: usize, a: usize) -> usize { - //~^ only_used_in_recursion - //~| only_used_in_recursion - + //~^ only_used_in_recursion + //~| only_used_in_recursion if flag == 0 { 0 } else { self._method_self(flag - 1, a) } } @@ -92,13 +88,13 @@ trait B { impl B for A { fn method(flag: u32, a: usize) -> usize { - //~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { Self::method(flag - 1, a) } } fn method_self(&self, flag: u32, a: usize) -> usize { - //~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { self.method_self(flag - 1, a) } } @@ -126,13 +122,13 @@ impl B for u32 { trait C { fn method(flag: u32, a: usize) -> usize { - //~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { Self::method(flag - 1, a) } } fn method_self(&self, flag: u32, a: usize) -> usize { - //~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { self.method_self(flag - 1, a) } } diff --git a/tests/ui/only_used_in_recursion.stderr b/tests/ui/only_used_in_recursion.stderr index 1f1aa75be6621..ca08319e11200 100644 --- a/tests/ui/only_used_in_recursion.stderr +++ b/tests/ui/only_used_in_recursion.stderr @@ -19,7 +19,7 @@ LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:22:53 + --> tests/ui/only_used_in_recursion.rs:21:53 | LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ @@ -31,163 +31,163 @@ LL | fn _two_unused(flag: u32, a: u32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:22:56 + --> tests/ui/only_used_in_recursion.rs:21:56 | LL | if flag == 0 { 0 } else { _two_unused(flag - 1, a, b) } | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:25:26 + --> tests/ui/only_used_in_recursion.rs:24:26 | LL | fn _with_calc(flag: u32, a: i64) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:31:32 + --> tests/ui/only_used_in_recursion.rs:30:32 | LL | _with_calc(flag - 1, (-a + 10) * 5) | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:40:33 + --> tests/ui/only_used_in_recursion.rs:39:33 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:48:38 + --> tests/ui/only_used_in_recursion.rs:46:38 | LL | _used_with_unused(flag - 1, -a, a + b) | ^ ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:40:41 + --> tests/ui/only_used_in_recursion.rs:39:41 | LL | fn _used_with_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:48:45 + --> tests/ui/only_used_in_recursion.rs:46:45 | LL | _used_with_unused(flag - 1, -a, a + b) | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:52:35 + --> tests/ui/only_used_in_recursion.rs:50:35 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:60:39 + --> tests/ui/only_used_in_recursion.rs:57:39 | LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:52:43 + --> tests/ui/only_used_in_recursion.rs:50:43 | LL | fn _codependent_unused(flag: u32, a: i32, b: i32) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:60:43 + --> tests/ui/only_used_in_recursion.rs:57:43 | LL | _codependent_unused(flag - 1, a * b, a + b) | ^ ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:64:30 + --> tests/ui/only_used_in_recursion.rs:61:30 | LL | fn _not_primitive(flag: u32, b: String) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:67:56 + --> tests/ui/only_used_in_recursion.rs:64:56 | LL | if flag == 0 { 0 } else { _not_primitive(flag - 1, b) } | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:73:29 + --> tests/ui/only_used_in_recursion.rs:70:29 | LL | fn _method(flag: usize, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:76:59 + --> tests/ui/only_used_in_recursion.rs:73:59 | LL | if flag == 0 { 0 } else { Self::_method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:79:22 + --> tests/ui/only_used_in_recursion.rs:76:22 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { | ^^^^ | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:84:35 + --> tests/ui/only_used_in_recursion.rs:80:35 | LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^^^^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:79:41 + --> tests/ui/only_used_in_recursion.rs:76:41 | LL | fn _method_self(&self, flag: usize, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:84:63 + --> tests/ui/only_used_in_recursion.rs:80:63 | LL | if flag == 0 { 0 } else { self._method_self(flag - 1, a) } | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:94:26 + --> tests/ui/only_used_in_recursion.rs:90:26 | LL | fn method(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:97:58 + --> tests/ui/only_used_in_recursion.rs:93:58 | LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:100:38 + --> tests/ui/only_used_in_recursion.rs:96:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:103:62 + --> tests/ui/only_used_in_recursion.rs:99:62 | LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:128:26 + --> tests/ui/only_used_in_recursion.rs:124:26 | LL | fn method(flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:131:58 + --> tests/ui/only_used_in_recursion.rs:127:58 | LL | if flag == 0 { 0 } else { Self::method(flag - 1, a) } | ^ error: parameter is only used in recursion - --> tests/ui/only_used_in_recursion.rs:134:38 + --> tests/ui/only_used_in_recursion.rs:130:38 | LL | fn method_self(&self, flag: u32, a: usize) -> usize { | ^ help: if this is intentional, prefix it with an underscore: `_a` | note: parameter used here - --> tests/ui/only_used_in_recursion.rs:137:62 + --> tests/ui/only_used_in_recursion.rs:133:62 | LL | if flag == 0 { 0 } else { self.method_self(flag - 1, a) } | ^ diff --git a/tests/ui/only_used_in_recursion2.rs b/tests/ui/only_used_in_recursion2.rs index e4639c8b8a45a..2fe4e7b35d38a 100644 --- a/tests/ui/only_used_in_recursion2.rs +++ b/tests/ui/only_used_in_recursion2.rs @@ -1,10 +1,10 @@ #![warn(clippy::only_used_in_recursion)] //@no-rustfix fn _with_inner(flag: u32, a: u32, b: u32) -> usize { -//~^ only_used_in_recursion + //~^ only_used_in_recursion fn inner(flag: u32, a: u32) -> u32 { - //~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 } else { inner(flag, a) } } @@ -14,7 +14,7 @@ fn _with_inner(flag: u32, a: u32, b: u32) -> usize { } fn _with_closure(a: Option, b: u32, f: impl Fn(u32, u32) -> Option) -> u32 { -//~^ only_used_in_recursion + //~^ only_used_in_recursion if let Some(x) = a.and_then(|x| f(x, x)) { _with_closure(Some(x), b, f) @@ -66,7 +66,7 @@ impl E<()> for () { } fn overwritten_param(flag: u32, mut a: usize) -> usize { -//~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { return 0; @@ -79,7 +79,7 @@ fn overwritten_param(flag: u32, mut a: usize) -> usize { } fn field_direct(flag: u32, mut a: (usize,)) -> usize { -//~^ only_used_in_recursion + //~^ only_used_in_recursion if flag == 0 { 0 diff --git a/tests/ui/op_ref.fixed b/tests/ui/op_ref.fixed index a67f883fe2e27..46a59e419cce0 100644 --- a/tests/ui/op_ref.fixed +++ b/tests/ui/op_ref.fixed @@ -11,8 +11,6 @@ fn main() { let foo = 5 - 6; //~^ op_ref - - let bar = String::new(); let bar = "foo" == &bar; @@ -58,7 +56,6 @@ fn main() { let y = Y(2); let z = x & y; //~^ op_ref - } #[derive(Clone, Copy)] diff --git a/tests/ui/op_ref.rs b/tests/ui/op_ref.rs index 798484c9fe9e1..e10840ff4b97b 100644 --- a/tests/ui/op_ref.rs +++ b/tests/ui/op_ref.rs @@ -11,8 +11,6 @@ fn main() { let foo = &5 - &6; //~^ op_ref - - let bar = String::new(); let bar = "foo" == &bar; @@ -58,7 +56,6 @@ fn main() { let y = Y(2); let z = x & &y; //~^ op_ref - } #[derive(Clone, Copy)] diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index 86d0be4272c68..f3fb3920ee1fd 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -12,7 +12,7 @@ LL | let foo = 5 - 6; | ~ ~ error: taken reference of right operand - --> tests/ui/op_ref.rs:59:13 + --> tests/ui/op_ref.rs:57:13 | LL | let z = x & &y; | ^^^^-- @@ -20,7 +20,7 @@ LL | let z = x & &y; | help: use the right value directly: `y` error: taken reference of right operand - --> tests/ui/op_ref.rs:94:17 + --> tests/ui/op_ref.rs:91:17 | LL | let _ = one * &self; | ^^^^^^----- @@ -28,7 +28,7 @@ LL | let _ = one * &self; | help: use the right value directly: `self` error: taken reference of right operand - --> tests/ui/op_ref.rs:97:17 + --> tests/ui/op_ref.rs:94:17 | LL | let _ = two + &three; | ^^^^^^------ diff --git a/tests/ui/open_options.rs b/tests/ui/open_options.rs index acc2a5f861649..f2f6e6edb4de2 100644 --- a/tests/ui/open_options.rs +++ b/tests/ui/open_options.rs @@ -17,11 +17,9 @@ fn main() { OpenOptions::new().read(true).truncate(true).open("foo.txt"); //~^ nonsensical_open_options - OpenOptions::new().append(true).truncate(true).open("foo.txt"); //~^ nonsensical_open_options - OpenOptions::new().read(true).read(false).open("foo.txt"); //~^ nonsensical_open_options @@ -30,7 +28,6 @@ fn main() { .truncate(true) // Ensure we don't trigger suspicious open options by having create without truncate .create(false) //~^ nonsensical_open_options - .open("foo.txt"); OpenOptions::new().write(true).write(false).open("foo.txt"); //~^ nonsensical_open_options @@ -41,11 +38,9 @@ fn main() { OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); //~^ nonsensical_open_options - std::fs::File::options().read(true).read(false).open("foo.txt"); //~^ nonsensical_open_options - let mut options = std::fs::OpenOptions::new(); options.read(true); options.read(false); diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 27d8d01f3b5fb..11b2d55fa0582 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -8,43 +8,43 @@ LL | OpenOptions::new().read(true).truncate(true).open("foo.txt"); = help: to override `-D warnings` add `#[allow(clippy::nonsensical_open_options)]` error: file opened with `append` and `truncate` - --> tests/ui/open_options.rs:21:5 + --> tests/ui/open_options.rs:20:5 | LL | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method `read` is called more than once - --> tests/ui/open_options.rs:25:35 + --> tests/ui/open_options.rs:23:35 | LL | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^ error: the method `create` is called more than once - --> tests/ui/open_options.rs:31:10 + --> tests/ui/open_options.rs:29:10 | LL | .create(false) | ^^^^^^^^^^^^^ error: the method `write` is called more than once - --> tests/ui/open_options.rs:35:36 + --> tests/ui/open_options.rs:32:36 | LL | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^ error: the method `append` is called more than once - --> tests/ui/open_options.rs:38:37 + --> tests/ui/open_options.rs:35:37 | LL | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^ error: the method `truncate` is called more than once - --> tests/ui/open_options.rs:41:39 + --> tests/ui/open_options.rs:38:39 | LL | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^ error: the method `read` is called more than once - --> tests/ui/open_options.rs:45:41 + --> tests/ui/open_options.rs:41:41 | LL | std::fs::File::options().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^ diff --git a/tests/ui/open_options_fixable.fixed b/tests/ui/open_options_fixable.fixed index 7ba5a8782bef7..7f601eec2cf06 100644 --- a/tests/ui/open_options_fixable.fixed +++ b/tests/ui/open_options_fixable.fixed @@ -4,5 +4,4 @@ use std::fs::OpenOptions; fn main() { OpenOptions::new().create(true).truncate(true).open("foo.txt"); //~^ suspicious_open_options - } diff --git a/tests/ui/open_options_fixable.rs b/tests/ui/open_options_fixable.rs index 230d6d782074c..5f03528d7a569 100644 --- a/tests/ui/open_options_fixable.rs +++ b/tests/ui/open_options_fixable.rs @@ -4,5 +4,4 @@ use std::fs::OpenOptions; fn main() { OpenOptions::new().create(true).open("foo.txt"); //~^ suspicious_open_options - } diff --git a/tests/ui/option_filter_map.fixed b/tests/ui/option_filter_map.fixed index d8d3ba7edd28c..d390c41af53cf 100644 --- a/tests/ui/option_filter_map.fixed +++ b/tests/ui/option_filter_map.fixed @@ -14,7 +14,6 @@ fn main() { let _ = Some(1).map(odds_out).flatten(); //~^ option_filter_map - let _ = vec![Some(1)].into_iter().flatten(); //~^ option_filter_map diff --git a/tests/ui/option_filter_map.rs b/tests/ui/option_filter_map.rs index 68abaff01b445..2d3b983a76707 100644 --- a/tests/ui/option_filter_map.rs +++ b/tests/ui/option_filter_map.rs @@ -14,7 +14,6 @@ fn main() { let _ = Some(1).map(odds_out).filter(|o| o.is_some()).map(|o| o.unwrap()); //~^ option_filter_map - let _ = vec![Some(1)].into_iter().filter(Option::is_some).map(Option::unwrap); //~^ option_filter_map @@ -26,14 +25,12 @@ fn main() { .map(odds_out) .filter(Option::is_some) //~^ option_filter_map - .map(Option::unwrap); let _ = vec![1] .into_iter() .map(odds_out) .filter(|o| o.is_some()) //~^ option_filter_map - .map(|o| o.unwrap()); } diff --git a/tests/ui/option_filter_map.stderr b/tests/ui/option_filter_map.stderr index 24a3a2d7605ca..df3c1f9d47b8a 100644 --- a/tests/ui/option_filter_map.stderr +++ b/tests/ui/option_filter_map.stderr @@ -26,32 +26,32 @@ LL | let _ = Some(1).map(odds_out).filter(|o| o.is_some()).map(|o| o.unwrap( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> tests/ui/option_filter_map.rs:18:39 + --> tests/ui/option_filter_map.rs:17:39 | LL | let _ = vec![Some(1)].into_iter().filter(Option::is_some).map(Option::unwrap); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> tests/ui/option_filter_map.rs:21:39 + --> tests/ui/option_filter_map.rs:20:39 | LL | let _ = vec![Some(1)].into_iter().filter(|o| o.is_some()).map(|o| o.unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> tests/ui/option_filter_map.rs:27:10 + --> tests/ui/option_filter_map.rs:26:10 | LL | .filter(Option::is_some) | __________^ -... | +LL | | LL | | .map(Option::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Some` followed by `unwrap` - --> tests/ui/option_filter_map.rs:34:10 + --> tests/ui/option_filter_map.rs:32:10 | LL | .filter(|o| o.is_some()) | __________^ -... | +LL | | LL | | .map(|o| o.unwrap()); | |____________________________^ help: consider using `flatten` instead: `flatten()` diff --git a/tests/ui/option_if_let_else.fixed b/tests/ui/option_if_let_else.fixed index eb1aabe63e759..56b313244e36a 100644 --- a/tests/ui/option_if_let_else.fixed +++ b/tests/ui/option_if_let_else.fixed @@ -28,19 +28,19 @@ fn unop_bad(string: &Option<&str>, mut num: Option) { let _ = num.as_ref().map_or(&0, |s| s); //~^ option_if_let_else let _ = num.as_mut().map_or(&0, |s| { - //~^ option_if_let_else + //~^ option_if_let_else *s += 1; s }); let _ = num.as_ref().map_or(&0, |s| s); //~^ option_if_let_else let _ = num.map_or(0, |mut s| { - //~^ option_if_let_else + //~^ option_if_let_else s += 1; s }); let _ = num.as_mut().map_or(&0, |s| { - //~^ option_if_let_else + //~^ option_if_let_else *s += 1; s }); @@ -48,7 +48,7 @@ fn unop_bad(string: &Option<&str>, mut num: Option) { fn longer_body(arg: Option) -> u32 { arg.map_or(13, |x| { - //~^ option_if_let_else + //~^ option_if_let_else let y = x * x; y * y }) @@ -105,7 +105,7 @@ fn test_result_impure_else(variable: Result) -> bool { println!("Err"); false }, |binding| { - //~^ option_if_let_else + //~^ option_if_let_else println!("Ok {binding}"); true }) @@ -167,7 +167,7 @@ fn main() { let s = String::new(); // Lint, `Some` branch consumes `s`, but else branch doesn't use `s`. let _ = Some(0).map_or(1, |x| { - //~^ option_if_let_else + //~^ option_if_let_else let s = s; s.len() + x }); diff --git a/tests/ui/option_if_let_else.rs b/tests/ui/option_if_let_else.rs index f2e2de02a93d0..4a4bb141ed546 100644 --- a/tests/ui/option_if_let_else.rs +++ b/tests/ui/option_if_let_else.rs @@ -10,7 +10,7 @@ fn bad1(string: Option<&str>) -> (bool, &str) { if let Some(x) = string { - //~^ option_if_let_else + //~^ option_if_let_else (true, x) } else { (false, "hello") @@ -33,7 +33,7 @@ fn unop_bad(string: &Option<&str>, mut num: Option) { let _ = if let Some(s) = &num { s } else { &0 }; //~^ option_if_let_else let _ = if let Some(s) = &mut num { - //~^ option_if_let_else + //~^ option_if_let_else *s += 1; s } else { @@ -42,14 +42,14 @@ fn unop_bad(string: &Option<&str>, mut num: Option) { let _ = if let Some(ref s) = num { s } else { &0 }; //~^ option_if_let_else let _ = if let Some(mut s) = num { - //~^ option_if_let_else + //~^ option_if_let_else s += 1; s } else { 0 }; let _ = if let Some(ref mut s) = num { - //~^ option_if_let_else + //~^ option_if_let_else *s += 1; s } else { @@ -59,7 +59,7 @@ fn unop_bad(string: &Option<&str>, mut num: Option) { fn longer_body(arg: Option) -> u32 { if let Some(x) = arg { - //~^ option_if_let_else + //~^ option_if_let_else let y = x * x; y * y } else { @@ -73,7 +73,7 @@ fn impure_else(arg: Option) { 1 }; let _ = if let Some(x) = arg { - //~^ option_if_let_else + //~^ option_if_let_else x } else { // map_or_else must be suggested @@ -83,7 +83,7 @@ fn impure_else(arg: Option) { fn test_map_or_else(arg: Option) { let _ = if let Some(x) = arg { - //~^ option_if_let_else + //~^ option_if_let_else x * x * x * x } else { let mut y = 1; @@ -117,7 +117,7 @@ fn pattern_to_vec(pattern: &str) -> Vec { .split('/') .flat_map(|s| { if let Some(idx) = s.find('.') { - //~^ option_if_let_else + //~^ option_if_let_else vec![s[..idx].to_string(), s[idx..].to_string()] } else { vec![s.to_string()] @@ -129,7 +129,7 @@ fn pattern_to_vec(pattern: &str) -> Vec { // #10335 fn test_result_impure_else(variable: Result) -> bool { if let Ok(binding) = variable { - //~^ option_if_let_else + //~^ option_if_let_else println!("Ok {binding}"); true } else { @@ -165,7 +165,7 @@ fn main() { let _ = impure_else(None); let _ = if let Some(x) = Some(0) { - //~^ option_if_let_else + //~^ option_if_let_else loop { if x == 0 { break x; @@ -199,7 +199,7 @@ fn main() { let s = String::new(); // Lint, `Some` branch consumes `s`, but else branch doesn't use `s`. let _ = if let Some(x) = Some(0) { - //~^ option_if_let_else + //~^ option_if_let_else let s = s; s.len() + x } else { @@ -239,24 +239,24 @@ fn main() { // issue #8492 let _ = match s { - //~^ option_if_let_else + //~^ option_if_let_else Some(string) => string.len(), None => 1, }; let _ = match Some(10) { - //~^ option_if_let_else + //~^ option_if_let_else Some(a) => a + 1, None => 5, }; let res: Result = Ok(5); let _ = match res { - //~^ option_if_let_else + //~^ option_if_let_else Ok(a) => a + 1, _ => 1, }; let _ = match res { - //~^ option_if_let_else + //~^ option_if_let_else Err(_) => 1, Ok(a) => a + 1, }; @@ -279,7 +279,7 @@ mod issue10729 { pub fn reproduce(initial: &Option) { // 👇 needs `.as_ref()` because initial is an `&Option<_>` let _ = match initial { - //~^ option_if_let_else + //~^ option_if_let_else Some(value) => do_something(value), None => 42, }; @@ -287,7 +287,7 @@ mod issue10729 { pub fn reproduce2(initial: &mut Option) { let _ = match initial { - //~^ option_if_let_else + //~^ option_if_let_else Some(value) => do_something2(value), None => 42, }; @@ -311,7 +311,7 @@ fn issue11429() { let opt: Option> = None; let mut _hashmap = if let Some(hm) = &opt { - //~^ option_if_let_else + //~^ option_if_let_else hm.clone() } else { HashMap::new() diff --git a/tests/ui/option_map_or_none.fixed b/tests/ui/option_map_or_none.fixed index c4d9f25bd28c1..183bf32e5361e 100644 --- a/tests/ui/option_map_or_none.fixed +++ b/tests/ui/option_map_or_none.fixed @@ -16,7 +16,7 @@ fn main() { let _: Option = opt.and_then(bar); //~^ option_map_or_none let _: Option = opt.and_then(|x| { - //~^ option_map_or_none + //~^ option_map_or_none let offset = 0; let height = x; Some(offset + height) diff --git a/tests/ui/option_map_or_none.rs b/tests/ui/option_map_or_none.rs index c3143f50cb6c0..626f206b25981 100644 --- a/tests/ui/option_map_or_none.rs +++ b/tests/ui/option_map_or_none.rs @@ -19,7 +19,7 @@ fn main() { let _: Option = opt.map_or(None, bar); //~^ option_map_or_none let _: Option = opt.map_or(None, |x| { - //~^ option_map_or_none + //~^ option_map_or_none let offset = 0; let height = x; Some(offset + height) diff --git a/tests/ui/or_fun_call.fixed b/tests/ui/or_fun_call.fixed index 73ba4394e9836..7014e20c1f85d 100644 --- a/tests/ui/or_fun_call.fixed +++ b/tests/ui/or_fun_call.fixed @@ -373,7 +373,6 @@ fn fn_call_in_nested_expr() { } let opt: Option = Some(1); - let _ = opt.unwrap_or_else(f); // suggest `.unwrap_or_else(f)` //~^ or_fun_call // @@ -383,7 +382,7 @@ fn fn_call_in_nested_expr() { // let _ = opt.unwrap_or_else(|| { - //~^ or_fun_call + //~^ or_fun_call let x = f(); x + 1 }); diff --git a/tests/ui/or_fun_call.rs b/tests/ui/or_fun_call.rs index ed34691781968..d8a0ab033c4df 100644 --- a/tests/ui/or_fun_call.rs +++ b/tests/ui/or_fun_call.rs @@ -373,7 +373,6 @@ fn fn_call_in_nested_expr() { } let opt: Option = Some(1); - let _ = opt.unwrap_or({ f() }); // suggest `.unwrap_or_else(f)` //~^ or_fun_call // @@ -383,7 +382,7 @@ fn fn_call_in_nested_expr() { // let _ = opt.unwrap_or({ - //~^ or_fun_call + //~^ or_fun_call let x = f(); x + 1 }); diff --git a/tests/ui/or_fun_call.stderr b/tests/ui/or_fun_call.stderr index a1eaf08e4458d..0cc8ad39421c3 100644 --- a/tests/ui/or_fun_call.stderr +++ b/tests/ui/or_fun_call.stderr @@ -197,19 +197,19 @@ LL | let _ = stringy.unwrap_or_else(String::new); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: function call inside of `unwrap_or` - --> tests/ui/or_fun_call.rs:377:17 + --> tests/ui/or_fun_call.rs:376:17 | LL | let _ = opt.unwrap_or({ f() }); // suggest `.unwrap_or_else(f)` | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(f)` error: function call inside of `unwrap_or` - --> tests/ui/or_fun_call.rs:381:17 + --> tests/ui/or_fun_call.rs:380:17 | LL | let _ = opt.unwrap_or(f() + 1); // suggest `.unwrap_or_else(|| f() + 1)` | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| f() + 1)` error: function call inside of `unwrap_or` - --> tests/ui/or_fun_call.rs:385:17 + --> tests/ui/or_fun_call.rs:384:17 | LL | let _ = opt.unwrap_or({ | _________________^ @@ -229,19 +229,19 @@ LL ~ }); | error: function call inside of `map_or` - --> tests/ui/or_fun_call.rs:391:17 + --> tests/ui/or_fun_call.rs:390:17 | LL | let _ = opt.map_or(f() + 1, |v| v); // suggest `.map_or_else(|| f() + 1, |v| v)` | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `map_or_else(|| f() + 1, |v| v)` error: use of `unwrap_or` to construct default value - --> tests/ui/or_fun_call.rs:395:17 + --> tests/ui/or_fun_call.rs:394:17 | LL | let _ = opt.unwrap_or({ i32::default() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: function call inside of `unwrap_or` - --> tests/ui/or_fun_call.rs:402:21 + --> tests/ui/or_fun_call.rs:401:21 | LL | let _ = opt_foo.unwrap_or(Foo { val: String::default() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| Foo { val: String::default() })` diff --git a/tests/ui/out_of_bounds_indexing/issue-3102.rs b/tests/ui/out_of_bounds_indexing/issue-3102.rs index 3ba35482780dc..e1e0fa02a9371 100644 --- a/tests/ui/out_of_bounds_indexing/issue-3102.rs +++ b/tests/ui/out_of_bounds_indexing/issue-3102.rs @@ -9,8 +9,6 @@ fn main() { &x[num..10]; //~^ out_of_bounds_indexing - &x[10..num]; //~^ out_of_bounds_indexing - } diff --git a/tests/ui/out_of_bounds_indexing/issue-3102.stderr b/tests/ui/out_of_bounds_indexing/issue-3102.stderr index 304adcfdc2d39..8bf0152601dfd 100644 --- a/tests/ui/out_of_bounds_indexing/issue-3102.stderr +++ b/tests/ui/out_of_bounds_indexing/issue-3102.stderr @@ -8,7 +8,7 @@ LL | &x[num..10]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> tests/ui/out_of_bounds_indexing/issue-3102.rs:13:8 + --> tests/ui/out_of_bounds_indexing/issue-3102.rs:12:8 | LL | &x[10..num]; | ^^ diff --git a/tests/ui/out_of_bounds_indexing/simple.rs b/tests/ui/out_of_bounds_indexing/simple.rs index 86f29f9ee408c..e613e527eee48 100644 --- a/tests/ui/out_of_bounds_indexing/simple.rs +++ b/tests/ui/out_of_bounds_indexing/simple.rs @@ -7,7 +7,6 @@ fn main() { &x[..=4]; //~^ out_of_bounds_indexing - &x[1..5]; //~^ out_of_bounds_indexing @@ -23,7 +22,6 @@ fn main() { &x[0..=4]; //~^ out_of_bounds_indexing - &x[4..]; // Ok, should not produce stderr. &x[..4]; // Ok, should not produce stderr. &x[..]; // Ok, should not produce stderr. diff --git a/tests/ui/out_of_bounds_indexing/simple.stderr b/tests/ui/out_of_bounds_indexing/simple.stderr index 47f36e51bffaf..f895317334317 100644 --- a/tests/ui/out_of_bounds_indexing/simple.stderr +++ b/tests/ui/out_of_bounds_indexing/simple.stderr @@ -8,31 +8,31 @@ LL | &x[..=4]; = help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]` error: range is out of bounds - --> tests/ui/out_of_bounds_indexing/simple.rs:11:11 + --> tests/ui/out_of_bounds_indexing/simple.rs:10:11 | LL | &x[1..5]; | ^ error: range is out of bounds - --> tests/ui/out_of_bounds_indexing/simple.rs:14:8 + --> tests/ui/out_of_bounds_indexing/simple.rs:13:8 | LL | &x[5..]; | ^ error: range is out of bounds - --> tests/ui/out_of_bounds_indexing/simple.rs:17:10 + --> tests/ui/out_of_bounds_indexing/simple.rs:16:10 | LL | &x[..5]; | ^ error: range is out of bounds - --> tests/ui/out_of_bounds_indexing/simple.rs:20:8 + --> tests/ui/out_of_bounds_indexing/simple.rs:19:8 | LL | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ error: range is out of bounds - --> tests/ui/out_of_bounds_indexing/simple.rs:23:12 + --> tests/ui/out_of_bounds_indexing/simple.rs:22:12 | LL | &x[0..=4]; | ^ diff --git a/tests/ui/panic_in_result_fn.rs b/tests/ui/panic_in_result_fn.rs index dc0fc65fd7774..005e38db90216 100644 --- a/tests/ui/panic_in_result_fn.rs +++ b/tests/ui/panic_in_result_fn.rs @@ -5,7 +5,6 @@ struct A; impl A { fn result_with_panic() -> Result // should emit lint //~^ panic_in_result_fn - { panic!("error"); } @@ -53,13 +52,12 @@ impl A { fn function_result_with_panic() -> Result // should emit lint //~^ panic_in_result_fn - { panic!("error"); } fn in_closure() -> Result { -//~^ panic_in_result_fn + //~^ panic_in_result_fn let c = || panic!(); c() } diff --git a/tests/ui/panic_in_result_fn.stderr b/tests/ui/panic_in_result_fn.stderr index 17fd03733abcc..1067f4fac11cf 100644 --- a/tests/ui/panic_in_result_fn.stderr +++ b/tests/ui/panic_in_result_fn.stderr @@ -2,13 +2,15 @@ error: used `panic!()` or assertion in a function that returns `Result` --> tests/ui/panic_in_result_fn.rs:6:5 | LL | / fn result_with_panic() -> Result // should emit lint -... | +LL | | +LL | | { +LL | | panic!("error"); LL | | } | |_____^ | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> tests/ui/panic_in_result_fn.rs:10:9 + --> tests/ui/panic_in_result_fn.rs:9:9 | LL | panic!("error"); | ^^^^^^^^^^^^^^^ @@ -16,22 +18,24 @@ LL | panic!("error"); = help: to override `-D warnings` add `#[allow(clippy::panic_in_result_fn)]` error: used `panic!()` or assertion in a function that returns `Result` - --> tests/ui/panic_in_result_fn.rs:54:1 + --> tests/ui/panic_in_result_fn.rs:53:1 | LL | / fn function_result_with_panic() -> Result // should emit lint -... | +LL | | +LL | | { +LL | | panic!("error"); LL | | } | |_^ | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> tests/ui/panic_in_result_fn.rs:58:5 + --> tests/ui/panic_in_result_fn.rs:56:5 | LL | panic!("error"); | ^^^^^^^^^^^^^^^ error: used `panic!()` or assertion in a function that returns `Result` - --> tests/ui/panic_in_result_fn.rs:61:1 + --> tests/ui/panic_in_result_fn.rs:59:1 | LL | / fn in_closure() -> Result { LL | | @@ -42,7 +46,7 @@ LL | | } | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> tests/ui/panic_in_result_fn.rs:63:16 + --> tests/ui/panic_in_result_fn.rs:61:16 | LL | let c = || panic!(); | ^^^^^^^^ diff --git a/tests/ui/panic_in_result_fn_assertions.rs b/tests/ui/panic_in_result_fn_assertions.rs index 894e63f8ff1e9..4e70282415794 100644 --- a/tests/ui/panic_in_result_fn_assertions.rs +++ b/tests/ui/panic_in_result_fn_assertions.rs @@ -6,7 +6,6 @@ struct A; impl A { fn result_with_assert_with_message(x: i32) -> Result // should emit lint //~^ panic_in_result_fn - { assert!(x == 5, "wrong argument"); Ok(true) @@ -14,7 +13,6 @@ impl A { fn result_with_assert_eq(x: i32) -> Result // should emit lint //~^ panic_in_result_fn - { assert_eq!(x, 5); Ok(true) @@ -22,7 +20,6 @@ impl A { fn result_with_assert_ne(x: i32) -> Result // should emit lint //~^ panic_in_result_fn - { assert_ne!(x, 1); Ok(true) diff --git a/tests/ui/panic_in_result_fn_assertions.stderr b/tests/ui/panic_in_result_fn_assertions.stderr index 46bc16fe8e163..cdb7762510d9c 100644 --- a/tests/ui/panic_in_result_fn_assertions.stderr +++ b/tests/ui/panic_in_result_fn_assertions.stderr @@ -2,14 +2,16 @@ error: used `panic!()` or assertion in a function that returns `Result` --> tests/ui/panic_in_result_fn_assertions.rs:7:5 | LL | / fn result_with_assert_with_message(x: i32) -> Result // should emit lint -... | +LL | | +LL | | { +LL | | assert!(x == 5, "wrong argument"); LL | | Ok(true) LL | | } | |_____^ | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> tests/ui/panic_in_result_fn_assertions.rs:11:9 + --> tests/ui/panic_in_result_fn_assertions.rs:10:9 | LL | assert!(x == 5, "wrong argument"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,33 +19,37 @@ LL | assert!(x == 5, "wrong argument"); = help: to override `-D warnings` add `#[allow(clippy::panic_in_result_fn)]` error: used `panic!()` or assertion in a function that returns `Result` - --> tests/ui/panic_in_result_fn_assertions.rs:15:5 + --> tests/ui/panic_in_result_fn_assertions.rs:14:5 | LL | / fn result_with_assert_eq(x: i32) -> Result // should emit lint -... | +LL | | +LL | | { +LL | | assert_eq!(x, 5); LL | | Ok(true) LL | | } | |_____^ | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> tests/ui/panic_in_result_fn_assertions.rs:19:9 + --> tests/ui/panic_in_result_fn_assertions.rs:17:9 | LL | assert_eq!(x, 5); | ^^^^^^^^^^^^^^^^ error: used `panic!()` or assertion in a function that returns `Result` - --> tests/ui/panic_in_result_fn_assertions.rs:23:5 + --> tests/ui/panic_in_result_fn_assertions.rs:21:5 | LL | / fn result_with_assert_ne(x: i32) -> Result // should emit lint -... | +LL | | +LL | | { +LL | | assert_ne!(x, 1); LL | | Ok(true) LL | | } | |_____^ | = help: `panic!()` or assertions should not be used in a function that returns `Result` as `Result` is expected to return an error instead of crashing note: return Err() instead of panicking - --> tests/ui/panic_in_result_fn_assertions.rs:27:9 + --> tests/ui/panic_in_result_fn_assertions.rs:24:9 | LL | assert_ne!(x, 1); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/panicking_macros.rs b/tests/ui/panicking_macros.rs index a718dd9252162..65854d7eb4bf9 100644 --- a/tests/ui/panicking_macros.rs +++ b/tests/ui/panicking_macros.rs @@ -22,7 +22,6 @@ fn panic() { panic!(); //~^ panic - panic!("message"); //~^ panic @@ -37,7 +36,6 @@ fn todo() { todo!(); //~^ todo - todo!("message"); //~^ todo @@ -52,7 +50,6 @@ fn unimplemented() { unimplemented!(); //~^ unimplemented - unimplemented!("message"); //~^ unimplemented @@ -67,7 +64,6 @@ fn unreachable() { unreachable!(); //~^ unreachable - unreachable!("message"); //~^ unreachable @@ -90,7 +86,6 @@ fn core_versions() { unreachable!(); //~^ unreachable - } fn assert() { diff --git a/tests/ui/panicking_macros.stderr b/tests/ui/panicking_macros.stderr index 0c2b4508a803d..03e459e4ec6ec 100644 --- a/tests/ui/panicking_macros.stderr +++ b/tests/ui/panicking_macros.stderr @@ -8,19 +8,19 @@ LL | panic!(); = help: to override `-D warnings` add `#[allow(clippy::panic)]` error: `panic` should not be present in production code - --> tests/ui/panicking_macros.rs:26:5 + --> tests/ui/panicking_macros.rs:25:5 | LL | panic!("message"); | ^^^^^^^^^^^^^^^^^ error: `panic` should not be present in production code - --> tests/ui/panicking_macros.rs:29:5 + --> tests/ui/panicking_macros.rs:28:5 | LL | panic!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `todo` should not be present in production code - --> tests/ui/panicking_macros.rs:37:5 + --> tests/ui/panicking_macros.rs:36:5 | LL | todo!(); | ^^^^^^^ @@ -29,19 +29,19 @@ LL | todo!(); = help: to override `-D warnings` add `#[allow(clippy::todo)]` error: `todo` should not be present in production code - --> tests/ui/panicking_macros.rs:41:5 + --> tests/ui/panicking_macros.rs:39:5 | LL | todo!("message"); | ^^^^^^^^^^^^^^^^ error: `todo` should not be present in production code - --> tests/ui/panicking_macros.rs:44:5 + --> tests/ui/panicking_macros.rs:42:5 | LL | todo!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> tests/ui/panicking_macros.rs:52:5 + --> tests/ui/panicking_macros.rs:50:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ @@ -50,19 +50,19 @@ LL | unimplemented!(); = help: to override `-D warnings` add `#[allow(clippy::unimplemented)]` error: `unimplemented` should not be present in production code - --> tests/ui/panicking_macros.rs:56:5 + --> tests/ui/panicking_macros.rs:53:5 | LL | unimplemented!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> tests/ui/panicking_macros.rs:59:5 + --> tests/ui/panicking_macros.rs:56:5 | LL | unimplemented!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> tests/ui/panicking_macros.rs:67:5 + --> tests/ui/panicking_macros.rs:64:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ @@ -71,37 +71,37 @@ LL | unreachable!(); = help: to override `-D warnings` add `#[allow(clippy::unreachable)]` error: usage of the `unreachable!` macro - --> tests/ui/panicking_macros.rs:71:5 + --> tests/ui/panicking_macros.rs:67:5 | LL | unreachable!("message"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> tests/ui/panicking_macros.rs:74:5 + --> tests/ui/panicking_macros.rs:70:5 | LL | unreachable!("{} {}", "panic with", "multiple arguments"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `panic` should not be present in production code - --> tests/ui/panicking_macros.rs:82:5 + --> tests/ui/panicking_macros.rs:78:5 | LL | panic!(); | ^^^^^^^^ error: `todo` should not be present in production code - --> tests/ui/panicking_macros.rs:85:5 + --> tests/ui/panicking_macros.rs:81:5 | LL | todo!(); | ^^^^^^^ error: `unimplemented` should not be present in production code - --> tests/ui/panicking_macros.rs:88:5 + --> tests/ui/panicking_macros.rs:84:5 | LL | unimplemented!(); | ^^^^^^^^^^^^^^^^ error: usage of the `unreachable!` macro - --> tests/ui/panicking_macros.rs:91:5 + --> tests/ui/panicking_macros.rs:87:5 | LL | unreachable!(); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/panicking_overflow_checks.rs b/tests/ui/panicking_overflow_checks.rs index 57a829d50d2c0..29789c9497567 100644 --- a/tests/ui/panicking_overflow_checks.rs +++ b/tests/ui/panicking_overflow_checks.rs @@ -2,20 +2,20 @@ #![allow(clippy::needless_if)] fn test(a: u32, b: u32, c: u32) { -if a + b < a {} -//~^ panicking_overflow_checks -if a > a + b {} -//~^ panicking_overflow_checks -if a + b < b {} -//~^ panicking_overflow_checks -if b > a + b {} -//~^ panicking_overflow_checks + if a + b < a {} + //~^ panicking_overflow_checks + if a > a + b {} + //~^ panicking_overflow_checks + if a + b < b {} + //~^ panicking_overflow_checks + if b > a + b {} + //~^ panicking_overflow_checks if a - b > b {} if b < a - b {} -if a - b > a {} -//~^ panicking_overflow_checks -if a < a - b {} -//~^ panicking_overflow_checks + if a - b > a {} + //~^ panicking_overflow_checks + if a < a - b {} + //~^ panicking_overflow_checks if a + b < c {} if c > a + b {} if a - b < c {} diff --git a/tests/ui/panicking_overflow_checks.stderr b/tests/ui/panicking_overflow_checks.stderr index 3bb209ccfa7e6..3022c9e52b0c2 100644 --- a/tests/ui/panicking_overflow_checks.stderr +++ b/tests/ui/panicking_overflow_checks.stderr @@ -1,41 +1,41 @@ error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/panicking_overflow_checks.rs:5:4 + --> tests/ui/panicking_overflow_checks.rs:5:8 | -LL | if a + b < a {} - | ^^^^^^^^^ +LL | if a + b < a {} + | ^^^^^^^^^ | = note: `-D clippy::panicking-overflow-checks` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::panicking_overflow_checks)]` error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/panicking_overflow_checks.rs:7:4 + --> tests/ui/panicking_overflow_checks.rs:7:8 | -LL | if a > a + b {} - | ^^^^^^^^^ +LL | if a > a + b {} + | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/panicking_overflow_checks.rs:9:4 + --> tests/ui/panicking_overflow_checks.rs:9:8 | -LL | if a + b < b {} - | ^^^^^^^^^ +LL | if a + b < b {} + | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/panicking_overflow_checks.rs:11:4 + --> tests/ui/panicking_overflow_checks.rs:11:8 | -LL | if b > a + b {} - | ^^^^^^^^^ +LL | if b > a + b {} + | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/panicking_overflow_checks.rs:15:4 + --> tests/ui/panicking_overflow_checks.rs:15:8 | -LL | if a - b > a {} - | ^^^^^^^^^ +LL | if a - b > a {} + | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/panicking_overflow_checks.rs:17:4 + --> tests/ui/panicking_overflow_checks.rs:17:8 | -LL | if a < a - b {} - | ^^^^^^^^^ +LL | if a < a - b {} + | ^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/partial_pub_fields.rs b/tests/ui/partial_pub_fields.rs index a0ee4f2b04966..27f4b2a0b4fcb 100644 --- a/tests/ui/partial_pub_fields.rs +++ b/tests/ui/partial_pub_fields.rs @@ -9,7 +9,6 @@ fn main() { files: HashMap, pub paths: HashMap, //~^ partial_pub_fields - } pub struct Color { @@ -17,18 +16,15 @@ fn main() { pub g: u8, b: u8, //~^ partial_pub_fields - } pub struct Point(i32, pub i32); //~^ partial_pub_fields - pub struct Visibility { r#pub: bool, pub pos: u32, //~^ partial_pub_fields - } // Don't lint on empty structs; diff --git a/tests/ui/partial_pub_fields.stderr b/tests/ui/partial_pub_fields.stderr index 4232f3e82e457..af3b2f7587578 100644 --- a/tests/ui/partial_pub_fields.stderr +++ b/tests/ui/partial_pub_fields.stderr @@ -9,7 +9,7 @@ LL | pub paths: HashMap, = help: to override `-D warnings` add `#[allow(clippy::partial_pub_fields)]` error: mixed usage of pub and non-pub fields - --> tests/ui/partial_pub_fields.rs:18:9 + --> tests/ui/partial_pub_fields.rs:17:9 | LL | b: u8, | ^ @@ -17,7 +17,7 @@ LL | b: u8, = help: consider using public field here error: mixed usage of pub and non-pub fields - --> tests/ui/partial_pub_fields.rs:23:27 + --> tests/ui/partial_pub_fields.rs:21:27 | LL | pub struct Point(i32, pub i32); | ^^^ @@ -25,7 +25,7 @@ LL | pub struct Point(i32, pub i32); = help: consider using private field here error: mixed usage of pub and non-pub fields - --> tests/ui/partial_pub_fields.rs:29:9 + --> tests/ui/partial_pub_fields.rs:26:9 | LL | pub pos: u32, | ^^^ diff --git a/tests/ui/partialeq_ne_impl.rs b/tests/ui/partialeq_ne_impl.rs index 42c235b381efa..a3b2b68708ba8 100644 --- a/tests/ui/partialeq_ne_impl.rs +++ b/tests/ui/partialeq_ne_impl.rs @@ -7,8 +7,7 @@ impl PartialEq for Foo { true } fn ne(&self, _: &Foo) -> bool { - //~^ partialeq_ne_impl - + //~^ partialeq_ne_impl false } diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index ffc26afa075de..dc01a375060b9 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -2,7 +2,9 @@ error: re-implementing `PartialEq::ne` is unnecessary --> tests/ui/partialeq_ne_impl.rs:9:5 | LL | / fn ne(&self, _: &Foo) -> bool { -... | +LL | | +LL | | +LL | | false LL | | } | |_____^ | diff --git a/tests/ui/partialeq_to_none.fixed b/tests/ui/partialeq_to_none.fixed index d650e28f2b68f..e700cc56349f2 100644 --- a/tests/ui/partialeq_to_none.fixed +++ b/tests/ui/partialeq_to_none.fixed @@ -64,7 +64,7 @@ fn main() { //~^ partialeq_to_none let _ = { - //~^ partialeq_to_none + //~^ partialeq_to_none /* This comment runs long */ diff --git a/tests/ui/partialeq_to_none.rs b/tests/ui/partialeq_to_none.rs index 77804b0765f18..1bae076dd3377 100644 --- a/tests/ui/partialeq_to_none.rs +++ b/tests/ui/partialeq_to_none.rs @@ -64,7 +64,7 @@ fn main() { //~^ partialeq_to_none let _ = { - //~^ partialeq_to_none + //~^ partialeq_to_none /* This comment runs long */ diff --git a/tests/ui/path_ends_with_ext.fixed b/tests/ui/path_ends_with_ext.fixed index a20925f9ba67d..fa4286e11644f 100644 --- a/tests/ui/path_ends_with_ext.fixed +++ b/tests/ui/path_ends_with_ext.fixed @@ -11,7 +11,6 @@ fn test(path: &Path) { path.extension().is_some_and(|ext| ext == "md"); //~^ path_ends_with_ext - // some "extensions" are allowed by default path.ends_with(".git"); @@ -32,7 +31,6 @@ fn test(path: &Path) { fn under_msv(path: &Path) -> bool { path.extension().map_or(false, |ext| ext == "md") //~^ path_ends_with_ext - } fn main() {} diff --git a/tests/ui/path_ends_with_ext.rs b/tests/ui/path_ends_with_ext.rs index e20620e983d07..00d7ede8ef936 100644 --- a/tests/ui/path_ends_with_ext.rs +++ b/tests/ui/path_ends_with_ext.rs @@ -11,7 +11,6 @@ fn test(path: &Path) { path.ends_with(".md"); //~^ path_ends_with_ext - // some "extensions" are allowed by default path.ends_with(".git"); @@ -32,7 +31,6 @@ fn test(path: &Path) { fn under_msv(path: &Path) -> bool { path.ends_with(".md") //~^ path_ends_with_ext - } fn main() {} diff --git a/tests/ui/path_ends_with_ext.stderr b/tests/ui/path_ends_with_ext.stderr index 7016b8e5b8fb9..deab71ff76268 100644 --- a/tests/ui/path_ends_with_ext.stderr +++ b/tests/ui/path_ends_with_ext.stderr @@ -8,7 +8,7 @@ LL | path.ends_with(".md"); = help: to override `-D warnings` add `#[allow(clippy::path_ends_with_ext)]` error: this looks like a failed attempt at checking for the file extension - --> tests/ui/path_ends_with_ext.rs:33:5 + --> tests/ui/path_ends_with_ext.rs:32:5 | LL | path.ends_with(".md") | ^^^^^^^^^^^^^^^^^^^^^ help: try: `path.extension().map_or(false, |ext| ext == "md")` diff --git a/tests/ui/pathbuf_init_then_push.fixed b/tests/ui/pathbuf_init_then_push.fixed index 43cc65f8dfbf2..2a90b8ce28141 100644 --- a/tests/ui/pathbuf_init_then_push.fixed +++ b/tests/ui/pathbuf_init_then_push.fixed @@ -3,14 +3,14 @@ use std::path::PathBuf; fn main() { -let mut path_buf = PathBuf::from("foo"); + let mut path_buf = PathBuf::from("foo"); -path_buf = PathBuf::from("foo").join("bar"); + path_buf = PathBuf::from("foo").join("bar"); let bar = "bar"; -path_buf = PathBuf::from("foo").join(bar); + path_buf = PathBuf::from("foo").join(bar); -let mut path_buf = PathBuf::from("foo").join("bar").join("buz"); + let mut path_buf = PathBuf::from("foo").join("bar").join("buz"); let mut x = PathBuf::new(); println!("{}", x.display()); diff --git a/tests/ui/pathbuf_init_then_push.rs b/tests/ui/pathbuf_init_then_push.rs index f3adb6d27abf1..7b65392e9519f 100644 --- a/tests/ui/pathbuf_init_then_push.rs +++ b/tests/ui/pathbuf_init_then_push.rs @@ -3,21 +3,21 @@ use std::path::PathBuf; fn main() { -let mut path_buf = PathBuf::new(); -//~^ pathbuf_init_then_push + let mut path_buf = PathBuf::new(); + //~^ pathbuf_init_then_push path_buf.push("foo"); -path_buf = PathBuf::from("foo"); -//~^ pathbuf_init_then_push + path_buf = PathBuf::from("foo"); + //~^ pathbuf_init_then_push path_buf.push("bar"); let bar = "bar"; -path_buf = PathBuf::from("foo"); -//~^ pathbuf_init_then_push + path_buf = PathBuf::from("foo"); + //~^ pathbuf_init_then_push path_buf.push(bar); -let mut path_buf = PathBuf::from("foo").join("bar"); -//~^ pathbuf_init_then_push + let mut path_buf = PathBuf::from("foo").join("bar"); + //~^ pathbuf_init_then_push path_buf.push("buz"); let mut x = PathBuf::new(); diff --git a/tests/ui/pathbuf_init_then_push.stderr b/tests/ui/pathbuf_init_then_push.stderr index 80e7b836fce3c..1aa730a0bea26 100644 --- a/tests/ui/pathbuf_init_then_push.stderr +++ b/tests/ui/pathbuf_init_then_push.stderr @@ -1,7 +1,7 @@ error: calls to `push` immediately after creation - --> tests/ui/pathbuf_init_then_push.rs:6:1 + --> tests/ui/pathbuf_init_then_push.rs:6:5 | -LL | / let mut path_buf = PathBuf::new(); +LL | / let mut path_buf = PathBuf::new(); LL | | LL | | path_buf.push("foo"); | |_________________________^ help: consider using the `.join()`: `let mut path_buf = PathBuf::from("foo");` @@ -10,25 +10,25 @@ LL | | path_buf.push("foo"); = help: to override `-D warnings` add `#[allow(clippy::pathbuf_init_then_push)]` error: calls to `push` immediately after creation - --> tests/ui/pathbuf_init_then_push.rs:10:1 + --> tests/ui/pathbuf_init_then_push.rs:10:5 | -LL | / path_buf = PathBuf::from("foo"); +LL | / path_buf = PathBuf::from("foo"); LL | | LL | | path_buf.push("bar"); | |_________________________^ help: consider using the `.join()`: `path_buf = PathBuf::from("foo").join("bar");` error: calls to `push` immediately after creation - --> tests/ui/pathbuf_init_then_push.rs:15:1 + --> tests/ui/pathbuf_init_then_push.rs:15:5 | -LL | / path_buf = PathBuf::from("foo"); +LL | / path_buf = PathBuf::from("foo"); LL | | LL | | path_buf.push(bar); | |_______________________^ help: consider using the `.join()`: `path_buf = PathBuf::from("foo").join(bar);` error: calls to `push` immediately after creation - --> tests/ui/pathbuf_init_then_push.rs:19:1 + --> tests/ui/pathbuf_init_then_push.rs:19:5 | -LL | / let mut path_buf = PathBuf::from("foo").join("bar"); +LL | / let mut path_buf = PathBuf::from("foo").join("bar"); LL | | LL | | path_buf.push("buz"); | |_________________________^ help: consider using the `.join()`: `let mut path_buf = PathBuf::from("foo").join("bar").join("buz");` diff --git a/tests/ui/pattern_type_mismatch/mutability.rs b/tests/ui/pattern_type_mismatch/mutability.rs index c62b336814395..bdac3764bf167 100644 --- a/tests/ui/pattern_type_mismatch/mutability.rs +++ b/tests/ui/pattern_type_mismatch/mutability.rs @@ -8,7 +8,6 @@ fn should_lint() { match value { Some(_) => (), //~^ pattern_type_mismatch - _ => (), } @@ -16,7 +15,6 @@ fn should_lint() { match value { Some(_) => (), //~^ pattern_type_mismatch - _ => (), } } diff --git a/tests/ui/pattern_type_mismatch/mutability.stderr b/tests/ui/pattern_type_mismatch/mutability.stderr index 805fc99ea212e..e795ded7386d2 100644 --- a/tests/ui/pattern_type_mismatch/mutability.stderr +++ b/tests/ui/pattern_type_mismatch/mutability.stderr @@ -9,7 +9,7 @@ LL | Some(_) => (), = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/mutability.rs:17:9 + --> tests/ui/pattern_type_mismatch/mutability.rs:16:9 | LL | Some(_) => (), | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_alternatives.rs b/tests/ui/pattern_type_mismatch/pattern_alternatives.rs index 9df08bfe72463..3c789f570b038 100644 --- a/tests/ui/pattern_type_mismatch/pattern_alternatives.rs +++ b/tests/ui/pattern_type_mismatch/pattern_alternatives.rs @@ -21,7 +21,6 @@ fn alternatives() { if let Value::B | Value::A(Some(_)) = *ref_value {} //~^ pattern_type_mismatch - // ok if let &Value::B | &Value::A(_) = ref_value {} if let Value::B | Value::A(_) = *ref_value {} diff --git a/tests/ui/pattern_type_mismatch/pattern_structs.rs b/tests/ui/pattern_type_mismatch/pattern_structs.rs index 862953120b4cf..7fc53d591a917 100644 --- a/tests/ui/pattern_type_mismatch/pattern_structs.rs +++ b/tests/ui/pattern_type_mismatch/pattern_structs.rs @@ -19,7 +19,6 @@ fn struct_types() { if let Struct { ref_inner: Some(_) } = *ref_value {} //~^ pattern_type_mismatch - // ok let &Struct { .. } = ref_value; let Struct { .. } = *ref_value; @@ -50,7 +49,6 @@ fn struct_enum_variants() { if let StructEnum::Empty = ref_value {} //~^ pattern_type_mismatch - // ok if let &StructEnum::Var { .. } = ref_value {} if let StructEnum::Var { .. } = *ref_value {} diff --git a/tests/ui/pattern_type_mismatch/pattern_structs.stderr b/tests/ui/pattern_type_mismatch/pattern_structs.stderr index bdb11c73a4577..70f7bdc389061 100644 --- a/tests/ui/pattern_type_mismatch/pattern_structs.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_structs.stderr @@ -25,7 +25,7 @@ LL | if let Struct { ref_inner: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_structs.rs:38:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:37:12 | LL | if let StructEnum::Var { .. } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let StructEnum::Var { .. } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_structs.rs:41:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:40:12 | LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_structs.rs:44:42 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:43:42 | LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let &StructEnum::Var { inner_ref: Some(_) } = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_structs.rs:47:41 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:46:41 | LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} | ^^^^^^^ @@ -57,7 +57,7 @@ LL | if let StructEnum::Var { inner_ref: Some(_) } = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_structs.rs:50:12 + --> tests/ui/pattern_type_mismatch/pattern_structs.rs:49:12 | LL | if let StructEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/pattern_tuples.rs b/tests/ui/pattern_type_mismatch/pattern_tuples.rs index 4847e1a30a205..ecd95d9ae2b3b 100644 --- a/tests/ui/pattern_type_mismatch/pattern_tuples.rs +++ b/tests/ui/pattern_type_mismatch/pattern_tuples.rs @@ -17,7 +17,6 @@ fn tuple_types() { if let TupleStruct(Some(_)) = *ref_value {} //~^ pattern_type_mismatch - // ok let &TupleStruct(_) = ref_value; let TupleStruct(_) = *ref_value; @@ -45,7 +44,6 @@ fn tuple_enum_variants() { if let TupleEnum::Empty = ref_value {} //~^ pattern_type_mismatch - // ok if let &TupleEnum::Var(_) = ref_value {} if let TupleEnum::Var(_) = *ref_value {} @@ -68,7 +66,6 @@ fn plain_tuples() { if let (_a, Some(_)) = *ref_value {} //~^ pattern_type_mismatch - // ok let &(_a, _b) = ref_value; let (_a, _b) = *ref_value; diff --git a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr index 8a80a888f7756..d47c5d509c3fa 100644 --- a/tests/ui/pattern_type_mismatch/pattern_tuples.stderr +++ b/tests/ui/pattern_type_mismatch/pattern_tuples.stderr @@ -25,7 +25,7 @@ LL | if let TupleStruct(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:36:12 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:35:12 | LL | if let TupleEnum::Var(_) = ref_value {} | ^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | if let TupleEnum::Var(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:39:28 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:38:28 | LL | if let &TupleEnum::Var(Some(_)) = ref_value {} | ^^^^^^^ @@ -41,7 +41,7 @@ LL | if let &TupleEnum::Var(Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:42:27 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:41:27 | LL | if let TupleEnum::Var(Some(_)) = *ref_value {} | ^^^^^^^ @@ -49,7 +49,7 @@ LL | if let TupleEnum::Var(Some(_)) = *ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:45:12 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:44:12 | LL | if let TupleEnum::Empty = ref_value {} | ^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | if let TupleEnum::Empty = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:62:9 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:60:9 | LL | let (_a, _b) = ref_value; | ^^^^^^^^ @@ -65,7 +65,7 @@ LL | let (_a, _b) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:65:18 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:63:18 | LL | if let &(_a, Some(_)) = ref_value {} | ^^^^^^^ @@ -73,7 +73,7 @@ LL | if let &(_a, Some(_)) = ref_value {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:68:17 + --> tests/ui/pattern_type_mismatch/pattern_tuples.rs:66:17 | LL | if let (_a, Some(_)) = *ref_value {} | ^^^^^^^ diff --git a/tests/ui/pattern_type_mismatch/syntax.rs b/tests/ui/pattern_type_mismatch/syntax.rs index 77e9ec772aa89..0bbc26a0c27c5 100644 --- a/tests/ui/pattern_type_mismatch/syntax.rs +++ b/tests/ui/pattern_type_mismatch/syntax.rs @@ -10,7 +10,6 @@ fn syntax_match() { match ref_value { Some(_) => (), //~^ pattern_type_mismatch - None => (), } @@ -32,7 +31,6 @@ fn syntax_if_let() { if let Some(_) = ref_value {} //~^ pattern_type_mismatch - // ok if let &Some(_) = ref_value {} if let Some(_) = *ref_value {} @@ -43,7 +41,7 @@ fn syntax_while_let() { // not ok while let Some(_) = ref_value { - //~^ pattern_type_mismatch + //~^ pattern_type_mismatch break; } @@ -65,7 +63,6 @@ fn syntax_for() { for (_a, _b) in slice.iter() {} //~^ pattern_type_mismatch - // ok for &(_a, _b) in slice.iter() {} } @@ -77,7 +74,6 @@ fn syntax_let() { let (_n, _m) = ref_value; //~^ pattern_type_mismatch - // ok let &(_n, _m) = ref_value; let (_n, _m) = *ref_value; @@ -88,7 +84,6 @@ fn syntax_fn() { fn foo((_a, _b): &(i32, i32)) {} //~^ pattern_type_mismatch - // ok fn foo_ok_1(&(_a, _b): &(i32, i32)) {} } @@ -104,7 +99,6 @@ fn syntax_closure() { foo(|(_a, _b)| ()); //~^ pattern_type_mismatch - // ok foo(|&(_a, _b)| ()); } @@ -121,7 +115,6 @@ fn macro_with_expression() { matching_macro!(match value { Some(_) => (), //~^ pattern_type_mismatch - _ => (), }); diff --git a/tests/ui/pattern_type_mismatch/syntax.stderr b/tests/ui/pattern_type_mismatch/syntax.stderr index eec9ea70c69de..3f6b5feb9b07b 100644 --- a/tests/ui/pattern_type_mismatch/syntax.stderr +++ b/tests/ui/pattern_type_mismatch/syntax.stderr @@ -9,7 +9,7 @@ LL | Some(_) => (), = help: to override `-D warnings` add `#[allow(clippy::pattern_type_mismatch)]` error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:32:12 + --> tests/ui/pattern_type_mismatch/syntax.rs:31:12 | LL | if let Some(_) = ref_value {} | ^^^^^^^ @@ -17,7 +17,7 @@ LL | if let Some(_) = ref_value {} = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:45:15 + --> tests/ui/pattern_type_mismatch/syntax.rs:43:15 | LL | while let Some(_) = ref_value { | ^^^^^^^ @@ -25,7 +25,7 @@ LL | while let Some(_) = ref_value { = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:65:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:63:9 | LL | for (_a, _b) in slice.iter() {} | ^^^^^^^^ @@ -33,7 +33,7 @@ LL | for (_a, _b) in slice.iter() {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:77:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:74:9 | LL | let (_n, _m) = ref_value; | ^^^^^^^^ @@ -41,7 +41,7 @@ LL | let (_n, _m) = ref_value; = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:88:12 + --> tests/ui/pattern_type_mismatch/syntax.rs:84:12 | LL | fn foo((_a, _b): &(i32, i32)) {} | ^^^^^^^^ @@ -49,7 +49,7 @@ LL | fn foo((_a, _b): &(i32, i32)) {} = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:104:10 + --> tests/ui/pattern_type_mismatch/syntax.rs:99:10 | LL | foo(|(_a, _b)| ()); | ^^^^^^^^ @@ -57,7 +57,7 @@ LL | foo(|(_a, _b)| ()); = help: explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:122:9 + --> tests/ui/pattern_type_mismatch/syntax.rs:116:9 | LL | Some(_) => (), | ^^^^^^^ @@ -65,7 +65,7 @@ LL | Some(_) => (), = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings error: type of pattern does not match the expression type - --> tests/ui/pattern_type_mismatch/syntax.rs:144:17 + --> tests/ui/pattern_type_mismatch/syntax.rs:137:17 | LL | Some(_) => (), | ^^^^^^^ diff --git a/tests/ui/patterns.fixed b/tests/ui/patterns.fixed index a119096865a09..bcb8ecfc38d25 100644 --- a/tests/ui/patterns.fixed +++ b/tests/ui/patterns.fixed @@ -28,7 +28,7 @@ fn main() { // required "ref" left out in suggestion: #5271 match mutv { ref mut x => { - //~^ redundant_pattern + //~^ redundant_pattern x.push(4); println!("vec: {:?}", x); }, diff --git a/tests/ui/patterns.rs b/tests/ui/patterns.rs index 4ba6ac319af99..19639ebd13d60 100644 --- a/tests/ui/patterns.rs +++ b/tests/ui/patterns.rs @@ -28,7 +28,7 @@ fn main() { // required "ref" left out in suggestion: #5271 match mutv { ref mut x @ _ => { - //~^ redundant_pattern + //~^ redundant_pattern x.push(4); println!("vec: {:?}", x); }, diff --git a/tests/ui/permissions_set_readonly_false.rs b/tests/ui/permissions_set_readonly_false.rs index 652ffd724d953..ccca523da551c 100644 --- a/tests/ui/permissions_set_readonly_false.rs +++ b/tests/ui/permissions_set_readonly_false.rs @@ -19,7 +19,6 @@ fn main() { permissions.set_readonly(false); //~^ permissions_set_readonly_false - // no lint permissions.set_readonly(true); diff --git a/tests/ui/pointers_in_nomem_asm_block.rs b/tests/ui/pointers_in_nomem_asm_block.rs index 6d23bd78e919c..171716be26024 100644 --- a/tests/ui/pointers_in_nomem_asm_block.rs +++ b/tests/ui/pointers_in_nomem_asm_block.rs @@ -26,11 +26,9 @@ unsafe fn nomem_good(p: &i32) { unsafe fn nomem_bad2(p: &mut i32) { asm!("asdf {p}", p = in(reg) p, options(nomem, nostack, preserves_flags)); //~^ pointers_in_nomem_asm_block - } unsafe fn nomem_fn(p: extern "C" fn()) { asm!("call {p}", p = in(reg) p, options(nomem)); //~^ pointers_in_nomem_asm_block - } diff --git a/tests/ui/pointers_in_nomem_asm_block.stderr b/tests/ui/pointers_in_nomem_asm_block.stderr index 6de9c476312a9..ca24e34f63c0f 100644 --- a/tests/ui/pointers_in_nomem_asm_block.stderr +++ b/tests/ui/pointers_in_nomem_asm_block.stderr @@ -22,7 +22,7 @@ LL | asm!("asdf {p}", p = in(reg) p, options(nomem, nostack, preserves_flags = note: if this is intentional and no pointers are read or written to, consider allowing the lint error: passing pointers to nomem asm block - --> tests/ui/pointers_in_nomem_asm_block.rs:33:22 + --> tests/ui/pointers_in_nomem_asm_block.rs:32:22 | LL | asm!("call {p}", p = in(reg) p, options(nomem)); | ^^^^^^^^^^^^^ diff --git a/tests/ui/print.rs b/tests/ui/print.rs index 7f7b8eb15b5de..ee3d9dc0de037 100644 --- a/tests/ui/print.rs +++ b/tests/ui/print.rs @@ -10,8 +10,6 @@ impl Display for Foo { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "{:?}", 43.1415) //~^ use_debug - - } } @@ -26,27 +24,20 @@ fn main() { println!("Hello"); //~^ print_stdout - print!("Hello"); //~^ print_stdout - print!("Hello {}", "World"); //~^ print_stdout - print!("Hello {:?}", "World"); //~^ print_stdout //~| use_debug - - print!("Hello {:#?}", "#orld"); //~^ print_stdout //~| use_debug - - assert_eq!(42, 1337); vec![1, 2]; diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index 4e9d4135486ce..9dd216bd1449d 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -8,7 +8,7 @@ LL | write!(f, "{:?}", 43.1415) = help: to override `-D warnings` add `#[allow(clippy::use_debug)]` error: use of `println!` - --> tests/ui/print.rs:26:5 + --> tests/ui/print.rs:24:5 | LL | println!("Hello"); | ^^^^^^^^^^^^^^^^^ @@ -17,37 +17,37 @@ LL | println!("Hello"); = help: to override `-D warnings` add `#[allow(clippy::print_stdout)]` error: use of `print!` - --> tests/ui/print.rs:30:5 + --> tests/ui/print.rs:27:5 | LL | print!("Hello"); | ^^^^^^^^^^^^^^^ error: use of `print!` - --> tests/ui/print.rs:34:5 + --> tests/ui/print.rs:30:5 | LL | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` - --> tests/ui/print.rs:38:5 + --> tests/ui/print.rs:33:5 | LL | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> tests/ui/print.rs:38:19 + --> tests/ui/print.rs:33:19 | LL | print!("Hello {:?}", "World"); | ^^^^ error: use of `print!` - --> tests/ui/print.rs:44:5 + --> tests/ui/print.rs:37:5 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> tests/ui/print.rs:44:19 + --> tests/ui/print.rs:37:19 | LL | print!("Hello {:#?}", "#orld"); | ^^^^^ diff --git a/tests/ui/print_in_format_impl.rs b/tests/ui/print_in_format_impl.rs index fdf6303550449..8bc7049212209 100644 --- a/tests/ui/print_in_format_impl.rs +++ b/tests/ui/print_in_format_impl.rs @@ -20,7 +20,6 @@ impl Debug for Foo { print!("{}", 1); //~^ print_in_format_impl - println!("{}", 2); //~^ print_in_format_impl diff --git a/tests/ui/print_in_format_impl.stderr b/tests/ui/print_in_format_impl.stderr index 1a9c62d39e032..91d6ce953849e 100644 --- a/tests/ui/print_in_format_impl.stderr +++ b/tests/ui/print_in_format_impl.stderr @@ -8,37 +8,37 @@ LL | print!("{}", 1); = help: to override `-D warnings` add `#[allow(clippy::print_in_format_impl)]` error: use of `println!` in `Debug` impl - --> tests/ui/print_in_format_impl.rs:24:9 + --> tests/ui/print_in_format_impl.rs:23:9 | LL | println!("{}", 2); | ^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `eprint!` in `Debug` impl - --> tests/ui/print_in_format_impl.rs:27:9 + --> tests/ui/print_in_format_impl.rs:26:9 | LL | eprint!("{}", 3); | ^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` error: use of `eprintln!` in `Debug` impl - --> tests/ui/print_in_format_impl.rs:30:9 + --> tests/ui/print_in_format_impl.rs:29:9 | LL | eprintln!("{}", 4); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `println!` in `Debug` impl - --> tests/ui/print_in_format_impl.rs:34:13 + --> tests/ui/print_in_format_impl.rs:33:13 | LL | println!("nested"); | ^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(f, ..)` error: use of `print!` in `Display` impl - --> tests/ui/print_in_format_impl.rs:49:9 + --> tests/ui/print_in_format_impl.rs:48:9 | LL | print!("Display"); | ^^^^^^^^^^^^^^^^^ help: replace with: `write!(f, ..)` error: use of `println!` in `Debug` impl - --> tests/ui/print_in_format_impl.rs:61:9 + --> tests/ui/print_in_format_impl.rs:60:9 | LL | println!("UnnamedFormatter"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `writeln!(..)` diff --git a/tests/ui/print_literal.fixed b/tests/ui/print_literal.fixed index bcf022badc6eb..24c45a4a61b99 100644 --- a/tests/ui/print_literal.fixed +++ b/tests/ui/print_literal.fixed @@ -27,7 +27,6 @@ fn main() { print!("Hello world"); //~^ print_literal - println!("Hello {} world", world); //~^ print_literal @@ -37,7 +36,6 @@ fn main() { println!("a literal {:.4}", 5); //~^ print_literal - // positional args don't change the fact // that we're using a literal -- this should // throw a warning @@ -47,7 +45,6 @@ fn main() { println!("world hello"); //~^ print_literal - // named args shouldn't change anything either println!("hello world"); //~^ print_literal @@ -55,7 +52,6 @@ fn main() { println!("world hello"); //~^ print_literal - // The string literal from `file!()` has a callsite span that isn't marked as coming from an // expansion println!("file: {}", file!()); diff --git a/tests/ui/print_literal.rs b/tests/ui/print_literal.rs index 96c150ae48105..42ae589ca639c 100644 --- a/tests/ui/print_literal.rs +++ b/tests/ui/print_literal.rs @@ -27,7 +27,6 @@ fn main() { print!("Hello {}", "world"); //~^ print_literal - println!("Hello {} {}", world, "world"); //~^ print_literal @@ -37,7 +36,6 @@ fn main() { println!("{} {:.4}", "a literal", 5); //~^ print_literal - // positional args don't change the fact // that we're using a literal -- this should // throw a warning @@ -47,7 +45,6 @@ fn main() { println!("{1} {0}", "hello", "world"); //~^ print_literal - // named args shouldn't change anything either println!("{foo} {bar}", foo = "hello", bar = "world"); //~^ print_literal @@ -55,7 +52,6 @@ fn main() { println!("{bar} {foo}", foo = "hello", bar = "world"); //~^ print_literal - // The string literal from `file!()` has a callsite span that isn't marked as coming from an // expansion println!("file: {}", file!()); diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index c2bc7d495f27c..da663000686fd 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -13,7 +13,7 @@ LL + print!("Hello world"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:31:36 + --> tests/ui/print_literal.rs:30:36 | LL | println!("Hello {} {}", world, "world"); | ^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {} world", world); | error: literal with an empty format string - --> tests/ui/print_literal.rs:34:26 + --> tests/ui/print_literal.rs:33:26 | LL | println!("Hello {}", "world"); | ^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("Hello world"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:37:26 + --> tests/ui/print_literal.rs:36:26 | LL | println!("{} {:.4}", "a literal", 5); | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("a literal {:.4}", 5); | error: literal with an empty format string - --> tests/ui/print_literal.rs:44:25 + --> tests/ui/print_literal.rs:42:25 | LL | println!("{0} {1}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!("hello world"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:47:25 + --> tests/ui/print_literal.rs:45:25 | LL | println!("{1} {0}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + println!("world hello"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:52:35 + --> tests/ui/print_literal.rs:49:35 | LL | println!("{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + println!("hello world"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:55:35 + --> tests/ui/print_literal.rs:52:35 | LL | println!("{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + println!("world hello"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:64:20 + --> tests/ui/print_literal.rs:60:20 | LL | println!("{}", "{} \x00 \u{ab123} \\\u{ab123} {:?}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + println!("{{}} \x00 \u{ab123} \\\u{ab123} {{:?}}"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:66:20 + --> tests/ui/print_literal.rs:62:20 | LL | println!("{}", "\\\u{1234}"); | ^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + println!("\\\u{1234}"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:71:20 + --> tests/ui/print_literal.rs:67:20 | LL | println!("{}", r"\u{ab123} \u{{"); | ^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + println!("\\u{{ab123}} \\u{{{{"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:73:21 + --> tests/ui/print_literal.rs:69:21 | LL | println!(r"{}", r"\u{ab123} \u{{"); | ^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + println!(r"\u{{ab123}} \u{{{{"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:75:20 + --> tests/ui/print_literal.rs:71:20 | LL | println!("{}", r"\{ab123} \u{{"); | ^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL + println!("\\{{ab123}} \\u{{{{"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:77:20 + --> tests/ui/print_literal.rs:73:20 | LL | println!("{}", "\\u{ab123}"); | ^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL + println!("\\u{{ab123}}"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:79:20 + --> tests/ui/print_literal.rs:75:20 | LL | println!("{}", "\\\\u{1234}"); | ^^^^^^^^^^^^^ @@ -181,7 +181,7 @@ LL + println!("\\\\u{{1234}}"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:82:35 + --> tests/ui/print_literal.rs:78:35 | LL | println!("mixed: {} {world}", "{hello}"); | ^^^^^^^^^ @@ -193,7 +193,7 @@ LL + println!("mixed: {{hello}} {world}"); | error: literal with an empty format string - --> tests/ui/print_literal.rs:87:20 + --> tests/ui/print_literal.rs:83:20 | LL | println!("{}", r#"""#); | ^^^^^^ @@ -205,7 +205,7 @@ LL + println!("\""); | error: literal with an empty format string - --> tests/ui/print_literal.rs:91:9 + --> tests/ui/print_literal.rs:87:9 | LL | / r#" LL | | diff --git a/tests/ui/print_stderr.rs b/tests/ui/print_stderr.rs index 2ad2c97b7cc1b..a086dfd37758d 100644 --- a/tests/ui/print_stderr.rs +++ b/tests/ui/print_stderr.rs @@ -4,7 +4,6 @@ fn main() { eprintln!("Hello"); //~^ print_stderr - println!("This should not do anything"); eprint!("World"); //~^ print_stderr diff --git a/tests/ui/print_stderr.stderr b/tests/ui/print_stderr.stderr index 7dfe72934c641..17019b886905a 100644 --- a/tests/ui/print_stderr.stderr +++ b/tests/ui/print_stderr.stderr @@ -8,7 +8,7 @@ LL | eprintln!("Hello"); = help: to override `-D warnings` add `#[allow(clippy::print_stderr)]` error: use of `eprint!` - --> tests/ui/print_stderr.rs:9:5 + --> tests/ui/print_stderr.rs:8:5 | LL | eprint!("World"); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/print_with_newline.fixed b/tests/ui/print_with_newline.fixed index 79bd8a2c8d366..96c5ee4c1e92c 100644 --- a/tests/ui/print_with_newline.fixed +++ b/tests/ui/print_with_newline.fixed @@ -7,7 +7,6 @@ fn main() { println!("Hello"); //~^ print_with_newline - println!("Hello {}", "world"); //~^ print_with_newline @@ -20,7 +19,6 @@ fn main() { println!(); //~^ print_with_newline - // these are all fine print!(""); print!("Hello"); @@ -52,13 +50,11 @@ fn main() { // Literal newlines should also fail println!( - //~^ print_with_newline - + //~^ print_with_newline ); println!( - //~^ print_with_newline - + //~^ print_with_newline ); diff --git a/tests/ui/print_with_newline.rs b/tests/ui/print_with_newline.rs index a9cbd214fc613..60d1e47883081 100644 --- a/tests/ui/print_with_newline.rs +++ b/tests/ui/print_with_newline.rs @@ -7,7 +7,6 @@ fn main() { print!("Hello\n"); //~^ print_with_newline - print!("Hello {}\n", "world"); //~^ print_with_newline @@ -20,7 +19,6 @@ fn main() { print!("\n"); //~^ print_with_newline - // these are all fine print!(""); print!("Hello"); @@ -52,14 +50,12 @@ fn main() { // Literal newlines should also fail print!( - //~^ print_with_newline - + //~^ print_with_newline " " ); print!( - //~^ print_with_newline - + //~^ print_with_newline r" " ); diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 45f858d689665..9ead0fca113bb 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -13,7 +13,7 @@ LL + println!("Hello"); | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:11:5 + --> tests/ui/print_with_newline.rs:10:5 | LL | print!("Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + println!("Hello {}", "world"); | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:14:5 + --> tests/ui/print_with_newline.rs:13:5 | LL | print!("Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + println!("Hello {} {}", "world", "#2"); | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:17:5 + --> tests/ui/print_with_newline.rs:16:5 | LL | print!("{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + println!("{}", 1265); | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:20:5 + --> tests/ui/print_with_newline.rs:19:5 | LL | print!("\n"); | ^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + println!(); | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:44:5 + --> tests/ui/print_with_newline.rs:42:5 | LL | print!("\\\n"); | ^^^^^^^^^^^^^^ @@ -73,11 +73,10 @@ LL + println!("\\"); | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:54:5 + --> tests/ui/print_with_newline.rs:52:5 | LL | / print!( LL | | -LL | | LL | | " LL | | " LL | | ); @@ -87,16 +86,14 @@ help: use `println!` instead | LL ~ println!( LL | -LL | LL ~ | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:60:5 + --> tests/ui/print_with_newline.rs:57:5 | LL | / print!( LL | | -LL | | LL | | r" LL | | " LL | | ); @@ -106,12 +103,11 @@ help: use `println!` instead | LL ~ println!( LL | -LL | LL ~ | error: using `print!()` with a format string that ends in a single newline - --> tests/ui/print_with_newline.rs:71:5 + --> tests/ui/print_with_newline.rs:67:5 | LL | print!("\\r\n"); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs index e8332cb97e1b4..2d77bf06ff942 100644 --- a/tests/ui/ptr_arg.rs +++ b/tests/ui/ptr_arg.rs @@ -11,45 +11,44 @@ use std::borrow::Cow; use std::path::{Path, PathBuf}; fn do_vec(x: &Vec) { -//~^ ptr_arg - + //~^ ptr_arg //Nothing here } fn do_vec_mut(x: &mut Vec) { -//~^ ptr_arg + //~^ ptr_arg //Nothing here } fn do_vec_mut2(x: &mut Vec) { -//~^ ptr_arg + //~^ ptr_arg x.len(); x.is_empty(); } fn do_str(x: &String) { -//~^ ptr_arg + //~^ ptr_arg //Nothing here either } fn do_str_mut(x: &mut String) { -//~^ ptr_arg + //~^ ptr_arg //Nothing here either } fn do_path(x: &PathBuf) { -//~^ ptr_arg + //~^ ptr_arg //Nothing here either } fn do_path_mut(x: &mut PathBuf) { -//~^ ptr_arg + //~^ ptr_arg //Nothing here either } @@ -74,7 +73,7 @@ impl Foo for Bar { } fn cloned(x: &Vec) -> Vec { -//~^ ptr_arg + //~^ ptr_arg let e = x.clone(); let f = e.clone(); // OK @@ -85,7 +84,7 @@ fn cloned(x: &Vec) -> Vec { } fn str_cloned(x: &String) -> String { -//~^ ptr_arg + //~^ ptr_arg let a = x.clone(); let b = x.clone(); @@ -95,7 +94,7 @@ fn str_cloned(x: &String) -> String { } fn path_cloned(x: &PathBuf) -> PathBuf { -//~^ ptr_arg + //~^ ptr_arg let a = x.clone(); let b = x.clone(); @@ -105,7 +104,7 @@ fn path_cloned(x: &PathBuf) -> PathBuf { } fn false_positive_capacity(x: &Vec, y: &String) { -//~^ ptr_arg + //~^ ptr_arg let a = x.capacity(); let b = y.clone(); @@ -123,7 +122,6 @@ fn false_positive_capacity_too(x: &String) -> String { fn test_cow_with_ref(c: &Cow<[i32]>) {} //~^ ptr_arg - fn test_cow(c: Cow<[i32]>) { let _c = c; } @@ -154,7 +152,6 @@ mod issue_5644 { fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec, _s: &String) {} //~^ ptr_arg - struct S; impl S { fn allowed( @@ -183,21 +180,21 @@ mod issue6509 { use std::path::PathBuf; fn foo_vec(vec: &Vec) { - //~^ ptr_arg + //~^ ptr_arg let _ = vec.clone().pop(); let _ = vec.clone().clone(); } fn foo_path(path: &PathBuf) { - //~^ ptr_arg + //~^ ptr_arg let _ = path.clone().pop(); let _ = path.clone().clone(); } fn foo_str(str: &PathBuf) { - //~^ ptr_arg + //~^ ptr_arg let _ = str.clone().pop(); let _ = str.clone().clone(); @@ -205,7 +202,7 @@ mod issue6509 { } fn mut_vec_slice_methods(v: &mut Vec) { -//~^ ptr_arg + //~^ ptr_arg v.copy_within(1..5, 10); } @@ -269,9 +266,9 @@ fn dyn_trait_ok(a: &mut Vec, b: &mut String, c: &mut PathBuf) { } fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { -//~^ ptr_arg -//~| ptr_arg -//~| ptr_arg + //~^ ptr_arg + //~| ptr_arg + //~| ptr_arg trait T {} impl T for Vec {} @@ -296,26 +293,26 @@ mod issue_9218 { // This one has an anonymous lifetime so it's not okay fn cow_elided_lifetime<'a>(input: &'a Cow) -> &'a str { - //~^ ptr_arg + //~^ ptr_arg todo!() } // These two's return types don't use 'a so it's not okay fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str { - //~^ ptr_arg + //~^ ptr_arg todo!() } fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str { - //~^ ptr_arg + //~^ ptr_arg todo!() } // Inferred to be `&'a str`, afaik. fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str { - //~^ ERROR: elided lifetime has a name + //~^ ERROR: elided lifetime has a name todo!() } } @@ -348,8 +345,8 @@ mod issue_13308 { // Other cases that are still ok to lint and ideally shouldn't regress fn good(v1: &String, v2: &String) { - //~^ ptr_arg - //~| ptr_arg + //~^ ptr_arg + //~| ptr_arg h1(v1); h2(String::new(), v2); diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index 94fa2184fd641..741e60cbd749c 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,5 +1,5 @@ error: elided lifetime has a name - --> tests/ui/ptr_arg.rs:317:56 + --> tests/ui/ptr_arg.rs:314:56 | LL | fn cow_good_ret_ty<'a>(input: &'a Cow<'a, str>) -> &str { | -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a` @@ -17,49 +17,49 @@ LL | fn do_vec(x: &Vec) { = help: to override `-D warnings` add `#[allow(clippy::ptr_arg)]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:20:18 + --> tests/ui/ptr_arg.rs:19:18 | LL | fn do_vec_mut(x: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:26:19 + --> tests/ui/ptr_arg.rs:25:19 | LL | fn do_vec_mut2(x: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [i64]` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:33:14 + --> tests/ui/ptr_arg.rs:32:14 | LL | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:39:18 + --> tests/ui/ptr_arg.rs:38:18 | LL | fn do_str_mut(x: &mut String) { | ^^^^^^^^^^^ help: change this to: `&mut str` error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:45:15 + --> tests/ui/ptr_arg.rs:44:15 | LL | fn do_path(x: &PathBuf) { | ^^^^^^^^ help: change this to: `&Path` error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:51:19 + --> tests/ui/ptr_arg.rs:50:19 | LL | fn do_path_mut(x: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:61:18 + --> tests/ui/ptr_arg.rs:60:18 | LL | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:76:14 + --> tests/ui/ptr_arg.rs:75:14 | LL | fn cloned(x: &Vec) -> Vec { | ^^^^^^^^ @@ -78,7 +78,7 @@ LL ~ x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:87:18 + --> tests/ui/ptr_arg.rs:86:18 | LL | fn str_cloned(x: &String) -> String { | ^^^^^^^ @@ -96,7 +96,7 @@ LL ~ x.to_owned() | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:97:19 + --> tests/ui/ptr_arg.rs:96:19 | LL | fn path_cloned(x: &PathBuf) -> PathBuf { | ^^^^^^^^ @@ -114,7 +114,7 @@ LL ~ x.to_path_buf() | error: writing `&String` instead of `&str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:107:44 + --> tests/ui/ptr_arg.rs:106:44 | LL | fn false_positive_capacity(x: &Vec, y: &String) { | ^^^^^^^ @@ -130,19 +130,19 @@ LL ~ let c = y; | error: using a reference to `Cow` is not recommended - --> tests/ui/ptr_arg.rs:123:25 + --> tests/ui/ptr_arg.rs:122:25 | LL | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:154:66 + --> tests/ui/ptr_arg.rs:152:66 | LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec, _s: &String) {} | ^^^^^^^ help: change this to: `&str` error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:185:21 + --> tests/ui/ptr_arg.rs:182:21 | LL | fn foo_vec(vec: &Vec) { | ^^^^^^^^ @@ -157,7 +157,7 @@ LL ~ let _ = vec.to_owned().clone(); | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:192:23 + --> tests/ui/ptr_arg.rs:189:23 | LL | fn foo_path(path: &PathBuf) { | ^^^^^^^^ @@ -172,7 +172,7 @@ LL ~ let _ = path.to_path_buf().clone(); | error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:199:21 + --> tests/ui/ptr_arg.rs:196:21 | LL | fn foo_str(str: &PathBuf) { | ^^^^^^^^ @@ -187,55 +187,55 @@ LL ~ let _ = str.to_path_buf().clone(); | error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:207:29 + --> tests/ui/ptr_arg.rs:204:29 | LL | fn mut_vec_slice_methods(v: &mut Vec) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:271:17 + --> tests/ui/ptr_arg.rs:268:17 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^^ help: change this to: `&mut [u32]` error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:271:35 + --> tests/ui/ptr_arg.rs:268:35 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^ help: change this to: `&mut str` error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:271:51 + --> tests/ui/ptr_arg.rs:268:51 | LL | fn dyn_trait(a: &mut Vec, b: &mut String, c: &mut PathBuf) { | ^^^^^^^^^^^^ help: change this to: `&mut Path` error: using a reference to `Cow` is not recommended - --> tests/ui/ptr_arg.rs:298:39 + --> tests/ui/ptr_arg.rs:295:39 | LL | fn cow_elided_lifetime<'a>(input: &'a Cow) -> &'a str { | ^^^^^^^^^^^^ help: change this to: `&str` error: using a reference to `Cow` is not recommended - --> tests/ui/ptr_arg.rs:305:36 + --> tests/ui/ptr_arg.rs:302:36 | LL | fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str { | ^^^^^^^^^^^^^^^^ help: change this to: `&str` error: using a reference to `Cow` is not recommended - --> tests/ui/ptr_arg.rs:310:40 + --> tests/ui/ptr_arg.rs:307:40 | LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str { | ^^^^^^^^^^^^^^^^ help: change this to: `&str` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:350:17 + --> tests/ui/ptr_arg.rs:347:17 | LL | fn good(v1: &String, v2: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&String` instead of `&str` involves a new object where a slice will do - --> tests/ui/ptr_arg.rs:350:30 + --> tests/ui/ptr_arg.rs:347:30 | LL | fn good(v1: &String, v2: &String) { | ^^^^^^^ help: change this to: `&str` diff --git a/tests/ui/pub_use.rs b/tests/ui/pub_use.rs index 4c2c3dfb30cbf..be4d1b2a964bc 100644 --- a/tests/ui/pub_use.rs +++ b/tests/ui/pub_use.rs @@ -9,7 +9,6 @@ pub mod outer { // should be linted pub use inner::Test; //~^ pub_use - } // should not be linted diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs index 609a4d3251e7d..fffaa803f39c2 100644 --- a/tests/ui/question_mark.rs +++ b/tests/ui/question_mark.rs @@ -5,7 +5,7 @@ fn some_func(a: Option) -> Option { if a.is_none() { - //~^ question_mark + //~^ question_mark return None; } @@ -86,7 +86,7 @@ pub struct MoveStruct { impl MoveStruct { pub fn ref_func(&self) -> Option> { if self.opt.is_none() { - //~^ question_mark + //~^ question_mark return None; } @@ -95,7 +95,7 @@ impl MoveStruct { pub fn mov_func_reuse(self) -> Option> { if self.opt.is_none() { - //~^ question_mark + //~^ question_mark return None; } @@ -104,7 +104,7 @@ impl MoveStruct { pub fn mov_func_no_use(self) -> Option> { if self.opt.is_none() { - //~^ question_mark + //~^ question_mark return None; } Some(Vec::new()) @@ -112,7 +112,7 @@ impl MoveStruct { pub fn if_let_ref_func(self) -> Option> { let v: &Vec<_> = if let Some(ref v) = self.opt { - //~^ question_mark + //~^ question_mark v } else { return None; @@ -123,7 +123,7 @@ impl MoveStruct { pub fn if_let_mov_func(self) -> Option> { let v = if let Some(v) = self.opt { - //~^ question_mark + //~^ question_mark v } else { return None; @@ -145,12 +145,12 @@ fn func() -> Option { } if f().is_none() { - //~^ question_mark + //~^ question_mark return None; } let _val = match f() { - //~^ question_mark + //~^ question_mark Some(val) => val, None => return None, }; @@ -161,13 +161,13 @@ fn func() -> Option { }; match f() { - //~^ question_mark + //~^ question_mark Some(val) => val, None => return None, }; match opt_none!() { - //~^ question_mark + //~^ question_mark Some(x) => x, None => return None, }; @@ -197,18 +197,18 @@ fn result_func(x: Result) -> Result { //~^ question_mark if x.is_err() { - //~^ question_mark + //~^ question_mark return x; } let _val = match func_returning_result() { - //~^ question_mark + //~^ question_mark Ok(val) => val, Err(err) => return Err(err), }; match func_returning_result() { - //~^ question_mark + //~^ question_mark Ok(val) => val, Err(err) => return Err(err), }; @@ -300,7 +300,7 @@ fn do_something() {} fn err_immediate_return() -> Result { if let Err(err) = func_returning_result() { - //~^ question_mark + //~^ question_mark return Err(err); } Ok(1) @@ -308,7 +308,7 @@ fn err_immediate_return() -> Result { fn err_immediate_return_and_do_something() -> Result { if let Err(err) = func_returning_result() { - //~^ question_mark + //~^ question_mark return Err(err); } do_something(); @@ -386,7 +386,7 @@ fn issue6828_nested_body() -> Option { try { fn f2(a: Option) -> Option { if a.is_none() { - //~^ question_mark + //~^ question_mark return None; // do lint here, the outer `try` is not relevant here // https://github.com/rust-lang/rust-clippy/pull/11001#issuecomment-1610636867 diff --git a/tests/ui/rc_clone_in_vec_init/arc.rs b/tests/ui/rc_clone_in_vec_init/arc.rs index 3b3e5dc643e13..ad5d131f34bc6 100644 --- a/tests/ui/rc_clone_in_vec_init/arc.rs +++ b/tests/ui/rc_clone_in_vec_init/arc.rs @@ -8,8 +8,6 @@ fn main() {} fn should_warn_simple_case() { let v = vec![Arc::new("x".to_string()); 2]; //~^ rc_clone_in_vec_init - - } fn should_warn_simple_case_with_big_indentation() { @@ -19,8 +17,6 @@ fn should_warn_simple_case_with_big_indentation() { if true { let v = vec![Arc::new("x".to_string()); 2]; //~^ rc_clone_in_vec_init - - } } } diff --git a/tests/ui/rc_clone_in_vec_init/arc.stderr b/tests/ui/rc_clone_in_vec_init/arc.stderr index 5d70bfc853636..598d3c0ae5774 100644 --- a/tests/ui/rc_clone_in_vec_init/arc.stderr +++ b/tests/ui/rc_clone_in_vec_init/arc.stderr @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/arc.rs:20:21 + --> tests/ui/rc_clone_in_vec_init/arc.rs:18:21 | LL | let v = vec![Arc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/arc.rs:29:13 + --> tests/ui/rc_clone_in_vec_init/arc.rs:25:13 | LL | let v = vec![ | _____________^ @@ -74,7 +74,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/arc.rs:41:14 + --> tests/ui/rc_clone_in_vec_init/arc.rs:37:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_clone_in_vec_init/rc.rs b/tests/ui/rc_clone_in_vec_init/rc.rs index e934087985859..d5af17c29e1d8 100644 --- a/tests/ui/rc_clone_in_vec_init/rc.rs +++ b/tests/ui/rc_clone_in_vec_init/rc.rs @@ -9,8 +9,6 @@ fn main() {} fn should_warn_simple_case() { let v = vec![Rc::new("x".to_string()); 2]; //~^ rc_clone_in_vec_init - - } fn should_warn_simple_case_with_big_indentation() { @@ -20,8 +18,6 @@ fn should_warn_simple_case_with_big_indentation() { if true { let v = vec![Rc::new("x".to_string()); 2]; //~^ rc_clone_in_vec_init - - } } } diff --git a/tests/ui/rc_clone_in_vec_init/rc.stderr b/tests/ui/rc_clone_in_vec_init/rc.stderr index 57ea31f9ff896..60d7f33ada9c5 100644 --- a/tests/ui/rc_clone_in_vec_init/rc.stderr +++ b/tests/ui/rc_clone_in_vec_init/rc.stderr @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/rc.rs:21:21 + --> tests/ui/rc_clone_in_vec_init/rc.rs:19:21 | LL | let v = vec![Rc::new("x".to_string()); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/rc.rs:30:13 + --> tests/ui/rc_clone_in_vec_init/rc.rs:26:13 | LL | let v = vec![ | _____________^ @@ -74,7 +74,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/rc.rs:42:14 + --> tests/ui/rc_clone_in_vec_init/rc.rs:38:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_clone_in_vec_init/weak.rs b/tests/ui/rc_clone_in_vec_init/weak.rs index af1ec1601dcf6..add09b6ba859e 100644 --- a/tests/ui/rc_clone_in_vec_init/weak.rs +++ b/tests/ui/rc_clone_in_vec_init/weak.rs @@ -10,20 +10,14 @@ fn should_warn_simple_case() { let v = vec![SyncWeak::::new(); 2]; //~^ rc_clone_in_vec_init - let v2 = vec![UnSyncWeak::::new(); 2]; //~^ rc_clone_in_vec_init - - let v = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; //~^ rc_clone_in_vec_init - let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; //~^ rc_clone_in_vec_init - - } fn should_warn_simple_case_with_big_indentation() { @@ -34,11 +28,8 @@ fn should_warn_simple_case_with_big_indentation() { let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; //~^ rc_clone_in_vec_init - let v2 = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; //~^ rc_clone_in_vec_init - - } } } diff --git a/tests/ui/rc_clone_in_vec_init/weak.stderr b/tests/ui/rc_clone_in_vec_init/weak.stderr index 26974dd7446cc..8bd018ab586cb 100644 --- a/tests/ui/rc_clone_in_vec_init/weak.stderr +++ b/tests/ui/rc_clone_in_vec_init/weak.stderr @@ -24,7 +24,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/weak.rs:14:14 + --> tests/ui/rc_clone_in_vec_init/weak.rs:13:14 | LL | let v2 = vec![UnSyncWeak::::new(); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -47,7 +47,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/weak.rs:19:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:16:13 | LL | let v = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/weak.rs:23:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:19:13 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +93,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/weak.rs:34:21 + --> tests/ui/rc_clone_in_vec_init/weak.rs:28:21 | LL | let v = vec![Arc::downgrade(&Arc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -116,7 +116,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/weak.rs:38:22 + --> tests/ui/rc_clone_in_vec_init/weak.rs:31:22 | LL | let v2 = vec![Rc::downgrade(&Rc::new("x".to_string())); 2]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/weak.rs:47:13 + --> tests/ui/rc_clone_in_vec_init/weak.rs:38:13 | LL | let v = vec![ | _____________^ @@ -166,7 +166,7 @@ LL ~ }; | error: initializing a reference-counted pointer in `vec![elem; len]` - --> tests/ui/rc_clone_in_vec_init/weak.rs:59:14 + --> tests/ui/rc_clone_in_vec_init/weak.rs:50:14 | LL | let v1 = vec![ | ______________^ diff --git a/tests/ui/rc_mutex.rs b/tests/ui/rc_mutex.rs index cccbc751f4174..c8700e13b11e5 100644 --- a/tests/ui/rc_mutex.rs +++ b/tests/ui/rc_mutex.rs @@ -33,7 +33,6 @@ fn test2(foo: Rc>) {} fn test3(foo: Rc>>) {} //~^ rc_mutex - // All of these test should be allowed because they are part of the // public api and `avoid_breaking_exported_api` is `false` by default. pub fn pub_test1(foo: Rc>) {} diff --git a/tests/ui/read_line_without_trim.fixed b/tests/ui/read_line_without_trim.fixed index 9263a398ad850..e7f208e78d203 100644 --- a/tests/ui/read_line_without_trim.fixed +++ b/tests/ui/read_line_without_trim.fixed @@ -41,14 +41,14 @@ fn main() { let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); if input.trim_end() == "foo" { - //~^ read_line_without_trim + //~^ read_line_without_trim println!("This will never ever execute!"); } let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); if input.trim_end().ends_with("foo") { - //~^ read_line_without_trim + //~^ read_line_without_trim println!("Neither will this"); } } diff --git a/tests/ui/read_line_without_trim.rs b/tests/ui/read_line_without_trim.rs index ba5196bb51ba8..6664278b5a876 100644 --- a/tests/ui/read_line_without_trim.rs +++ b/tests/ui/read_line_without_trim.rs @@ -41,14 +41,14 @@ fn main() { let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); if input == "foo" { - //~^ read_line_without_trim + //~^ read_line_without_trim println!("This will never ever execute!"); } let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); if input.ends_with("foo") { - //~^ read_line_without_trim + //~^ read_line_without_trim println!("Neither will this"); } } diff --git a/tests/ui/readonly_write_lock.fixed b/tests/ui/readonly_write_lock.fixed index 21822444f35f2..0cb91247232b0 100644 --- a/tests/ui/readonly_write_lock.fixed +++ b/tests/ui/readonly_write_lock.fixed @@ -16,7 +16,6 @@ fn main() { let writer = lock.read().unwrap(); //~^ readonly_write_lock - dbg!(&writer); } diff --git a/tests/ui/readonly_write_lock.rs b/tests/ui/readonly_write_lock.rs index b3fd1a611cc84..843755fe792c9 100644 --- a/tests/ui/readonly_write_lock.rs +++ b/tests/ui/readonly_write_lock.rs @@ -16,7 +16,6 @@ fn main() { let writer = lock.write().unwrap(); //~^ readonly_write_lock - dbg!(&writer); } diff --git a/tests/ui/readonly_write_lock.stderr b/tests/ui/readonly_write_lock.stderr index a3f88e92bfae2..6b1ef3c4720f0 100644 --- a/tests/ui/readonly_write_lock.stderr +++ b/tests/ui/readonly_write_lock.stderr @@ -8,7 +8,7 @@ LL | let writer = lock.write().unwrap(); = help: to override `-D warnings` add `#[allow(clippy::readonly_write_lock)]` error: this write lock is used only for reading - --> tests/ui/readonly_write_lock.rs:24:22 + --> tests/ui/readonly_write_lock.rs:23:22 | LL | let writer = lock.write().unwrap(); | ^^^^^^^^^^^^ help: consider using a read lock instead: `lock.read()` diff --git a/tests/ui/recursive_format_impl.rs b/tests/ui/recursive_format_impl.rs index d9b3a15eb9b1c..9f46fef62354a 100644 --- a/tests/ui/recursive_format_impl.rs +++ b/tests/ui/recursive_format_impl.rs @@ -30,8 +30,6 @@ impl fmt::Display for A { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_string()) //~^ recursive_format_impl - - } } @@ -77,7 +75,6 @@ impl std::fmt::Display for G { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self) //~^ recursive_format_impl - } } @@ -88,7 +85,6 @@ impl std::fmt::Display for H { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", &self) //~^ recursive_format_impl - } } @@ -96,7 +92,6 @@ impl std::fmt::Debug for H { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:?}", &self) //~^ recursive_format_impl - } } @@ -107,7 +102,6 @@ impl std::fmt::Display for H2 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", &&&self) //~^ recursive_format_impl - } } @@ -183,7 +177,6 @@ impl std::fmt::Display for J { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", &*self) //~^ recursive_format_impl - } } @@ -191,7 +184,6 @@ impl std::fmt::Debug for J { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", &*self) //~^ recursive_format_impl - } } @@ -209,7 +201,6 @@ impl std::fmt::Display for J2 { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", *self) //~^ recursive_format_impl - } } @@ -227,7 +218,6 @@ impl std::fmt::Display for J3 { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", **&&*self) //~^ recursive_format_impl - } } @@ -245,7 +235,6 @@ impl std::fmt::Display for J4 { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", &&**&&*self) //~^ recursive_format_impl - } } diff --git a/tests/ui/recursive_format_impl.stderr b/tests/ui/recursive_format_impl.stderr index 515f18d5b4774..31960c7193b44 100644 --- a/tests/ui/recursive_format_impl.stderr +++ b/tests/ui/recursive_format_impl.stderr @@ -8,7 +8,7 @@ LL | write!(f, "{}", self.to_string()) = help: to override `-D warnings` add `#[allow(clippy::recursive_format_impl)]` error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:78:9 + --> tests/ui/recursive_format_impl.rs:76:9 | LL | write!(f, "{}", self) | ^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | write!(f, "{}", self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:89:9 + --> tests/ui/recursive_format_impl.rs:86:9 | LL | write!(f, "{}", &self) | ^^^^^^^^^^^^^^^^^^^^^^ @@ -24,7 +24,7 @@ LL | write!(f, "{}", &self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Debug` in `impl Debug` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:97:9 + --> tests/ui/recursive_format_impl.rs:93:9 | LL | write!(f, "{:?}", &self) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | write!(f, "{:?}", &self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:108:9 + --> tests/ui/recursive_format_impl.rs:103:9 | LL | write!(f, "{}", &&&self) | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | write!(f, "{}", &&&self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:184:9 + --> tests/ui/recursive_format_impl.rs:178:9 | LL | write!(f, "{}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | write!(f, "{}", &*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Debug` in `impl Debug` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:192:9 + --> tests/ui/recursive_format_impl.rs:185:9 | LL | write!(f, "{:?}", &*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | write!(f, "{:?}", &*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:210:9 + --> tests/ui/recursive_format_impl.rs:202:9 | LL | write!(f, "{}", *self) | ^^^^^^^^^^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | write!(f, "{}", *self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:228:9 + --> tests/ui/recursive_format_impl.rs:219:9 | LL | write!(f, "{}", **&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | write!(f, "{}", **&&*self) = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) error: using `self` as `Display` in `impl Display` will cause infinite recursion - --> tests/ui/recursive_format_impl.rs:246:9 + --> tests/ui/recursive_format_impl.rs:236:9 | LL | write!(f, "{}", &&**&&*self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_allocation.rs b/tests/ui/redundant_allocation.rs index e3bf6c58b153a..0562f7dcc7614 100644 --- a/tests/ui/redundant_allocation.rs +++ b/tests/ui/redundant_allocation.rs @@ -16,26 +16,18 @@ mod outer_box { pub fn box_test6(foo: Box>) {} //~^ redundant_allocation - - pub fn box_test7(foo: Box>) {} //~^ redundant_allocation - - pub fn box_test8() -> Box>> { - //~^ redundant_allocation - + //~^ redundant_allocation unimplemented!(); } pub fn box_test9(foo: Box>) -> Box>> { - //~^ redundant_allocation - //~| redundant_allocation - - - + //~^ redundant_allocation + //~| redundant_allocation unimplemented!(); } @@ -50,26 +42,18 @@ mod outer_rc { pub fn rc_test5(a: Rc>) {} //~^ redundant_allocation - - pub fn rc_test7(a: Rc>) {} //~^ redundant_allocation - - pub fn rc_test8() -> Rc>> { - //~^ redundant_allocation - + //~^ redundant_allocation unimplemented!(); } pub fn rc_test9(foo: Rc>) -> Rc>> { - //~^ redundant_allocation - //~| redundant_allocation - - - + //~^ redundant_allocation + //~| redundant_allocation unimplemented!(); } @@ -84,26 +68,18 @@ mod outer_arc { pub fn arc_test5(a: Arc>) {} //~^ redundant_allocation - - pub fn arc_test6(a: Arc>) {} //~^ redundant_allocation - - pub fn arc_test8() -> Arc>> { - //~^ redundant_allocation - + //~^ redundant_allocation unimplemented!(); } pub fn arc_test9(foo: Arc>) -> Arc>> { - //~^ redundant_allocation - //~| redundant_allocation - - - + //~^ redundant_allocation + //~| redundant_allocation unimplemented!(); } @@ -128,8 +104,6 @@ mod box_dyn { pub fn test_arc(_: Arc>) {} pub fn test_rc_box(_: Rc>>) {} //~^ redundant_allocation - - } // https://github.com/rust-lang/rust-clippy/issues/8604 @@ -164,19 +138,14 @@ mod box_fat_ptr { pub fn test_rc_box_str(_: Rc>>) {} //~^ redundant_allocation - pub fn test_rc_box_slice(_: Rc>>) {} //~^ redundant_allocation - pub fn test_rc_box_path(_: Rc>>) {} //~^ redundant_allocation - pub fn test_rc_box_custom(_: Rc>>) {} //~^ redundant_allocation - - } // https://github.com/rust-lang/rust-clippy/issues/11417 diff --git a/tests/ui/redundant_allocation.stderr b/tests/ui/redundant_allocation.stderr index 407cdef1c20de..44d30f95d7bc3 100644 --- a/tests/ui/redundant_allocation.stderr +++ b/tests/ui/redundant_allocation.stderr @@ -10,7 +10,7 @@ LL | pub fn box_test6(foo: Box>) {} = help: to override `-D warnings` add `#[allow(clippy::redundant_allocation)]` error: usage of `Box>` - --> tests/ui/redundant_allocation.rs:21:30 + --> tests/ui/redundant_allocation.rs:19:30 | LL | pub fn box_test7(foo: Box>) {} | ^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | pub fn box_test7(foo: Box>) {} = help: consider using just `Box` or `Arc` error: usage of `Box>>` - --> tests/ui/redundant_allocation.rs:26:27 + --> tests/ui/redundant_allocation.rs:22:27 | LL | pub fn box_test8() -> Box>> { | ^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | pub fn box_test8() -> Box>> { = help: consider using just `Box>` or `Rc>` error: usage of `Box>` - --> tests/ui/redundant_allocation.rs:33:30 + --> tests/ui/redundant_allocation.rs:28:30 | LL | pub fn box_test9(foo: Box>) -> Box>> { | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = help: consider using just `Box` or `Arc` error: usage of `Box>>` - --> tests/ui/redundant_allocation.rs:33:46 + --> tests/ui/redundant_allocation.rs:28:46 | LL | pub fn box_test9(foo: Box>) -> Box>> { | ^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | pub fn box_test9(foo: Box>) -> Box>> { = help: consider using just `Box>` or `Arc>` error: usage of `Rc>` - --> tests/ui/redundant_allocation.rs:50:24 + --> tests/ui/redundant_allocation.rs:42:24 | LL | pub fn rc_test5(a: Rc>) {} | ^^^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | pub fn rc_test5(a: Rc>) {} = help: consider using just `Rc` or `Box` error: usage of `Rc>` - --> tests/ui/redundant_allocation.rs:55:24 + --> tests/ui/redundant_allocation.rs:45:24 | LL | pub fn rc_test7(a: Rc>) {} | ^^^^^^^^^^^^^ @@ -64,7 +64,7 @@ LL | pub fn rc_test7(a: Rc>) {} = help: consider using just `Rc` or `Arc` error: usage of `Rc>>` - --> tests/ui/redundant_allocation.rs:60:26 + --> tests/ui/redundant_allocation.rs:48:26 | LL | pub fn rc_test8() -> Rc>> { | ^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | pub fn rc_test8() -> Rc>> { = help: consider using just `Rc>` or `Box>` error: usage of `Rc>` - --> tests/ui/redundant_allocation.rs:67:29 + --> tests/ui/redundant_allocation.rs:54:29 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { | ^^^^^^^^^^ @@ -82,7 +82,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = help: consider using just `Rc` or `Arc` error: usage of `Rc>>` - --> tests/ui/redundant_allocation.rs:67:44 + --> tests/ui/redundant_allocation.rs:54:44 | LL | pub fn rc_test9(foo: Rc>) -> Rc>> { | ^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | pub fn rc_test9(foo: Rc>) -> Rc>> { = help: consider using just `Rc>` or `Arc>` error: usage of `Arc>` - --> tests/ui/redundant_allocation.rs:84:25 + --> tests/ui/redundant_allocation.rs:68:25 | LL | pub fn arc_test5(a: Arc>) {} | ^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ LL | pub fn arc_test5(a: Arc>) {} = help: consider using just `Arc` or `Box` error: usage of `Arc>` - --> tests/ui/redundant_allocation.rs:89:25 + --> tests/ui/redundant_allocation.rs:71:25 | LL | pub fn arc_test6(a: Arc>) {} | ^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | pub fn arc_test6(a: Arc>) {} = help: consider using just `Arc` or `Rc` error: usage of `Arc>>` - --> tests/ui/redundant_allocation.rs:94:27 + --> tests/ui/redundant_allocation.rs:74:27 | LL | pub fn arc_test8() -> Arc>> { | ^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL | pub fn arc_test8() -> Arc>> { = help: consider using just `Arc>` or `Box>` error: usage of `Arc>` - --> tests/ui/redundant_allocation.rs:101:30 + --> tests/ui/redundant_allocation.rs:80:30 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { | ^^^^^^^^^^ @@ -127,7 +127,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = help: consider using just `Arc` or `Rc` error: usage of `Arc>>` - --> tests/ui/redundant_allocation.rs:101:45 + --> tests/ui/redundant_allocation.rs:80:45 | LL | pub fn arc_test9(foo: Arc>) -> Arc>> { | ^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | pub fn arc_test9(foo: Arc>) -> Arc>> { = help: consider using just `Arc>` or `Rc>` error: usage of `Rc>>` - --> tests/ui/redundant_allocation.rs:129:27 + --> tests/ui/redundant_allocation.rs:105:27 | LL | pub fn test_rc_box(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | pub fn test_rc_box(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> tests/ui/redundant_allocation.rs:164:31 + --> tests/ui/redundant_allocation.rs:138:31 | LL | pub fn test_rc_box_str(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL | pub fn test_rc_box_str(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> tests/ui/redundant_allocation.rs:168:33 + --> tests/ui/redundant_allocation.rs:141:33 | LL | pub fn test_rc_box_slice(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | pub fn test_rc_box_slice(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> tests/ui/redundant_allocation.rs:172:32 + --> tests/ui/redundant_allocation.rs:144:32 | LL | pub fn test_rc_box_path(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^ @@ -172,7 +172,7 @@ LL | pub fn test_rc_box_path(_: Rc>>) {} = help: consider using just `Rc>` or `Box>` error: usage of `Rc>>` - --> tests/ui/redundant_allocation.rs:176:34 + --> tests/ui/redundant_allocation.rs:147:34 | LL | pub fn test_rc_box_custom(_: Rc>>) {} | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_clone.fixed b/tests/ui/redundant_clone.fixed index e0657246bd00d..23c00b34a00a8 100644 --- a/tests/ui/redundant_clone.fixed +++ b/tests/ui/redundant_clone.fixed @@ -221,7 +221,7 @@ fn clone_then_move_cloned() { let x = Alpha; // ok, data is moved while the clone is in use. foo(&x, move || { - //~^ redundant_clone + //~^ redundant_clone let _ = x; }); diff --git a/tests/ui/redundant_clone.rs b/tests/ui/redundant_clone.rs index 53e60a44d7dff..f9fe8ba0236d0 100644 --- a/tests/ui/redundant_clone.rs +++ b/tests/ui/redundant_clone.rs @@ -221,7 +221,7 @@ fn clone_then_move_cloned() { let x = Alpha; // ok, data is moved while the clone is in use. foo(&x.clone(), move || { - //~^ redundant_clone + //~^ redundant_clone let _ = x; }); diff --git a/tests/ui/redundant_closure_call_early.rs b/tests/ui/redundant_closure_call_early.rs index 2f4feeed9ae63..722f7c03909f0 100644 --- a/tests/ui/redundant_closure_call_early.rs +++ b/tests/ui/redundant_closure_call_early.rs @@ -9,13 +9,10 @@ fn main() { let mut k = (|m| m + 1)(i); //~^ redundant_closure_call - - // lint here k = (|a, b| a * b)(1, 5); //~^ redundant_closure_call - // don't lint these #[allow(clippy::needless_return)] (|| return 2)(); diff --git a/tests/ui/redundant_closure_call_early.stderr b/tests/ui/redundant_closure_call_early.stderr index 4cfde9a64b578..1dd24baf9daeb 100644 --- a/tests/ui/redundant_closure_call_early.stderr +++ b/tests/ui/redundant_closure_call_early.stderr @@ -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 - --> tests/ui/redundant_closure_call_early.rs:15:9 + --> tests/ui/redundant_closure_call_early.rs:13:9 | LL | k = (|a, b| a * b)(1, 5); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_closure_call_fixable.fixed b/tests/ui/redundant_closure_call_fixable.fixed index 528a2000693ee..099c118e64e35 100644 --- a/tests/ui/redundant_closure_call_fixable.fixed +++ b/tests/ui/redundant_closure_call_fixable.fixed @@ -15,13 +15,13 @@ fn main() { let a = 42; //~^ redundant_closure_call let b = async { - //~^ redundant_closure_call + //~^ redundant_closure_call let x = something().await; let y = something_else().await; x * y }; let c = { - //~^ redundant_closure_call + //~^ redundant_closure_call let x = 21; let y = 2; x * y diff --git a/tests/ui/redundant_closure_call_fixable.rs b/tests/ui/redundant_closure_call_fixable.rs index c3cbd8d61ada1..da5dd7ef263b6 100644 --- a/tests/ui/redundant_closure_call_fixable.rs +++ b/tests/ui/redundant_closure_call_fixable.rs @@ -15,13 +15,13 @@ fn main() { let a = (|| 42)(); //~^ redundant_closure_call let b = (async || { - //~^ redundant_closure_call + //~^ redundant_closure_call let x = something().await; let y = something_else().await; x * y })(); let c = (|| { - //~^ redundant_closure_call + //~^ redundant_closure_call let x = 21; let y = 2; x * y diff --git a/tests/ui/redundant_closure_call_late.rs b/tests/ui/redundant_closure_call_late.rs index c697fedb871e6..fd997b1b5fa7b 100644 --- a/tests/ui/redundant_closure_call_late.rs +++ b/tests/ui/redundant_closure_call_late.rs @@ -16,8 +16,6 @@ fn main() { i = redun_closure(); //~^ redundant_closure_call - - // shadowed closures are supported, lint here let shadowed_closure = || 1; i = shadowed_closure(); @@ -27,7 +25,6 @@ fn main() { i = shadowed_closure(); //~^ redundant_closure_call - // don't lint here let shadowed_closure = || 2; i = shadowed_closure(); diff --git a/tests/ui/redundant_closure_call_late.stderr b/tests/ui/redundant_closure_call_late.stderr index abe7ac7b65952..ce2a21c23872e 100644 --- a/tests/ui/redundant_closure_call_late.stderr +++ b/tests/ui/redundant_closure_call_late.stderr @@ -8,13 +8,13 @@ LL | i = redun_closure(); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure_call)]` error: closure called just once immediately after it was declared - --> tests/ui/redundant_closure_call_late.rs:23:5 + --> tests/ui/redundant_closure_call_late.rs:21:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ error: closure called just once immediately after it was declared - --> tests/ui/redundant_closure_call_late.rs:27:5 + --> tests/ui/redundant_closure_call_late.rs:25:5 | LL | i = shadowed_closure(); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/redundant_else.fixed b/tests/ui/redundant_else.fixed index 4dc3253302490..8a3279f50180b 100644 --- a/tests/ui/redundant_else.fixed +++ b/tests/ui/redundant_else.fixed @@ -10,7 +10,7 @@ fn main() { } //~^ redundant_else - println!("yet don't pull down your hedge."); + println!("yet don't pull down your hedge."); // continue if foo() { println!("He that lies down with Dogs,"); @@ -18,7 +18,7 @@ fn main() { } //~^ redundant_else - println!("shall rise up with fleas."); + println!("shall rise up with fleas."); // match block if foo() { match foo() { @@ -28,7 +28,7 @@ fn main() { } //~^ redundant_else - println!("You may delay, but time will not."); + println!("You may delay, but time will not."); } // else if if foo() { @@ -38,7 +38,7 @@ fn main() { } //~^ redundant_else - println!("A fat kitchen makes a lean will."); + println!("A fat kitchen makes a lean will."); // let binding outside of block let _ = { if foo() { @@ -46,7 +46,7 @@ fn main() { } //~^ redundant_else - 1 + 1 }; // else if with let binding outside of block let _ = { @@ -57,7 +57,7 @@ fn main() { } //~^ redundant_else - 2 + 2 }; // inside if let let _ = if let Some(1) = foo() { @@ -67,7 +67,7 @@ fn main() { } //~^ redundant_else - 1 + 1 } else { 1 }; diff --git a/tests/ui/redundant_else.rs b/tests/ui/redundant_else.rs index 842cb4bc94113..78abf4247a568 100644 --- a/tests/ui/redundant_else.rs +++ b/tests/ui/redundant_else.rs @@ -8,7 +8,7 @@ fn main() { println!("Love your neighbor;"); break; } else { - //~^ redundant_else + //~^ redundant_else println!("yet don't pull down your hedge."); } @@ -17,7 +17,7 @@ fn main() { println!("He that lies down with Dogs,"); continue; } else { - //~^ redundant_else + //~^ redundant_else println!("shall rise up with fleas."); } @@ -28,7 +28,7 @@ fn main() { _ => return, } } else { - //~^ redundant_else + //~^ redundant_else println!("You may delay, but time will not."); } @@ -39,7 +39,7 @@ fn main() { } else if foo() { return; } else { - //~^ redundant_else + //~^ redundant_else println!("A fat kitchen makes a lean will."); } @@ -48,7 +48,7 @@ fn main() { if foo() { return; } else { - //~^ redundant_else + //~^ redundant_else 1 } @@ -60,7 +60,7 @@ fn main() { } else if foo() { return; } else { - //~^ redundant_else + //~^ redundant_else 2 } @@ -71,7 +71,7 @@ fn main() { if foo() { return; } else { - //~^ redundant_else + //~^ redundant_else 1 } diff --git a/tests/ui/redundant_else.stderr b/tests/ui/redundant_else.stderr index 2cb0fd6f127fa..0902c97af0dd7 100644 --- a/tests/ui/redundant_else.stderr +++ b/tests/ui/redundant_else.stderr @@ -16,7 +16,7 @@ help: remove the `else` block and move the contents out LL ~ } LL + LL + -LL + println!("yet don't pull down your hedge."); +LL + println!("yet don't pull down your hedge."); | error: redundant else block @@ -35,7 +35,7 @@ help: remove the `else` block and move the contents out LL ~ } LL + LL + -LL + println!("shall rise up with fleas."); +LL + println!("shall rise up with fleas."); | error: redundant else block @@ -54,7 +54,7 @@ help: remove the `else` block and move the contents out LL ~ } LL + LL + -LL + println!("You may delay, but time will not."); +LL + println!("You may delay, but time will not."); | error: redundant else block @@ -73,7 +73,7 @@ help: remove the `else` block and move the contents out LL ~ } LL + LL + -LL + println!("A fat kitchen makes a lean will."); +LL + println!("A fat kitchen makes a lean will."); | error: redundant else block @@ -92,7 +92,7 @@ help: remove the `else` block and move the contents out LL ~ } LL + LL + -LL + 1 +LL + 1 | error: redundant else block @@ -111,7 +111,7 @@ help: remove the `else` block and move the contents out LL ~ } LL + LL + -LL + 2 +LL + 2 | error: redundant else block @@ -130,7 +130,7 @@ help: remove the `else` block and move the contents out LL ~ } LL + LL + -LL + 1 +LL + 1 | error: aborting due to 7 previous errors diff --git a/tests/ui/redundant_field_names.fixed b/tests/ui/redundant_field_names.fixed index 142828a2b2d86..4c922030eb66b 100644 --- a/tests/ui/redundant_field_names.fixed +++ b/tests/ui/redundant_field_names.fixed @@ -34,7 +34,6 @@ fn main() { //~^ redundant_field_names age, //~^ redundant_field_names - name, //should be ok buzz: fizz, //should be ok foo: foo::BAR, //should be ok diff --git a/tests/ui/redundant_field_names.rs b/tests/ui/redundant_field_names.rs index 15fef11a0408a..7d03e269cf25e 100644 --- a/tests/ui/redundant_field_names.rs +++ b/tests/ui/redundant_field_names.rs @@ -34,7 +34,6 @@ fn main() { //~^ redundant_field_names age: age, //~^ redundant_field_names - name, //should be ok buzz: fizz, //should be ok foo: foo::BAR, //should be ok diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index 78b8a4f1118e5..5554c28b7cff3 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -14,37 +14,37 @@ LL | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization - --> tests/ui/redundant_field_names.rs:57:25 + --> tests/ui/redundant_field_names.rs:56:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> tests/ui/redundant_field_names.rs:59:23 + --> tests/ui/redundant_field_names.rs:58:23 | LL | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> tests/ui/redundant_field_names.rs:61:21 + --> tests/ui/redundant_field_names.rs:60:21 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> tests/ui/redundant_field_names.rs:61:35 + --> tests/ui/redundant_field_names.rs:60:35 | LL | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> tests/ui/redundant_field_names.rs:65:32 + --> tests/ui/redundant_field_names.rs:64:32 | LL | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> tests/ui/redundant_field_names.rs:78:25 + --> tests/ui/redundant_field_names.rs:77:25 | LL | let _ = S { v: v }; | ^^^^ help: replace it with: `v` @@ -55,7 +55,7 @@ LL | internal!(v); = note: this error originates in the macro `internal` (in Nightly builds, run with -Z macro-backtrace for more info) error: redundant field names in struct initialization - --> tests/ui/redundant_field_names.rs:107:25 + --> tests/ui/redundant_field_names.rs:106:25 | LL | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` diff --git a/tests/ui/redundant_guards.fixed b/tests/ui/redundant_guards.fixed index c7e6f44ad83e6..9dd9d341db2ef 100644 --- a/tests/ui/redundant_guards.fixed +++ b/tests/ui/redundant_guards.fixed @@ -52,7 +52,7 @@ fn main() { Some(Some(1)) if true => .., //~^ redundant_guards Some(Some(1)) => { - //~^ redundant_guards + //~^ redundant_guards println!("a"); .. }, diff --git a/tests/ui/redundant_guards.rs b/tests/ui/redundant_guards.rs index d3c55c18884d2..e9950d3bbd1d2 100644 --- a/tests/ui/redundant_guards.rs +++ b/tests/ui/redundant_guards.rs @@ -52,7 +52,7 @@ fn main() { Some(x) if matches!(x, Some(1) if true) => .., //~^ redundant_guards Some(x) if matches!(x, Some(1)) => { - //~^ redundant_guards + //~^ redundant_guards println!("a"); .. }, diff --git a/tests/ui/redundant_pattern_matching_drop_order.fixed b/tests/ui/redundant_pattern_matching_drop_order.fixed index 4de47a1ad3eec..1141b5db3ebf4 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.fixed +++ b/tests/ui/redundant_pattern_matching_drop_order.fixed @@ -22,7 +22,7 @@ fn main() { //~^ redundant_pattern_matching } if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching } else { } if Ok::<_, std::sync::MutexGuard<()>>(()).is_ok() {} @@ -46,7 +46,7 @@ fn main() { //~^ redundant_pattern_matching } if None::>.is_none() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching } else { } @@ -69,7 +69,7 @@ fn main() { //~^ redundant_pattern_matching } if Pending::>.is_pending() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching } else { } diff --git a/tests/ui/redundant_pattern_matching_drop_order.rs b/tests/ui/redundant_pattern_matching_drop_order.rs index 4e37837c1fe6b..f60ddf4683096 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.rs +++ b/tests/ui/redundant_pattern_matching_drop_order.rs @@ -22,7 +22,7 @@ fn main() { //~^ redundant_pattern_matching } if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching } else { } if let Ok(_) = Ok::<_, std::sync::MutexGuard<()>>(()) {} @@ -46,7 +46,7 @@ fn main() { //~^ redundant_pattern_matching } if let None = None::> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching } else { } @@ -69,7 +69,7 @@ fn main() { //~^ redundant_pattern_matching } if let Pending = Pending::> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching } else { } diff --git a/tests/ui/redundant_pattern_matching_if_let_true.fixed b/tests/ui/redundant_pattern_matching_if_let_true.fixed index f40cd01d16cb4..980455da2ee7e 100644 --- a/tests/ui/redundant_pattern_matching_if_let_true.fixed +++ b/tests/ui/redundant_pattern_matching_if_let_true.fixed @@ -27,11 +27,11 @@ fn main() { //~^ redundant_pattern_matching if let (true, true) = (k > 1, k > 2) {} while k > 1 { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching k += 1; } while condition!() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching k += 1; } diff --git a/tests/ui/redundant_pattern_matching_if_let_true.rs b/tests/ui/redundant_pattern_matching_if_let_true.rs index 143c279e41c16..9cb0fe2e65f63 100644 --- a/tests/ui/redundant_pattern_matching_if_let_true.rs +++ b/tests/ui/redundant_pattern_matching_if_let_true.rs @@ -27,11 +27,11 @@ fn main() { //~^ redundant_pattern_matching if let (true, true) = (k > 1, k > 2) {} while let true = k > 1 { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching k += 1; } while let true = condition!() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching k += 1; } diff --git a/tests/ui/redundant_pattern_matching_ipaddr.fixed b/tests/ui/redundant_pattern_matching_ipaddr.fixed index 05ea8f75dc892..549c97d9534ad 100644 --- a/tests/ui/redundant_pattern_matching_ipaddr.fixed +++ b/tests/ui/redundant_pattern_matching_ipaddr.fixed @@ -52,7 +52,7 @@ fn main() { V6(Ipv6Addr::LOCALHOST).is_ipv4(); let _ = if V4(Ipv4Addr::LOCALHOST).is_ipv4() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching true } else { false @@ -61,10 +61,10 @@ fn main() { ipaddr_const(); let _ = if gen_ipaddr().is_ipv4() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if gen_ipaddr().is_ipv6() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 diff --git a/tests/ui/redundant_pattern_matching_ipaddr.rs b/tests/ui/redundant_pattern_matching_ipaddr.rs index 4ff9b2204e8a3..decb1396d56dd 100644 --- a/tests/ui/redundant_pattern_matching_ipaddr.rs +++ b/tests/ui/redundant_pattern_matching_ipaddr.rs @@ -44,31 +44,31 @@ fn main() { } match V4(Ipv4Addr::LOCALHOST) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching V4(_) => true, V6(_) => false, }; match V4(Ipv4Addr::LOCALHOST) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching V4(_) => false, V6(_) => true, }; match V6(Ipv6Addr::LOCALHOST) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching V4(_) => false, V6(_) => true, }; match V6(Ipv6Addr::LOCALHOST) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching V4(_) => true, V6(_) => false, }; let _ = if let V4(_) = V4(Ipv4Addr::LOCALHOST) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching true } else { false @@ -77,10 +77,10 @@ fn main() { ipaddr_const(); let _ = if let V4(_) = gen_ipaddr() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if let V6(_) = gen_ipaddr() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 @@ -105,13 +105,13 @@ const fn ipaddr_const() { //~^ redundant_pattern_matching match V4(Ipv4Addr::LOCALHOST) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching V4(_) => true, V6(_) => false, }; match V6(Ipv6Addr::LOCALHOST) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching V4(_) => false, V6(_) => true, }; diff --git a/tests/ui/redundant_pattern_matching_option.fixed b/tests/ui/redundant_pattern_matching_option.fixed index 7d45bb63a3951..711196f8e19bc 100644 --- a/tests/ui/redundant_pattern_matching_option.fixed +++ b/tests/ui/redundant_pattern_matching_option.fixed @@ -38,7 +38,7 @@ fn main() { //~^ redundant_pattern_matching if Some(42).is_some() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching foo(); } else { bar(); @@ -55,7 +55,7 @@ fn main() { let mut v = vec![1, 2, 3]; while v.pop().is_some() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching foo(); } @@ -78,10 +78,10 @@ fn main() { issue10803(); let _ = if gen_opt().is_some() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if gen_opt().is_none() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 diff --git a/tests/ui/redundant_pattern_matching_option.rs b/tests/ui/redundant_pattern_matching_option.rs index 3d02bade4409f..41106840cb8d1 100644 --- a/tests/ui/redundant_pattern_matching_option.rs +++ b/tests/ui/redundant_pattern_matching_option.rs @@ -38,7 +38,7 @@ fn main() { //~^ redundant_pattern_matching if let Some(_) = Some(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching foo(); } else { bar(); @@ -55,7 +55,7 @@ fn main() { let mut v = vec![1, 2, 3]; while let Some(_) = v.pop() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching foo(); } @@ -64,19 +64,19 @@ fn main() { if Some(42).is_some() {} match Some(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Some(_) => true, None => false, }; match None::<()> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Some(_) => false, None => true, }; let _ = match None::<()> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Some(_) => false, None => true, }; @@ -90,10 +90,10 @@ fn main() { issue10803(); let _ = if let Some(_) = gen_opt() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if let None = gen_opt() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 @@ -128,13 +128,13 @@ const fn issue6067() { //~^ redundant_pattern_matching match Some(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Some(_) => true, None => false, }; match None::<()> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Some(_) => false, None => true, }; @@ -152,25 +152,25 @@ fn issue10726() { let x = Some(42); match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Some(_) => true, _ => false, }; match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching None => true, _ => false, }; match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Some(_) => false, _ => true, }; match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching None => false, _ => true, }; diff --git a/tests/ui/redundant_pattern_matching_poll.fixed b/tests/ui/redundant_pattern_matching_poll.fixed index f3ffb6b3c7554..c8e18e8676f21 100644 --- a/tests/ui/redundant_pattern_matching_poll.fixed +++ b/tests/ui/redundant_pattern_matching_poll.fixed @@ -19,7 +19,7 @@ fn main() { //~^ redundant_pattern_matching if Ready(42).is_ready() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching foo(); } else { bar(); @@ -59,10 +59,10 @@ fn main() { poll_const(); let _ = if gen_poll().is_ready() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if gen_poll().is_pending() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 diff --git a/tests/ui/redundant_pattern_matching_poll.rs b/tests/ui/redundant_pattern_matching_poll.rs index 30e80b24521da..727503d21a54a 100644 --- a/tests/ui/redundant_pattern_matching_poll.rs +++ b/tests/ui/redundant_pattern_matching_poll.rs @@ -19,7 +19,7 @@ fn main() { //~^ redundant_pattern_matching if let Ready(_) = Ready(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching foo(); } else { bar(); @@ -47,19 +47,19 @@ fn main() { if Ready(42).is_ready() {} match Ready(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ready(_) => true, Pending => false, }; match Pending::<()> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ready(_) => false, Pending => true, }; let _ = match Pending::<()> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ready(_) => false, Pending => true, }; @@ -71,10 +71,10 @@ fn main() { poll_const(); let _ = if let Ready(_) = gen_poll() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if let Pending = gen_poll() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 @@ -103,13 +103,13 @@ const fn poll_const() { //~^ redundant_pattern_matching match Ready(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ready(_) => true, Pending => false, }; match Pending::<()> { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ready(_) => false, Pending => true, }; diff --git a/tests/ui/redundant_pattern_matching_result.fixed b/tests/ui/redundant_pattern_matching_result.fixed index 3bb9dacf4618e..1158796083147 100644 --- a/tests/ui/redundant_pattern_matching_result.fixed +++ b/tests/ui/redundant_pattern_matching_result.fixed @@ -53,10 +53,10 @@ fn main() { issue10803(); let _ = if gen_res().is_ok() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if gen_res().is_err() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 diff --git a/tests/ui/redundant_pattern_matching_result.rs b/tests/ui/redundant_pattern_matching_result.rs index f2632286ea3c1..35f8f91b31527 100644 --- a/tests/ui/redundant_pattern_matching_result.rs +++ b/tests/ui/redundant_pattern_matching_result.rs @@ -36,25 +36,25 @@ fn main() { } match Ok::(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => true, Err(_) => false, }; match Ok::(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => false, Err(_) => true, }; match Err::(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => false, Err(_) => true, }; match Err::(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => true, Err(_) => false, }; @@ -69,10 +69,10 @@ fn main() { issue10803(); let _ = if let Ok(_) = gen_res() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 1 } else if let Err(_) = gen_res() { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching 2 } else { 3 @@ -138,13 +138,13 @@ const fn issue6067() { //~^ redundant_pattern_matching match Ok::(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => true, Err(_) => false, }; match Err::(42) { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => false, Err(_) => true, }; @@ -155,25 +155,25 @@ fn issue10726() { let x: Result = Ok(42); match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => true, _ => false, }; match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Ok(_) => false, _ => true, }; match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Err(_) => true, _ => false, }; match x { - //~^ redundant_pattern_matching + //~^ redundant_pattern_matching Err(_) => false, _ => true, }; diff --git a/tests/ui/redundant_pub_crate.fixed b/tests/ui/redundant_pub_crate.fixed index 2072282bd2c3e..7424af19a9996 100644 --- a/tests/ui/redundant_pub_crate.fixed +++ b/tests/ui/redundant_pub_crate.fixed @@ -16,7 +16,7 @@ mod m1 { } pub mod m1_2 { - //~^ redundant_pub_crate + //~^ redundant_pub_crate //:^ private due to m1 fn f() {} pub fn g() {} // private due to m1_2 and m1 @@ -46,7 +46,7 @@ pub(crate) mod m2 { } pub mod m2_2 { - //~^ redundant_pub_crate + //~^ redundant_pub_crate //:^ already crate visible due to m2 fn f() {} pub fn g() {} // already crate visible due to m2_2 and m2 @@ -103,7 +103,7 @@ mod m4 { } pub mod m4_2 { - //~^ redundant_pub_crate + //~^ redundant_pub_crate //:^ private: not re-exported by `pub use m4::*` fn f() {} pub fn g() {} // private due to m4_2 diff --git a/tests/ui/redundant_pub_crate.rs b/tests/ui/redundant_pub_crate.rs index d8eaa8cdbc69f..a995ed5922892 100644 --- a/tests/ui/redundant_pub_crate.rs +++ b/tests/ui/redundant_pub_crate.rs @@ -16,7 +16,7 @@ mod m1 { } pub(crate) mod m1_2 { - //~^ redundant_pub_crate + //~^ redundant_pub_crate //:^ private due to m1 fn f() {} pub(crate) fn g() {} // private due to m1_2 and m1 @@ -46,7 +46,7 @@ pub(crate) mod m2 { } pub(crate) mod m2_2 { - //~^ redundant_pub_crate + //~^ redundant_pub_crate //:^ already crate visible due to m2 fn f() {} pub(crate) fn g() {} // already crate visible due to m2_2 and m2 @@ -103,7 +103,7 @@ mod m4 { } pub(crate) mod m4_2 { - //~^ redundant_pub_crate + //~^ redundant_pub_crate //:^ private: not re-exported by `pub use m4::*` fn f() {} pub(crate) fn g() {} // private due to m4_2 diff --git a/tests/ui/redundant_static_lifetimes_multiple.rs b/tests/ui/redundant_static_lifetimes_multiple.rs index 02f3829d8c03c..8cb6e44918426 100644 --- a/tests/ui/redundant_static_lifetimes_multiple.rs +++ b/tests/ui/redundant_static_lifetimes_multiple.rs @@ -5,31 +5,20 @@ const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ER //~^ redundant_static_lifetimes //~| redundant_static_lifetimes - - - const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; //~^ redundant_static_lifetimes //~| redundant_static_lifetimes - - static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static //~^ redundant_static_lifetimes //~| redundant_static_lifetimes - - static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static //~^ redundant_static_lifetimes //~| redundant_static_lifetimes - - static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; //~^ redundant_static_lifetimes //~| redundant_static_lifetimes - - fn main() {} diff --git a/tests/ui/redundant_static_lifetimes_multiple.stderr b/tests/ui/redundant_static_lifetimes_multiple.stderr index 486a23b06089c..aed16204f1c2e 100644 --- a/tests/ui/redundant_static_lifetimes_multiple.stderr +++ b/tests/ui/redundant_static_lifetimes_multiple.stderr @@ -14,49 +14,49 @@ LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; | -^^^^^^^---- help: consider removing `'static`: `&str` error: constants have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:11:29 + --> tests/ui/redundant_static_lifetimes_multiple.rs:8:29 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: constants have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:11:39 + --> tests/ui/redundant_static_lifetimes_multiple.rs:8:39 | LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:17:40 + --> tests/ui/redundant_static_lifetimes_multiple.rs:12:40 | LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:17:55 + --> tests/ui/redundant_static_lifetimes_multiple.rs:12:55 | LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:23:26 + --> tests/ui/redundant_static_lifetimes_multiple.rs:16:26 | LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` error: statics have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:23:38 + --> tests/ui/redundant_static_lifetimes_multiple.rs:16:38 | LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR: Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: statics have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:29:37 + --> tests/ui/redundant_static_lifetimes_multiple.rs:20:37 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: statics have by default a `'static` lifetime - --> tests/ui/redundant_static_lifetimes_multiple.rs:29:47 + --> tests/ui/redundant_static_lifetimes_multiple.rs:20:47 | LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` diff --git a/tests/ui/redundant_type_annotations.rs b/tests/ui/redundant_type_annotations.rs index 5023ec7ee5760..55c19d194a490 100644 --- a/tests/ui/redundant_type_annotations.rs +++ b/tests/ui/redundant_type_annotations.rs @@ -81,13 +81,11 @@ impl Pie { let v: u32 = self.return_an_int(); //~^ redundant_type_annotations - let v: &u32 = self.return_a_ref(); //~^ redundant_type_annotations let v: &Slice = self.return_a_ref_to_struct(); //~^ redundant_type_annotations - } } @@ -162,38 +160,29 @@ fn test_functions() { let _return: String = return_a_string(); //~^ redundant_type_annotations - let _return: Pie = return_a_struct(); //~^ redundant_type_annotations - let _return: Pizza = return_an_enum(); //~^ redundant_type_annotations - let _return: u32 = return_an_int(); //~^ redundant_type_annotations - let _return: String = String::new(); //~^ redundant_type_annotations - let new_pie: Pie = Pie::new(); //~^ redundant_type_annotations - let _return: u32 = new_pie.return_an_int(); //~^ redundant_type_annotations - let _return: u32 = Pie::associated_return_an_int(); //~^ redundant_type_annotations - let _return: String = Pie::associated_return_a_string(); //~^ redundant_type_annotations - } fn test_simple_types() { @@ -202,22 +191,17 @@ fn test_simple_types() { let _var: u32 = u32::MAX; //~^ redundant_type_annotations - let _var: u32 = 5_u32; //~^ redundant_type_annotations - let _var: &str = "test"; //~^ redundant_type_annotations - let _var: &[u8; 4] = b"test"; //~^ redundant_type_annotations - let _var: bool = false; //~^ redundant_type_annotations - } fn issue12212() { diff --git a/tests/ui/redundant_type_annotations.stderr b/tests/ui/redundant_type_annotations.stderr index de78ad5e4b489..d2f04cc4768e1 100644 --- a/tests/ui/redundant_type_annotations.stderr +++ b/tests/ui/redundant_type_annotations.stderr @@ -8,97 +8,97 @@ LL | let v: u32 = self.return_an_int(); = help: to override `-D warnings` add `#[allow(clippy::redundant_type_annotations)]` error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:85:9 + --> tests/ui/redundant_type_annotations.rs:84:9 | LL | let v: &u32 = self.return_a_ref(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:88:9 + --> tests/ui/redundant_type_annotations.rs:87:9 | LL | let v: &Slice = self.return_a_ref_to_struct(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:162:5 + --> tests/ui/redundant_type_annotations.rs:160:5 | LL | let _return: String = return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:166:5 + --> tests/ui/redundant_type_annotations.rs:163:5 | LL | let _return: Pie = return_a_struct(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:170:5 + --> tests/ui/redundant_type_annotations.rs:166:5 | LL | let _return: Pizza = return_an_enum(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:174:5 + --> tests/ui/redundant_type_annotations.rs:169:5 | LL | let _return: u32 = return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:178:5 + --> tests/ui/redundant_type_annotations.rs:172:5 | LL | let _return: String = String::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:182:5 + --> tests/ui/redundant_type_annotations.rs:175:5 | LL | let new_pie: Pie = Pie::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:186:5 + --> tests/ui/redundant_type_annotations.rs:178:5 | LL | let _return: u32 = new_pie.return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:190:5 + --> tests/ui/redundant_type_annotations.rs:181:5 | LL | let _return: u32 = Pie::associated_return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:194:5 + --> tests/ui/redundant_type_annotations.rs:184:5 | LL | let _return: String = Pie::associated_return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:202:5 + --> tests/ui/redundant_type_annotations.rs:191:5 | LL | let _var: u32 = u32::MAX; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:206:5 + --> tests/ui/redundant_type_annotations.rs:194:5 | LL | let _var: u32 = 5_u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:210:5 + --> tests/ui/redundant_type_annotations.rs:197:5 | LL | let _var: &str = "test"; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:214:5 + --> tests/ui/redundant_type_annotations.rs:200:5 | LL | let _var: &[u8; 4] = b"test"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation - --> tests/ui/redundant_type_annotations.rs:218:5 + --> tests/ui/redundant_type_annotations.rs:203:5 | LL | let _var: bool = false; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/ref_binding_to_reference.rs b/tests/ui/ref_binding_to_reference.rs index 55df796c41dc2..365fd8edea789 100644 --- a/tests/ui/ref_binding_to_reference.rs +++ b/tests/ui/ref_binding_to_reference.rs @@ -29,15 +29,13 @@ fn main() { let _: &&String = match Some(&x) { Some(ref x) => x, //~^ ref_binding_to_reference - - None => return, }; // Err, reference to a &String let _: &&String = match Some(&x) { Some(ref x) => { - //~^ ref_binding_to_reference + //~^ ref_binding_to_reference f1(x); f1(*x); @@ -50,13 +48,12 @@ fn main() { match Some(&x) { Some(ref x) => m2!(x), //~^ ref_binding_to_reference - None => return, } // Err, reference to a &String let _ = |&ref x: &&String| { - //~^ ref_binding_to_reference + //~^ ref_binding_to_reference let _: &&String = x; }; @@ -64,7 +61,7 @@ fn main() { // Err, reference to a &String fn f2<'a>(&ref x: &&'a String) -> &'a String { -//~^ ref_binding_to_reference + //~^ ref_binding_to_reference let _: &&String = x; *x @@ -73,7 +70,7 @@ fn f2<'a>(&ref x: &&'a String) -> &'a String { trait T1 { // Err, reference to a &String fn f(&ref x: &&String) { - //~^ ref_binding_to_reference + //~^ ref_binding_to_reference let _: &&String = x; } @@ -83,7 +80,7 @@ struct S; impl T1 for S { // Err, reference to a &String fn f(&ref x: &&String) { - //~^ ref_binding_to_reference + //~^ ref_binding_to_reference let _: &&String = x; } diff --git a/tests/ui/ref_binding_to_reference.stderr b/tests/ui/ref_binding_to_reference.stderr index 66e769ec61b33..d245355c139d2 100644 --- a/tests/ui/ref_binding_to_reference.stderr +++ b/tests/ui/ref_binding_to_reference.stderr @@ -12,7 +12,7 @@ LL | Some(x) => &x, | ~ ~~ error: this pattern creates a reference to a reference - --> tests/ui/ref_binding_to_reference.rs:39:14 + --> tests/ui/ref_binding_to_reference.rs:37:14 | LL | Some(ref x) => { | ^^^^^ @@ -28,7 +28,7 @@ LL ~ &x | error: this pattern creates a reference to a reference - --> tests/ui/ref_binding_to_reference.rs:51:14 + --> tests/ui/ref_binding_to_reference.rs:49:14 | LL | Some(ref x) => m2!(x), | ^^^^^ @@ -39,7 +39,7 @@ LL | Some(x) => m2!(&x), | ~ ~~ error: this pattern creates a reference to a reference - --> tests/ui/ref_binding_to_reference.rs:58:15 + --> tests/ui/ref_binding_to_reference.rs:55:15 | LL | let _ = |&ref x: &&String| { | ^^^^^ @@ -53,7 +53,7 @@ LL ~ let _: &&String = &x; | error: this pattern creates a reference to a reference - --> tests/ui/ref_binding_to_reference.rs:66:12 + --> tests/ui/ref_binding_to_reference.rs:63:12 | LL | fn f2<'a>(&ref x: &&'a String) -> &'a String { | ^^^^^ @@ -68,7 +68,7 @@ LL ~ x | error: this pattern creates a reference to a reference - --> tests/ui/ref_binding_to_reference.rs:75:11 + --> tests/ui/ref_binding_to_reference.rs:72:11 | LL | fn f(&ref x: &&String) { | ^^^^^ @@ -82,7 +82,7 @@ LL ~ let _: &&String = &x; | error: this pattern creates a reference to a reference - --> tests/ui/ref_binding_to_reference.rs:85:11 + --> tests/ui/ref_binding_to_reference.rs:82:11 | LL | fn f(&ref x: &&String) { | ^^^^^ diff --git a/tests/ui/ref_option/ref_option.all.fixed b/tests/ui/ref_option/ref_option.all.fixed index d7b0e13e5bb9d..4159e916f1995 100644 --- a/tests/ui/ref_option/ref_option.all.fixed +++ b/tests/ui/ref_option/ref_option.all.fixed @@ -12,17 +12,17 @@ fn opt_gen(a: Option<&T>) {} fn opt_string(a: std::option::Option<&String>) {} //~^ ref_option fn ret_string<'a>(p: &'a str) -> Option<&'a u8> { -//~^ ref_option + //~^ ref_option panic!() } fn ret_string_static() -> Option<&'static u8> { -//~^ ref_option + //~^ ref_option panic!() } fn mult_string(a: Option<&String>, b: Option<&Vec>) {} //~^ ref_option fn ret_box<'a>() -> Option<&'a Box> { -//~^ ref_option + //~^ ref_option panic!() } @@ -51,14 +51,14 @@ impl PubStruct { pub fn pub_opt_params(&self, a: Option<&()>) {} //~[all]^ ref_option pub fn pub_opt_ret(&self) -> Option<&String> { - //~[all]^ ref_option + //~[all]^ ref_option panic!() } fn private_opt_params(&self, a: Option<&()>) {} //~^ ref_option fn private_opt_ret(&self) -> Option<&String> { - //~^ ref_option + //~^ ref_option panic!() } } diff --git a/tests/ui/ref_option/ref_option.private.fixed b/tests/ui/ref_option/ref_option.private.fixed index 4036c6a08dcae..3b158befb926e 100644 --- a/tests/ui/ref_option/ref_option.private.fixed +++ b/tests/ui/ref_option/ref_option.private.fixed @@ -12,17 +12,17 @@ fn opt_gen(a: Option<&T>) {} fn opt_string(a: std::option::Option<&String>) {} //~^ ref_option fn ret_string<'a>(p: &'a str) -> Option<&'a u8> { -//~^ ref_option + //~^ ref_option panic!() } fn ret_string_static() -> Option<&'static u8> { -//~^ ref_option + //~^ ref_option panic!() } fn mult_string(a: Option<&String>, b: Option<&Vec>) {} //~^ ref_option fn ret_box<'a>() -> Option<&'a Box> { -//~^ ref_option + //~^ ref_option panic!() } @@ -51,14 +51,14 @@ impl PubStruct { pub fn pub_opt_params(&self, a: &Option<()>) {} //~[all]^ ref_option pub fn pub_opt_ret(&self) -> &Option { - //~[all]^ ref_option + //~[all]^ ref_option panic!() } fn private_opt_params(&self, a: Option<&()>) {} //~^ ref_option fn private_opt_ret(&self) -> Option<&String> { - //~^ ref_option + //~^ ref_option panic!() } } diff --git a/tests/ui/ref_option/ref_option.rs b/tests/ui/ref_option/ref_option.rs index 86b5c6fe896bb..35cd94174f8bc 100644 --- a/tests/ui/ref_option/ref_option.rs +++ b/tests/ui/ref_option/ref_option.rs @@ -12,17 +12,17 @@ fn opt_gen(a: &Option) {} fn opt_string(a: &std::option::Option) {} //~^ ref_option fn ret_string<'a>(p: &'a str) -> &'a Option { -//~^ ref_option + //~^ ref_option panic!() } fn ret_string_static() -> &'static Option { -//~^ ref_option + //~^ ref_option panic!() } fn mult_string(a: &Option, b: &Option>) {} //~^ ref_option fn ret_box<'a>() -> &'a Option> { -//~^ ref_option + //~^ ref_option panic!() } @@ -51,14 +51,14 @@ impl PubStruct { pub fn pub_opt_params(&self, a: &Option<()>) {} //~[all]^ ref_option pub fn pub_opt_ret(&self) -> &Option { - //~[all]^ ref_option + //~[all]^ ref_option panic!() } fn private_opt_params(&self, a: &Option<()>) {} //~^ ref_option fn private_opt_ret(&self) -> &Option { - //~^ ref_option + //~^ ref_option panic!() } } diff --git a/tests/ui/ref_option_ref.rs b/tests/ui/ref_option_ref.rs index de936cb081086..9632611f7df4d 100644 --- a/tests/ui/ref_option_ref.rs +++ b/tests/ui/ref_option_ref.rs @@ -10,25 +10,21 @@ static THRESHOLD: i32 = 10; static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); //~^ ref_option_ref - const CONST_THRESHOLD: &i32 = &10; const REF_CONST: &Option<&i32> = &Some(CONST_THRESHOLD); //~^ ref_option_ref - type RefOptRefU32<'a> = &'a Option<&'a u32>; //~^ ref_option_ref type RefOptRef<'a, T> = &'a Option<&'a T>; //~^ ref_option_ref - fn foo(data: &Option<&u32>) {} //~^ ref_option_ref - fn bar(data: &u32) -> &Option<&u32> { -//~^ ref_option_ref + //~^ ref_option_ref &None } @@ -36,18 +32,15 @@ fn bar(data: &u32) -> &Option<&u32> { struct StructRef<'a> { data: &'a Option<&'a u32>, //~^ ref_option_ref - } struct StructTupleRef<'a>(u32, &'a Option<&'a u32>); //~^ ref_option_ref - enum EnumRef<'a> { Variant1(u32), Variant2(&'a Option<&'a u32>), //~^ ref_option_ref - } trait RefOptTrait { @@ -59,14 +52,12 @@ impl RefOptTrait for u32 { type A = &'static Option<&'static Self>; //~^ ref_option_ref - fn foo(&self, _: Self::A) {} } fn main() { let x: &Option<&u32> = &None; //~^ ref_option_ref - } fn issue9682(arg: &Option<&mut String>) { diff --git a/tests/ui/ref_option_ref.stderr b/tests/ui/ref_option_ref.stderr index fcafbc5ea18eb..25064a61ee88b 100644 --- a/tests/ui/ref_option_ref.stderr +++ b/tests/ui/ref_option_ref.stderr @@ -8,61 +8,61 @@ LL | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); = help: to override `-D warnings` add `#[allow(clippy::ref_option_ref)]` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:15:18 + --> tests/ui/ref_option_ref.rs:14:18 | LL | const REF_CONST: &Option<&i32> = &Some(CONST_THRESHOLD); | ^^^^^^^^^^^^^ help: try: `Option<&i32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:19:25 + --> tests/ui/ref_option_ref.rs:17:25 | LL | type RefOptRefU32<'a> = &'a Option<&'a u32>; | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:22:25 + --> tests/ui/ref_option_ref.rs:20:25 | LL | type RefOptRef<'a, T> = &'a Option<&'a T>; | ^^^^^^^^^^^^^^^^^ help: try: `Option<&'a T>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:26:14 + --> tests/ui/ref_option_ref.rs:23:14 | LL | fn foo(data: &Option<&u32>) {} | ^^^^^^^^^^^^^ help: try: `Option<&u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:30:23 + --> tests/ui/ref_option_ref.rs:26:23 | LL | fn bar(data: &u32) -> &Option<&u32> { | ^^^^^^^^^^^^^ help: try: `Option<&u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:37:11 + --> tests/ui/ref_option_ref.rs:33:11 | LL | data: &'a Option<&'a u32>, | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:42:32 + --> tests/ui/ref_option_ref.rs:37:32 | LL | struct StructTupleRef<'a>(u32, &'a Option<&'a u32>); | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:48:14 + --> tests/ui/ref_option_ref.rs:42:14 | LL | Variant2(&'a Option<&'a u32>), | ^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'a u32>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:59:14 + --> tests/ui/ref_option_ref.rs:52:14 | LL | type A = &'static Option<&'static Self>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Option<&'static Self>` error: since `&` implements the `Copy` trait, `&Option<&T>` can be simplified to `Option<&T>` - --> tests/ui/ref_option_ref.rs:67:12 + --> tests/ui/ref_option_ref.rs:59:12 | LL | let x: &Option<&u32> = &None; | ^^^^^^^^^^^^^ help: try: `Option<&u32>` diff --git a/tests/ui/ref_patterns.rs b/tests/ui/ref_patterns.rs index 214778b78b5b7..2905af13ccb63 100644 --- a/tests/ui/ref_patterns.rs +++ b/tests/ui/ref_patterns.rs @@ -7,7 +7,6 @@ fn use_in_pattern() { None => {}, Some(ref opt) => {}, //~^ ref_patterns - } } @@ -15,11 +14,9 @@ fn use_in_binding() { let x = 5; let ref y = x; //~^ ref_patterns - } fn use_in_parameter(ref x: i32) {} //~^ ref_patterns - fn main() {} diff --git a/tests/ui/ref_patterns.stderr b/tests/ui/ref_patterns.stderr index bf63189a15b0d..9e2d036e34838 100644 --- a/tests/ui/ref_patterns.stderr +++ b/tests/ui/ref_patterns.stderr @@ -9,7 +9,7 @@ LL | Some(ref opt) => {}, = help: to override `-D warnings` add `#[allow(clippy::ref_patterns)]` error: usage of ref pattern - --> tests/ui/ref_patterns.rs:16:9 + --> tests/ui/ref_patterns.rs:15:9 | LL | let ref y = x; | ^^^^^ @@ -17,7 +17,7 @@ LL | let ref y = x; = help: consider using `&` for clarity instead error: usage of ref pattern - --> tests/ui/ref_patterns.rs:21:21 + --> tests/ui/ref_patterns.rs:19:21 | LL | fn use_in_parameter(ref x: i32) {} | ^^^^^ diff --git a/tests/ui/repeat_vec_with_capacity.fixed b/tests/ui/repeat_vec_with_capacity.fixed index 318839db221ef..5c6736a9a4eef 100644 --- a/tests/ui/repeat_vec_with_capacity.fixed +++ b/tests/ui/repeat_vec_with_capacity.fixed @@ -5,14 +5,12 @@ fn main() { { (0..123).map(|_| Vec::<()>::with_capacity(42)).collect::>(); //~^ repeat_vec_with_capacity - } { let n = 123; (0..n).map(|_| Vec::<()>::with_capacity(42)).collect::>(); //~^ repeat_vec_with_capacity - } { @@ -28,7 +26,6 @@ fn main() { { std::iter::repeat_with(|| Vec::<()>::with_capacity(42)); //~^ repeat_vec_with_capacity - } { diff --git a/tests/ui/repeat_vec_with_capacity.rs b/tests/ui/repeat_vec_with_capacity.rs index 0ce4658c10895..2646794822c01 100644 --- a/tests/ui/repeat_vec_with_capacity.rs +++ b/tests/ui/repeat_vec_with_capacity.rs @@ -5,14 +5,12 @@ fn main() { { vec![Vec::<()>::with_capacity(42); 123]; //~^ repeat_vec_with_capacity - } { let n = 123; vec![Vec::<()>::with_capacity(42); n]; //~^ repeat_vec_with_capacity - } { @@ -28,7 +26,6 @@ fn main() { { std::iter::repeat(Vec::<()>::with_capacity(42)); //~^ repeat_vec_with_capacity - } { diff --git a/tests/ui/repeat_vec_with_capacity.stderr b/tests/ui/repeat_vec_with_capacity.stderr index bdfd58137b0b6..43027c9cb8926 100644 --- a/tests/ui/repeat_vec_with_capacity.stderr +++ b/tests/ui/repeat_vec_with_capacity.stderr @@ -13,7 +13,7 @@ LL | (0..123).map(|_| Vec::<()>::with_capacity(42)).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: repeating `Vec::with_capacity` using `vec![x; n]`, which does not retain capacity - --> tests/ui/repeat_vec_with_capacity.rs:13:9 + --> tests/ui/repeat_vec_with_capacity.rs:12:9 | LL | vec![Vec::<()>::with_capacity(42); n]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | (0..n).map(|_| Vec::<()>::with_capacity(42)).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: repeating `Vec::with_capacity` using `iter::repeat`, which does not retain capacity - --> tests/ui/repeat_vec_with_capacity.rs:29:9 + --> tests/ui/repeat_vec_with_capacity.rs:27:9 | LL | std::iter::repeat(Vec::<()>::with_capacity(42)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/repl_uninit.rs b/tests/ui/repl_uninit.rs index f9887eedcf462..e9469d4c5e2ff 100644 --- a/tests/ui/repl_uninit.rs +++ b/tests/ui/repl_uninit.rs @@ -15,7 +15,6 @@ fn main() { let taken_v = mem::replace(&mut v, mem::uninitialized()); //~^ mem_replace_with_uninit - let new_v = might_panic(taken_v); std::mem::forget(mem::replace(&mut v, new_v)); } diff --git a/tests/ui/repl_uninit.stderr b/tests/ui/repl_uninit.stderr index 6e314d0dd1664..08b0b265942d7 100644 --- a/tests/ui/repl_uninit.stderr +++ b/tests/ui/repl_uninit.stderr @@ -8,13 +8,13 @@ LL | let taken_v = mem::replace(&mut v, mem::uninitialized()); = help: to override `-D warnings` add `#[allow(clippy::mem_replace_with_uninit)]` error: replacing with `mem::MaybeUninit::uninit().assume_init()` - --> tests/ui/repl_uninit.rs:24:23 + --> tests/ui/repl_uninit.rs:23:23 | LL | let taken_v = mem::replace(&mut v, mem::MaybeUninit::uninit().assume_init()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(&mut v)` error: replacing with `mem::zeroed()` - --> tests/ui/repl_uninit.rs:32:23 + --> tests/ui/repl_uninit.rs:31:23 | LL | let taken_v = mem::replace(&mut v, mem::zeroed()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | let taken_v = mem::replace(&mut v, mem::zeroed()); = help: consider using a default value or the `take_mut` crate instead error: replacing with `mem::uninitialized()` - --> tests/ui/repl_uninit.rs:46:28 + --> tests/ui/repl_uninit.rs:45:28 | LL | let taken_u = unsafe { mem::replace(uref, mem::uninitialized()) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::ptr::read(uref)` diff --git a/tests/ui/repr_packed_without_abi.rs b/tests/ui/repr_packed_without_abi.rs index 4f51d4b9aec6f..c5f1852e98b81 100644 --- a/tests/ui/repr_packed_without_abi.rs +++ b/tests/ui/repr_packed_without_abi.rs @@ -2,14 +2,14 @@ #[repr(packed)] struct NetworkPacketHeader { -//~^ repr_packed_without_abi + //~^ repr_packed_without_abi header_length: u8, header_version: u16, } #[repr(packed)] union Foo { -//~^ repr_packed_without_abi + //~^ repr_packed_without_abi a: u8, b: u16, } diff --git a/tests/ui/rest_pat_in_fully_bound_structs.rs b/tests/ui/rest_pat_in_fully_bound_structs.rs index fd6cf0d1ce1fa..bede01688972a 100644 --- a/tests/ui/rest_pat_in_fully_bound_structs.rs +++ b/tests/ui/rest_pat_in_fully_bound_structs.rs @@ -22,10 +22,8 @@ fn main() { match a_struct { A { a: 5, b: 42, c: "", .. } => {}, // Lint //~^ rest_pat_in_fully_bound_structs - A { a: 0, b: 0, c: "", .. } => {}, // Lint //~^ rest_pat_in_fully_bound_structs - _ => {}, } @@ -33,7 +31,6 @@ fn main() { A { a: 5, b: 42, .. } => {}, A { a: 0, b: 0, c: "", .. } => {}, // Lint //~^ rest_pat_in_fully_bound_structs - _ => {}, } diff --git a/tests/ui/rest_pat_in_fully_bound_structs.stderr b/tests/ui/rest_pat_in_fully_bound_structs.stderr index 72cf778ca64c4..d048933ddb7bc 100644 --- a/tests/ui/rest_pat_in_fully_bound_structs.stderr +++ b/tests/ui/rest_pat_in_fully_bound_structs.stderr @@ -9,7 +9,7 @@ LL | A { a: 5, b: 42, c: "", .. } => {}, // Lint = help: to override `-D warnings` add `#[allow(clippy::rest_pat_in_fully_bound_structs)]` error: unnecessary use of `..` pattern in struct binding. All fields were already bound - --> tests/ui/rest_pat_in_fully_bound_structs.rs:26:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:25:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint = help: consider removing `..` from this binding error: unnecessary use of `..` pattern in struct binding. All fields were already bound - --> tests/ui/rest_pat_in_fully_bound_structs.rs:34:9 + --> tests/ui/rest_pat_in_fully_bound_structs.rs:32:9 | LL | A { a: 0, b: 0, c: "", .. } => {}, // Lint | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/result_filter_map.rs b/tests/ui/result_filter_map.rs index f5e0a9da9ea59..ebd9c4288e3b7 100644 --- a/tests/ui/result_filter_map.rs +++ b/tests/ui/result_filter_map.rs @@ -12,14 +12,12 @@ fn main() { .into_iter() .filter(Result::is_ok) //~^ result_filter_map - .map(Result::unwrap); let _ = vec![Ok(1) as Result] .into_iter() .filter(|o| o.is_ok()) //~^ result_filter_map - .map(|o| o.unwrap()); let _ = vec![1] @@ -27,13 +25,11 @@ fn main() { .map(odds_out) .filter(Result::is_ok) //~^ result_filter_map - .map(Result::unwrap); let _ = vec![1] .into_iter() .map(odds_out) .filter(|o| o.is_ok()) //~^ result_filter_map - .map(|o| o.unwrap()); } diff --git a/tests/ui/result_filter_map.stderr b/tests/ui/result_filter_map.stderr index f3ff5173c171b..12eb7083b5a82 100644 --- a/tests/ui/result_filter_map.stderr +++ b/tests/ui/result_filter_map.stderr @@ -3,7 +3,7 @@ error: `filter` for `Ok` followed by `unwrap` | LL | .filter(Result::is_ok) | __________^ -... | +LL | | LL | | .map(Result::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` | @@ -11,29 +11,29 @@ LL | | .map(Result::unwrap); = help: to override `-D warnings` add `#[allow(clippy::result_filter_map)]` error: `filter` for `Ok` followed by `unwrap` - --> tests/ui/result_filter_map.rs:20:10 + --> tests/ui/result_filter_map.rs:19:10 | LL | .filter(|o| o.is_ok()) | __________^ -... | +LL | | LL | | .map(|o| o.unwrap()); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Ok` followed by `unwrap` - --> tests/ui/result_filter_map.rs:28:10 + --> tests/ui/result_filter_map.rs:26:10 | LL | .filter(Result::is_ok) | __________^ -... | +LL | | LL | | .map(Result::unwrap); | |____________________________^ help: consider using `flatten` instead: `flatten()` error: `filter` for `Ok` followed by `unwrap` - --> tests/ui/result_filter_map.rs:35:10 + --> tests/ui/result_filter_map.rs:32:10 | LL | .filter(|o| o.is_ok()) | __________^ -... | +LL | | LL | | .map(|o| o.unwrap()); | |____________________________^ help: consider using `flatten` instead: `flatten()` diff --git a/tests/ui/result_large_err.rs b/tests/ui/result_large_err.rs index bdcf40a99ab9b..fa57b3f553fc9 100644 --- a/tests/ui/result_large_err.rs +++ b/tests/ui/result_large_err.rs @@ -8,7 +8,7 @@ pub fn small_err() -> Result<(), u128> { } pub fn large_err() -> Result<(), [u8; 512]> { -//~^ result_large_err + //~^ result_large_err Ok(()) } @@ -21,21 +21,21 @@ pub struct FullyDefinedLargeError { impl FullyDefinedLargeError { pub fn ret() -> Result<(), Self> { - //~^ result_large_err + //~^ result_large_err Ok(()) } } pub fn struct_error() -> Result<(), FullyDefinedLargeError> { -//~^ result_large_err + //~^ result_large_err Ok(()) } type Fdlr = std::result::Result; pub fn large_err_via_type_alias(x: T) -> Fdlr { -//~^ result_large_err + //~^ result_large_err Ok(x) } @@ -45,7 +45,7 @@ pub fn param_small_error() -> Result<(), (R, u128)> { } pub fn param_large_error() -> Result<(), (u128, R, FullyDefinedLargeError)> { -//~^ result_large_err + //~^ result_large_err Ok(()) } @@ -58,7 +58,7 @@ pub enum LargeErrorVariants { impl LargeErrorVariants<()> { pub fn large_enum_error() -> Result<(), Self> { - //~^ result_large_err + //~^ result_large_err Ok(()) } @@ -72,7 +72,7 @@ enum MultipleLargeVariants { impl MultipleLargeVariants { fn large_enum_error() -> Result<(), Self> { - //~^ result_large_err + //~^ result_large_err Ok(()) } @@ -80,7 +80,7 @@ impl MultipleLargeVariants { trait TraitForcesLargeError { fn large_error() -> Result<(), [u8; 512]> { - //~^ result_large_err + //~^ result_large_err Ok(()) } @@ -101,7 +101,7 @@ pub union FullyDefinedUnionError { } pub fn large_union_err() -> Result<(), FullyDefinedUnionError> { -//~^ result_large_err + //~^ result_large_err Ok(()) } @@ -112,7 +112,7 @@ pub union UnionError { } pub fn param_large_union() -> Result<(), UnionError> { -//~^ result_large_err + //~^ result_large_err Ok(()) } @@ -123,13 +123,13 @@ pub struct ArrayError { } pub fn array_error_subst() -> Result<(), ArrayError> { -//~^ result_large_err + //~^ result_large_err Ok(()) } pub fn array_error() -> Result<(), ArrayError<(i32, T), U>> { -//~^ result_large_err + //~^ result_large_err Ok(()) } diff --git a/tests/ui/result_map_or_into_option.fixed b/tests/ui/result_map_or_into_option.fixed index 47ba2b03bfc4d..4cf218b846424 100644 --- a/tests/ui/result_map_or_into_option.fixed +++ b/tests/ui/result_map_or_into_option.fixed @@ -12,7 +12,6 @@ fn main() { let _ = opt.ok(); //~^ result_map_or_into_option - let rewrap = |s: u32| -> Option { Some(s) }; // A non-Some `f` arg should not emit the lint diff --git a/tests/ui/result_map_or_into_option.rs b/tests/ui/result_map_or_into_option.rs index 3c6b2f0e836fd..9a0bde8569e8f 100644 --- a/tests/ui/result_map_or_into_option.rs +++ b/tests/ui/result_map_or_into_option.rs @@ -12,7 +12,6 @@ fn main() { let _ = opt.map_or_else(|_| { None }, Some); //~^ result_map_or_into_option - let rewrap = |s: u32| -> Option { Some(s) }; // A non-Some `f` arg should not emit the lint diff --git a/tests/ui/result_unit_error.rs b/tests/ui/result_unit_error.rs index a6cf36bff913b..ddbe0eb556c85 100644 --- a/tests/ui/result_unit_error.rs +++ b/tests/ui/result_unit_error.rs @@ -1,7 +1,7 @@ #![warn(clippy::result_unit_err)] pub fn returns_unit_error() -> Result { -//~^ result_unit_err + //~^ result_unit_err Err(()) } @@ -14,9 +14,8 @@ pub trait HasUnitError { fn get_that_error(&self) -> Result; //~^ result_unit_err - fn get_this_one_too(&self) -> Result { - //~^ result_unit_err + //~^ result_unit_err Err(()) } @@ -36,7 +35,7 @@ pub struct UnitErrorHolder; impl UnitErrorHolder { pub fn unit_error(&self) -> Result { - //~^ result_unit_err + //~^ result_unit_err Ok(0) } @@ -47,7 +46,7 @@ pub mod issue_6546 { type ResInv = Result; pub fn should_lint() -> ResInv<(), usize> { - //~^ result_unit_err + //~^ result_unit_err Ok(0) } diff --git a/tests/ui/result_unit_error.stderr b/tests/ui/result_unit_error.stderr index a59271f8f72ed..d6c0924d88689 100644 --- a/tests/ui/result_unit_error.stderr +++ b/tests/ui/result_unit_error.stderr @@ -17,7 +17,7 @@ LL | fn get_that_error(&self) -> Result; = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> tests/ui/result_unit_error.rs:18:5 + --> tests/ui/result_unit_error.rs:17:5 | LL | fn get_this_one_too(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | fn get_this_one_too(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> tests/ui/result_unit_error.rs:38:5 + --> tests/ui/result_unit_error.rs:37:5 | LL | pub fn unit_error(&self) -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | pub fn unit_error(&self) -> Result { = help: use a custom `Error` type instead error: this returns a `Result<_, ()>` - --> tests/ui/result_unit_error.rs:49:5 + --> tests/ui/result_unit_error.rs:48:5 | LL | pub fn should_lint() -> ResInv<(), usize> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/result_unit_error_no_std.rs b/tests/ui/result_unit_error_no_std.rs index cd2b17a522349..8a1849b8490ab 100644 --- a/tests/ui/result_unit_error_no_std.rs +++ b/tests/ui/result_unit_error_no_std.rs @@ -10,7 +10,7 @@ pub fn returns_unit_error_no_lint() -> Result { #[clippy::msrv = "1.81"] pub fn returns_unit_error_lint() -> Result { -//~^ result_unit_err + //~^ result_unit_err Err(()) } diff --git a/tests/ui/return_and_then.fixed b/tests/ui/return_and_then.fixed index 732854d2b9698..74efa14eeec81 100644 --- a/tests/ui/return_and_then.fixed +++ b/tests/ui/return_and_then.fixed @@ -4,9 +4,9 @@ fn main() { fn test_opt_block(opt: Option) -> Option { let n = opt?; //~^ return_and_then - let mut ret = n + 1; - ret += n; - if n > 1 { Some(ret) } else { None } + let mut ret = n + 1; + ret += n; + if n > 1 { Some(ret) } else { None } } fn test_opt_func(opt: Option) -> Option { @@ -43,7 +43,7 @@ fn main() { fn test_tmp_only() -> Option { // unused temporary: vec![1, 2, 4] let x = Some(match (vec![1, 2, 3], vec![1, 2, 4]) { - //~^ return_and_then + //~^ return_and_then (a, _) if a.len() > 1 => a, (_, b) => b, })?; diff --git a/tests/ui/return_and_then.rs b/tests/ui/return_and_then.rs index cfefee373c782..188dc57e588cf 100644 --- a/tests/ui/return_and_then.rs +++ b/tests/ui/return_and_then.rs @@ -3,7 +3,7 @@ fn main() { fn test_opt_block(opt: Option) -> Option { opt.and_then(|n| { - //~^ return_and_then + //~^ return_and_then let mut ret = n + 1; ret += n; if n > 1 { Some(ret) } else { None } @@ -39,7 +39,7 @@ fn main() { fn test_tmp_only() -> Option { // unused temporary: vec![1, 2, 4] Some(match (vec![1, 2, 3], vec![1, 2, 4]) { - //~^ return_and_then + //~^ return_and_then (a, _) if a.len() > 1 => a, (_, b) => b, }) diff --git a/tests/ui/return_and_then.stderr b/tests/ui/return_and_then.stderr index ef5f7417de78f..cc611c3dba679 100644 --- a/tests/ui/return_and_then.stderr +++ b/tests/ui/return_and_then.stderr @@ -15,9 +15,9 @@ help: try | LL ~ let n = opt?; LL + -LL + let mut ret = n + 1; -LL + ret += n; -LL + if n > 1 { Some(ret) } else { None } +LL + let mut ret = n + 1; +LL + ret += n; +LL + if n > 1 { Some(ret) } else { None } | error: use the question mark operator instead of an `and_then` call diff --git a/tests/ui/return_self_not_must_use.rs b/tests/ui/return_self_not_must_use.rs index 2e9a29aea0d71..83965662d15e1 100644 --- a/tests/ui/return_self_not_must_use.rs +++ b/tests/ui/return_self_not_must_use.rs @@ -18,12 +18,12 @@ impl Bar { Self } pub fn foo(&self) -> Self { - //~^ return_self_not_must_use + //~^ return_self_not_must_use Self } pub fn bar(self) -> Self { - //~^ return_self_not_must_use + //~^ return_self_not_must_use self } diff --git a/tests/ui/reversed_empty_ranges_loops_fixable.fixed b/tests/ui/reversed_empty_ranges_loops_fixable.fixed index 5d7f852e4e533..55080da8a1377 100644 --- a/tests/ui/reversed_empty_ranges_loops_fixable.fixed +++ b/tests/ui/reversed_empty_ranges_loops_fixable.fixed @@ -5,17 +5,17 @@ fn main() { const MAX_LEN: usize = 42; for i in (0..10).rev() { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } for i in (0..=10).rev() { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } for i in (0..MAX_LEN).rev() { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } @@ -35,18 +35,18 @@ fn main() { } for i in (0..10).rev().map(|x| x * 2) { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } // testing that the empty range lint folds constants for i in (5 + 4..10).rev() { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } for i in ((3 - 1)..(5 + 2)).rev() { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } diff --git a/tests/ui/reversed_empty_ranges_loops_fixable.rs b/tests/ui/reversed_empty_ranges_loops_fixable.rs index b65d4adb090a1..e51557bc2796a 100644 --- a/tests/ui/reversed_empty_ranges_loops_fixable.rs +++ b/tests/ui/reversed_empty_ranges_loops_fixable.rs @@ -5,17 +5,17 @@ fn main() { const MAX_LEN: usize = 42; for i in 10..0 { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } for i in 10..=0 { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } for i in MAX_LEN..0 { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } @@ -35,18 +35,18 @@ fn main() { } for i in (10..0).map(|x| x * 2) { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } // testing that the empty range lint folds constants for i in 10..5 + 4 { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } for i in (5 + 2)..(3 - 1) { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } diff --git a/tests/ui/reversed_empty_ranges_loops_unfixable.rs b/tests/ui/reversed_empty_ranges_loops_unfixable.rs index 4fc7fb50a9eca..00aa20d25bdad 100644 --- a/tests/ui/reversed_empty_ranges_loops_unfixable.rs +++ b/tests/ui/reversed_empty_ranges_loops_unfixable.rs @@ -3,14 +3,13 @@ fn main() { for i in 5..5 { - //~^ reversed_empty_ranges - + //~^ reversed_empty_ranges println!("{}", i); } for i in (5 + 2)..(8 - 1) { - //~^ reversed_empty_ranges + //~^ reversed_empty_ranges println!("{}", i); } diff --git a/tests/ui/reversed_empty_ranges_loops_unfixable.stderr b/tests/ui/reversed_empty_ranges_loops_unfixable.stderr index b5c17aad46bcc..b9e6fa04a34c6 100644 --- a/tests/ui/reversed_empty_ranges_loops_unfixable.stderr +++ b/tests/ui/reversed_empty_ranges_loops_unfixable.stderr @@ -8,7 +8,7 @@ LL | for i in 5..5 { = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` error: this range is empty so it will yield no values - --> tests/ui/reversed_empty_ranges_loops_unfixable.rs:12:14 + --> tests/ui/reversed_empty_ranges_loops_unfixable.rs:11:14 | LL | for i in (5 + 2)..(8 - 1) { | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/reversed_empty_ranges_unfixable.rs b/tests/ui/reversed_empty_ranges_unfixable.rs index 1ed35786a0daf..7bf434544378f 100644 --- a/tests/ui/reversed_empty_ranges_unfixable.rs +++ b/tests/ui/reversed_empty_ranges_unfixable.rs @@ -8,15 +8,12 @@ fn main() { let _ = &arr[3usize..=1usize]; //~^ reversed_empty_ranges - let _ = &arr[SOME_NUM..1]; //~^ reversed_empty_ranges - for _ in ANSWER..ANSWER {} //~^ reversed_empty_ranges - // Should not be linted, see issue #5689 let _ = (42 + 10..42 + 10).map(|x| x / 2).find(|&x| x == 21); } diff --git a/tests/ui/reversed_empty_ranges_unfixable.stderr b/tests/ui/reversed_empty_ranges_unfixable.stderr index 770d916bad666..bc2b9576c41d3 100644 --- a/tests/ui/reversed_empty_ranges_unfixable.stderr +++ b/tests/ui/reversed_empty_ranges_unfixable.stderr @@ -8,13 +8,13 @@ LL | let _ = &arr[3usize..=1usize]; = help: to override `-D warnings` add `#[allow(clippy::reversed_empty_ranges)]` error: this range is reversed and using it to index a slice will panic at run-time - --> tests/ui/reversed_empty_ranges_unfixable.rs:12:18 + --> tests/ui/reversed_empty_ranges_unfixable.rs:11:18 | LL | let _ = &arr[SOME_NUM..1]; | ^^^^^^^^^^^ error: this range is empty so it will yield no values - --> tests/ui/reversed_empty_ranges_unfixable.rs:16:14 + --> tests/ui/reversed_empty_ranges_unfixable.rs:14:14 | LL | for _ in ANSWER..ANSWER {} | ^^^^^^^^^^^^^^ diff --git a/tests/ui/same_functions_in_if_condition.rs b/tests/ui/same_functions_in_if_condition.rs index 47954392178ab..b7ed3aab00434 100644 --- a/tests/ui/same_functions_in_if_condition.rs +++ b/tests/ui/same_functions_in_if_condition.rs @@ -37,39 +37,33 @@ fn ifs_same_cond_fn() { if function() { } else if function() { - //~^ same_functions_in_if_condition - + //~^ same_functions_in_if_condition } if fn_arg(a) { } else if fn_arg(a) { - //~^ same_functions_in_if_condition - + //~^ same_functions_in_if_condition } if obj.method() { } else if obj.method() { - //~^ same_functions_in_if_condition - + //~^ same_functions_in_if_condition } if obj.method_arg(a) { } else if obj.method_arg(a) { - //~^ same_functions_in_if_condition - + //~^ same_functions_in_if_condition } let mut v = vec![1]; if v.pop().is_none() { } else if v.pop().is_none() { - //~^ same_functions_in_if_condition - + //~^ same_functions_in_if_condition } if v.len() == 42 { } else if v.len() == 42 { - //~^ same_functions_in_if_condition - + //~^ same_functions_in_if_condition } if v.len() == 1 { diff --git a/tests/ui/same_functions_in_if_condition.stderr b/tests/ui/same_functions_in_if_condition.stderr index 0d40c83595574..6cd4f96c13e32 100644 --- a/tests/ui/same_functions_in_if_condition.stderr +++ b/tests/ui/same_functions_in_if_condition.stderr @@ -16,61 +16,61 @@ LL | #![deny(clippy::same_functions_in_if_condition)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> tests/ui/same_functions_in_if_condition.rs:45:15 + --> tests/ui/same_functions_in_if_condition.rs:44:15 | LL | } else if fn_arg(a) { | ^^^^^^^^^ | note: same as this - --> tests/ui/same_functions_in_if_condition.rs:44:8 + --> tests/ui/same_functions_in_if_condition.rs:43:8 | LL | if fn_arg(a) { | ^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> tests/ui/same_functions_in_if_condition.rs:51:15 + --> tests/ui/same_functions_in_if_condition.rs:49:15 | LL | } else if obj.method() { | ^^^^^^^^^^^^ | note: same as this - --> tests/ui/same_functions_in_if_condition.rs:50:8 + --> tests/ui/same_functions_in_if_condition.rs:48:8 | LL | if obj.method() { | ^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> tests/ui/same_functions_in_if_condition.rs:57:15 + --> tests/ui/same_functions_in_if_condition.rs:54:15 | LL | } else if obj.method_arg(a) { | ^^^^^^^^^^^^^^^^^ | note: same as this - --> tests/ui/same_functions_in_if_condition.rs:56:8 + --> tests/ui/same_functions_in_if_condition.rs:53:8 | LL | if obj.method_arg(a) { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> tests/ui/same_functions_in_if_condition.rs:64:15 + --> tests/ui/same_functions_in_if_condition.rs:60:15 | LL | } else if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ | note: same as this - --> tests/ui/same_functions_in_if_condition.rs:63:8 + --> tests/ui/same_functions_in_if_condition.rs:59:8 | LL | if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ error: this `if` has the same function call as a previous `if` - --> tests/ui/same_functions_in_if_condition.rs:70:15 + --> tests/ui/same_functions_in_if_condition.rs:65:15 | LL | } else if v.len() == 42 { | ^^^^^^^^^^^^^ | note: same as this - --> tests/ui/same_functions_in_if_condition.rs:69:8 + --> tests/ui/same_functions_in_if_condition.rs:64:8 | LL | if v.len() == 42 { | ^^^^^^^^^^^^^ diff --git a/tests/ui/same_item_push.rs b/tests/ui/same_item_push.rs index dbe9c729bc565..a08e8872a9324 100644 --- a/tests/ui/same_item_push.rs +++ b/tests/ui/same_item_push.rs @@ -22,7 +22,6 @@ fn main() { for _ in 5..=20 { vec.push(item); //~^ same_item_push - } let mut vec: Vec = Vec::new(); @@ -30,21 +29,18 @@ fn main() { let item = 2; vec.push(item); //~^ same_item_push - } let mut vec: Vec = Vec::new(); for _ in 0..15 { vec.push(13); //~^ same_item_push - } let mut vec = Vec::new(); for _ in 0..20 { vec.push(VALUE); //~^ same_item_push - } let mut vec = Vec::new(); @@ -52,7 +48,6 @@ fn main() { for _ in 0..20 { vec.push(item); //~^ same_item_push - } #[clippy::msrv = "1.81"] @@ -62,7 +57,6 @@ fn main() { for _ in 0..20 { vec.push(item); //~^ same_item_push - } } diff --git a/tests/ui/same_item_push.stderr b/tests/ui/same_item_push.stderr index d2bf5069a8467..e3fa4f9cbcec2 100644 --- a/tests/ui/same_item_push.stderr +++ b/tests/ui/same_item_push.stderr @@ -10,7 +10,7 @@ LL | vec.push(item); = help: to override `-D warnings` add `#[allow(clippy::same_item_push)]` error: it looks like the same item is being pushed into this `Vec` - --> tests/ui/same_item_push.rs:31:9 + --> tests/ui/same_item_push.rs:30:9 | LL | vec.push(item); | ^^^ @@ -19,7 +19,7 @@ LL | vec.push(item); = help: or `vec.extend(std::iter::repeat_n(item, SIZE))` error: it looks like the same item is being pushed into this `Vec` - --> tests/ui/same_item_push.rs:38:9 + --> tests/ui/same_item_push.rs:36:9 | LL | vec.push(13); | ^^^ @@ -28,7 +28,7 @@ LL | vec.push(13); = help: or `vec.extend(std::iter::repeat_n(13, SIZE))` error: it looks like the same item is being pushed into this `Vec` - --> tests/ui/same_item_push.rs:45:9 + --> tests/ui/same_item_push.rs:42:9 | LL | vec.push(VALUE); | ^^^ @@ -37,7 +37,7 @@ LL | vec.push(VALUE); = help: or `vec.extend(std::iter::repeat_n(VALUE, SIZE))` error: it looks like the same item is being pushed into this `Vec` - --> tests/ui/same_item_push.rs:53:9 + --> tests/ui/same_item_push.rs:49:9 | LL | vec.push(item); | ^^^ @@ -46,7 +46,7 @@ LL | vec.push(item); = help: or `vec.extend(std::iter::repeat_n(item, SIZE))` error: it looks like the same item is being pushed into this `Vec` - --> tests/ui/same_item_push.rs:63:13 + --> tests/ui/same_item_push.rs:58:13 | LL | vec.push(item); | ^^^ diff --git a/tests/ui/same_name_method.rs b/tests/ui/same_name_method.rs index 398f3a7d5f91c..43c664b1505fa 100644 --- a/tests/ui/same_name_method.rs +++ b/tests/ui/same_name_method.rs @@ -19,7 +19,6 @@ mod should_lint { impl S { fn foo() {} //~^ same_name_method - } impl T1 for S { @@ -35,7 +34,6 @@ mod should_lint { impl S { fn clone() {} //~^ same_name_method - } } @@ -47,7 +45,6 @@ mod should_lint { impl S { fn foo() {} //~^ same_name_method - } impl T1 for S { @@ -63,7 +60,6 @@ mod should_lint { impl S { fn foo() {} //~^ same_name_method - } impl T1 for S {} @@ -78,8 +74,6 @@ mod should_lint { fn foo() {} //~^ same_name_method //~| same_name_method - - } impl T1 for S {} diff --git a/tests/ui/same_name_method.stderr b/tests/ui/same_name_method.stderr index d3bf386ea5457..fefdb5c9c23d0 100644 --- a/tests/ui/same_name_method.stderr +++ b/tests/ui/same_name_method.stderr @@ -5,7 +5,7 @@ LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> tests/ui/same_name_method.rs:26:13 + --> tests/ui/same_name_method.rs:25:13 | LL | fn foo() {} | ^^^^^^^^^^^ @@ -13,62 +13,62 @@ LL | fn foo() {} = help: to override `-D warnings` add `#[allow(clippy::same_name_method)]` error: method's name is the same as an existing method in a trait - --> tests/ui/same_name_method.rs:36:13 + --> tests/ui/same_name_method.rs:35:13 | LL | fn clone() {} | ^^^^^^^^^^^^^ | note: existing `clone` defined here - --> tests/ui/same_name_method.rs:32:18 + --> tests/ui/same_name_method.rs:31:18 | LL | #[derive(Clone)] | ^^^^^ = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) error: method's name is the same as an existing method in a trait - --> tests/ui/same_name_method.rs:48:13 + --> tests/ui/same_name_method.rs:46:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> tests/ui/same_name_method.rs:54:13 + --> tests/ui/same_name_method.rs:51:13 | LL | fn foo() {} | ^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> tests/ui/same_name_method.rs:64:13 + --> tests/ui/same_name_method.rs:61:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> tests/ui/same_name_method.rs:69:9 + --> tests/ui/same_name_method.rs:65:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> tests/ui/same_name_method.rs:78:13 + --> tests/ui/same_name_method.rs:74:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> tests/ui/same_name_method.rs:85:9 + --> tests/ui/same_name_method.rs:79:9 | LL | impl T1 for S {} | ^^^^^^^^^^^^^^^^ error: method's name is the same as an existing method in a trait - --> tests/ui/same_name_method.rs:78:13 + --> tests/ui/same_name_method.rs:74:13 | LL | fn foo() {} | ^^^^^^^^^^^ | note: existing `foo` defined here - --> tests/ui/same_name_method.rs:87:9 + --> tests/ui/same_name_method.rs:81:9 | LL | impl T2 for S {} | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/search_is_some_fixable_none.fixed b/tests/ui/search_is_some_fixable_none.fixed index e33f32d5bdb84..8169550b0d551 100644 --- a/tests/ui/search_is_some_fixable_none.fixed +++ b/tests/ui/search_is_some_fixable_none.fixed @@ -105,7 +105,7 @@ mod issue7392 { let vfoo = vec![(42, Foo { foo: 1, bar: 2 })]; let _ = !vfoo - //~^ search_is_some + //~^ search_is_some .iter().any(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2); } @@ -174,7 +174,7 @@ mod issue7392 { }, }]; let _ = !vfoo - //~^ search_is_some + //~^ search_is_some .iter().any(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2); } diff --git a/tests/ui/search_is_some_fixable_none.rs b/tests/ui/search_is_some_fixable_none.rs index 86885c7d3be3f..5935f0dd7e296 100644 --- a/tests/ui/search_is_some_fixable_none.rs +++ b/tests/ui/search_is_some_fixable_none.rs @@ -23,7 +23,7 @@ fn main() { let _ = (1..3).find(|x| [1, 2, 3].contains(x) || *x == 0).is_none(); //~^ search_is_some let _ = (1..3) - //~^ search_is_some + //~^ search_is_some .find(|x| [1, 2, 3].contains(x) || *x == 0 || [4, 5, 6].contains(x) || *x == -1) .is_none(); @@ -108,7 +108,7 @@ mod issue7392 { let vfoo = vec![(42, Foo { foo: 1, bar: 2 })]; let _ = vfoo - //~^ search_is_some + //~^ search_is_some .iter() .find(|(i, v)| *i == 42 && v.foo == 1 && v.bar == 2) .is_none(); @@ -179,7 +179,7 @@ mod issue7392 { }, }]; let _ = vfoo - //~^ search_is_some + //~^ search_is_some .iter() .find(|v| v.inner_double.bar[0][0] == 2 && v.inner.bar[0] == 2) .is_none(); diff --git a/tests/ui/self_assignment.rs b/tests/ui/self_assignment.rs index a12a2829ba1a8..6e82b42cf6d70 100644 --- a/tests/ui/self_assignment.rs +++ b/tests/ui/self_assignment.rs @@ -13,7 +13,6 @@ pub fn positives(mut a: usize, b: &mut u32, mut s: S) { a = a; //~^ self_assignment - *b = *b; //~^ self_assignment @@ -38,14 +37,12 @@ pub fn positives(mut a: usize, b: &mut u32, mut s: S) { s.b[a + 10] = s.b[10 + a]; //~^ self_assignment - let mut t = (0, 1); t.1 = t.1; //~^ self_assignment t.0 = (t.0); //~^ self_assignment - } pub fn negatives_not_equal(mut a: usize, b: &mut usize, mut s: S) { diff --git a/tests/ui/self_assignment.stderr b/tests/ui/self_assignment.stderr index 02c5b4195e9c6..e9a2164187ced 100644 --- a/tests/ui/self_assignment.stderr +++ b/tests/ui/self_assignment.stderr @@ -8,61 +8,61 @@ LL | a = a; = help: to override `-D warnings` add `#[allow(clippy::self_assignment)]` error: self-assignment of `*b` to `*b` - --> tests/ui/self_assignment.rs:17:5 + --> tests/ui/self_assignment.rs:16:5 | LL | *b = *b; | ^^^^^^^ error: self-assignment of `s` to `s` - --> tests/ui/self_assignment.rs:20:5 + --> tests/ui/self_assignment.rs:19:5 | LL | s = s; | ^^^^^ error: self-assignment of `s.a` to `s.a` - --> tests/ui/self_assignment.rs:23:5 + --> tests/ui/self_assignment.rs:22:5 | LL | s.a = s.a; | ^^^^^^^^^ error: self-assignment of `s.b[5 + 4]` to `s.b[9]` - --> tests/ui/self_assignment.rs:26:5 + --> tests/ui/self_assignment.rs:25:5 | LL | s.b[9] = s.b[5 + 4]; | ^^^^^^^^^^^^^^^^^^^ error: self-assignment of `s.c[0][1]` to `s.c[0][1]` - --> tests/ui/self_assignment.rs:29:5 + --> tests/ui/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]` - --> tests/ui/self_assignment.rs:32:5 + --> tests/ui/self_assignment.rs:31:5 | LL | s.b[a] = s.b[a]; | ^^^^^^^^^^^^^^^ error: self-assignment of `*s.e` to `*s.e` - --> tests/ui/self_assignment.rs:35:5 + --> tests/ui/self_assignment.rs:34:5 | LL | *s.e = *s.e; | ^^^^^^^^^^^ error: self-assignment of `s.b[10 + a]` to `s.b[a + 10]` - --> tests/ui/self_assignment.rs:38:5 + --> tests/ui/self_assignment.rs:37:5 | LL | s.b[a + 10] = s.b[10 + a]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: self-assignment of `t.1` to `t.1` - --> tests/ui/self_assignment.rs:43:5 + --> tests/ui/self_assignment.rs:41:5 | LL | t.1 = t.1; | ^^^^^^^^^ error: self-assignment of `(t.0)` to `t.0` - --> tests/ui/self_assignment.rs:46:5 + --> tests/ui/self_assignment.rs:44:5 | LL | t.0 = (t.0); | ^^^^^^^^^^^ diff --git a/tests/ui/self_named_constructors.rs b/tests/ui/self_named_constructors.rs index 3dcd20b58c9d2..8b6453e0d1d7b 100644 --- a/tests/ui/self_named_constructors.rs +++ b/tests/ui/self_named_constructors.rs @@ -5,8 +5,7 @@ struct ShouldNotSpawn; impl ShouldSpawn { pub fn should_spawn() -> ShouldSpawn { - //~^ self_named_constructors - + //~^ self_named_constructors ShouldSpawn } diff --git a/tests/ui/self_named_constructors.stderr b/tests/ui/self_named_constructors.stderr index 54d7fb939796e..1d8b44f6bc2bd 100644 --- a/tests/ui/self_named_constructors.stderr +++ b/tests/ui/self_named_constructors.stderr @@ -2,7 +2,9 @@ error: constructor `should_spawn` has the same name as the type --> tests/ui/self_named_constructors.rs:7:5 | LL | / pub fn should_spawn() -> ShouldSpawn { -... | +LL | | +LL | | +LL | | ShouldSpawn LL | | } | |_____^ | diff --git a/tests/ui/set_contains_or_insert.rs b/tests/ui/set_contains_or_insert.rs index 0e54afe91a807..575cfda139a4c 100644 --- a/tests/ui/set_contains_or_insert.rs +++ b/tests/ui/set_contains_or_insert.rs @@ -10,42 +10,42 @@ fn should_warn_hashset() { let value = 5; if !set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); println!("Just a comment"); } if set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); println!("Just a comment"); } if !set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); } if !!set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); println!("Just a comment"); } if (&set).contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); } let borrow_value = &6; if !set.contains(borrow_value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(*borrow_value); } let borrow_set = &mut set; if !borrow_set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert borrow_set.insert(value); } } @@ -84,42 +84,42 @@ fn should_warn_btreeset() { let value = 5; if !set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); println!("Just a comment"); } if set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); println!("Just a comment"); } if !set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); } if !!set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); println!("Just a comment"); } if (&set).contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(value); } let borrow_value = &6; if !set.contains(borrow_value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert set.insert(*borrow_value); } let borrow_set = &mut set; if !borrow_set.contains(&value) { - //~^ set_contains_or_insert + //~^ set_contains_or_insert borrow_set.insert(value); } } diff --git a/tests/ui/shadow.rs b/tests/ui/shadow.rs index b44705dfc7d6e..7d503a1cf6c17 100644 --- a/tests/ui/shadow.rs +++ b/tests/ui/shadow.rs @@ -49,7 +49,7 @@ fn shadow_reuse() -> Option<()> { //~^ shadow_reuse let y = 1; let y = match y { - //~^ shadow_reuse + //~^ shadow_reuse 1 => 2, _ => 3, }; @@ -77,7 +77,7 @@ fn syntax() { match Some(1) { Some(1) => {}, Some(x) => { - //~^ shadow_unrelated + //~^ shadow_unrelated let x = 1; //~^ shadow_unrelated }, @@ -88,7 +88,7 @@ fn syntax() { while let Some(x) = Some(1) {} //~^ shadow_unrelated let _ = |[x]: [u32; 1]| { - //~^ shadow_unrelated + //~^ shadow_unrelated let x = 1; //~^ shadow_unrelated }; diff --git a/tests/ui/short_circuit_statement.fixed b/tests/ui/short_circuit_statement.fixed index 672f692db51ef..133d296e259cf 100644 --- a/tests/ui/short_circuit_statement.fixed +++ b/tests/ui/short_circuit_statement.fixed @@ -17,7 +17,6 @@ fn main() { if !(f() || g()) { H * 2; } //~^ short_circuit_statement - macro_rules! mac { ($f:ident or $g:ident) => { $f() || $g() @@ -36,7 +35,6 @@ fn main() { if !mac!() { mac!(); } //~^ short_circuit_statement - // Do not lint if the expression comes from a macro mac!(); } diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs index ca8913c8e6375..4275ae64fdd65 100644 --- a/tests/ui/short_circuit_statement.rs +++ b/tests/ui/short_circuit_statement.rs @@ -17,7 +17,6 @@ fn main() { (f() || g()) || (H * 2); //~^ short_circuit_statement - macro_rules! mac { ($f:ident or $g:ident) => { $f() || $g() @@ -36,7 +35,6 @@ fn main() { mac!() || mac!(); //~^ short_circuit_statement - // Do not lint if the expression comes from a macro mac!(); } diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index f69f411b4885a..acd28d41a33ae 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -32,13 +32,13 @@ LL | (f() || g()) || (H * 2); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `if !(f() || g()) { H * 2; }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> tests/ui/short_circuit_statement.rs:33:5 + --> tests/ui/short_circuit_statement.rs:32:5 | LL | mac!() && mac!(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `if mac!() { mac!(); }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> tests/ui/short_circuit_statement.rs:36:5 + --> tests/ui/short_circuit_statement.rs:35:5 | LL | mac!() || mac!(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `if !mac!() { mac!(); }` diff --git a/tests/ui/should_impl_trait/method_list_1.rs b/tests/ui/should_impl_trait/method_list_1.rs index 664d8aab75682..87b3a7d2fa0cf 100644 --- a/tests/ui/should_impl_trait/method_list_1.rs +++ b/tests/ui/should_impl_trait/method_list_1.rs @@ -23,91 +23,91 @@ impl T { // trait method list part 1, should lint all // ***************************************** pub fn add(self, other: T) -> T { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn as_mut(&mut self) -> &mut T { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn as_ref(&self) -> &T { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn bitand(self, rhs: T) -> T { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn bitor(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn bitxor(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn borrow(&self) -> &str { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn borrow_mut(&mut self) -> &mut str { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn clone(&self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn cmp(&self, other: &Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn default() -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn deref(&self) -> &Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn deref_mut(&mut self) -> &mut Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn div(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn drop(&mut self) { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } diff --git a/tests/ui/should_impl_trait/method_list_2.rs b/tests/ui/should_impl_trait/method_list_2.rs index 29b96c33ce9ce..f0c4d4f15cb63 100644 --- a/tests/ui/should_impl_trait/method_list_2.rs +++ b/tests/ui/should_impl_trait/method_list_2.rs @@ -24,91 +24,91 @@ impl T { // ***************************************** pub fn eq(&self, other: &Self) -> bool { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn from_iter(iter: T) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn from_str(s: &str) -> Result { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn hash(&self, state: &mut T) { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn index(&self, index: usize) -> &Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn index_mut(&mut self, index: usize) -> &mut Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn into_iter(self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn mul(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn neg(self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn next(&mut self) -> Option { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn not(self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn rem(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn shl(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn shr(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } pub fn sub(self, rhs: Self) -> Self { - //~^ should_implement_trait + //~^ should_implement_trait unimplemented!() } diff --git a/tests/ui/significant_drop_in_scrutinee.rs b/tests/ui/significant_drop_in_scrutinee.rs index db4f8867fa414..4f65a06680d6c 100644 --- a/tests/ui/significant_drop_in_scrutinee.rs +++ b/tests/ui/significant_drop_in_scrutinee.rs @@ -58,7 +58,7 @@ fn should_trigger_lint_with_mutex_guard_in_match_scrutinee() { // is preserved until the end of the match, but there is no clear indication that this is the // case. match mutex.lock().unwrap().foo() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee true => { mutex.lock().unwrap().bar(); }, @@ -145,7 +145,7 @@ fn should_trigger_lint_with_wrapped_mutex() { // lifetime is not obvious. Additionally, it is not obvious from looking at the scrutinee that // the temporary contains such a type, making it potentially even more surprising. match s.lock_m().get_the_value() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee 1 => { println!("Got 1. Is it still 1?"); println!("{}", s.lock_m().get_the_value()); @@ -167,7 +167,7 @@ fn should_trigger_lint_with_double_wrapped_mutex() { // looking at the scrutinee that the temporary contains such a type, making it potentially even // more surprising. match s.lock_m_m().get_the_value() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee 1 => { println!("Got 1. Is it still 1?"); println!("{}", s.lock_m().get_the_value()); @@ -216,7 +216,7 @@ fn should_trigger_lint_for_vec() { // which have significant drops. The types with significant drops are also non-obvious when // reading the expression in the scrutinee. match counter.temp_increment().len() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee 2 => { let current_count = counter.i.load(Ordering::Relaxed); println!("Current count {}", current_count); @@ -240,7 +240,7 @@ fn should_trigger_lint_for_tuple_in_scrutinee() { { match (mutex1.lock().unwrap().s.len(), true) { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee (3, _) => { println!("started"); mutex1.lock().unwrap().s.len(); @@ -250,7 +250,7 @@ fn should_trigger_lint_for_tuple_in_scrutinee() { }; match (true, mutex1.lock().unwrap().s.len(), true) { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee (_, 3, _) => { println!("started"); mutex1.lock().unwrap().s.len(); @@ -261,8 +261,8 @@ fn should_trigger_lint_for_tuple_in_scrutinee() { let mutex2 = Mutex::new(StateWithField { s: "two".to_owned() }); match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { - //~^ significant_drop_in_scrutinee - //~| significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee + //~| significant_drop_in_scrutinee (3, _, 3) => { println!("started"); mutex1.lock().unwrap().s.len(); @@ -314,7 +314,7 @@ fn should_trigger_lint_for_accessing_field_in_mutex_in_one_side_of_binary_op() { let mutex = Mutex::new(StateWithField { s: "state".to_owned() }); match mutex.lock().unwrap().s.len() > 1 { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee true => { mutex.lock().unwrap().s.len(); }, @@ -322,7 +322,7 @@ fn should_trigger_lint_for_accessing_field_in_mutex_in_one_side_of_binary_op() { }; match 1 < mutex.lock().unwrap().s.len() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee true => { mutex.lock().unwrap().s.len(); }, @@ -341,8 +341,8 @@ fn should_trigger_lint_for_accessing_fields_in_mutex_in_both_sides_of_binary_op( }); match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() { - //~^ significant_drop_in_scrutinee - //~| significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee + //~| significant_drop_in_scrutinee true => { println!( "{} < {}", @@ -354,8 +354,8 @@ fn should_trigger_lint_for_accessing_fields_in_mutex_in_both_sides_of_binary_op( }; match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() { - //~^ significant_drop_in_scrutinee - //~| significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee + //~| significant_drop_in_scrutinee true => { println!( "{} >= {}", @@ -391,7 +391,7 @@ fn should_trigger_lint_for_return_from_closure_in_scrutinee() { // Should trigger lint because the temporary with a significant drop is returned from the // closure but not used directly in any match arms, so it has a potentially surprising lifetime. match get_mutex_guard().s.len() > 1 { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee true => { mutex1.lock().unwrap().s.len(); }, @@ -409,7 +409,7 @@ fn should_trigger_lint_for_return_from_match_in_scrutinee() { // significant drop is but not used directly in any match arms, so it has a potentially // surprising lifetime. match match i { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee 100 => mutex1.lock().unwrap(), _ => mutex2.lock().unwrap(), } @@ -436,7 +436,7 @@ fn should_trigger_lint_for_return_from_if_in_scrutinee() { // with a significant drop is but not used directly in any match arms, so it has a potentially // surprising lifetime. match if i > 1 { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee mutex1.lock().unwrap() } else { mutex2.lock().unwrap() @@ -491,7 +491,7 @@ fn should_trigger_lint_for_boxed_mutex_guard() { // Should trigger lint because a temporary Box holding a type with a significant drop in a match // scrutinee may have a potentially surprising lifetime. match s.lock().deref().deref() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee 0 | 1 => println!("Value was less than 2"), _ => println!("Value is {}", s.lock().deref()), }; @@ -540,28 +540,28 @@ fn should_trigger_lint_in_assign_expr() { let mut i = 100; match mutex.lock().unwrap().i = i { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee _ => { println!("{}", mutex.lock().unwrap().i); }, }; match i = mutex.lock().unwrap().i { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee _ => { println!("{}", mutex.lock().unwrap().i); }, }; match mutex.lock().unwrap().i += 1 { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee _ => { println!("{}", mutex.lock().unwrap().i); }, }; match i += mutex.lock().unwrap().i { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee _ => { println!("{}", mutex.lock().unwrap().i); }, @@ -625,7 +625,7 @@ impl ResultReturner { fn should_trigger_lint_for_non_ref_move_and_clone_suggestion() { let rwlock = RwLock::::new(ResultReturner { s: "1".to_string() }); match rwlock.read().unwrap().to_number() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee Ok(n) => println!("Converted to number: {}", n), Err(e) => println!("Could not convert {} to number", e), }; @@ -652,7 +652,7 @@ fn should_trigger_lint_without_significant_drop_in_arm() { // is preserved until the end of the match, but there is no clear indication that this is the // case. match mutex.lock().unwrap().foo() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee true => do_bar(&mutex), false => {}, }; @@ -714,7 +714,7 @@ fn should_not_trigger_for_significant_drop_ref() { } match guard.take().len() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee 0 => println!("empty"), _ => println!("not empty"), }; @@ -739,7 +739,7 @@ fn should_trigger_lint_if_and_only_if_lifetime_is_irrelevant() { // Should trigger lint even if `copy_old_lifetime()` has a lifetime, as the lifetime of // `&vec` is unrelated to the temporary with significant drop (i.e., the `MutexGuard`). for val in mutex.lock().unwrap().copy_old_lifetime() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee println!("{}", val); } @@ -778,7 +778,7 @@ fn should_not_trigger_lint_with_explicit_drop() { // Should trigger lint if there is no explicit drop. for val in [mutex.lock().unwrap()[0], 2] { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee println!("{:?}", val); } } @@ -787,7 +787,7 @@ fn should_trigger_lint_in_if_let() { let mutex = Mutex::new(vec![1]); if let Some(val) = mutex.lock().unwrap().first().copied() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee println!("{}", val); } @@ -802,7 +802,7 @@ fn should_trigger_lint_in_while_let() { let mutex = Mutex::new(vec![1]); while let Some(val) = mutex.lock().unwrap().pop() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee println!("{}", val); } } @@ -813,7 +813,7 @@ async fn foo_async(mutex: &Mutex) -> Option> { async fn should_trigger_lint_for_async(mutex: Mutex) -> i32 { match *foo_async(&mutex).await.unwrap() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee n if n < 10 => n, _ => 10, } @@ -833,7 +833,7 @@ fn should_trigger_lint_in_match_expr() { // is preserved until the end of the match, but there is no clear indication that this is the // case. let _ = match mutex.lock().unwrap().foo() { - //~^ significant_drop_in_scrutinee + //~^ significant_drop_in_scrutinee true => 0, false => 1, }; diff --git a/tests/ui/similar_names.rs b/tests/ui/similar_names.rs index a6b20b94a4a76..69b6ab6220bf2 100644 --- a/tests/ui/similar_names.rs +++ b/tests/ui/similar_names.rs @@ -47,13 +47,11 @@ fn main() { let bluby: i32; //~^ similar_names - let cake: i32; let cakes: i32; let coke: i32; //~^ similar_names - match 5 { cheese @ 1 => {}, rabbit => panic!(), @@ -73,13 +71,11 @@ fn main() { let xyzeabc: i32; //~^ similar_names - let parser: i32; let parsed: i32; let parsee: i32; //~^ similar_names - let setter: i32; let getter: i32; let tx1: i32; @@ -101,7 +97,6 @@ fn foo() { apple: spring, bpple: sprang, //~^ similar_names - } = unimplemented!(); } diff --git a/tests/ui/similar_names.stderr b/tests/ui/similar_names.stderr index 36255f52e825e..8d722fb8b564e 100644 --- a/tests/ui/similar_names.stderr +++ b/tests/ui/similar_names.stderr @@ -13,49 +13,49 @@ LL | let blubx: i32; = help: to override `-D warnings` add `#[allow(clippy::similar_names)]` error: binding's name is too similar to existing binding - --> tests/ui/similar_names.rs:53:9 + --> tests/ui/similar_names.rs:52:9 | LL | let coke: i32; | ^^^^ | note: existing binding defined here - --> tests/ui/similar_names.rs:51:9 + --> tests/ui/similar_names.rs:50:9 | LL | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> tests/ui/similar_names.rs:73:9 + --> tests/ui/similar_names.rs:71:9 | LL | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> tests/ui/similar_names.rs:71:9 + --> tests/ui/similar_names.rs:69:9 | LL | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> tests/ui/similar_names.rs:79:9 + --> tests/ui/similar_names.rs:76:9 | LL | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> tests/ui/similar_names.rs:77:9 + --> tests/ui/similar_names.rs:74:9 | LL | let parser: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> tests/ui/similar_names.rs:102:16 + --> tests/ui/similar_names.rs:98:16 | LL | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> tests/ui/similar_names.rs:101:16 + --> tests/ui/similar_names.rs:97:16 | LL | apple: spring, | ^^^^^^ diff --git a/tests/ui/single_call_fn.rs b/tests/ui/single_call_fn.rs index 0894509b73ea3..c1cc4032bec99 100644 --- a/tests/ui/single_call_fn.rs +++ b/tests/ui/single_call_fn.rs @@ -34,7 +34,7 @@ fn g() { } fn c() { -//~^ single_call_fn + //~^ single_call_fn println!("really"); println!("long"); println!("function..."); diff --git a/tests/ui/single_char_lifetime_names.rs b/tests/ui/single_char_lifetime_names.rs index e6a35cfe16428..f4dcf46b0e2d3 100644 --- a/tests/ui/single_char_lifetime_names.rs +++ b/tests/ui/single_char_lifetime_names.rs @@ -5,8 +5,6 @@ struct DiagnosticCtx<'a, 'b> //~^ single_char_lifetime_names //~| single_char_lifetime_names - - where 'a: 'b, { @@ -16,9 +14,8 @@ where // Only the lifetimes on the `impl`'s generics should be linted impl<'a, 'b> DiagnosticCtx<'a, 'b> { -//~^ single_char_lifetime_names -//~| single_char_lifetime_names - + //~^ single_char_lifetime_names + //~| single_char_lifetime_names fn new(source: &'a str, unit: &'b ()) -> DiagnosticCtx<'a, 'b> { Self { @@ -40,7 +37,7 @@ impl<'src, 'unit> DiagnosticCtx<'src, 'unit> { // Only 'a should be linted here fn split_once<'a>(base: &'a str, other: &'_ str) -> (&'a str, Option<&'a str>) { -//~^ single_char_lifetime_names + //~^ single_char_lifetime_names base.split_once(other) .map(|(left, right)| (left, Some(right))) diff --git a/tests/ui/single_char_lifetime_names.stderr b/tests/ui/single_char_lifetime_names.stderr index 010390ce15cca..834b654baa572 100644 --- a/tests/ui/single_char_lifetime_names.stderr +++ b/tests/ui/single_char_lifetime_names.stderr @@ -17,7 +17,7 @@ LL | struct DiagnosticCtx<'a, 'b> = help: use a more informative name error: single-character lifetime names are likely uninformative - --> tests/ui/single_char_lifetime_names.rs:18:6 + --> tests/ui/single_char_lifetime_names.rs:16:6 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | ^^ @@ -25,7 +25,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { = help: use a more informative name error: single-character lifetime names are likely uninformative - --> tests/ui/single_char_lifetime_names.rs:18:10 + --> tests/ui/single_char_lifetime_names.rs:16:10 | LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { | ^^ @@ -33,7 +33,7 @@ LL | impl<'a, 'b> DiagnosticCtx<'a, 'b> { = help: use a more informative name error: single-character lifetime names are likely uninformative - --> tests/ui/single_char_lifetime_names.rs:42:15 + --> tests/ui/single_char_lifetime_names.rs:39:15 | LL | fn split_once<'a>(base: &'a str, other: &'_ str) -> (&'a str, Option<&'a str>) { | ^^ diff --git a/tests/ui/single_component_path_imports_nested_first.rs b/tests/ui/single_component_path_imports_nested_first.rs index b1c6e6f94e42f..acfda8b3a9c8a 100644 --- a/tests/ui/single_component_path_imports_nested_first.rs +++ b/tests/ui/single_component_path_imports_nested_first.rs @@ -4,8 +4,6 @@ use regex; //~^ single_component_path_imports - - use serde as edres; pub use serde; @@ -19,7 +17,6 @@ mod root_nested_use_mod { //~^ single_component_path_imports //~| single_component_path_imports - #[allow(dead_code)] fn root_nested_use_mod() {} } diff --git a/tests/ui/single_component_path_imports_nested_first.stderr b/tests/ui/single_component_path_imports_nested_first.stderr index 8df4d8404eea6..6dbfd2711b4a8 100644 --- a/tests/ui/single_component_path_imports_nested_first.stderr +++ b/tests/ui/single_component_path_imports_nested_first.stderr @@ -8,7 +8,7 @@ LL | use regex; = help: to override `-D warnings` add `#[allow(clippy::single_component_path_imports)]` error: this import is redundant - --> tests/ui/single_component_path_imports_nested_first.rs:18:10 + --> tests/ui/single_component_path_imports_nested_first.rs:16:10 | LL | use {regex, serde}; | ^^^^^ @@ -16,7 +16,7 @@ LL | use {regex, serde}; = help: remove this import error: this import is redundant - --> tests/ui/single_component_path_imports_nested_first.rs:18:17 + --> tests/ui/single_component_path_imports_nested_first.rs:16:17 | LL | use {regex, serde}; | ^^^^^ diff --git a/tests/ui/single_element_loop.fixed b/tests/ui/single_element_loop.fixed index eadf77f0fa50a..76c3cf56c11ec 100644 --- a/tests/ui/single_element_loop.fixed +++ b/tests/ui/single_element_loop.fixed @@ -7,33 +7,33 @@ fn main() { let item1 = 2; { let item = &item1; - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } { let item = &item1; - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in 0..5 { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in 0..5 { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in 0..5 { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in 0..5 { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } @@ -54,7 +54,7 @@ fn main() { // should lint (issue #10018) { let _ = 42; - //~^ single_element_loop + //~^ single_element_loop let _f = |n: u32| { for i in 0..n { if i > 10 { @@ -70,7 +70,7 @@ fn main() { { let (Ok(mut _x) | Err(mut _x)) = res_void; - //~^ single_element_loop + //~^ single_element_loop let ptr: *const bool = std::ptr::null(); } } diff --git a/tests/ui/single_element_loop.rs b/tests/ui/single_element_loop.rs index 6aa9269e56c0c..2eb928397b0a6 100644 --- a/tests/ui/single_element_loop.rs +++ b/tests/ui/single_element_loop.rs @@ -6,32 +6,32 @@ fn main() { let item1 = 2; for item in &[item1] { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in [item1].iter() { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in &[0..5] { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in [0..5].iter_mut() { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in [0..5] { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } for item in [0..5].into_iter() { - //~^ single_element_loop + //~^ single_element_loop dbg!(item); } @@ -51,7 +51,7 @@ fn main() { // should lint (issue #10018) for _ in [42] { - //~^ single_element_loop + //~^ single_element_loop let _f = |n: u32| { for i in 0..n { if i > 10 { @@ -66,7 +66,7 @@ fn main() { let res_void: Result = Ok(true); for (Ok(mut _x) | Err(mut _x)) in [res_void] { - //~^ single_element_loop + //~^ single_element_loop let ptr: *const bool = std::ptr::null(); } } diff --git a/tests/ui/single_option_map.rs b/tests/ui/single_option_map.rs index fd9db9165bdc8..6126582f4635a 100644 --- a/tests/ui/single_option_map.rs +++ b/tests/ui/single_option_map.rs @@ -6,13 +6,13 @@ static ATOM: AtomicUsize = AtomicUsize::new(42); static MAYBE_ATOMIC: Option<&AtomicUsize> = Some(&ATOM); fn h(arg: Option) -> Option { -//~^ single_option_map + //~^ single_option_map arg.map(|x| x * 2) } fn j(arg: Option) -> Option { -//~^ single_option_map + //~^ single_option_map arg.map(|x| x * 2) } @@ -22,7 +22,7 @@ fn mul_args(a: String, b: u64) -> String { } fn mul_args_opt(a: Option, b: u64) -> Option { -//~^ single_option_map + //~^ single_option_map a.map(|val| mul_args(val, b + 1)) } diff --git a/tests/ui/size_of_in_element_count/expressions.rs b/tests/ui/size_of_in_element_count/expressions.rs index 39c482af78c04..3fe4d923441dd 100644 --- a/tests/ui/size_of_in_element_count/expressions.rs +++ b/tests/ui/size_of_in_element_count/expressions.rs @@ -15,17 +15,14 @@ fn main() { unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::() * SIZE) }; //~^ size_of_in_element_count - // Count expression involving nested multiplications of size_of (Should trigger the lint) unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) }; //~^ size_of_in_element_count - // Count expression involving divisions of size_of (Should trigger the lint) unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() / 2) }; //~^ size_of_in_element_count - // Count expression involving divisions by size_of (Should not trigger the lint) unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / size_of::()) }; @@ -36,7 +33,6 @@ fn main() { unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::())) }; //~^ size_of_in_element_count - // No size_of calls (Should not trigger the lint) unsafe { copy(x.as_ptr(), y.as_mut_ptr(), SIZE) }; } diff --git a/tests/ui/size_of_in_element_count/expressions.stderr b/tests/ui/size_of_in_element_count/expressions.stderr index 8af8867e04ddc..74be0d7773dff 100644 --- a/tests/ui/size_of_in_element_count/expressions.stderr +++ b/tests/ui/size_of_in_element_count/expressions.stderr @@ -9,7 +9,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of:: = help: to override `-D warnings` add `#[allow(clippy::size_of_in_element_count)]` error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/expressions.rs:20:62 + --> tests/ui/size_of_in_element_count/expressions.rs:19:62 | LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * si = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/expressions.rs:25:47 + --> tests/ui/size_of_in_element_count/expressions.rs:23:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::() / 2) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::( = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/expressions.rs:36:47 + --> tests/ui/size_of_in_element_count/expressions.rs:33:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::())) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/size_of_in_element_count/functions.rs b/tests/ui/size_of_in_element_count/functions.rs index c8bb603d8165e..afd12edec1edb 100644 --- a/tests/ui/size_of_in_element_count/functions.rs +++ b/tests/ui/size_of_in_element_count/functions.rs @@ -21,7 +21,6 @@ fn main() { unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; //~^ size_of_in_element_count - unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; //~^ size_of_in_element_count @@ -34,32 +33,27 @@ fn main() { unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::()) }; //~^ size_of_in_element_count - unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; //~^ size_of_in_element_count unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; //~^ size_of_in_element_count - unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::() * SIZE) }; //~^ size_of_in_element_count - slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); //~^ size_of_in_element_count slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); //~^ size_of_in_element_count - unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; //~^ size_of_in_element_count unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; //~^ size_of_in_element_count - unsafe { y.as_mut_ptr().sub(size_of::()) }; //~^ size_of_in_element_count @@ -77,5 +71,4 @@ fn main() { y.as_mut_ptr().wrapping_offset(size_of::() as isize); //~^ size_of_in_element_count - } diff --git a/tests/ui/size_of_in_element_count/functions.stderr b/tests/ui/size_of_in_element_count/functions.stderr index a05f88436a6a4..f11c331676691 100644 --- a/tests/ui/size_of_in_element_count/functions.stderr +++ b/tests/ui/size_of_in_element_count/functions.stderr @@ -17,7 +17,7 @@ LL | unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:25:49 + --> tests/ui/size_of_in_element_count/functions.rs:24:49 | LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:28:64 + --> tests/ui/size_of_in_element_count/functions.rs:27:64 | LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of:: tests/ui/size_of_in_element_count/functions.rs:31:51 + --> tests/ui/size_of_in_element_count/functions.rs:30:51 | LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:34:66 + --> tests/ui/size_of_in_element_count/functions.rs:33:66 | LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::< = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:38:47 + --> tests/ui/size_of_in_element_count/functions.rs:36:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; | ^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:41:47 + --> tests/ui/size_of_in_element_count/functions.rs:39:47 | LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; | ^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:45:66 + --> tests/ui/size_of_in_element_count/functions.rs:42:66 | LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::< = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:49:46 + --> tests/ui/size_of_in_element_count/functions.rs:45:46 | LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:52:38 + --> tests/ui/size_of_in_element_count/functions.rs:48:38 | LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | slice_from_raw_parts(y.as_ptr(), size_of::() * SIZE); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:56:49 + --> tests/ui/size_of_in_element_count/functions.rs:51:49 | LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:59:41 + --> tests/ui/size_of_in_element_count/functions.rs:54:41 | LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL | unsafe { from_raw_parts(y.as_ptr(), size_of::() * SIZE) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:63:33 + --> tests/ui/size_of_in_element_count/functions.rs:57:33 | LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; | ^^^^^^^^^^^^^^^^ @@ -113,7 +113,7 @@ LL | unsafe { y.as_mut_ptr().sub(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:66:29 + --> tests/ui/size_of_in_element_count/functions.rs:60:29 | LL | y.as_ptr().wrapping_sub(size_of::()); | ^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | y.as_ptr().wrapping_sub(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:69:29 + --> tests/ui/size_of_in_element_count/functions.rs:63:29 | LL | unsafe { y.as_ptr().add(size_of::()) }; | ^^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | unsafe { y.as_ptr().add(size_of::()) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:72:33 + --> tests/ui/size_of_in_element_count/functions.rs:66:33 | LL | y.as_mut_ptr().wrapping_add(size_of::()); | ^^^^^^^^^^^^^^^^ @@ -137,7 +137,7 @@ LL | y.as_mut_ptr().wrapping_add(size_of::()); = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:75:32 + --> tests/ui/size_of_in_element_count/functions.rs:69:32 | LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL | unsafe { y.as_ptr().offset(size_of::() as isize) }; = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type error: found a count of bytes instead of a count of elements of `T` - --> tests/ui/size_of_in_element_count/functions.rs:78:36 + --> tests/ui/size_of_in_element_count/functions.rs:72:36 | LL | y.as_mut_ptr().wrapping_offset(size_of::() as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/size_of_ref.rs b/tests/ui/size_of_ref.rs index 06ed216b3422f..9a6a9419f681e 100644 --- a/tests/ui/size_of_ref.rs +++ b/tests/ui/size_of_ref.rs @@ -15,7 +15,6 @@ fn main() { size_of_val(&y); //~^ size_of_ref - } struct S { @@ -28,6 +27,5 @@ impl S { pub fn size(&self) -> usize { std::mem::size_of_val(&self) + (std::mem::size_of::() * self.data.capacity()) //~^ size_of_ref - } } diff --git a/tests/ui/size_of_ref.stderr b/tests/ui/size_of_ref.stderr index 0dc64673940ee..6ac0b0dd2f065 100644 --- a/tests/ui/size_of_ref.stderr +++ b/tests/ui/size_of_ref.stderr @@ -17,7 +17,7 @@ LL | size_of_val(&y); = help: dereference the argument to `std::mem::size_of_val()` to get the size of the value instead of the size of the reference-type error: argument to `std::mem::size_of_val()` is a reference to a reference - --> tests/ui/size_of_ref.rs:29:9 + --> tests/ui/size_of_ref.rs:28:9 | LL | std::mem::size_of_val(&self) + (std::mem::size_of::() * self.data.capacity()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/slow_vector_initialization.rs b/tests/ui/slow_vector_initialization.rs index 6a09d1f36a66e..52f2a52fbbb86 100644 --- a/tests/ui/slow_vector_initialization.rs +++ b/tests/ui/slow_vector_initialization.rs @@ -14,7 +14,6 @@ fn extend_vector() { let mut vec1 = Vec::with_capacity(len); //~^ slow_vector_initialization - vec1.extend(repeat(0).take(len)); // Extend with len expression diff --git a/tests/ui/slow_vector_initialization.stderr b/tests/ui/slow_vector_initialization.stderr index 67a0b928618a4..e83eef8264724 100644 --- a/tests/ui/slow_vector_initialization.stderr +++ b/tests/ui/slow_vector_initialization.stderr @@ -11,7 +11,7 @@ LL | | vec1.extend(repeat(0).take(len)); = help: to override `-D warnings` add `#[allow(clippy::slow_vector_initialization)]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:21:20 + --> tests/ui/slow_vector_initialization.rs:20:20 | LL | let mut vec2 = Vec::with_capacity(len - 10); | ____________________^ @@ -20,7 +20,7 @@ LL | | vec2.extend(repeat(0).take(len - 10)); | |_________________________________________^ help: consider replacing this with: `vec![0; len - 10]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:30:20 + --> tests/ui/slow_vector_initialization.rs:29:20 | LL | let mut vec4 = Vec::with_capacity(len); | ____________________^ @@ -29,7 +29,7 @@ LL | | vec4.extend(repeat(0).take(vec4.capacity())); | |________________________________________________^ help: consider replacing this with: `vec![0; len]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:42:27 + --> tests/ui/slow_vector_initialization.rs:41:27 | LL | let mut resized_vec = Vec::with_capacity(30); | ___________________________^ @@ -38,7 +38,7 @@ LL | | resized_vec.resize(30, 0); | |_____________________________^ help: consider replacing this with: `vec![0; 30]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:47:26 + --> tests/ui/slow_vector_initialization.rs:46:26 | LL | let mut extend_vec = Vec::with_capacity(30); | __________________________^ @@ -47,7 +47,7 @@ LL | | extend_vec.extend(repeat(0).take(30)); | |_________________________________________^ help: consider replacing this with: `vec![0; 30]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:56:20 + --> tests/ui/slow_vector_initialization.rs:55:20 | LL | let mut vec1 = Vec::with_capacity(len); | ____________________^ @@ -56,7 +56,7 @@ LL | | vec1.resize(len, 0); | |_______________________^ help: consider replacing this with: `vec![0; len]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:66:20 + --> tests/ui/slow_vector_initialization.rs:65:20 | LL | let mut vec3 = Vec::with_capacity(len - 10); | ____________________^ @@ -65,7 +65,7 @@ LL | | vec3.resize(len - 10, 0); | |____________________________^ help: consider replacing this with: `vec![0; len - 10]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:71:20 + --> tests/ui/slow_vector_initialization.rs:70:20 | LL | let mut vec4 = Vec::with_capacity(len); | ____________________^ @@ -74,7 +74,7 @@ LL | | vec4.resize(vec4.capacity(), 0); | |___________________________________^ help: consider replacing this with: `vec![0; len]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:77:12 + --> tests/ui/slow_vector_initialization.rs:76:12 | LL | vec1 = Vec::with_capacity(10); | ____________^ @@ -83,7 +83,7 @@ LL | | vec1.resize(10, 0); | |______________________^ help: consider replacing this with: `vec![0; 10]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:86:20 + --> tests/ui/slow_vector_initialization.rs:85:20 | LL | let mut vec1 = Vec::new(); | ____________________^ @@ -92,7 +92,7 @@ LL | | vec1.resize(len, 0); | |_______________________^ help: consider replacing this with: `vec![0; len]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:92:20 + --> tests/ui/slow_vector_initialization.rs:91:20 | LL | let mut vec3 = Vec::new(); | ____________________^ @@ -101,7 +101,7 @@ LL | | vec3.resize(len - 10, 0); | |____________________________^ help: consider replacing this with: `vec![0; len - 10]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:98:12 + --> tests/ui/slow_vector_initialization.rs:97:12 | LL | vec1 = Vec::new(); | ____________^ @@ -110,7 +110,7 @@ LL | | vec1.resize(10, 0); | |______________________^ help: consider replacing this with: `vec![0; 10]` error: slow zero-filling initialization - --> tests/ui/slow_vector_initialization.rs:103:12 + --> tests/ui/slow_vector_initialization.rs:102:12 | LL | vec1 = vec![]; | ____________^ diff --git a/tests/ui/starts_ends_with.fixed b/tests/ui/starts_ends_with.fixed index 3e1ea00a341eb..b4f9d5867703a 100644 --- a/tests/ui/starts_ends_with.fixed +++ b/tests/ui/starts_ends_with.fixed @@ -19,32 +19,32 @@ fn starts_with() { fn chars_cmp_with_unwrap() { let s = String::from("foo"); if s.starts_with('f') { - //~^ chars_next_cmp + //~^ chars_next_cmp // s.starts_with('f') // Nothing here } if s.ends_with('o') { - //~^ chars_last_cmp + //~^ chars_last_cmp // s.ends_with('o') // Nothing here } if s.ends_with('o') { - //~^ chars_last_cmp + //~^ chars_last_cmp // s.ends_with('o') // Nothing here } if !s.starts_with('f') { - //~^ chars_next_cmp + //~^ chars_next_cmp // !s.starts_with('f') // Nothing here } if !s.ends_with('o') { - //~^ chars_last_cmp + //~^ chars_last_cmp // !s.ends_with('o') // Nothing here } if !s.ends_with('\n') { - //~^ chars_last_cmp + //~^ chars_last_cmp // !s.ends_with('o') // Nothing here } diff --git a/tests/ui/starts_ends_with.rs b/tests/ui/starts_ends_with.rs index ef7143a455f95..dae04ac4a62d5 100644 --- a/tests/ui/starts_ends_with.rs +++ b/tests/ui/starts_ends_with.rs @@ -19,32 +19,32 @@ fn starts_with() { fn chars_cmp_with_unwrap() { let s = String::from("foo"); if s.chars().next().unwrap() == 'f' { - //~^ chars_next_cmp + //~^ chars_next_cmp // s.starts_with('f') // Nothing here } if s.chars().next_back().unwrap() == 'o' { - //~^ chars_last_cmp + //~^ chars_last_cmp // s.ends_with('o') // Nothing here } if s.chars().last().unwrap() == 'o' { - //~^ chars_last_cmp + //~^ chars_last_cmp // s.ends_with('o') // Nothing here } if s.chars().next().unwrap() != 'f' { - //~^ chars_next_cmp + //~^ chars_next_cmp // !s.starts_with('f') // Nothing here } if s.chars().next_back().unwrap() != 'o' { - //~^ chars_last_cmp + //~^ chars_last_cmp // !s.ends_with('o') // Nothing here } if s.chars().last().unwrap() != '\n' { - //~^ chars_last_cmp + //~^ chars_last_cmp // !s.ends_with('o') // Nothing here } diff --git a/tests/ui/str_to_string.fixed b/tests/ui/str_to_string.fixed index 4977e9c944d11..2941c4dbd33d9 100644 --- a/tests/ui/str_to_string.fixed +++ b/tests/ui/str_to_string.fixed @@ -7,5 +7,4 @@ fn main() { let msg = &hello[..]; msg.to_owned(); //~^ str_to_string - } diff --git a/tests/ui/str_to_string.rs b/tests/ui/str_to_string.rs index f710761471b64..4c4d2bb180625 100644 --- a/tests/ui/str_to_string.rs +++ b/tests/ui/str_to_string.rs @@ -7,5 +7,4 @@ fn main() { let msg = &hello[..]; msg.to_string(); //~^ str_to_string - } diff --git a/tests/ui/string_slice.rs b/tests/ui/string_slice.rs index 9251b348af3fe..0acc48c1f4121 100644 --- a/tests/ui/string_slice.rs +++ b/tests/ui/string_slice.rs @@ -7,7 +7,6 @@ fn main() { &"Ölkanne"[1..]; //~^ string_slice - let m = "Mötörhead"; &m[2..5]; //~^ string_slice @@ -19,5 +18,4 @@ fn main() { let a = Cow::Borrowed("foo"); &a[0..3]; //~^ string_slice - } diff --git a/tests/ui/string_slice.stderr b/tests/ui/string_slice.stderr index 4932152af6b6f..f99413c6dfc6f 100644 --- a/tests/ui/string_slice.stderr +++ b/tests/ui/string_slice.stderr @@ -8,19 +8,19 @@ LL | &"Ölkanne"[1..]; = help: to override `-D warnings` add `#[allow(clippy::string_slice)]` error: indexing into a string may panic if the index is within a UTF-8 character - --> tests/ui/string_slice.rs:12:6 + --> tests/ui/string_slice.rs:11:6 | LL | &m[2..5]; | ^^^^^^^ error: indexing into a string may panic if the index is within a UTF-8 character - --> tests/ui/string_slice.rs:16:6 + --> tests/ui/string_slice.rs:15:6 | LL | &s[0..2]; | ^^^^^^^ error: indexing into a string may panic if the index is within a UTF-8 character - --> tests/ui/string_slice.rs:20:6 + --> tests/ui/string_slice.rs:19:6 | LL | &a[0..3]; | ^^^^^^^ diff --git a/tests/ui/string_to_string.rs b/tests/ui/string_to_string.rs index e3f5b6cf3bdce..94174e1253b8c 100644 --- a/tests/ui/string_to_string.rs +++ b/tests/ui/string_to_string.rs @@ -5,5 +5,4 @@ fn main() { let mut message = String::from("Hello"); let mut v = message.to_string(); //~^ string_to_string - } diff --git a/tests/ui/struct_excessive_bools.rs b/tests/ui/struct_excessive_bools.rs index f509c3143a868..36cbc62780302 100644 --- a/tests/ui/struct_excessive_bools.rs +++ b/tests/ui/struct_excessive_bools.rs @@ -20,8 +20,7 @@ struct Foo { } struct BadFoo { -//~^ struct_excessive_bools - + //~^ struct_excessive_bools a: bool, b: bool, c: bool, @@ -38,8 +37,7 @@ struct Bar { fn main() { struct FooFoo { - //~^ struct_excessive_bools - + //~^ struct_excessive_bools a: bool, b: bool, c: bool, diff --git a/tests/ui/struct_excessive_bools.stderr b/tests/ui/struct_excessive_bools.stderr index 573af45355a69..bdf6f0b7a1dae 100644 --- a/tests/ui/struct_excessive_bools.stderr +++ b/tests/ui/struct_excessive_bools.stderr @@ -3,9 +3,9 @@ error: more than 3 bools in a struct | LL | / struct BadFoo { LL | | -LL | | LL | | a: bool, -... | +LL | | b: bool, +LL | | c: bool, LL | | d: bool, LL | | } | |_^ @@ -15,13 +15,13 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::struct_excessive_bools)]` error: more than 3 bools in a struct - --> tests/ui/struct_excessive_bools.rs:40:5 + --> tests/ui/struct_excessive_bools.rs:39:5 | LL | / struct FooFoo { LL | | -LL | | LL | | a: bool, -... | +LL | | b: bool, +LL | | c: bool, LL | | d: bool, LL | | } | |_____^ diff --git a/tests/ui/suspicious_arithmetic_impl.rs b/tests/ui/suspicious_arithmetic_impl.rs index b9207b1b3f913..9798d2049c624 100644 --- a/tests/ui/suspicious_arithmetic_impl.rs +++ b/tests/ui/suspicious_arithmetic_impl.rs @@ -13,8 +13,6 @@ impl Add for Foo { fn add(self, other: Self) -> Self { Foo(self.0 - other.0) //~^ suspicious_arithmetic_impl - - } } @@ -22,8 +20,6 @@ impl AddAssign for Foo { fn add_assign(&mut self, other: Foo) { *self = *self - other; //~^ suspicious_op_assign_impl - - } } @@ -38,7 +34,6 @@ impl MulAssign for Foo { fn mul_assign(&mut self, other: Foo) { self.0 /= other.0; //~^ suspicious_op_assign_impl - } } @@ -78,7 +73,6 @@ impl Rem for Foo { fn rem(self, other: Self) -> Self { Foo(self.0 / other.0) //~^ suspicious_arithmetic_impl - } } @@ -88,7 +82,6 @@ impl BitAnd for Foo { fn bitand(self, other: Self) -> Self { Foo(self.0 | other.0) //~^ suspicious_arithmetic_impl - } } @@ -98,7 +91,6 @@ impl BitOr for Foo { fn bitor(self, other: Self) -> Self { Foo(self.0 ^ other.0) //~^ suspicious_arithmetic_impl - } } @@ -108,7 +100,6 @@ impl BitXor for Foo { fn bitxor(self, other: Self) -> Self { Foo(self.0 & other.0) //~^ suspicious_arithmetic_impl - } } @@ -118,7 +109,6 @@ impl Shl for Foo { fn shl(self, other: Self) -> Self { Foo(self.0 >> other.0) //~^ suspicious_arithmetic_impl - } } @@ -128,7 +118,6 @@ impl Shr for Foo { fn shr(self, other: Self) -> Self { Foo(self.0 << other.0) //~^ suspicious_arithmetic_impl - } } diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index a392aa16f1d45..2d8aac4db2a7e 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -8,7 +8,7 @@ LL | Foo(self.0 - other.0) = help: to override `-D warnings` add `#[allow(clippy::suspicious_arithmetic_impl)]` error: suspicious use of `-` in `AddAssign` impl - --> tests/ui/suspicious_arithmetic_impl.rs:23:23 + --> tests/ui/suspicious_arithmetic_impl.rs:21:23 | LL | *self = *self - other; | ^ @@ -17,43 +17,43 @@ LL | *self = *self - other; = help: to override `-D warnings` add `#[allow(clippy::suspicious_op_assign_impl)]` error: suspicious use of `/` in `MulAssign` impl - --> tests/ui/suspicious_arithmetic_impl.rs:39:16 + --> tests/ui/suspicious_arithmetic_impl.rs:35:16 | LL | self.0 /= other.0; | ^^ error: suspicious use of `/` in `Rem` impl - --> tests/ui/suspicious_arithmetic_impl.rs:79:20 + --> tests/ui/suspicious_arithmetic_impl.rs:74:20 | LL | Foo(self.0 / other.0) | ^ error: suspicious use of `|` in `BitAnd` impl - --> tests/ui/suspicious_arithmetic_impl.rs:89:20 + --> tests/ui/suspicious_arithmetic_impl.rs:83:20 | LL | Foo(self.0 | other.0) | ^ error: suspicious use of `^` in `BitOr` impl - --> tests/ui/suspicious_arithmetic_impl.rs:99:20 + --> tests/ui/suspicious_arithmetic_impl.rs:92:20 | LL | Foo(self.0 ^ other.0) | ^ error: suspicious use of `&` in `BitXor` impl - --> tests/ui/suspicious_arithmetic_impl.rs:109:20 + --> tests/ui/suspicious_arithmetic_impl.rs:101:20 | LL | Foo(self.0 & other.0) | ^ error: suspicious use of `>>` in `Shl` impl - --> tests/ui/suspicious_arithmetic_impl.rs:119:20 + --> tests/ui/suspicious_arithmetic_impl.rs:110:20 | LL | Foo(self.0 >> other.0) | ^^ error: suspicious use of `<<` in `Shr` impl - --> tests/ui/suspicious_arithmetic_impl.rs:129:20 + --> tests/ui/suspicious_arithmetic_impl.rs:119:20 | LL | Foo(self.0 << other.0) | ^^ diff --git a/tests/ui/suspicious_command_arg_space.fixed b/tests/ui/suspicious_command_arg_space.fixed index 5ab070f88dcf7..0a0d90f75e573 100644 --- a/tests/ui/suspicious_command_arg_space.fixed +++ b/tests/ui/suspicious_command_arg_space.fixed @@ -4,11 +4,9 @@ fn main() { std::process::Command::new("echo").args(["-n", "hello"]).spawn().unwrap(); //~^ suspicious_command_arg_space - std::process::Command::new("cat").args(["--number", "file"]).spawn().unwrap(); //~^ suspicious_command_arg_space - // Things it should not warn about: std::process::Command::new("echo").arg("hello world").spawn().unwrap(); std::process::Command::new("a").arg("--fmt=%a %b %c").spawn().unwrap(); diff --git a/tests/ui/suspicious_command_arg_space.rs b/tests/ui/suspicious_command_arg_space.rs index 0017bd44dbfe2..78bdfbdf0cb6b 100644 --- a/tests/ui/suspicious_command_arg_space.rs +++ b/tests/ui/suspicious_command_arg_space.rs @@ -4,11 +4,9 @@ fn main() { std::process::Command::new("echo").arg("-n hello").spawn().unwrap(); //~^ suspicious_command_arg_space - std::process::Command::new("cat").arg("--number file").spawn().unwrap(); //~^ suspicious_command_arg_space - // Things it should not warn about: std::process::Command::new("echo").arg("hello world").spawn().unwrap(); std::process::Command::new("a").arg("--fmt=%a %b %c").spawn().unwrap(); diff --git a/tests/ui/suspicious_command_arg_space.stderr b/tests/ui/suspicious_command_arg_space.stderr index f4d7d79def14b..6fd07d07d7be6 100644 --- a/tests/ui/suspicious_command_arg_space.stderr +++ b/tests/ui/suspicious_command_arg_space.stderr @@ -12,7 +12,7 @@ LL | std::process::Command::new("echo").args(["-n", "hello"]).spawn().unwrap | ~~~~ ~~~~~~~~~~~~~~~ error: single argument that looks like it should be multiple arguments - --> tests/ui/suspicious_command_arg_space.rs:8:43 + --> tests/ui/suspicious_command_arg_space.rs:7:43 | LL | std::process::Command::new("cat").arg("--number file").spawn().unwrap(); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/suspicious_doc_comments.fixed b/tests/ui/suspicious_doc_comments.fixed index 58f6ebdb4c7c1..0c878afc66e1b 100644 --- a/tests/ui/suspicious_doc_comments.fixed +++ b/tests/ui/suspicious_doc_comments.fixed @@ -21,8 +21,8 @@ pub mod singleline_inner_doc { pub mod multiline_outer_doc { /*! This module contains useful functions. - //~^ suspicious_doc_comments */ + //~^^ suspicious_doc_comments pub fn bar() {} } diff --git a/tests/ui/suspicious_doc_comments.rs b/tests/ui/suspicious_doc_comments.rs index 26ee028b8c571..d89fe4f1bec7e 100644 --- a/tests/ui/suspicious_doc_comments.rs +++ b/tests/ui/suspicious_doc_comments.rs @@ -21,8 +21,8 @@ pub mod singleline_inner_doc { pub mod multiline_outer_doc { /**! This module contains useful functions. - //~^ suspicious_doc_comments */ + //~^^ suspicious_doc_comments pub fn bar() {} } diff --git a/tests/ui/suspicious_doc_comments.stderr b/tests/ui/suspicious_doc_comments.stderr index 8982e98b4daab..61363ff9bd206 100644 --- a/tests/ui/suspicious_doc_comments.stderr +++ b/tests/ui/suspicious_doc_comments.stderr @@ -26,14 +26,12 @@ error: this is an outer doc comment and does not apply to the parent module or c --> tests/ui/suspicious_doc_comments.rs:23:5 | LL | / /**! This module contains useful functions. -LL | | LL | | */ | |_______^ | help: use an inner doc comment to document the parent module or crate | LL ~ /*! This module contains useful functions. -LL + LL + */ | diff --git a/tests/ui/suspicious_doc_comments_unfixable.rs b/tests/ui/suspicious_doc_comments_unfixable.rs index 255c6f7237df0..e526de5ca2c35 100644 --- a/tests/ui/suspicious_doc_comments_unfixable.rs +++ b/tests/ui/suspicious_doc_comments_unfixable.rs @@ -4,7 +4,6 @@ ///! a //~^ suspicious_doc_comments - ///! b /// c ///! d diff --git a/tests/ui/suspicious_doc_comments_unfixable.stderr b/tests/ui/suspicious_doc_comments_unfixable.stderr index ff4cb3358a814..234a22021df39 100644 --- a/tests/ui/suspicious_doc_comments_unfixable.stderr +++ b/tests/ui/suspicious_doc_comments_unfixable.stderr @@ -2,7 +2,9 @@ error: this is an outer doc comment and does not apply to the parent module or c --> tests/ui/suspicious_doc_comments_unfixable.rs:4:1 | LL | / ///! a -... | +LL | | +LL | | +LL | | ///! b LL | | /// c LL | | ///! d | |______^ @@ -14,14 +16,13 @@ help: use an inner doc comment to document the parent module or crate LL + //! a LL | LL | -LL | LL + //! b LL | /// c LL + //! d | error: this is an outer doc comment and does not apply to the parent module or crate - --> tests/ui/suspicious_doc_comments_unfixable.rs:13:1 + --> tests/ui/suspicious_doc_comments_unfixable.rs:12:1 | LL | / ///! a LL | | diff --git a/tests/ui/suspicious_map.rs b/tests/ui/suspicious_map.rs index 3e3035a68f492..86e48e29bb9e5 100644 --- a/tests/ui/suspicious_map.rs +++ b/tests/ui/suspicious_map.rs @@ -5,11 +5,9 @@ fn main() { let _ = (0..3).map(|x| x + 2).count(); //~^ suspicious_map - let f = |x| x + 1; let _ = (0..3).map(f).count(); //~^ suspicious_map - } fn negative() { diff --git a/tests/ui/suspicious_map.stderr b/tests/ui/suspicious_map.stderr index 7c08168f0c204..769adebaede7c 100644 --- a/tests/ui/suspicious_map.stderr +++ b/tests/ui/suspicious_map.stderr @@ -9,7 +9,7 @@ LL | let _ = (0..3).map(|x| x + 2).count(); = help: to override `-D warnings` add `#[allow(clippy::suspicious_map)]` error: this call to `map()` won't have an effect on the call to `count()` - --> tests/ui/suspicious_map.rs:10:13 + --> tests/ui/suspicious_map.rs:9:13 | LL | let _ = (0..3).map(f).count(); | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/suspicious_operation_groupings.fixed b/tests/ui/suspicious_operation_groupings.fixed index 1da292130d050..37054222bd622 100644 --- a/tests/ui/suspicious_operation_groupings.fixed +++ b/tests/ui/suspicious_operation_groupings.fixed @@ -216,7 +216,7 @@ fn inside_fn_with_similar_expression(s1: &S, s2: &S, strict: bool) -> bool { fn inside_an_if_statement(s1: &mut S, s2: &S) { // There's no `s1.b` if s1.a < s2.a && s1.b < s2.b { - //~^ suspicious_operation_groupings + //~^ suspicious_operation_groupings s1.c = s2.c; } } diff --git a/tests/ui/suspicious_operation_groupings.rs b/tests/ui/suspicious_operation_groupings.rs index 25ccba182fa5b..f4d1c3c70b564 100644 --- a/tests/ui/suspicious_operation_groupings.rs +++ b/tests/ui/suspicious_operation_groupings.rs @@ -216,7 +216,7 @@ fn inside_fn_with_similar_expression(s1: &S, s2: &S, strict: bool) -> bool { fn inside_an_if_statement(s1: &mut S, s2: &S) { // There's no `s1.b` if s1.a < s2.a && s1.a < s2.b { - //~^ suspicious_operation_groupings + //~^ suspicious_operation_groupings s1.c = s2.c; } } diff --git a/tests/ui/suspicious_splitn.rs b/tests/ui/suspicious_splitn.rs index d7c1dd9724508..535f62c6bedee 100644 --- a/tests/ui/suspicious_splitn.rs +++ b/tests/ui/suspicious_splitn.rs @@ -10,39 +10,28 @@ fn main() { let _ = "a,b".splitn(0, ','); //~^ suspicious_splitn - let _ = "a,b".rsplitn(0, ','); //~^ suspicious_splitn - let _ = "a,b".splitn(1, ','); //~^ suspicious_splitn - let _ = [0, 1, 2].splitn(0, |&x| x == 1); //~^ suspicious_splitn - let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); //~^ suspicious_splitn - let _ = [0, 1, 2].splitn(1, |&x| x == 1); //~^ suspicious_splitn - let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); //~^ suspicious_splitn - - const X: usize = 0; let _ = "a,b".splitn(X + 1, ','); //~^ suspicious_splitn - let _ = "a,b".splitn(X, ','); //~^ suspicious_splitn - - } diff --git a/tests/ui/suspicious_splitn.stderr b/tests/ui/suspicious_splitn.stderr index 1e1a9b22ffbde..910c905bc990e 100644 --- a/tests/ui/suspicious_splitn.stderr +++ b/tests/ui/suspicious_splitn.stderr @@ -9,7 +9,7 @@ LL | let _ = "a,b".splitn(0, ','); = help: to override `-D warnings` add `#[allow(clippy::suspicious_splitn)]` error: `rsplitn` called with `0` splits - --> tests/ui/suspicious_splitn.rs:14:13 + --> tests/ui/suspicious_splitn.rs:13:13 | LL | let _ = "a,b".rsplitn(0, ','); | ^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let _ = "a,b".rsplitn(0, ','); = note: the resulting iterator will always return `None` error: `splitn` called with `1` split - --> tests/ui/suspicious_splitn.rs:18:13 + --> tests/ui/suspicious_splitn.rs:16:13 | LL | let _ = "a,b".splitn(1, ','); | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let _ = "a,b".splitn(1, ','); = note: the resulting iterator will always return the entire string followed by `None` error: `splitn` called with `0` splits - --> tests/ui/suspicious_splitn.rs:22:13 + --> tests/ui/suspicious_splitn.rs:19:13 | LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let _ = [0, 1, 2].splitn(0, |&x| x == 1); = note: the resulting iterator will always return `None` error: `splitn_mut` called with `0` splits - --> tests/ui/suspicious_splitn.rs:26:13 + --> tests/ui/suspicious_splitn.rs:22:13 | LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let _ = [0, 1, 2].splitn_mut(0, |&x| x == 1); = note: the resulting iterator will always return `None` error: `splitn` called with `1` split - --> tests/ui/suspicious_splitn.rs:30:13 + --> tests/ui/suspicious_splitn.rs:25:13 | LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let _ = [0, 1, 2].splitn(1, |&x| x == 1); = note: the resulting iterator will always return the entire slice followed by `None` error: `rsplitn_mut` called with `1` split - --> tests/ui/suspicious_splitn.rs:34:13 + --> tests/ui/suspicious_splitn.rs:28:13 | LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | let _ = [0, 1, 2].rsplitn_mut(1, |&x| x == 1); = note: the resulting iterator will always return the entire slice followed by `None` error: `splitn` called with `1` split - --> tests/ui/suspicious_splitn.rs:40:13 + --> tests/ui/suspicious_splitn.rs:32:13 | LL | let _ = "a,b".splitn(X + 1, ','); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | let _ = "a,b".splitn(X + 1, ','); = note: the resulting iterator will always return the entire string followed by `None` error: `splitn` called with `0` splits - --> tests/ui/suspicious_splitn.rs:44:13 + --> tests/ui/suspicious_splitn.rs:35:13 | LL | let _ = "a,b".splitn(X, ','); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/suspicious_to_owned.rs b/tests/ui/suspicious_to_owned.rs index bde20f4116c3b..2eec05ccaf4cb 100644 --- a/tests/ui/suspicious_to_owned.rs +++ b/tests/ui/suspicious_to_owned.rs @@ -17,7 +17,6 @@ fn main() { let _ = cow.to_owned(); //~^ suspicious_to_owned - // we expect no lints for this let cow = Cow::Borrowed(moo); let _ = cow.into_owned(); @@ -70,8 +69,6 @@ fn main() { let _ = String::from(moo).to_owned(); //~^ implicit_clone - let _ = moos_vec.to_owned(); //~^ implicit_clone - } diff --git a/tests/ui/suspicious_to_owned.stderr b/tests/ui/suspicious_to_owned.stderr index 6c00819b48636..cc6f5b7d3a5ac 100644 --- a/tests/ui/suspicious_to_owned.stderr +++ b/tests/ui/suspicious_to_owned.stderr @@ -16,7 +16,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, [char; 3]> itself and does not cause the Cow<'_, [char; 3]> contents to become owned - --> tests/ui/suspicious_to_owned.rs:30:13 + --> tests/ui/suspicious_to_owned.rs:29:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, Vec> itself and does not cause the Cow<'_, Vec> contents to become owned - --> tests/ui/suspicious_to_owned.rs:42:13 + --> tests/ui/suspicious_to_owned.rs:41:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: this `to_owned` call clones the Cow<'_, str> itself and does not cause the Cow<'_, str> contents to become owned - --> tests/ui/suspicious_to_owned.rs:54:13 + --> tests/ui/suspicious_to_owned.rs:53:13 | LL | let _ = cow.to_owned(); | ^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL | let _ = cow.clone(); | ~~~~~~~~~~~ error: implicitly cloning a `String` by calling `to_owned` on its dereferenced type - --> tests/ui/suspicious_to_owned.rs:70:13 + --> tests/ui/suspicious_to_owned.rs:69:13 | LL | let _ = String::from(moo).to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::from(moo).clone()` @@ -70,7 +70,7 @@ LL | let _ = String::from(moo).to_owned(); = help: to override `-D warnings` add `#[allow(clippy::implicit_clone)]` error: implicitly cloning a `Vec` by calling `to_owned` on its dereferenced type - --> tests/ui/suspicious_to_owned.rs:74:13 + --> tests/ui/suspicious_to_owned.rs:72:13 | LL | let _ = moos_vec.to_owned(); | ^^^^^^^^^^^^^^^^^^^ help: consider using: `moos_vec.clone()` diff --git a/tests/ui/suspicious_xor_used_as_pow.rs b/tests/ui/suspicious_xor_used_as_pow.rs index 229ed33833299..e0290b7ce8f14 100644 --- a/tests/ui/suspicious_xor_used_as_pow.rs +++ b/tests/ui/suspicious_xor_used_as_pow.rs @@ -20,7 +20,6 @@ fn main() { let _ = 2 ^ 5; //~^ suspicious_xor_used_as_pow - let _ = 2i32 ^ 9i32; //~^ suspicious_xor_used_as_pow diff --git a/tests/ui/suspicious_xor_used_as_pow.stderr b/tests/ui/suspicious_xor_used_as_pow.stderr index 3fb3b4a34e53d..d08773a8759ab 100644 --- a/tests/ui/suspicious_xor_used_as_pow.stderr +++ b/tests/ui/suspicious_xor_used_as_pow.stderr @@ -12,7 +12,7 @@ LL | let _ = 2.pow(5); | ~~~~~~~~ error: `^` is not the exponentiation operator - --> tests/ui/suspicious_xor_used_as_pow.rs:24:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:23:13 | LL | let _ = 2i32 ^ 9i32; | ^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = 2i32.pow(9i32); | ~~~~~~~~~~~~~~ error: `^` is not the exponentiation operator - --> tests/ui/suspicious_xor_used_as_pow.rs:27:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:26:13 | LL | let _ = 2i32 ^ 2i32; | ^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = 2i32.pow(2i32); | ~~~~~~~~~~~~~~ error: `^` is not the exponentiation operator - --> tests/ui/suspicious_xor_used_as_pow.rs:30:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:29:13 | LL | let _ = 50i32 ^ 3i32; | ^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | let _ = 50i32.pow(3i32); | ~~~~~~~~~~~~~~~ error: `^` is not the exponentiation operator - --> tests/ui/suspicious_xor_used_as_pow.rs:33:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:32:13 | LL | let _ = 5i32 ^ 8i32; | ^^^^^^^^^^^ @@ -56,7 +56,7 @@ LL | let _ = 5i32.pow(8i32); | ~~~~~~~~~~~~~~ error: `^` is not the exponentiation operator - --> tests/ui/suspicious_xor_used_as_pow.rs:36:13 + --> tests/ui/suspicious_xor_used_as_pow.rs:35:13 | LL | let _ = 2i32 ^ 32i32; | ^^^^^^^^^^^^ diff --git a/tests/ui/swap_ptr_to_ref_unfixable.rs b/tests/ui/swap_ptr_to_ref_unfixable.rs index 9fe5925214a43..9c7cf27096ccf 100644 --- a/tests/ui/swap_ptr_to_ref_unfixable.rs +++ b/tests/ui/swap_ptr_to_ref_unfixable.rs @@ -14,12 +14,10 @@ fn main() { core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); //~^ swap_ptr_to_ref - core::mem::swap(&mut *y, addr_of_mut_to_ref!(x)); //~^ swap_ptr_to_ref core::mem::swap(addr_of_mut_to_ref!(x), addr_of_mut_to_ref!(x)); //~^ swap_ptr_to_ref - } } diff --git a/tests/ui/swap_ptr_to_ref_unfixable.stderr b/tests/ui/swap_ptr_to_ref_unfixable.stderr index f4c7c8db15ac4..3bb9d87b70a57 100644 --- a/tests/ui/swap_ptr_to_ref_unfixable.stderr +++ b/tests/ui/swap_ptr_to_ref_unfixable.stderr @@ -8,13 +8,13 @@ LL | core::mem::swap(addr_of_mut_to_ref!(x), &mut *y); = help: to override `-D warnings` add `#[allow(clippy::swap_ptr_to_ref)]` error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> tests/ui/swap_ptr_to_ref_unfixable.rs:18:9 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:17:9 | LL | core::mem::swap(&mut *y, addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: call to `core::mem::swap` with a parameter derived from a raw pointer - --> tests/ui/swap_ptr_to_ref_unfixable.rs:21:9 + --> tests/ui/swap_ptr_to_ref_unfixable.rs:20:9 | LL | core::mem::swap(addr_of_mut_to_ref!(x), addr_of_mut_to_ref!(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.fixed b/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.fixed index 5e5821a140dea..c96a53ba2cd18 100644 --- a/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.fixed +++ b/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.fixed @@ -4,5 +4,6 @@ use std::marker::PhantomData; pub struct Aa(PhantomData); fn aa(a: Aa) { +//~^ ERROR: expected one of } diff --git a/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.rs b/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.rs index d6e1da0e08981..a3a35eb26d10a 100644 --- a/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.rs +++ b/tests/ui/syntax-error-recovery/non_expressive_names_error_recovery.rs @@ -4,5 +4,6 @@ use std::marker::PhantomData; pub struct Aa(PhantomData); fn aa(a: Aa tests/ui/temporary_assignment.rs:52:5 + --> tests/ui/temporary_assignment.rs:51:5 | LL | / MultiStruct { LL | | -LL | | LL | | structure: Struct { field: 0 }, -LL | | } -LL | | .structure +... | LL | | .field = 1; | |______________^ error: assignment to temporary - --> tests/ui/temporary_assignment.rs:59:5 + --> tests/ui/temporary_assignment.rs:57:5 | LL | ArrayStruct { array: [0] }.array[0] = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: assignment to temporary - --> tests/ui/temporary_assignment.rs:62:5 + --> tests/ui/temporary_assignment.rs:60:5 | LL | (0, 0).0 = 1; | ^^^^^^^^^^^^ diff --git a/tests/ui/test_attr_in_doctest.rs b/tests/ui/test_attr_in_doctest.rs index 8ca33c677f886..6cffd813b8358 100644 --- a/tests/ui/test_attr_in_doctest.rs +++ b/tests/ui/test_attr_in_doctest.rs @@ -9,10 +9,9 @@ /// assert_eq!(1, 1); /// } /// ``` -/// +/// /// Make sure we catch multiple tests in one example, /// and show that we really parse the attr: -/// /// ``` /// #[test] //~^ test_attr_in_doctest @@ -29,24 +28,20 @@ /// "); /// } /// ``` -/// +/// /// We don't catch examples that aren't run: -/// /// ```ignore /// #[test] /// fn ignored() { todo!() } /// ``` -/// /// ```no_run /// #[test] /// fn ignored() { todo!() } /// ``` -/// /// ```compile_fail /// #[test] /// fn ignored() { Err(()) } /// ``` -/// /// ```txt /// #[test] /// fn not_even_rust() { panic!("Ouch") } diff --git a/tests/ui/test_attr_in_doctest.stderr b/tests/ui/test_attr_in_doctest.stderr index b8de466e96985..166b9b417b626 100644 --- a/tests/ui/test_attr_in_doctest.stderr +++ b/tests/ui/test_attr_in_doctest.stderr @@ -11,7 +11,7 @@ LL | | /// fn should_be_linted() { = help: to override `-D warnings` add `#[allow(clippy::test_attr_in_doctest)]` error: unit tests in doctest are not executed - --> tests/ui/test_attr_in_doctest.rs:17:5 + --> tests/ui/test_attr_in_doctest.rs:16:5 | LL | /// #[test] | _____^ @@ -20,7 +20,7 @@ LL | | /// fn should_also_be_linted() { | |____________________________^ error: unit tests in doctest are not executed - --> tests/ui/test_attr_in_doctest.rs:24:5 + --> tests/ui/test_attr_in_doctest.rs:23:5 | LL | /// #[test] | _____^ diff --git a/tests/ui/to_string_trait_impl.rs b/tests/ui/to_string_trait_impl.rs index f8195e55f9a82..646ec4db1f110 100644 --- a/tests/ui/to_string_trait_impl.rs +++ b/tests/ui/to_string_trait_impl.rs @@ -9,7 +9,7 @@ struct Point { } impl ToString for Point { -//~^ to_string_trait_impl + //~^ to_string_trait_impl fn to_string(&self) -> String { format!("({}, {})", self.x, self.y) } diff --git a/tests/ui/toplevel_ref_arg_non_rustfix.rs b/tests/ui/toplevel_ref_arg_non_rustfix.rs index 729f528a8e591..87c84a7ee14ab 100644 --- a/tests/ui/toplevel_ref_arg_non_rustfix.rs +++ b/tests/ui/toplevel_ref_arg_non_rustfix.rs @@ -7,7 +7,7 @@ extern crate proc_macros; use proc_macros::{external, inline_macros}; fn the_answer(ref mut x: u8) { -//~^ toplevel_ref_arg + //~^ toplevel_ref_arg *x = 42; } diff --git a/tests/ui/trailing_empty_array.rs b/tests/ui/trailing_empty_array.rs index 2297e645c9e6a..a8c3ffdb0dab3 100644 --- a/tests/ui/trailing_empty_array.rs +++ b/tests/ui/trailing_empty_array.rs @@ -4,45 +4,39 @@ // Do lint: struct RarelyUseful { -//~^ trailing_empty_array - + //~^ trailing_empty_array field: i32, last: [usize; 0], } struct OnlyField { -//~^ trailing_empty_array - + //~^ trailing_empty_array first_and_last: [usize; 0], } struct GenericArrayType { -//~^ trailing_empty_array - + //~^ trailing_empty_array field: i32, last: [T; 0], } #[must_use] struct OnlyAnotherAttribute { -//~^ trailing_empty_array - + //~^ trailing_empty_array field: i32, last: [usize; 0], } #[derive(Debug)] struct OnlyADeriveAttribute { -//~^ trailing_empty_array - + //~^ trailing_empty_array field: i32, last: [usize; 0], } const ZERO: usize = 0; struct ZeroSizedWithConst { -//~^ trailing_empty_array - + //~^ trailing_empty_array field: i32, last: [usize; ZERO], } @@ -52,8 +46,7 @@ const fn compute_zero() -> usize { (4 + 6) - (2 * 5) } struct ZeroSizedWithConstFunction { -//~^ trailing_empty_array - + //~^ trailing_empty_array field: i32, last: [usize; compute_zero()], } @@ -62,8 +55,7 @@ const fn compute_zero_from_arg(x: usize) -> usize { x - 1 } struct ZeroSizedWithConstFunction2 { -//~^ trailing_empty_array - + //~^ trailing_empty_array field: i32, last: [usize; compute_zero_from_arg(1)], } @@ -71,14 +63,11 @@ struct ZeroSizedWithConstFunction2 { struct ZeroSizedArrayWrapper([usize; 0]); //~^ trailing_empty_array - struct TupleStruct(i32, [usize; 0]); //~^ trailing_empty_array - struct LotsOfFields { -//~^ trailing_empty_array - + //~^ trailing_empty_array f1: u32, f2: u32, f3: u32, diff --git a/tests/ui/trailing_empty_array.stderr b/tests/ui/trailing_empty_array.stderr index 424d23d07cdf3..7ebff372cf759 100644 --- a/tests/ui/trailing_empty_array.stderr +++ b/tests/ui/trailing_empty_array.stderr @@ -3,7 +3,6 @@ error: trailing zero-sized array in a struct which is not marked with a `repr` a | LL | / struct RarelyUseful { LL | | -LL | | LL | | field: i32, LL | | last: [usize; 0], LL | | } @@ -14,11 +13,10 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::trailing_empty_array)]` error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:13:1 + --> tests/ui/trailing_empty_array.rs:12:1 | LL | / struct OnlyField { LL | | -LL | | LL | | first_and_last: [usize; 0], LL | | } | |_^ @@ -26,11 +24,10 @@ LL | | } = help: consider annotating `OnlyField` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:19:1 + --> tests/ui/trailing_empty_array.rs:17:1 | LL | / struct GenericArrayType { LL | | -LL | | LL | | field: i32, LL | | last: [T; 0], LL | | } @@ -39,11 +36,10 @@ LL | | } = help: consider annotating `GenericArrayType` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:27:1 + --> tests/ui/trailing_empty_array.rs:24:1 | LL | / struct OnlyAnotherAttribute { LL | | -LL | | LL | | field: i32, LL | | last: [usize; 0], LL | | } @@ -52,11 +48,10 @@ LL | | } = help: consider annotating `OnlyAnotherAttribute` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:35:1 + --> tests/ui/trailing_empty_array.rs:31:1 | LL | / struct OnlyADeriveAttribute { LL | | -LL | | LL | | field: i32, LL | | last: [usize; 0], LL | | } @@ -65,11 +60,10 @@ LL | | } = help: consider annotating `OnlyADeriveAttribute` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:43:1 + --> tests/ui/trailing_empty_array.rs:38:1 | LL | / struct ZeroSizedWithConst { LL | | -LL | | LL | | field: i32, LL | | last: [usize; ZERO], LL | | } @@ -78,11 +72,10 @@ LL | | } = help: consider annotating `ZeroSizedWithConst` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:54:1 + --> tests/ui/trailing_empty_array.rs:48:1 | LL | / struct ZeroSizedWithConstFunction { LL | | -LL | | LL | | field: i32, LL | | last: [usize; compute_zero()], LL | | } @@ -91,11 +84,10 @@ LL | | } = help: consider annotating `ZeroSizedWithConstFunction` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:64:1 + --> tests/ui/trailing_empty_array.rs:57:1 | LL | / struct ZeroSizedWithConstFunction2 { LL | | -LL | | LL | | field: i32, LL | | last: [usize; compute_zero_from_arg(1)], LL | | } @@ -104,7 +96,7 @@ LL | | } = help: consider annotating `ZeroSizedWithConstFunction2` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:71:1 + --> tests/ui/trailing_empty_array.rs:63:1 | LL | struct ZeroSizedArrayWrapper([usize; 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +104,7 @@ LL | struct ZeroSizedArrayWrapper([usize; 0]); = help: consider annotating `ZeroSizedArrayWrapper` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:75:1 + --> tests/ui/trailing_empty_array.rs:66:1 | LL | struct TupleStruct(i32, [usize; 0]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,12 +112,12 @@ LL | struct TupleStruct(i32, [usize; 0]); = help: consider annotating `TupleStruct` with `#[repr(C)]` or another `repr` attribute error: trailing zero-sized array in a struct which is not marked with a `repr` attribute - --> tests/ui/trailing_empty_array.rs:79:1 + --> tests/ui/trailing_empty_array.rs:69:1 | LL | / struct LotsOfFields { LL | | -LL | | LL | | f1: u32, +LL | | f2: u32, ... | LL | | last: [usize; 0], LL | | } diff --git a/tests/ui/trailing_zeros.fixed b/tests/ui/trailing_zeros.fixed index 273dd5d70646d..8c30b062fb183 100644 --- a/tests/ui/trailing_zeros.fixed +++ b/tests/ui/trailing_zeros.fixed @@ -6,7 +6,6 @@ fn main() { let _ = x.trailing_zeros() >= 4; //~^ verbose_bit_mask - let _ = x.trailing_zeros() >= 5; //~^ verbose_bit_mask diff --git a/tests/ui/trailing_zeros.rs b/tests/ui/trailing_zeros.rs index f3fffa7be8404..369a31557392c 100644 --- a/tests/ui/trailing_zeros.rs +++ b/tests/ui/trailing_zeros.rs @@ -6,7 +6,6 @@ fn main() { let _ = (x & 0b1111 == 0); //~^ verbose_bit_mask - let _ = x & 0b1_1111 == 0; //~^ verbose_bit_mask diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 4b608e32a587d..6f3e7aa1d762e 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -8,7 +8,7 @@ LL | let _ = (x & 0b1111 == 0); = help: to override `-D warnings` add `#[allow(clippy::verbose_bit_mask)]` error: bit mask could be simplified with a call to `trailing_zeros` - --> tests/ui/trailing_zeros.rs:10:13 + --> tests/ui/trailing_zeros.rs:9:13 | LL | let _ = x & 0b1_1111 == 0; | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` diff --git a/tests/ui/trait_duplication_in_bounds.fixed b/tests/ui/trait_duplication_in_bounds.fixed index afd0f4d77d3e2..666ff78b21897 100644 --- a/tests/ui/trait_duplication_in_bounds.fixed +++ b/tests/ui/trait_duplication_in_bounds.fixed @@ -5,7 +5,7 @@ use std::any::Any; fn bad_foo(arg0: T, argo1: U) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -41,7 +41,7 @@ trait GoodSelfWhereClause { } trait BadSelfTraitBound: Clone { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds fn f(); } @@ -49,7 +49,7 @@ trait BadSelfWhereClause { fn f() where Self: Clone; - //~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds } trait GoodTraitBound { @@ -64,7 +64,7 @@ trait GoodWhereClause { } trait BadTraitBound { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds fn f(); } @@ -106,7 +106,7 @@ fn good_generic + GenericTrait>(arg0: T) { } fn bad_generic + GenericTrait>(arg0: T) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -115,7 +115,7 @@ mod foo { } fn qualified_path(arg0: T) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -124,7 +124,7 @@ fn good_trait_object(arg0: &(dyn Any + Send)) { } fn bad_trait_object(arg0: &(dyn Any + Send)) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -174,14 +174,12 @@ const fn const_trait_bounds_good() {} const fn const_trait_bounds_bad() {} //~^ trait_duplication_in_bounds - fn projections() where U: ToOwned, V: ToOwned, T: IntoIterator, //~^ trait_duplication_in_bounds - V: IntoIterator + IntoIterator, { } @@ -204,6 +202,5 @@ fn assoc_const_args() where T: AssocConstTrait, //~^ trait_duplication_in_bounds - { } diff --git a/tests/ui/trait_duplication_in_bounds.rs b/tests/ui/trait_duplication_in_bounds.rs index 4d417e89bd829..a1a86fe058e63 100644 --- a/tests/ui/trait_duplication_in_bounds.rs +++ b/tests/ui/trait_duplication_in_bounds.rs @@ -5,7 +5,7 @@ use std::any::Any; fn bad_foo(arg0: T, argo1: U) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -41,7 +41,7 @@ trait GoodSelfWhereClause { } trait BadSelfTraitBound: Clone + Clone + Clone { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds fn f(); } @@ -49,7 +49,7 @@ trait BadSelfWhereClause { fn f() where Self: Clone + Clone + Clone; - //~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds } trait GoodTraitBound { @@ -64,7 +64,7 @@ trait GoodWhereClause { } trait BadTraitBound { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds fn f(); } @@ -106,7 +106,7 @@ fn good_generic + GenericTrait>(arg0: T) { } fn bad_generic + GenericTrait + GenericTrait>(arg0: T) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -115,7 +115,7 @@ mod foo { } fn qualified_path(arg0: T) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -124,7 +124,7 @@ fn good_trait_object(arg0: &(dyn Any + Send)) { } fn bad_trait_object(arg0: &(dyn Any + Send + Send)) { -//~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds unimplemented!(); } @@ -174,14 +174,12 @@ const fn const_trait_bounds_good() {} const fn const_trait_bounds_bad() {} //~^ trait_duplication_in_bounds - fn projections() where U: ToOwned, V: ToOwned, T: IntoIterator + IntoIterator, //~^ trait_duplication_in_bounds - V: IntoIterator + IntoIterator, { } @@ -204,6 +202,5 @@ fn assoc_const_args() where T: AssocConstTrait + AssocConstTrait, //~^ trait_duplication_in_bounds - { } diff --git a/tests/ui/trait_duplication_in_bounds.stderr b/tests/ui/trait_duplication_in_bounds.stderr index 974dfe538799a..d76b4e458480f 100644 --- a/tests/ui/trait_duplication_in_bounds.stderr +++ b/tests/ui/trait_duplication_in_bounds.stderr @@ -65,13 +65,13 @@ LL | const fn const_trait_bounds_bad() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `~const ConstTrait` error: these where clauses contain repeated elements - --> tests/ui/trait_duplication_in_bounds.rs:182:8 + --> tests/ui/trait_duplication_in_bounds.rs:181:8 | LL | T: IntoIterator + IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `IntoIterator` error: these where clauses contain repeated elements - --> tests/ui/trait_duplication_in_bounds.rs:205:8 + --> tests/ui/trait_duplication_in_bounds.rs:203:8 | LL | T: AssocConstTrait + AssocConstTrait, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `AssocConstTrait` diff --git a/tests/ui/trait_duplication_in_bounds_unfixable.rs b/tests/ui/trait_duplication_in_bounds_unfixable.rs index 38a42c3bd365b..cf72ed844a78c 100644 --- a/tests/ui/trait_duplication_in_bounds_unfixable.rs +++ b/tests/ui/trait_duplication_in_bounds_unfixable.rs @@ -7,8 +7,6 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; fn bad_foo(arg0: T, arg1: Z) //~^ trait_duplication_in_bounds //~| trait_duplication_in_bounds - - where T: Clone, T: Default, @@ -38,8 +36,7 @@ trait T: Default { fn f() where Self: Default; - //~^ trait_duplication_in_bounds - + //~^ trait_duplication_in_bounds } trait U: Default { @@ -54,22 +51,20 @@ trait ZZ: Default { fn f() where Self: Default + Clone; - //~^ trait_duplication_in_bounds - + //~^ trait_duplication_in_bounds } trait BadTrait: Default + Clone { fn f() where Self: Default + Clone; - //~^ trait_duplication_in_bounds - //~| trait_duplication_in_bounds - + //~^ trait_duplication_in_bounds + //~| trait_duplication_in_bounds fn g() where Self: Default; - //~^ trait_duplication_in_bounds + //~^ trait_duplication_in_bounds fn h() where @@ -107,7 +102,6 @@ trait FooIter: Iterator { where Self: Iterator, //~^ trait_duplication_in_bounds - { } } diff --git a/tests/ui/trait_duplication_in_bounds_unfixable.stderr b/tests/ui/trait_duplication_in_bounds_unfixable.stderr index c7b8ba01c493c..546d39518e1fa 100644 --- a/tests/ui/trait_duplication_in_bounds_unfixable.stderr +++ b/tests/ui/trait_duplication_in_bounds_unfixable.stderr @@ -20,7 +20,7 @@ LL | fn bad_foo(arg0: T, arg1: Z) = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> tests/ui/trait_duplication_in_bounds_unfixable.rs:40:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:38:15 | LL | Self: Default; | ^^^^^^^ @@ -28,7 +28,7 @@ LL | Self: Default; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> tests/ui/trait_duplication_in_bounds_unfixable.rs:56:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:53:15 | LL | Self: Default + Clone; | ^^^^^^^ @@ -36,7 +36,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> tests/ui/trait_duplication_in_bounds_unfixable.rs:64:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:60:15 | LL | Self: Default + Clone; | ^^^^^^^ @@ -44,7 +44,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> tests/ui/trait_duplication_in_bounds_unfixable.rs:64:25 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:60:25 | LL | Self: Default + Clone; | ^^^^^ @@ -52,7 +52,7 @@ LL | Self: Default + Clone; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> tests/ui/trait_duplication_in_bounds_unfixable.rs:71:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:66:15 | LL | Self: Default; | ^^^^^^^ @@ -60,7 +60,7 @@ LL | Self: Default; = help: consider removing this trait bound error: this trait bound is already specified in trait declaration - --> tests/ui/trait_duplication_in_bounds_unfixable.rs:108:15 + --> tests/ui/trait_duplication_in_bounds_unfixable.rs:103:15 | LL | Self: Iterator, | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute.rs b/tests/ui/transmute.rs index 0fec14ffd9751..3aecde398dc3f 100644 --- a/tests/ui/transmute.rs +++ b/tests/ui/transmute.rs @@ -31,15 +31,11 @@ unsafe fn _generic<'a, T, U: 'a>(t: &'a T) { let _: *const T = core::mem::transmute(t); //~^ useless_transmute - - let _: *mut T = core::mem::transmute(t); //~^ useless_transmute - let _: *const U = core::mem::transmute(t); //~^ useless_transmute - } #[warn(clippy::useless_transmute)] @@ -48,33 +44,26 @@ fn useless() { let _: Vec = core::mem::transmute(my_vec()); //~^ useless_transmute - let _: Vec = core::mem::transmute(my_vec()); //~^ useless_transmute - let _: Vec = std::mem::transmute(my_vec()); //~^ useless_transmute - let _: Vec = std::mem::transmute(my_vec()); //~^ useless_transmute - let _: Vec = my_transmute(my_vec()); //~^ useless_transmute - let _: *const usize = std::mem::transmute(5_isize); //~^ useless_transmute - let _ = 5_isize as *const usize; let _: *const usize = std::mem::transmute(1 + 1usize); //~^ useless_transmute - let _ = (1 + 1_usize) as *const usize; } @@ -107,19 +96,14 @@ fn crosspointer() { let _: Usize = core::mem::transmute(int_const_ptr); //~^ crosspointer_transmute - - let _: Usize = core::mem::transmute(int_mut_ptr); //~^ crosspointer_transmute - let _: *const Usize = core::mem::transmute(my_int()); //~^ crosspointer_transmute - let _: *mut Usize = core::mem::transmute(my_int()); //~^ crosspointer_transmute - } } @@ -127,8 +111,6 @@ fn crosspointer() { fn int_to_bool() { let _: bool = unsafe { std::mem::transmute(0_u8) }; //~^ transmute_int_to_bool - - } #[warn(clippy::transmute_int_to_float)] @@ -137,7 +119,6 @@ mod int_to_float { let _: f16 = unsafe { std::mem::transmute(0_u16) }; //~^ transmute_int_to_float - let _: f16 = unsafe { std::mem::transmute(0_i16) }; //~^ transmute_int_to_float @@ -158,7 +139,6 @@ mod int_to_float { let _: f128 = unsafe { std::mem::transmute(0_i128) }; //~^ transmute_int_to_float - } mod issue_5747 { @@ -174,29 +154,24 @@ mod int_to_float { const VALUE128: f128 = unsafe { std::mem::transmute(0_i128) }; //~^ transmute_int_to_float - const fn from_bits_16(v: i16) -> f16 { unsafe { std::mem::transmute(v) } //~^ transmute_int_to_float - } const fn from_bits_32(v: i32) -> f32 { unsafe { std::mem::transmute(v) } //~^ transmute_int_to_float - } const fn from_bits_64(v: u64) -> f64 { unsafe { std::mem::transmute(v) } //~^ transmute_int_to_float - } const fn from_bits_128(v: u128) -> f128 { unsafe { std::mem::transmute(v) } //~^ transmute_int_to_float - } } } @@ -207,7 +182,6 @@ mod num_to_bytes { let _: [u8; 1] = std::mem::transmute(0u8); //~^ transmute_num_to_bytes - let _: [u8; 4] = std::mem::transmute(0u32); //~^ transmute_num_to_bytes @@ -223,7 +197,6 @@ mod num_to_bytes { let _: [u8; 16] = std::mem::transmute(0i128); //~^ transmute_num_to_bytes - let _: [u8; 2] = std::mem::transmute(0.0f16); //~^ transmute_num_to_bytes @@ -235,7 +208,6 @@ mod num_to_bytes { let _: [u8; 16] = std::mem::transmute(0.0f128); //~^ transmute_num_to_bytes - } } const fn test_const() { @@ -258,7 +230,6 @@ mod num_to_bytes { let _: [u8; 16] = std::mem::transmute(0i128); //~^ transmute_num_to_bytes - let _: [u8; 2] = std::mem::transmute(0.0f16); //~^ transmute_num_to_bytes @@ -270,7 +241,6 @@ mod num_to_bytes { let _: [u8; 16] = std::mem::transmute(0.0f128); //~^ transmute_num_to_bytes - } } } @@ -281,13 +251,11 @@ fn bytes_to_str(mb: &mut [u8]) { let _: &str = unsafe { std::mem::transmute(B) }; //~^ transmute_bytes_to_str - let _: &mut str = unsafe { std::mem::transmute(mb) }; //~^ transmute_bytes_to_str const _: &str = unsafe { std::mem::transmute(B) }; //~^ transmute_bytes_to_str - } fn main() {} diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index 7db7fad28d803..e0d28437aafc8 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -8,61 +8,61 @@ LL | let _: *const T = core::mem::transmute(t); = help: to override `-D warnings` add `#[allow(clippy::useless_transmute)]` error: transmute from a reference to a pointer - --> tests/ui/transmute.rs:36:21 + --> tests/ui/transmute.rs:34:21 | LL | let _: *mut T = core::mem::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T` error: transmute from a reference to a pointer - --> tests/ui/transmute.rs:40:23 + --> tests/ui/transmute.rs:37:23 | LL | let _: *const U = core::mem::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U` error: transmute from a type (`std::vec::Vec`) to itself - --> tests/ui/transmute.rs:48:27 + --> tests/ui/transmute.rs:44:27 | LL | let _: Vec = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> tests/ui/transmute.rs:52:27 + --> tests/ui/transmute.rs:47:27 | LL | let _: Vec = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> tests/ui/transmute.rs:56:27 + --> tests/ui/transmute.rs:50:27 | LL | let _: Vec = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> tests/ui/transmute.rs:60:27 + --> tests/ui/transmute.rs:53:27 | LL | let _: Vec = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> tests/ui/transmute.rs:64:27 + --> tests/ui/transmute.rs:56:27 | LL | let _: Vec = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from an integer to a pointer - --> tests/ui/transmute.rs:68:31 + --> tests/ui/transmute.rs:59:31 | LL | let _: *const usize = std::mem::transmute(5_isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` error: transmute from an integer to a pointer - --> tests/ui/transmute.rs:74:31 + --> tests/ui/transmute.rs:64:31 | LL | let _: *const usize = std::mem::transmute(1 + 1usize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1 + 1usize) as *const usize` error: transmute from a type (`*const Usize`) to the type that it points to (`Usize`) - --> tests/ui/transmute.rs:107:24 + --> tests/ui/transmute.rs:96:24 | LL | let _: Usize = core::mem::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,25 +71,25 @@ LL | let _: Usize = core::mem::transmute(int_const_ptr); = help: to override `-D warnings` add `#[allow(clippy::crosspointer_transmute)]` error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) - --> tests/ui/transmute.rs:112:24 + --> tests/ui/transmute.rs:99:24 | LL | let _: Usize = core::mem::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) - --> tests/ui/transmute.rs:116:31 + --> tests/ui/transmute.rs:102:31 | LL | let _: *const Usize = core::mem::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) - --> tests/ui/transmute.rs:120:29 + --> tests/ui/transmute.rs:105:29 | LL | let _: *mut Usize = core::mem::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `u8` to a `bool` - --> tests/ui/transmute.rs:128:28 + --> tests/ui/transmute.rs:112:28 | LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` @@ -98,7 +98,7 @@ LL | let _: bool = unsafe { std::mem::transmute(0_u8) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_bool)]` error: transmute from a `u16` to a `f16` - --> tests/ui/transmute.rs:137:31 + --> tests/ui/transmute.rs:119:31 | LL | let _: f16 = unsafe { std::mem::transmute(0_u16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_u16)` @@ -107,97 +107,97 @@ LL | let _: f16 = unsafe { std::mem::transmute(0_u16) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_float)]` error: transmute from a `i16` to a `f16` - --> tests/ui/transmute.rs:141:31 + --> tests/ui/transmute.rs:122:31 | LL | let _: f16 = unsafe { std::mem::transmute(0_i16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_i16 as u16)` error: transmute from a `u32` to a `f32` - --> tests/ui/transmute.rs:144:31 + --> tests/ui/transmute.rs:125:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` error: transmute from a `i32` to a `f32` - --> tests/ui/transmute.rs:147:31 + --> tests/ui/transmute.rs:128:31 | LL | let _: f32 = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` error: transmute from a `u64` to a `f64` - --> tests/ui/transmute.rs:150:31 + --> tests/ui/transmute.rs:131:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_u64)` error: transmute from a `i64` to a `f64` - --> tests/ui/transmute.rs:153:31 + --> tests/ui/transmute.rs:134:31 | LL | let _: f64 = unsafe { std::mem::transmute(0_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)` error: transmute from a `u128` to a `f128` - --> tests/ui/transmute.rs:156:32 + --> tests/ui/transmute.rs:137:32 | LL | let _: f128 = unsafe { std::mem::transmute(0_u128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_u128)` error: transmute from a `i128` to a `f128` - --> tests/ui/transmute.rs:159:32 + --> tests/ui/transmute.rs:140:32 | LL | let _: f128 = unsafe { std::mem::transmute(0_i128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_i128 as u128)` error: transmute from a `u16` to a `f16` - --> tests/ui/transmute.rs:165:39 + --> tests/ui/transmute.rs:145:39 | LL | const VALUE16: f16 = unsafe { std::mem::transmute(0_u16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(0_u16)` error: transmute from a `u32` to a `f32` - --> tests/ui/transmute.rs:168:39 + --> tests/ui/transmute.rs:148:39 | LL | const VALUE32: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` error: transmute from a `i64` to a `f64` - --> tests/ui/transmute.rs:171:39 + --> tests/ui/transmute.rs:151:39 | LL | const VALUE64: f64 = unsafe { std::mem::transmute(0_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(0_i64 as u64)` error: transmute from a `i128` to a `f128` - --> tests/ui/transmute.rs:174:41 + --> tests/ui/transmute.rs:154:41 | LL | const VALUE128: f128 = unsafe { std::mem::transmute(0_i128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(0_i128 as u128)` error: transmute from a `i16` to a `f16` - --> tests/ui/transmute.rs:179:22 + --> tests/ui/transmute.rs:158:22 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f16::from_bits(v as u16)` error: transmute from a `i32` to a `f32` - --> tests/ui/transmute.rs:185:22 + --> tests/ui/transmute.rs:163:22 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(v as u32)` error: transmute from a `u64` to a `f64` - --> tests/ui/transmute.rs:191:22 + --> tests/ui/transmute.rs:168:22 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f64::from_bits(v)` error: transmute from a `u128` to a `f128` - --> tests/ui/transmute.rs:197:22 + --> tests/ui/transmute.rs:173:22 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f128::from_bits(v)` error: transmute from a `u8` to a `[u8; 1]` - --> tests/ui/transmute.rs:207:30 + --> tests/ui/transmute.rs:182:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` @@ -206,121 +206,121 @@ LL | let _: [u8; 1] = std::mem::transmute(0u8); = help: to override `-D warnings` add `#[allow(clippy::transmute_num_to_bytes)]` error: transmute from a `u32` to a `[u8; 4]` - --> tests/ui/transmute.rs:211:30 + --> tests/ui/transmute.rs:185:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` error: transmute from a `u128` to a `[u8; 16]` - --> tests/ui/transmute.rs:214:31 + --> tests/ui/transmute.rs:188:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` error: transmute from a `i8` to a `[u8; 1]` - --> tests/ui/transmute.rs:217:30 + --> tests/ui/transmute.rs:191:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` error: transmute from a `i32` to a `[u8; 4]` - --> tests/ui/transmute.rs:220:30 + --> tests/ui/transmute.rs:194:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` error: transmute from a `i128` to a `[u8; 16]` - --> tests/ui/transmute.rs:223:31 + --> tests/ui/transmute.rs:197:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` error: transmute from a `f16` to a `[u8; 2]` - --> tests/ui/transmute.rs:227:30 + --> tests/ui/transmute.rs:200:30 | LL | let _: [u8; 2] = std::mem::transmute(0.0f16); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f16.to_ne_bytes()` error: transmute from a `f32` to a `[u8; 4]` - --> tests/ui/transmute.rs:230:30 + --> tests/ui/transmute.rs:203:30 | LL | let _: [u8; 4] = std::mem::transmute(0.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()` error: transmute from a `f64` to a `[u8; 8]` - --> tests/ui/transmute.rs:233:30 + --> tests/ui/transmute.rs:206:30 | LL | let _: [u8; 8] = std::mem::transmute(0.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()` error: transmute from a `f128` to a `[u8; 16]` - --> tests/ui/transmute.rs:236:31 + --> tests/ui/transmute.rs:209:31 | LL | let _: [u8; 16] = std::mem::transmute(0.0f128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f128.to_ne_bytes()` error: transmute from a `u8` to a `[u8; 1]` - --> tests/ui/transmute.rs:243:30 + --> tests/ui/transmute.rs:215:30 | LL | let _: [u8; 1] = std::mem::transmute(0u8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u8.to_ne_bytes()` error: transmute from a `u32` to a `[u8; 4]` - --> tests/ui/transmute.rs:246:30 + --> tests/ui/transmute.rs:218:30 | LL | let _: [u8; 4] = std::mem::transmute(0u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u32.to_ne_bytes()` error: transmute from a `u128` to a `[u8; 16]` - --> tests/ui/transmute.rs:249:31 + --> tests/ui/transmute.rs:221:31 | LL | let _: [u8; 16] = std::mem::transmute(0u128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0u128.to_ne_bytes()` error: transmute from a `i8` to a `[u8; 1]` - --> tests/ui/transmute.rs:252:30 + --> tests/ui/transmute.rs:224:30 | LL | let _: [u8; 1] = std::mem::transmute(0i8); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i8.to_ne_bytes()` error: transmute from a `i32` to a `[u8; 4]` - --> tests/ui/transmute.rs:255:30 + --> tests/ui/transmute.rs:227:30 | LL | let _: [u8; 4] = std::mem::transmute(0i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i32.to_ne_bytes()` error: transmute from a `i128` to a `[u8; 16]` - --> tests/ui/transmute.rs:258:31 + --> tests/ui/transmute.rs:230:31 | LL | let _: [u8; 16] = std::mem::transmute(0i128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0i128.to_ne_bytes()` error: transmute from a `f16` to a `[u8; 2]` - --> tests/ui/transmute.rs:262:30 + --> tests/ui/transmute.rs:233:30 | LL | let _: [u8; 2] = std::mem::transmute(0.0f16); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f16.to_ne_bytes()` error: transmute from a `f32` to a `[u8; 4]` - --> tests/ui/transmute.rs:265:30 + --> tests/ui/transmute.rs:236:30 | LL | let _: [u8; 4] = std::mem::transmute(0.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f32.to_ne_bytes()` error: transmute from a `f64` to a `[u8; 8]` - --> tests/ui/transmute.rs:268:30 + --> tests/ui/transmute.rs:239:30 | LL | let _: [u8; 8] = std::mem::transmute(0.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f64.to_ne_bytes()` error: transmute from a `f128` to a `[u8; 16]` - --> tests/ui/transmute.rs:271:31 + --> tests/ui/transmute.rs:242:31 | LL | let _: [u8; 16] = std::mem::transmute(0.0f128); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `to_ne_bytes()`: `0.0f128.to_ne_bytes()` error: transmute from a `&[u8]` to a `&str` - --> tests/ui/transmute.rs:281:28 + --> tests/ui/transmute.rs:251:28 | LL | let _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(B).unwrap()` @@ -329,13 +329,13 @@ LL | let _: &str = unsafe { std::mem::transmute(B) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_bytes_to_str)]` error: transmute from a `&mut [u8]` to a `&mut str` - --> tests/ui/transmute.rs:285:32 + --> tests/ui/transmute.rs:254:32 | LL | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` error: transmute from a `&[u8]` to a `&str` - --> tests/ui/transmute.rs:288:30 + --> tests/ui/transmute.rs:257:30 | LL | const _: &str = unsafe { std::mem::transmute(B) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_unchecked(B)` diff --git a/tests/ui/transmute_64bit.rs b/tests/ui/transmute_64bit.rs index 9570fa5ab0933..1a4bfffdc3226 100644 --- a/tests/ui/transmute_64bit.rs +++ b/tests/ui/transmute_64bit.rs @@ -6,10 +6,7 @@ fn main() { let _: *const usize = std::mem::transmute(6.0f64); //~^ wrong_transmute - - let _: *mut usize = std::mem::transmute(6.0f64); //~^ wrong_transmute - } } diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index 789eba5247fa5..e75b81671e093 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -8,7 +8,7 @@ LL | let _: *const usize = std::mem::transmute(6.0f64); = help: to override `-D warnings` add `#[allow(clippy::wrong_transmute)]` error: transmute from a `f64` to a pointer - --> tests/ui/transmute_64bit.rs:11:29 + --> tests/ui/transmute_64bit.rs:9:29 | LL | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute_collection.rs b/tests/ui/transmute_collection.rs index 20952dfa28395..74d7f5e38bf8d 100644 --- a/tests/ui/transmute_collection.rs +++ b/tests/ui/transmute_collection.rs @@ -10,12 +10,10 @@ fn main() { let _ = transmute::<_, Vec>(vec![0u8]); //~^ unsound_collection_transmute - // wrong layout let _ = transmute::<_, Vec<[u8; 4]>>(vec![1234u32]); //~^ unsound_collection_transmute - // wrong size let _ = transmute::<_, VecDeque>(VecDeque::::new()); //~^ unsound_collection_transmute @@ -24,7 +22,6 @@ fn main() { let _ = transmute::<_, VecDeque>(VecDeque::<[u8; 4]>::new()); //~^ unsound_collection_transmute - // wrong size let _ = transmute::<_, BinaryHeap>(BinaryHeap::::new()); //~^ unsound_collection_transmute @@ -33,7 +30,6 @@ fn main() { let _ = transmute::<_, BinaryHeap>(BinaryHeap::<[u8; 4]>::new()); //~^ unsound_collection_transmute - // wrong size let _ = transmute::<_, BTreeSet>(BTreeSet::::new()); //~^ unsound_collection_transmute @@ -42,7 +38,6 @@ fn main() { let _ = transmute::<_, BTreeSet>(BTreeSet::<[u8; 4]>::new()); //~^ unsound_collection_transmute - // wrong size let _ = transmute::<_, HashSet>(HashSet::::new()); //~^ unsound_collection_transmute @@ -51,7 +46,6 @@ fn main() { let _ = transmute::<_, HashSet>(HashSet::<[u8; 4]>::new()); //~^ unsound_collection_transmute - // wrong size let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); //~^ unsound_collection_transmute @@ -66,7 +60,6 @@ fn main() { let _ = transmute::<_, BTreeMap>(BTreeMap::<[u8; 4], u32>::new()); //~^ unsound_collection_transmute - // wrong size let _ = transmute::<_, HashMap>(HashMap::::new()); //~^ unsound_collection_transmute @@ -81,7 +74,6 @@ fn main() { let _ = transmute::<_, HashMap>(HashMap::<[u8; 4], u32>::new()); //~^ unsound_collection_transmute - let _ = transmute::<_, Vec>(Vec::>::new()); let _ = transmute::<_, Vec<*mut u32>>(Vec::>::new()); } diff --git a/tests/ui/transmute_collection.stderr b/tests/ui/transmute_collection.stderr index f887afc9b6769..ac2de07f6bf27 100644 --- a/tests/ui/transmute_collection.stderr +++ b/tests/ui/transmute_collection.stderr @@ -8,103 +8,103 @@ LL | let _ = transmute::<_, Vec>(vec![0u8]); = help: to override `-D warnings` add `#[allow(clippy::unsound_collection_transmute)]` error: transmute from `std::vec::Vec` to `std::vec::Vec<[u8; 4]>` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:15:17 + --> tests/ui/transmute_collection.rs:14:17 | LL | let _ = transmute::<_, Vec<[u8; 4]>>(vec![1234u32]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::VecDeque` to `std::collections::VecDeque` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:20:17 + --> tests/ui/transmute_collection.rs:18:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::VecDeque<[u8; 4]>` to `std::collections::VecDeque` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:24:17 + --> tests/ui/transmute_collection.rs:22:17 | LL | let _ = transmute::<_, VecDeque>(VecDeque::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BinaryHeap` to `std::collections::BinaryHeap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:29:17 + --> tests/ui/transmute_collection.rs:26:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BinaryHeap<[u8; 4]>` to `std::collections::BinaryHeap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:33:17 + --> tests/ui/transmute_collection.rs:30:17 | LL | let _ = transmute::<_, BinaryHeap>(BinaryHeap::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeSet` to `std::collections::BTreeSet` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:38:17 + --> tests/ui/transmute_collection.rs:34:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeSet<[u8; 4]>` to `std::collections::BTreeSet` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:42:17 + --> tests/ui/transmute_collection.rs:38:17 | LL | let _ = transmute::<_, BTreeSet>(BTreeSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashSet` to `std::collections::HashSet` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:47:17 + --> tests/ui/transmute_collection.rs:42:17 | LL | let _ = transmute::<_, HashSet>(HashSet::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashSet<[u8; 4]>` to `std::collections::HashSet` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:51:17 + --> tests/ui/transmute_collection.rs:46:17 | LL | let _ = transmute::<_, HashSet>(HashSet::<[u8; 4]>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:56:17 + --> tests/ui/transmute_collection.rs:50:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:59:17 + --> tests/ui/transmute_collection.rs:53:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap` to `std::collections::BTreeMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:63:17 + --> tests/ui/transmute_collection.rs:57:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::BTreeMap<[u8; 4], u32>` to `std::collections::BTreeMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:66:17 + --> tests/ui/transmute_collection.rs:60:17 | LL | let _ = transmute::<_, BTreeMap>(BTreeMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:71:17 + --> tests/ui/transmute_collection.rs:64:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:74:17 + --> tests/ui/transmute_collection.rs:67:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap` to `std::collections::HashMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:78:17 + --> tests/ui/transmute_collection.rs:71:17 | LL | let _ = transmute::<_, HashMap>(HashMap::::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `std::collections::HashMap<[u8; 4], u32>` to `std::collections::HashMap` with mismatched layout is unsound - --> tests/ui/transmute_collection.rs:81:17 + --> tests/ui/transmute_collection.rs:74:17 | LL | let _ = transmute::<_, HashMap>(HashMap::<[u8; 4], u32>::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute_float_to_int.fixed b/tests/ui/transmute_float_to_int.fixed index e1feb57ae7365..1f97b997eaa0e 100644 --- a/tests/ui/transmute_float_to_int.fixed +++ b/tests/ui/transmute_float_to_int.fixed @@ -7,7 +7,6 @@ fn float_to_int() { let _: u32 = unsafe { 1f32.to_bits() }; //~^ transmute_float_to_int - let _: i32 = unsafe { 1f32.to_bits() as i32 }; //~^ transmute_float_to_int @@ -22,7 +21,6 @@ fn float_to_int() { let _: u64 = unsafe { (-1.0f64).to_bits() }; //~^ transmute_float_to_int - } mod issue_5747 { @@ -38,29 +36,24 @@ mod issue_5747 { const VALUE128: u128 = unsafe { 1f128.to_bits() }; //~^ transmute_float_to_int - const fn to_bits_16(v: f16) -> u16 { unsafe { v.to_bits() } //~^ transmute_float_to_int - } const fn to_bits_32(v: f32) -> u32 { unsafe { v.to_bits() } //~^ transmute_float_to_int - } const fn to_bits_64(v: f64) -> i64 { unsafe { v.to_bits() as i64 } //~^ transmute_float_to_int - } const fn to_bits_128(v: f128) -> i128 { unsafe { v.to_bits() as i128 } //~^ transmute_float_to_int - } } diff --git a/tests/ui/transmute_float_to_int.rs b/tests/ui/transmute_float_to_int.rs index ac2a1a1ad05da..788a7e1026c67 100644 --- a/tests/ui/transmute_float_to_int.rs +++ b/tests/ui/transmute_float_to_int.rs @@ -7,7 +7,6 @@ fn float_to_int() { let _: u32 = unsafe { std::mem::transmute(1f32) }; //~^ transmute_float_to_int - let _: i32 = unsafe { std::mem::transmute(1f32) }; //~^ transmute_float_to_int @@ -22,7 +21,6 @@ fn float_to_int() { let _: u64 = unsafe { std::mem::transmute(-1.0) }; //~^ transmute_float_to_int - } mod issue_5747 { @@ -38,29 +36,24 @@ mod issue_5747 { const VALUE128: u128 = unsafe { std::mem::transmute(1f128) }; //~^ transmute_float_to_int - const fn to_bits_16(v: f16) -> u16 { unsafe { std::mem::transmute(v) } //~^ transmute_float_to_int - } const fn to_bits_32(v: f32) -> u32 { unsafe { std::mem::transmute(v) } //~^ transmute_float_to_int - } const fn to_bits_64(v: f64) -> i64 { unsafe { std::mem::transmute(v) } //~^ transmute_float_to_int - } const fn to_bits_128(v: f128) -> i128 { unsafe { std::mem::transmute(v) } //~^ transmute_float_to_int - } } diff --git a/tests/ui/transmute_float_to_int.stderr b/tests/ui/transmute_float_to_int.stderr index 551fcb1f7d0d9..223cbc4e90c07 100644 --- a/tests/ui/transmute_float_to_int.stderr +++ b/tests/ui/transmute_float_to_int.stderr @@ -8,79 +8,79 @@ LL | let _: u32 = unsafe { std::mem::transmute(1f32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_float_to_int)]` error: transmute from a `f32` to a `i32` - --> tests/ui/transmute_float_to_int.rs:11:27 + --> tests/ui/transmute_float_to_int.rs:10:27 | LL | let _: i32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits() as i32` error: transmute from a `f64` to a `u64` - --> tests/ui/transmute_float_to_int.rs:14:27 + --> tests/ui/transmute_float_to_int.rs:13:27 | LL | let _: u64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits()` error: transmute from a `f64` to a `i64` - --> tests/ui/transmute_float_to_int.rs:17:27 + --> tests/ui/transmute_float_to_int.rs:16:27 | LL | let _: i64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits() as i64` error: transmute from a `f64` to a `u64` - --> tests/ui/transmute_float_to_int.rs:20:27 + --> tests/ui/transmute_float_to_int.rs:19:27 | LL | let _: u64 = unsafe { std::mem::transmute(1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1.0f64.to_bits()` error: transmute from a `f64` to a `u64` - --> tests/ui/transmute_float_to_int.rs:23:27 + --> tests/ui/transmute_float_to_int.rs:22:27 | LL | let _: u64 = unsafe { std::mem::transmute(-1.0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(-1.0f64).to_bits()` error: transmute from a `f16` to a `i16` - --> tests/ui/transmute_float_to_int.rs:29:35 + --> tests/ui/transmute_float_to_int.rs:27:35 | LL | const VALUE16: i16 = unsafe { std::mem::transmute(1f16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f16.to_bits() as i16` error: transmute from a `f32` to a `i32` - --> tests/ui/transmute_float_to_int.rs:32:35 + --> tests/ui/transmute_float_to_int.rs:30:35 | LL | const VALUE32: i32 = unsafe { std::mem::transmute(1f32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f32.to_bits() as i32` error: transmute from a `f64` to a `u64` - --> tests/ui/transmute_float_to_int.rs:35:35 + --> tests/ui/transmute_float_to_int.rs:33:35 | LL | const VALUE64: u64 = unsafe { std::mem::transmute(1f64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f64.to_bits()` error: transmute from a `f128` to a `u128` - --> tests/ui/transmute_float_to_int.rs:38:37 + --> tests/ui/transmute_float_to_int.rs:36:37 | LL | const VALUE128: u128 = unsafe { std::mem::transmute(1f128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1f128.to_bits()` error: transmute from a `f16` to a `u16` - --> tests/ui/transmute_float_to_int.rs:43:18 + --> tests/ui/transmute_float_to_int.rs:40:18 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `v.to_bits()` error: transmute from a `f32` to a `u32` - --> tests/ui/transmute_float_to_int.rs:49:18 + --> tests/ui/transmute_float_to_int.rs:45:18 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `v.to_bits()` error: transmute from a `f64` to a `i64` - --> tests/ui/transmute_float_to_int.rs:55:18 + --> tests/ui/transmute_float_to_int.rs:50:18 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `v.to_bits() as i64` error: transmute from a `f128` to a `i128` - --> tests/ui/transmute_float_to_int.rs:61:18 + --> tests/ui/transmute_float_to_int.rs:55:18 | LL | unsafe { std::mem::transmute(v) } | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `v.to_bits() as i128` diff --git a/tests/ui/transmute_int_to_char.fixed b/tests/ui/transmute_int_to_char.fixed index e28467f004349..b5425a2e9e854 100644 --- a/tests/ui/transmute_int_to_char.fixed +++ b/tests/ui/transmute_int_to_char.fixed @@ -5,11 +5,9 @@ fn int_to_char() { let _: char = unsafe { std::char::from_u32(0_u32).unwrap() }; //~^ transmute_int_to_char - let _: char = unsafe { std::char::from_u32(0_i32 as u32).unwrap() }; //~^ transmute_int_to_char - // These shouldn't warn const _: char = unsafe { std::mem::transmute(0_u32) }; const _: char = unsafe { std::mem::transmute(0_i32) }; diff --git a/tests/ui/transmute_int_to_char.rs b/tests/ui/transmute_int_to_char.rs index decdaaa463a9c..b24bb177c9fc0 100644 --- a/tests/ui/transmute_int_to_char.rs +++ b/tests/ui/transmute_int_to_char.rs @@ -5,11 +5,9 @@ fn int_to_char() { let _: char = unsafe { std::mem::transmute(0_u32) }; //~^ transmute_int_to_char - let _: char = unsafe { std::mem::transmute(0_i32) }; //~^ transmute_int_to_char - // These shouldn't warn const _: char = unsafe { std::mem::transmute(0_u32) }; const _: char = unsafe { std::mem::transmute(0_i32) }; diff --git a/tests/ui/transmute_int_to_char.stderr b/tests/ui/transmute_int_to_char.stderr index 5dc58abb38ea7..e3a3620f28b75 100644 --- a/tests/ui/transmute_int_to_char.stderr +++ b/tests/ui/transmute_int_to_char.stderr @@ -8,7 +8,7 @@ LL | let _: char = unsafe { std::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_char)]` error: transmute from a `i32` to a `char` - --> tests/ui/transmute_int_to_char.rs:9:28 + --> tests/ui/transmute_int_to_char.rs:8:28 | LL | let _: char = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` diff --git a/tests/ui/transmute_int_to_char_no_std.fixed b/tests/ui/transmute_int_to_char_no_std.fixed index 09a353dc1ae9b..e525751e306ea 100644 --- a/tests/ui/transmute_int_to_char_no_std.fixed +++ b/tests/ui/transmute_int_to_char_no_std.fixed @@ -17,11 +17,9 @@ fn int_to_char() { let _: char = unsafe { core::char::from_u32(0_u32).unwrap() }; //~^ transmute_int_to_char - let _: char = unsafe { core::char::from_u32(0_i32 as u32).unwrap() }; //~^ transmute_int_to_char - // These shouldn't warn const _: char = unsafe { core::mem::transmute(0_u32) }; const _: char = unsafe { core::mem::transmute(0_i32) }; diff --git a/tests/ui/transmute_int_to_char_no_std.rs b/tests/ui/transmute_int_to_char_no_std.rs index fb47b3ce3ba93..7cb508ceaf3bc 100644 --- a/tests/ui/transmute_int_to_char_no_std.rs +++ b/tests/ui/transmute_int_to_char_no_std.rs @@ -17,11 +17,9 @@ fn int_to_char() { let _: char = unsafe { core::mem::transmute(0_u32) }; //~^ transmute_int_to_char - let _: char = unsafe { core::mem::transmute(0_i32) }; //~^ transmute_int_to_char - // These shouldn't warn const _: char = unsafe { core::mem::transmute(0_u32) }; const _: char = unsafe { core::mem::transmute(0_i32) }; diff --git a/tests/ui/transmute_int_to_char_no_std.stderr b/tests/ui/transmute_int_to_char_no_std.stderr index 37f996e6277fa..d94580a84d7a4 100644 --- a/tests/ui/transmute_int_to_char_no_std.stderr +++ b/tests/ui/transmute_int_to_char_no_std.stderr @@ -8,7 +8,7 @@ LL | let _: char = unsafe { core::mem::transmute(0_u32) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_char)]` error: transmute from a `i32` to a `char` - --> tests/ui/transmute_int_to_char_no_std.rs:21:28 + --> tests/ui/transmute_int_to_char_no_std.rs:20:28 | LL | let _: char = unsafe { core::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `core::char::from_u32(0_i32 as u32).unwrap()` diff --git a/tests/ui/transmute_int_to_non_zero.fixed b/tests/ui/transmute_int_to_non_zero.fixed index 12d8d20f4d8f1..273090fef3876 100644 --- a/tests/ui/transmute_int_to_non_zero.fixed +++ b/tests/ui/transmute_int_to_non_zero.fixed @@ -19,7 +19,6 @@ fn main() { let _: NonZero = unsafe { NonZero::new_unchecked(int_u8) }; //~^ transmute_int_to_non_zero - let _: NonZero = unsafe { NonZero::new_unchecked(int_u16) }; //~^ transmute_int_to_non_zero @@ -32,7 +31,6 @@ fn main() { let _: NonZero = unsafe { NonZero::new_unchecked(int_u128) }; //~^ transmute_int_to_non_zero - let _: NonZero = unsafe { NonZero::new_unchecked(int_i8) }; //~^ transmute_int_to_non_zero @@ -48,7 +46,6 @@ fn main() { let _: NonZero = unsafe { NonZero::new_unchecked(int_i128) }; //~^ transmute_int_to_non_zero - let _: NonZero = unsafe { NonZero::new_unchecked(int_u8) }; let _: NonZero = unsafe { NonZero::new_unchecked(int_u16) }; let _: NonZero = unsafe { NonZero::new_unchecked(int_u32) }; diff --git a/tests/ui/transmute_int_to_non_zero.rs b/tests/ui/transmute_int_to_non_zero.rs index a01b9aaa7f2e5..f27bc9b42d426 100644 --- a/tests/ui/transmute_int_to_non_zero.rs +++ b/tests/ui/transmute_int_to_non_zero.rs @@ -19,7 +19,6 @@ fn main() { let _: NonZero = unsafe { std::mem::transmute(int_u8) }; //~^ transmute_int_to_non_zero - let _: NonZero = unsafe { std::mem::transmute(int_u16) }; //~^ transmute_int_to_non_zero @@ -32,7 +31,6 @@ fn main() { let _: NonZero = unsafe { std::mem::transmute(int_u128) }; //~^ transmute_int_to_non_zero - let _: NonZero = unsafe { std::mem::transmute(int_i8) }; //~^ transmute_int_to_non_zero @@ -48,7 +46,6 @@ fn main() { let _: NonZero = unsafe { std::mem::transmute(int_i128) }; //~^ transmute_int_to_non_zero - let _: NonZero = unsafe { NonZero::new_unchecked(int_u8) }; let _: NonZero = unsafe { NonZero::new_unchecked(int_u16) }; let _: NonZero = unsafe { NonZero::new_unchecked(int_u32) }; diff --git a/tests/ui/transmute_int_to_non_zero.stderr b/tests/ui/transmute_int_to_non_zero.stderr index 1a1cd03248b42..995ab11a5bc96 100644 --- a/tests/ui/transmute_int_to_non_zero.stderr +++ b/tests/ui/transmute_int_to_non_zero.stderr @@ -8,55 +8,55 @@ LL | let _: NonZero = unsafe { std::mem::transmute(int_u8) }; = help: to override `-D warnings` add `#[allow(clippy::transmute_int_to_non_zero)]` error: transmute from a `u16` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:23:36 + --> tests/ui/transmute_int_to_non_zero.rs:22:36 | LL | let _: NonZero = unsafe { std::mem::transmute(int_u16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u16)` error: transmute from a `u32` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:26:36 + --> tests/ui/transmute_int_to_non_zero.rs:25:36 | LL | let _: NonZero = unsafe { std::mem::transmute(int_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u32)` error: transmute from a `u64` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:29:36 + --> tests/ui/transmute_int_to_non_zero.rs:28:36 | LL | let _: NonZero = unsafe { std::mem::transmute(int_u64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u64)` error: transmute from a `u128` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:32:37 + --> tests/ui/transmute_int_to_non_zero.rs:31:37 | LL | let _: NonZero = unsafe { std::mem::transmute(int_u128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_u128)` error: transmute from a `i8` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:36:35 + --> tests/ui/transmute_int_to_non_zero.rs:34:35 | LL | let _: NonZero = unsafe { std::mem::transmute(int_i8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i8)` error: transmute from a `i16` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:39:36 + --> tests/ui/transmute_int_to_non_zero.rs:37:36 | LL | let _: NonZero = unsafe { std::mem::transmute(int_i16) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i16)` error: transmute from a `i32` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:42:36 + --> tests/ui/transmute_int_to_non_zero.rs:40:36 | LL | let _: NonZero = unsafe { std::mem::transmute(int_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i32)` error: transmute from a `i64` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:45:36 + --> tests/ui/transmute_int_to_non_zero.rs:43:36 | LL | let _: NonZero = unsafe { std::mem::transmute(int_i64) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i64)` error: transmute from a `i128` to a `NonZero` - --> tests/ui/transmute_int_to_non_zero.rs:48:37 + --> tests/ui/transmute_int_to_non_zero.rs:46:37 | LL | let _: NonZero = unsafe { std::mem::transmute(int_i128) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `NonZero::new_unchecked(int_i128)` diff --git a/tests/ui/transmute_null_to_fn.rs b/tests/ui/transmute_null_to_fn.rs index a9eaf16d05aa7..e88f05bb662e2 100644 --- a/tests/ui/transmute_null_to_fn.rs +++ b/tests/ui/transmute_null_to_fn.rs @@ -10,7 +10,6 @@ fn one_liners() { let _: fn() = std::mem::transmute(std::ptr::null::<()>()); //~^ transmute_null_to_fn - } } @@ -38,7 +37,6 @@ fn issue_11485() { let _: fn() = std::mem::transmute(ZPTR as *const u8); //~^ transmute_null_to_fn - } } diff --git a/tests/ui/transmute_null_to_fn.stderr b/tests/ui/transmute_null_to_fn.stderr index 9b2253c444f4d..f7d80147445d8 100644 --- a/tests/ui/transmute_null_to_fn.stderr +++ b/tests/ui/transmute_null_to_fn.stderr @@ -17,7 +17,7 @@ LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>()); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> tests/ui/transmute_null_to_fn.rs:23:23 + --> tests/ui/transmute_null_to_fn.rs:22:23 | LL | let _: fn() = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -25,7 +25,7 @@ LL | let _: fn() = std::mem::transmute(ZPTR); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> tests/ui/transmute_null_to_fn.rs:33:23 + --> tests/ui/transmute_null_to_fn.rs:32:23 | LL | let _: fn() = std::mem::transmute(0 as *const u8 as *const ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -33,7 +33,7 @@ LL | let _: fn() = std::mem::transmute(0 as *const u8 as *const ()); = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> tests/ui/transmute_null_to_fn.rs:36:23 + --> tests/ui/transmute_null_to_fn.rs:35:23 | LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior @@ -41,7 +41,7 @@ LL | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const = help: try wrapping your function pointer type in `Option` instead, and using `None` as a null pointer value error: transmuting a known null pointer into a function pointer - --> tests/ui/transmute_null_to_fn.rs:39:23 + --> tests/ui/transmute_null_to_fn.rs:38:23 | LL | let _: fn() = std::mem::transmute(ZPTR as *const u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this transmute results in undefined behavior diff --git a/tests/ui/transmute_ptr_to_ptr.fixed b/tests/ui/transmute_ptr_to_ptr.fixed index d595ecf32a1c8..3a67be5f45d0b 100644 --- a/tests/ui/transmute_ptr_to_ptr.fixed +++ b/tests/ui/transmute_ptr_to_ptr.fixed @@ -59,7 +59,6 @@ fn transmute_ptr_to_ptr() { let _: *mut u32 = ptr.cast_mut(); //~^ transmute_ptr_to_ptr - } // transmute internal lifetimes, should not lint @@ -72,7 +71,6 @@ fn transmute_ptr_to_ptr() { fn lifetime_to_static(v: *mut &()) -> *const &'static () { unsafe { v as *const &() } //~^ transmute_ptr_to_ptr - } // dereferencing raw pointers in const contexts, should not lint as it's unstable (issue 5959) diff --git a/tests/ui/transmute_ptr_to_ptr.rs b/tests/ui/transmute_ptr_to_ptr.rs index 2e72f86dd3b33..01ad3a3296b17 100644 --- a/tests/ui/transmute_ptr_to_ptr.rs +++ b/tests/ui/transmute_ptr_to_ptr.rs @@ -59,7 +59,6 @@ fn transmute_ptr_to_ptr() { let _: *mut u32 = transmute(ptr); //~^ transmute_ptr_to_ptr - } // transmute internal lifetimes, should not lint @@ -72,7 +71,6 @@ fn transmute_ptr_to_ptr() { fn lifetime_to_static(v: *mut &()) -> *const &'static () { unsafe { transmute(v) } //~^ transmute_ptr_to_ptr - } // dereferencing raw pointers in const contexts, should not lint as it's unstable (issue 5959) diff --git a/tests/ui/transmute_ptr_to_ptr.stderr b/tests/ui/transmute_ptr_to_ptr.stderr index 3e7e170eff7ff..0ff1cd3c090b3 100644 --- a/tests/ui/transmute_ptr_to_ptr.stderr +++ b/tests/ui/transmute_ptr_to_ptr.stderr @@ -75,7 +75,7 @@ LL | let _: *mut u32 = ptr.cast_mut(); | ~~~~~~~~~~~~~~ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:73:14 + --> tests/ui/transmute_ptr_to_ptr.rs:72:14 | LL | unsafe { transmute(v) } | ^^^^^^^^^^^^ @@ -86,7 +86,7 @@ LL | unsafe { v as *const &() } | ~~~~~~~~~~~~~~~ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:89:28 + --> tests/ui/transmute_ptr_to_ptr.rs:87:28 | LL | let _: *const i8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _: *const i8 = ptr as *const i8; | ~~~~~~~~~~~~~~~~ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:97:28 + --> tests/ui/transmute_ptr_to_ptr.rs:95:28 | LL | let _: *const i8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | let _: *const i8 = ptr.cast::(); | ~~~~~~~~~~~~~~~~ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:105:26 + --> tests/ui/transmute_ptr_to_ptr.rs:103:26 | LL | let _: *mut u8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | let _: *mut u8 = ptr as *mut u8; | ~~~~~~~~~~~~~~ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:107:28 + --> tests/ui/transmute_ptr_to_ptr.rs:105:28 | LL | let _: *const u8 = transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | let _: *const u8 = mut_ptr as *const u8; | ~~~~~~~~~~~~~~~~~~~~ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:115:26 + --> tests/ui/transmute_ptr_to_ptr.rs:113:26 | LL | let _: *mut u8 = transmute(ptr); | ^^^^^^^^^^^^^^ @@ -141,7 +141,7 @@ LL | let _: *mut u8 = ptr.cast_mut(); | ~~~~~~~~~~~~~~ error: transmute from a pointer to a pointer - --> tests/ui/transmute_ptr_to_ptr.rs:117:28 + --> tests/ui/transmute_ptr_to_ptr.rs:115:28 | LL | let _: *const u8 = transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmute_ref_to_ref.rs b/tests/ui/transmute_ref_to_ref.rs index c2094ab0cad6e..8bdf07b4a428b 100644 --- a/tests/ui/transmute_ref_to_ref.rs +++ b/tests/ui/transmute_ref_to_ref.rs @@ -16,6 +16,5 @@ fn main() { let bytes = &[1u8, 2u8, 3u8, 4u8] as &[u8]; let alt_slice: &[u32] = unsafe { std::mem::transmute(bytes) }; //~^ transmute_ptr_to_ptr - } } diff --git a/tests/ui/transmute_ref_to_ref_no_std.rs b/tests/ui/transmute_ref_to_ref_no_std.rs index 86c4189d87e4d..faa776f2afcec 100644 --- a/tests/ui/transmute_ref_to_ref_no_std.rs +++ b/tests/ui/transmute_ref_to_ref_no_std.rs @@ -28,6 +28,5 @@ fn main() { let bytes = &[1u8, 2u8, 3u8, 4u8] as &[u8]; let alt_slice: &[u32] = unsafe { core::mem::transmute(bytes) }; //~^ transmute_ptr_to_ptr - } } diff --git a/tests/ui/transmute_undefined_repr.rs b/tests/ui/transmute_undefined_repr.rs index db876150f4066..a449d6a4302f8 100644 --- a/tests/ui/transmute_undefined_repr.rs +++ b/tests/ui/transmute_undefined_repr.rs @@ -34,12 +34,10 @@ fn main() { let _: Ty2C = transmute(value::>()); //~^ transmute_undefined_repr - // Lint, Ty2 is unordered let _: Ty2 = transmute(value::>()); //~^ transmute_undefined_repr - // Ok, Ty2 types are the same let _: Ty2 = transmute(value::>>()); // Ok, Ty2 types are the same @@ -49,13 +47,10 @@ fn main() { let _: Ty2 = transmute(value::>>()); //~^ transmute_undefined_repr - // Lint, different Ty2 instances let _: Ty> = transmute(value::>()); //~^ transmute_undefined_repr - - let _: Ty<&()> = transmute(value::<&()>()); let _: &() = transmute(value::>()); @@ -63,13 +58,10 @@ fn main() { let _: &Ty2 = transmute(value::>>()); //~^ transmute_undefined_repr - // Lint, different Ty2 instances let _: Ty<&Ty2> = transmute(value::<&Ty2>()); //~^ transmute_undefined_repr - - // Ok, pointer to usize conversion let _: Ty = transmute(value::<&Ty2>()); // Ok, pointer to usize conversion @@ -99,13 +91,10 @@ fn main() { let _: &'static mut Ty2 = transmute(value::>>()); //~^ transmute_undefined_repr - // Lint, different Ty2 instances let _: Box> = transmute(value::<&'static mut Ty2>()); //~^ transmute_undefined_repr - - // Ok, type erasure let _: *const () = transmute(value::>>()); // Ok, reverse type erasure @@ -202,13 +191,10 @@ fn main() { let _: *const Ty2 = transmute(value::<*const Ty2C>>()); //~^ transmute_undefined_repr - // Err let _: *const Ty2C> = transmute(value::<*const Ty2>()); //~^ transmute_undefined_repr - - // Ok let _: NonNull = transmute(value::>()); // Ok @@ -255,13 +241,10 @@ fn _with_generics() { let _: Vec> = transmute(value::>>()); //~^ transmute_undefined_repr - // Err let _: Vec> = transmute(value::>>()); //~^ transmute_undefined_repr - - // Ok let _: *const u32 = transmute(value::>()); // Ok diff --git a/tests/ui/transmute_undefined_repr.stderr b/tests/ui/transmute_undefined_repr.stderr index a569309b2eb41..a259ef784c782 100644 --- a/tests/ui/transmute_undefined_repr.stderr +++ b/tests/ui/transmute_undefined_repr.stderr @@ -8,13 +8,13 @@ LL | let _: Ty2C = transmute(value::>()); = help: to override `-D warnings` add `#[allow(clippy::transmute_undefined_repr)]` error: transmute into `Ty2` which has an undefined layout - --> tests/ui/transmute_undefined_repr.rs:39:32 + --> tests/ui/transmute_undefined_repr.rs:38:32 | LL | let _: Ty2 = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from `Ty>` to `Ty2`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:49:32 + --> tests/ui/transmute_undefined_repr.rs:47:32 | LL | let _: Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | let _: Ty2 = transmute(value::>>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `Ty2` to `Ty>`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:54:36 + --> tests/ui/transmute_undefined_repr.rs:51:36 | LL | let _: Ty> = transmute(value::>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | let _: Ty> = transmute(value::>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `Ty<&Ty2>` to `&Ty2`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:63:33 + --> tests/ui/transmute_undefined_repr.rs:58:33 | LL | let _: &Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ LL | let _: &Ty2 = transmute(value::>>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `&Ty2` to `Ty<&Ty2>`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:68:37 + --> tests/ui/transmute_undefined_repr.rs:62:37 | LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL | let _: Ty<&Ty2> = transmute(value::<&Ty2>()); = note: two instances of the same generic type (`Ty2`) may have different layouts error: transmute from `std::boxed::Box>` to `&mut Ty2`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:99:45 + --> tests/ui/transmute_undefined_repr.rs:91:45 | LL | let _: &'static mut Ty2 = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,7 +54,7 @@ LL | let _: &'static mut Ty2 = transmute(value::` to `std::boxed::Box>`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:104:37 + --> tests/ui/transmute_undefined_repr.rs:95:37 | LL | let _: Box> = transmute(value::<&'static mut Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -62,7 +62,7 @@ LL | let _: Box> = transmute(value::<&'static mut Ty2` which has an undefined layout - --> tests/ui/transmute_undefined_repr.rs:202:39 + --> tests/ui/transmute_undefined_repr.rs:191:39 | LL | let _: *const Ty2 = transmute(value::<*const Ty2C>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ LL | let _: *const Ty2 = transmute(value::<*const Ty2C` has an undefined layout error: transmute from `*const Ty2` which has an undefined layout - --> tests/ui/transmute_undefined_repr.rs:207:50 + --> tests/ui/transmute_undefined_repr.rs:195:50 | LL | let _: *const Ty2C> = transmute(value::<*const Ty2>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +78,7 @@ LL | let _: *const Ty2C> = transmute(value::<*const T = note: the contained type `Ty2` has an undefined layout error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:255:35 + --> tests/ui/transmute_undefined_repr.rs:241:35 | LL | let _: Vec> = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -86,7 +86,7 @@ LL | let _: Vec> = transmute(value::>>()); = note: two instances of the same generic type (`Vec`) may have different layouts error: transmute from `std::vec::Vec>` to `std::vec::Vec>`, both of which have an undefined layout - --> tests/ui/transmute_undefined_repr.rs:260:35 + --> tests/ui/transmute_undefined_repr.rs:245:35 | LL | let _: Vec> = transmute(value::>>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmuting_null.rs b/tests/ui/transmuting_null.rs index 91f32a725589b..bcd35bbd4e72a 100644 --- a/tests/ui/transmuting_null.rs +++ b/tests/ui/transmuting_null.rs @@ -10,10 +10,8 @@ fn one_liners() { let _: &u64 = std::mem::transmute(0 as *const u64); //~^ transmuting_null - let _: &u64 = std::mem::transmute(std::ptr::null::()); //~^ transmuting_null - } } diff --git a/tests/ui/transmuting_null.stderr b/tests/ui/transmuting_null.stderr index 2e5fffd3ac285..84e6e374d5253 100644 --- a/tests/ui/transmuting_null.stderr +++ b/tests/ui/transmuting_null.stderr @@ -8,13 +8,13 @@ LL | let _: &u64 = std::mem::transmute(0 as *const u64); = help: to override `-D warnings` add `#[allow(clippy::transmuting_null)]` error: transmuting a known null pointer into a reference - --> tests/ui/transmuting_null.rs:14:23 + --> tests/ui/transmuting_null.rs:13:23 | LL | let _: &u64 = std::mem::transmute(std::ptr::null::()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmuting a known null pointer into a reference - --> tests/ui/transmuting_null.rs:26:23 + --> tests/ui/transmuting_null.rs:24:23 | LL | let _: &u64 = std::mem::transmute(ZPTR); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type_complexity.rs b/tests/ui/type_complexity.rs index 09c7bcc684087..89c4955c9f6f0 100644 --- a/tests/ui/type_complexity.rs +++ b/tests/ui/type_complexity.rs @@ -7,28 +7,22 @@ type Alias = Vec>>; // no warning here const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~^ type_complexity - static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~^ type_complexity - struct S { f: Vec>>, //~^ type_complexity - } struct Ts(Vec>>); //~^ type_complexity - enum E { Tuple(Vec>>), //~^ type_complexity - Struct { f: Vec>> }, //~^ type_complexity - } impl S { @@ -37,7 +31,6 @@ impl S { fn impl_method(&self, p: Vec>>) {} //~^ type_complexity - } trait T { @@ -52,7 +45,6 @@ trait T { fn def_method(&self, p: Vec>>) {} //~^ type_complexity - } // Should not warn since there is likely no way to simplify this (#1013) @@ -65,7 +57,7 @@ impl T for () { } fn test1() -> Vec>> { -//~^ type_complexity + //~^ type_complexity vec![] } @@ -73,11 +65,9 @@ fn test1() -> Vec>> { fn test2(_x: Vec>>) {} //~^ type_complexity - fn test3() { let _y: Vec>> = vec![]; //~^ type_complexity - } #[repr(C)] diff --git a/tests/ui/type_complexity.stderr b/tests/ui/type_complexity.stderr index 4926432aab880..181e04d38e9a4 100644 --- a/tests/ui/type_complexity.stderr +++ b/tests/ui/type_complexity.stderr @@ -8,85 +8,85 @@ LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); = help: to override `-D warnings` add `#[allow(clippy::type_complexity)]` error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:11:12 + --> tests/ui/type_complexity.rs:10:12 | LL | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:16:8 + --> tests/ui/type_complexity.rs:14:8 | LL | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:21:11 + --> tests/ui/type_complexity.rs:18:11 | LL | struct Ts(Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:26:11 + --> tests/ui/type_complexity.rs:22:11 | LL | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:29:17 + --> tests/ui/type_complexity.rs:24:17 | LL | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:35:14 + --> tests/ui/type_complexity.rs:29:14 | LL | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:38:30 + --> tests/ui/type_complexity.rs:32:30 | LL | fn impl_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:44:14 + --> tests/ui/type_complexity.rs:37:14 | LL | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:47:14 + --> tests/ui/type_complexity.rs:40:14 | LL | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:50:25 + --> tests/ui/type_complexity.rs:43:25 | LL | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:53:29 + --> tests/ui/type_complexity.rs:46:29 | LL | fn def_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:67:15 + --> tests/ui/type_complexity.rs:59:15 | LL | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:73:14 + --> tests/ui/type_complexity.rs:65:14 | LL | fn test2(_x: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> tests/ui/type_complexity.rs:78:13 + --> tests/ui/type_complexity.rs:69:13 | LL | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type_id_on_box.fixed b/tests/ui/type_id_on_box.fixed index f0d8a4acb2e31..2e241c36b34a1 100644 --- a/tests/ui/type_id_on_box.fixed +++ b/tests/ui/type_id_on_box.fixed @@ -31,7 +31,6 @@ fn main() { let _ = (*any_box).type_id(); //~^ type_id_on_box - // Don't lint. We explicitly say "do this instead" if this is intentional let _ = TypeId::of::>(); let _ = (*any_box).type_id(); @@ -41,7 +40,6 @@ fn main() { let _ = (**any_box).type_id(); //~^ type_id_on_box - let b = existential(); let _ = b.type_id(); // Don't @@ -49,12 +47,10 @@ fn main() { let _ = (*b).type_id(); //~^ type_id_on_box - let b: SomeBox = Box::new(0usize); let _ = (*b).type_id(); //~^ type_id_on_box - let b = BadBox(Box::new(0usize)); let _ = b.type_id(); // Don't lint. This is a call to `::type_id`. Not `std::boxed::Box`! } diff --git a/tests/ui/type_id_on_box.rs b/tests/ui/type_id_on_box.rs index b446ec287b670..46fac632894c3 100644 --- a/tests/ui/type_id_on_box.rs +++ b/tests/ui/type_id_on_box.rs @@ -31,7 +31,6 @@ fn main() { let _ = any_box.type_id(); //~^ type_id_on_box - // Don't lint. We explicitly say "do this instead" if this is intentional let _ = TypeId::of::>(); let _ = (*any_box).type_id(); @@ -41,7 +40,6 @@ fn main() { let _ = any_box.type_id(); //~^ type_id_on_box - let b = existential(); let _ = b.type_id(); // Don't @@ -49,12 +47,10 @@ fn main() { let _ = b.type_id(); //~^ type_id_on_box - let b: SomeBox = Box::new(0usize); let _ = b.type_id(); //~^ type_id_on_box - let b = BadBox(Box::new(0usize)); let _ = b.type_id(); // Don't lint. This is a call to `::type_id`. Not `std::boxed::Box`! } diff --git a/tests/ui/type_id_on_box.stderr b/tests/ui/type_id_on_box.stderr index 8004ef71287cc..4528195607dad 100644 --- a/tests/ui/type_id_on_box.stderr +++ b/tests/ui/type_id_on_box.stderr @@ -12,7 +12,7 @@ LL | let _ = any_box.type_id(); = help: to override `-D warnings` add `#[allow(clippy::type_id_on_box)]` error: calling `.type_id()` on `Box` - --> tests/ui/type_id_on_box.rs:41:13 + --> tests/ui/type_id_on_box.rs:40:13 | LL | let _ = any_box.type_id(); | -------^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = any_box.type_id(); = note: if this is intentional, use `TypeId::of::>()` instead, which makes it more clear error: calling `.type_id()` on `Box` - --> tests/ui/type_id_on_box.rs:49:13 + --> tests/ui/type_id_on_box.rs:47:13 | LL | let _ = b.type_id(); | -^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = b.type_id(); = note: if this is intentional, use `TypeId::of::>()` instead, which makes it more clear error: calling `.type_id()` on `Box` - --> tests/ui/type_id_on_box.rs:54:13 + --> tests/ui/type_id_on_box.rs:51:13 | LL | let _ = b.type_id(); | -^^^^^^^^^^ diff --git a/tests/ui/type_id_on_box_unfixable.rs b/tests/ui/type_id_on_box_unfixable.rs index 4df0ebb897a8b..58d245d56aa59 100644 --- a/tests/ui/type_id_on_box_unfixable.rs +++ b/tests/ui/type_id_on_box_unfixable.rs @@ -25,9 +25,7 @@ fn main() { let _ = b.type_id(); //~^ type_id_on_box - let b: Box = Box::new(1); let _ = b.type_id(); //~^ type_id_on_box - } diff --git a/tests/ui/type_id_on_box_unfixable.stderr b/tests/ui/type_id_on_box_unfixable.stderr index c653fd7835ff5..539ed481ec101 100644 --- a/tests/ui/type_id_on_box_unfixable.stderr +++ b/tests/ui/type_id_on_box_unfixable.stderr @@ -10,7 +10,7 @@ LL | let _ = b.type_id(); = help: to override `-D warnings` add `#[allow(clippy::type_id_on_box)]` error: calling `.type_id()` on `Box` - --> tests/ui/type_id_on_box_unfixable.rs:30:13 + --> tests/ui/type_id_on_box_unfixable.rs:29:13 | LL | let _ = b.type_id(); | ^^^^^^^^^^^ diff --git a/tests/ui/unbuffered_bytes.rs b/tests/ui/unbuffered_bytes.rs index 82c8839e83912..87199c7e335df 100644 --- a/tests/ui/unbuffered_bytes.rs +++ b/tests/ui/unbuffered_bytes.rs @@ -8,10 +8,12 @@ fn main() { // File is not buffered, should complain let file = File::open("./bytes.txt").unwrap(); file.bytes(); + //~^ unbuffered_bytes // TcpStream is not buffered, should complain let tcp_stream: TcpStream = TcpStream::connect("127.0.0.1:80").unwrap(); tcp_stream.bytes(); + //~^ unbuffered_bytes // BufReader is buffered, should not complain let file = BufReader::new(File::open("./bytes.txt").unwrap()); @@ -24,6 +26,7 @@ fn main() { // Stdio would acquire the lock for every byte, should complain let s: Stdin = stdin(); s.bytes(); + //~^ unbuffered_bytes // But when locking stdin, this is fine so should not complain let s: Stdin = stdin(); @@ -34,4 +37,5 @@ fn main() { fn use_read(r: R) { // Callers of `use_read` may choose a `R` that is not buffered r.bytes(); + //~^ unbuffered_bytes } diff --git a/tests/ui/unbuffered_bytes.stderr b/tests/ui/unbuffered_bytes.stderr index 3303d579fedcb..7505eb9e363a5 100644 --- a/tests/ui/unbuffered_bytes.stderr +++ b/tests/ui/unbuffered_bytes.stderr @@ -9,7 +9,7 @@ LL | file.bytes(); = help: to override `-D warnings` add `#[allow(clippy::unbuffered_bytes)]` error: calling .bytes() is very inefficient when data is not in memory - --> tests/ui/unbuffered_bytes.rs:14:5 + --> tests/ui/unbuffered_bytes.rs:15:5 | LL | tcp_stream.bytes(); | ^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | tcp_stream.bytes(); = help: consider using `BufReader` error: calling .bytes() is very inefficient when data is not in memory - --> tests/ui/unbuffered_bytes.rs:26:5 + --> tests/ui/unbuffered_bytes.rs:28:5 | LL | s.bytes(); | ^^^^^^^^^ @@ -25,7 +25,7 @@ LL | s.bytes(); = help: consider using `BufReader` error: calling .bytes() is very inefficient when data is not in memory - --> tests/ui/unbuffered_bytes.rs:36:5 + --> tests/ui/unbuffered_bytes.rs:39:5 | LL | r.bytes(); | ^^^^^^^^^ diff --git a/tests/ui/unconditional_recursion.rs b/tests/ui/unconditional_recursion.rs index 6cbd6bffb8db2..d9f4c07dc9025 100644 --- a/tests/ui/unconditional_recursion.rs +++ b/tests/ui/unconditional_recursion.rs @@ -15,12 +15,12 @@ enum Foo { impl PartialEq for Foo { fn ne(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion self != other } fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion self == other } @@ -33,11 +33,11 @@ enum Foo2 { impl PartialEq for Foo2 { fn ne(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion self != &Foo2::B // no error here } fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion self == &Foo2::B // no error here } } @@ -49,13 +49,13 @@ enum Foo3 { impl PartialEq for Foo3 { fn ne(&self, other: &Self) -> bool { - //~^ unconditional_recursion - //~| ERROR: function cannot return without recursing + //~^ unconditional_recursion + //~| ERROR: function cannot return without recursing self.ne(other) } fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion - //~| ERROR: function cannot return without recursing + //~^ unconditional_recursion + //~| ERROR: function cannot return without recursing self.eq(other) } @@ -100,12 +100,12 @@ struct S; // Check the order doesn't matter. impl PartialEq for S { fn ne(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion other != self } fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion other == self } @@ -116,13 +116,13 @@ struct S2; // Check that if the same element is compared, it's also triggering the lint. impl PartialEq for S2 { fn ne(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion other != other //~^ eq_op } fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion other == other //~^ eq_op @@ -133,13 +133,13 @@ struct S3; impl PartialEq for S3 { fn ne(&self, _other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion self != self //~^ eq_op } fn eq(&self, _other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion self == self //~^ eq_op @@ -169,7 +169,7 @@ macro_rules! impl_partial_eq { ($ty:ident) => { impl PartialEq for $ty { fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion self == other } @@ -199,7 +199,7 @@ struct S7<'a> { impl<'a> PartialEq for S7<'a> { fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion let mine = &self.field; let theirs = &other.field; @@ -269,7 +269,7 @@ impl std::default::Default for S12 { impl S12 { fn new() -> Self { - //~^ unconditional_recursion + //~^ unconditional_recursion Self::default() } @@ -309,7 +309,7 @@ struct S15<'a> { impl PartialEq for S15<'_> { fn eq(&self, other: &Self) -> bool { - //~^ unconditional_recursion + //~^ unconditional_recursion let mine = &self.field; let theirs = &other.field; @@ -381,7 +381,7 @@ struct BadFromTy1<'a>(&'a ()); struct BadIntoTy1<'b>(&'b ()); impl<'a> From> for BadIntoTy1<'static> { fn from(f: BadFromTy1<'a>) -> Self { - //~^ unconditional_recursion + //~^ unconditional_recursion f.into() } } @@ -391,7 +391,7 @@ struct BadFromTy2<'a>(&'a ()); struct BadIntoTy2<'b>(&'b ()); impl<'a> From> for BadIntoTy2<'static> { fn from(f: BadFromTy2<'a>) -> Self { - //~^ unconditional_recursion + //~^ unconditional_recursion Into::into(f) } } diff --git a/tests/ui/uninhabited_references.rs b/tests/ui/uninhabited_references.rs index 649af4312ce46..9b3616ad51871 100644 --- a/tests/ui/uninhabited_references.rs +++ b/tests/ui/uninhabited_references.rs @@ -3,14 +3,14 @@ #![feature(never_type)] fn ret_uninh_ref() -> &'static std::convert::Infallible { -//~^ uninhabited_references + //~^ uninhabited_references unsafe { std::mem::transmute(&()) } } macro_rules! ret_something { ($name:ident, $ty:ty) => { fn $name(x: &$ty) -> &$ty { - //~^ uninhabited_references + //~^ uninhabited_references &*x //~^ uninhabited_references } diff --git a/tests/ui/uninit.rs b/tests/ui/uninit.rs index 965ef4a10b399..f74248c8aea80 100644 --- a/tests/ui/uninit.rs +++ b/tests/ui/uninit.rs @@ -12,8 +12,6 @@ fn main() { let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; //~^ uninit_assumed_init - - // This is OK, because ZSTs do not contain data. let _: () = unsafe { MaybeUninit::uninit().assume_init() }; @@ -36,7 +34,6 @@ fn main() { let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; //~^ uninit_assumed_init - polymorphic::<()>(); polymorphic_maybe_uninit_array::<10>(); polymorphic_maybe_uninit::(); @@ -45,7 +42,6 @@ fn main() { // We are conservative around polymorphic types. let _: T = unsafe { MaybeUninit::uninit().assume_init() }; //~^ uninit_assumed_init - } fn polymorphic_maybe_uninit_array() { diff --git a/tests/ui/uninit.stderr b/tests/ui/uninit.stderr index 9179a2b28dbb2..d6f54dd61ca0e 100644 --- a/tests/ui/uninit.stderr +++ b/tests/ui/uninit.stderr @@ -7,13 +7,13 @@ LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; = note: `#[deny(clippy::uninit_assumed_init)]` on by default error: this call for this type may be undefined behavior - --> tests/ui/uninit.rs:36:29 + --> tests/ui/uninit.rs:34:29 | LL | let _: usize = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this call for this type may be undefined behavior - --> tests/ui/uninit.rs:46:29 + --> tests/ui/uninit.rs:43:29 | LL | let _: T = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/uninlined_format_args.fixed b/tests/ui/uninlined_format_args.fixed index 444a5b1cfb5f8..6db094babb245 100644 --- a/tests/ui/uninlined_format_args.fixed +++ b/tests/ui/uninlined_format_args.fixed @@ -53,7 +53,7 @@ fn tester(fn_arg: i32) { println!("val='{local_i32}'"); // tab+space //~^ uninlined_format_args println!( - //~^ uninlined_format_args + //~^ uninlined_format_args "val='{local_i32}'" ); println!("{local_i32}"); @@ -173,7 +173,7 @@ fn tester(fn_arg: i32) { println!("{local_f64:width$.prec$} {local_f64} {width} {prec}"); //~^ uninlined_format_args println!( - //~^ uninlined_format_args + //~^ uninlined_format_args "{local_i32:width$.prec$} {local_i32:prec$.width$} {width:local_i32$.prec$} {width:prec$.local_i32$} {prec:local_i32$.width$} {prec:width$.local_i32$}", ); println!( @@ -208,7 +208,7 @@ fn tester(fn_arg: i32) { println!(no_param_str!(), local_i32); println!( - //~^ uninlined_format_args + //~^ uninlined_format_args "{val}", ); println!("{val}"); diff --git a/tests/ui/uninlined_format_args.rs b/tests/ui/uninlined_format_args.rs index 526fd98dfa4b5..7ca61b8002193 100644 --- a/tests/ui/uninlined_format_args.rs +++ b/tests/ui/uninlined_format_args.rs @@ -53,7 +53,7 @@ fn tester(fn_arg: i32) { println!("val='{ }'", local_i32); // tab+space //~^ uninlined_format_args println!( - //~^ uninlined_format_args + //~^ uninlined_format_args "val='{ }'", local_i32 @@ -175,7 +175,7 @@ fn tester(fn_arg: i32) { println!("{:1$.2$} {0} {1} {2}", local_f64, width, prec); //~^ uninlined_format_args println!( - //~^ uninlined_format_args + //~^ uninlined_format_args "{0:1$.2$} {0:2$.1$} {1:0$.2$} {1:2$.0$} {2:0$.1$} {2:1$.0$}", local_i32, width, prec, ); @@ -211,7 +211,7 @@ fn tester(fn_arg: i32) { println!(no_param_str!(), local_i32); println!( - //~^ uninlined_format_args + //~^ uninlined_format_args "{}", // comment with a comma , in it val, diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs index 3a3962d09143e..22a6a26dab626 100644 --- a/tests/ui/unit_arg.rs +++ b/tests/ui/unit_arg.rs @@ -61,30 +61,30 @@ impl Tr for B { fn bad() { foo({ - //~^ unit_arg + //~^ unit_arg 1; }); foo(foo(1)); //~^ unit_arg foo({ - //~^ unit_arg + //~^ unit_arg foo(1); foo(2); }); let b = Bar; b.bar({ - //~^ unit_arg + //~^ unit_arg 1; }); taking_multiple_units(foo(0), foo(1)); //~^ unit_arg taking_multiple_units(foo(0), { - //~^ unit_arg + //~^ unit_arg foo(1); foo(2); }); taking_multiple_units( - //~^ unit_arg + //~^ unit_arg { foo(0); foo(1); diff --git a/tests/ui/unit_cmp.rs b/tests/ui/unit_cmp.rs index 0b1cccfbadf64..93f5b87c3d2a7 100644 --- a/tests/ui/unit_cmp.rs +++ b/tests/ui/unit_cmp.rs @@ -15,8 +15,7 @@ fn main() { // this warns if { - //~^ unit_cmp - + //~^ unit_cmp true; } == { @@ -24,7 +23,7 @@ fn main() { } {} if { - //~^ unit_cmp + //~^ unit_cmp true; } > { @@ -32,8 +31,7 @@ fn main() { } {} assert_eq!( - //~^ unit_cmp - + //~^ unit_cmp { true; }, @@ -42,8 +40,7 @@ fn main() { } ); debug_assert_eq!( - //~^ unit_cmp - + //~^ unit_cmp { true; }, @@ -53,8 +50,7 @@ fn main() { ); assert_ne!( - //~^ unit_cmp - + //~^ unit_cmp { true; }, @@ -63,8 +59,7 @@ fn main() { } ); debug_assert_ne!( - //~^ unit_cmp - + //~^ unit_cmp { true; }, diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index 0c485edd9736b..8f26749fd8605 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -3,7 +3,10 @@ error: ==-comparison of unit values detected. This will always be true | LL | if { | ________^ -... | +LL | | +LL | | +LL | | true; +LL | | } == { LL | | false; LL | | } {} | |_____^ @@ -12,7 +15,7 @@ LL | | } {} = help: to override `-D warnings` add `#[allow(clippy::unit_cmp)]` error: >-comparison of unit values detected. This will always be false - --> tests/ui/unit_cmp.rs:26:8 + --> tests/ui/unit_cmp.rs:25:8 | LL | if { | ________^ @@ -25,33 +28,45 @@ LL | | } {} | |_____^ error: `assert_eq` of unit values detected. This will always succeed - --> tests/ui/unit_cmp.rs:34:5 + --> tests/ui/unit_cmp.rs:33:5 | LL | / assert_eq!( +LL | | +LL | | { +LL | | true; ... | LL | | ); | |_____^ error: `debug_assert_eq` of unit values detected. This will always succeed - --> tests/ui/unit_cmp.rs:44:5 + --> tests/ui/unit_cmp.rs:42:5 | LL | / debug_assert_eq!( +LL | | +LL | | { +LL | | true; ... | LL | | ); | |_____^ error: `assert_ne` of unit values detected. This will always fail - --> tests/ui/unit_cmp.rs:55:5 + --> tests/ui/unit_cmp.rs:52:5 | LL | / assert_ne!( +LL | | +LL | | { +LL | | true; ... | LL | | ); | |_____^ error: `debug_assert_ne` of unit values detected. This will always fail - --> tests/ui/unit_cmp.rs:65:5 + --> tests/ui/unit_cmp.rs:61:5 | LL | / debug_assert_ne!( +LL | | +LL | | { +LL | | true; ... | LL | | ); | |_____^ diff --git a/tests/ui/unit_hash.fixed b/tests/ui/unit_hash.fixed index 4df67c783d326..25c90e6ddc4c2 100644 --- a/tests/ui/unit_hash.fixed +++ b/tests/ui/unit_hash.fixed @@ -18,8 +18,6 @@ fn main() { match my_enum { Foo::Empty => 0_u8.hash(&mut state), //~^ unit_hash - - Foo::WithValue(x) => x.hash(&mut state), } @@ -27,11 +25,7 @@ fn main() { 0_u8.hash(&mut state); //~^ unit_hash - - #[allow(clippy::unit_arg)] 0_u8.hash(&mut state); //~^ unit_hash - - } diff --git a/tests/ui/unit_hash.rs b/tests/ui/unit_hash.rs index 15f27aab95e1d..b04cca6adf2a5 100644 --- a/tests/ui/unit_hash.rs +++ b/tests/ui/unit_hash.rs @@ -18,8 +18,6 @@ fn main() { match my_enum { Foo::Empty => ().hash(&mut state), //~^ unit_hash - - Foo::WithValue(x) => x.hash(&mut state), } @@ -27,11 +25,7 @@ fn main() { res.hash(&mut state); //~^ unit_hash - - #[allow(clippy::unit_arg)] do_nothing().hash(&mut state); //~^ unit_hash - - } diff --git a/tests/ui/unit_hash.stderr b/tests/ui/unit_hash.stderr index be019d398b58d..d1cabf89f8e71 100644 --- a/tests/ui/unit_hash.stderr +++ b/tests/ui/unit_hash.stderr @@ -9,7 +9,7 @@ LL | Foo::Empty => ().hash(&mut state), = help: to override `-D warnings` add `#[allow(clippy::unit_hash)]` error: this call to `hash` on the unit type will do nothing - --> tests/ui/unit_hash.rs:27:5 + --> tests/ui/unit_hash.rs:25:5 | LL | res.hash(&mut state); | ^^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` @@ -17,7 +17,7 @@ LL | res.hash(&mut state); = note: the implementation of `Hash` for `()` is a no-op error: this call to `hash` on the unit type will do nothing - --> tests/ui/unit_hash.rs:33:5 + --> tests/ui/unit_hash.rs:29:5 | LL | do_nothing().hash(&mut state); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the call to `hash` or consider using: `0_u8.hash(&mut state)` diff --git a/tests/ui/unit_return_expecting_ord.rs b/tests/ui/unit_return_expecting_ord.rs index 3585eb5395dbe..74cd304726842 100644 --- a/tests/ui/unit_return_expecting_ord.rs +++ b/tests/ui/unit_return_expecting_ord.rs @@ -16,18 +16,18 @@ fn unit(_i: isize) {} fn main() { let mut structs = vec![Struct { field: 2 }, Struct { field: 1 }]; structs.sort_by_key(|s| { - //~^ unit_return_expecting_ord + //~^ unit_return_expecting_ord double(s.field); }); structs.sort_by_key(|s| double(s.field)); structs.is_sorted_by_key(|s| { - //~^ unit_return_expecting_ord + //~^ unit_return_expecting_ord double(s.field); }); structs.is_sorted_by_key(|s| { - //~^ unit_return_expecting_ord + //~^ unit_return_expecting_ord if s.field > 0 { () @@ -40,5 +40,4 @@ fn main() { }); structs.sort_by_key(|s| unit(s.field)); //~^ unit_return_expecting_ord - } diff --git a/tests/ui/unnecessary_box_returns.rs b/tests/ui/unnecessary_box_returns.rs index 5037c05a0acb4..a7ab7e90be06b 100644 --- a/tests/ui/unnecessary_box_returns.rs +++ b/tests/ui/unnecessary_box_returns.rs @@ -4,7 +4,6 @@ trait Bar { // lint fn baz(&self) -> Box; //~^ unnecessary_box_returns - } pub struct Foo {} @@ -18,7 +17,7 @@ impl Bar for Foo { impl Foo { fn baz(&self) -> Box { - //~^ unnecessary_box_returns + //~^ unnecessary_box_returns // lint Box::new(13) @@ -27,14 +26,14 @@ impl Foo { // lint fn bxed_usize() -> Box { -//~^ unnecessary_box_returns + //~^ unnecessary_box_returns Box::new(5) } // lint fn _bxed_foo() -> Box { -//~^ unnecessary_box_returns + //~^ unnecessary_box_returns Box::new(Foo {}) } diff --git a/tests/ui/unnecessary_box_returns.stderr b/tests/ui/unnecessary_box_returns.stderr index 9df056569a29e..ab1d90f13b922 100644 --- a/tests/ui/unnecessary_box_returns.stderr +++ b/tests/ui/unnecessary_box_returns.stderr @@ -9,7 +9,7 @@ LL | fn baz(&self) -> Box; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_box_returns)]` error: boxed return of the sized type `usize` - --> tests/ui/unnecessary_box_returns.rs:20:22 + --> tests/ui/unnecessary_box_returns.rs:19:22 | LL | fn baz(&self) -> Box { | ^^^^^^^^^^ help: try: `usize` @@ -17,7 +17,7 @@ LL | fn baz(&self) -> Box { = help: changing this also requires a change to the return expressions in this function error: boxed return of the sized type `usize` - --> tests/ui/unnecessary_box_returns.rs:29:20 + --> tests/ui/unnecessary_box_returns.rs:28:20 | LL | fn bxed_usize() -> Box { | ^^^^^^^^^^ help: try: `usize` @@ -25,7 +25,7 @@ LL | fn bxed_usize() -> Box { = help: changing this also requires a change to the return expressions in this function error: boxed return of the sized type `Foo` - --> tests/ui/unnecessary_box_returns.rs:36:19 + --> tests/ui/unnecessary_box_returns.rs:35:19 | LL | fn _bxed_foo() -> Box { | ^^^^^^^^ help: try: `Foo` diff --git a/tests/ui/unnecessary_cast_unfixable.rs b/tests/ui/unnecessary_cast_unfixable.rs index 05dd20c7a1144..2bb64c3e80e34 100644 --- a/tests/ui/unnecessary_cast_unfixable.rs +++ b/tests/ui/unnecessary_cast_unfixable.rs @@ -3,8 +3,6 @@ fn main() { let _ = std::ptr::null() as *const u8; //~^ unnecessary_cast - - } mod issue11113 { @@ -21,7 +19,6 @@ mod issue11113 { unsafe fn query(&self) { ((*(*(self.object as *mut *mut _) as *mut Vtbl)).query)() //~^ unnecessary_cast - } } } diff --git a/tests/ui/unnecessary_cast_unfixable.stderr b/tests/ui/unnecessary_cast_unfixable.stderr index 0047b38850b75..6ba1c78730667 100644 --- a/tests/ui/unnecessary_cast_unfixable.stderr +++ b/tests/ui/unnecessary_cast_unfixable.stderr @@ -8,7 +8,7 @@ LL | let _ = std::ptr::null() as *const u8; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_cast)]` error: casting raw pointers to the same type and constness is unnecessary (`*mut issue11113::Vtbl` -> `*mut issue11113::Vtbl`) - --> tests/ui/unnecessary_cast_unfixable.rs:22:16 + --> tests/ui/unnecessary_cast_unfixable.rs:20:16 | LL | ((*(*(self.object as *mut *mut _) as *mut Vtbl)).query)() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `*(self.object as *mut *mut _)` diff --git a/tests/ui/unnecessary_clippy_cfg.rs b/tests/ui/unnecessary_clippy_cfg.rs index 406c0133c5d3f..e7e01248dfbed 100644 --- a/tests/ui/unnecessary_clippy_cfg.rs +++ b/tests/ui/unnecessary_clippy_cfg.rs @@ -3,28 +3,21 @@ #![warn(clippy::unnecessary_clippy_cfg)] #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg - #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg - #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg //~| duplicated_attributes - #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg - #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg - #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg - #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg //~| duplicated_attributes - #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] //~^ unnecessary_clippy_cfg diff --git a/tests/ui/unnecessary_clippy_cfg.stderr b/tests/ui/unnecessary_clippy_cfg.stderr index f6f36fbf2baad..f66c68949548b 100644 --- a/tests/ui/unnecessary_clippy_cfg.stderr +++ b/tests/ui/unnecessary_clippy_cfg.stderr @@ -8,7 +8,7 @@ LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] = help: to override `-D warnings` add `#[allow(clippy::unnecessary_clippy_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:7:37 + --> tests/ui/unnecessary_clippy_cfg.rs:6:37 | LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] = note: write instead: `#![deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:10:37 + --> tests/ui/unnecessary_clippy_cfg.rs:8:37 | LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,19 +24,19 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] = note: write instead: `#![deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:14:1 + --> tests/ui/unnecessary_clippy_cfg.rs:11:1 | LL | #![cfg_attr(clippy, deny(clippy::non_minimal_cfg))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#![deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:18:1 + --> tests/ui/unnecessary_clippy_cfg.rs:14:1 | LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:21:36 + --> tests/ui/unnecessary_clippy_cfg.rs:16:36 | LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] = note: write instead: `#[deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:24:36 + --> tests/ui/unnecessary_clippy_cfg.rs:18:36 | LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,24 +52,24 @@ LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] = note: write instead: `#[deny(clippy::non_minimal_cfg)]` error: no need to put clippy lints behind a `clippy` cfg - --> tests/ui/unnecessary_clippy_cfg.rs:28:1 + --> tests/ui/unnecessary_clippy_cfg.rs:21:1 | LL | #[cfg_attr(clippy, deny(clippy::non_minimal_cfg))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `#[deny(clippy::non_minimal_cfg)]` error: duplicated attribute - --> tests/ui/unnecessary_clippy_cfg.rs:10:26 + --> tests/ui/unnecessary_clippy_cfg.rs:8:26 | LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^ | note: first defined here - --> tests/ui/unnecessary_clippy_cfg.rs:7:26 + --> tests/ui/unnecessary_clippy_cfg.rs:6:26 | LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^ help: remove this attribute - --> tests/ui/unnecessary_clippy_cfg.rs:10:26 + --> tests/ui/unnecessary_clippy_cfg.rs:8:26 | LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^ @@ -77,18 +77,18 @@ LL | #![cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] = help: to override `-D warnings` add `#[allow(clippy::duplicated_attributes)]` error: duplicated attribute - --> tests/ui/unnecessary_clippy_cfg.rs:24:25 + --> tests/ui/unnecessary_clippy_cfg.rs:18:25 | LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^ | note: first defined here - --> tests/ui/unnecessary_clippy_cfg.rs:21:25 + --> tests/ui/unnecessary_clippy_cfg.rs:16:25 | LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^ help: remove this attribute - --> tests/ui/unnecessary_clippy_cfg.rs:24:25 + --> tests/ui/unnecessary_clippy_cfg.rs:18:25 | LL | #[cfg_attr(clippy, deny(dead_code, clippy::non_minimal_cfg))] | ^^^^^^^^^ diff --git a/tests/ui/unnecessary_clone.rs b/tests/ui/unnecessary_clone.rs index 3ce7c7ef0252e..7335b6f9f0390 100644 --- a/tests/ui/unnecessary_clone.rs +++ b/tests/ui/unnecessary_clone.rs @@ -23,7 +23,6 @@ fn clone_on_ref_ptr() { rc.clone(); //~^ clone_on_ref_ptr - Rc::clone(&rc); arc.clone(); @@ -44,18 +43,14 @@ fn clone_on_ref_ptr() { let x = Arc::new(SomeImpl); let _: Arc = x.clone(); //~^ clone_on_ref_ptr - } fn clone_on_copy_generic(t: T) { t.clone(); //~^ clone_on_copy - - Some(t).clone(); //~^ clone_on_copy - } mod many_derefs { @@ -112,6 +107,5 @@ mod issue2076 { let rc = Rc::new(42); Some(try_opt!(Some(rc)).clone()) //~^ clone_on_ref_ptr - } } diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index cf508eb4c645b..a4fdf09cd5dcb 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -8,31 +8,31 @@ LL | rc.clone(); = help: to override `-D warnings` add `#[allow(clippy::clone_on_ref_ptr)]` error: using `.clone()` on a ref-counted pointer - --> tests/ui/unnecessary_clone.rs:29:5 + --> tests/ui/unnecessary_clone.rs:28:5 | LL | arc.clone(); | ^^^^^^^^^^^ help: try: `Arc::::clone(&arc)` error: using `.clone()` on a ref-counted pointer - --> tests/ui/unnecessary_clone.rs:34:5 + --> tests/ui/unnecessary_clone.rs:33:5 | LL | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try: `Weak::::clone(&rcweak)` error: using `.clone()` on a ref-counted pointer - --> tests/ui/unnecessary_clone.rs:39:5 + --> tests/ui/unnecessary_clone.rs:38:5 | LL | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try: `Weak::::clone(&arc_weak)` error: using `.clone()` on a ref-counted pointer - --> tests/ui/unnecessary_clone.rs:45:33 + --> tests/ui/unnecessary_clone.rs:44:33 | LL | let _: Arc = x.clone(); | ^^^^^^^^^ help: try: `Arc::::clone(&x)` error: using `clone` on type `T` which implements the `Copy` trait - --> tests/ui/unnecessary_clone.rs:51:5 + --> tests/ui/unnecessary_clone.rs:49:5 | LL | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` @@ -41,19 +41,19 @@ LL | t.clone(); = help: to override `-D warnings` add `#[allow(clippy::clone_on_copy)]` error: using `clone` on type `Option` which implements the `Copy` trait - --> tests/ui/unnecessary_clone.rs:56:5 + --> tests/ui/unnecessary_clone.rs:52:5 | LL | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` error: using `clone` on type `E` which implements the `Copy` trait - --> tests/ui/unnecessary_clone.rs:92:20 + --> tests/ui/unnecessary_clone.rs:87:20 | LL | let _: E = a.clone(); | ^^^^^^^^^ help: try dereferencing it: `*****a` error: using `.clone()` on a ref-counted pointer - --> tests/ui/unnecessary_clone.rs:113:14 + --> tests/ui/unnecessary_clone.rs:108:14 | LL | Some(try_opt!(Some(rc)).clone()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc::::clone(&try_opt!(Some(rc)))` diff --git a/tests/ui/unnecessary_fallible_conversions.fixed b/tests/ui/unnecessary_fallible_conversions.fixed index 59d24e9bb7e2f..bae8f066cf12e 100644 --- a/tests/ui/unnecessary_fallible_conversions.fixed +++ b/tests/ui/unnecessary_fallible_conversions.fixed @@ -6,48 +6,38 @@ fn main() { let _: i64 = 0i32.into(); //~^ unnecessary_fallible_conversions - let _: i64 = 0i32.into(); //~^ unnecessary_fallible_conversions - // --- TryFromFunction `T::try_from(U)` --- let _ = i64::from(0i32); //~^ unnecessary_fallible_conversions - let _ = i64::from(0i32); //~^ unnecessary_fallible_conversions - // --- TryIntoFunction `U::try_into(t)` --- let _: i64 = i32::into(0); //~^ unnecessary_fallible_conversions - let _: i64 = i32::into(0i32); //~^ unnecessary_fallible_conversions - // --- TryFromFunction `>::try_from(U)` --- let _ = >::from(0); //~^ unnecessary_fallible_conversions - let _ = >::from(0); //~^ unnecessary_fallible_conversions - // --- TryIntoFunction `>::try_into(U)` --- let _: i64 = >::into(0); //~^ unnecessary_fallible_conversions - let _: i64 = >::into(0); //~^ unnecessary_fallible_conversions - } diff --git a/tests/ui/unnecessary_fallible_conversions.rs b/tests/ui/unnecessary_fallible_conversions.rs index 7e504acb5e21c..04c9826f3765e 100644 --- a/tests/ui/unnecessary_fallible_conversions.rs +++ b/tests/ui/unnecessary_fallible_conversions.rs @@ -6,48 +6,38 @@ fn main() { let _: i64 = 0i32.try_into().unwrap(); //~^ unnecessary_fallible_conversions - let _: i64 = 0i32.try_into().expect("can't happen"); //~^ unnecessary_fallible_conversions - // --- TryFromFunction `T::try_from(U)` --- let _ = i64::try_from(0i32).unwrap(); //~^ unnecessary_fallible_conversions - let _ = i64::try_from(0i32).expect("can't happen"); //~^ unnecessary_fallible_conversions - // --- TryIntoFunction `U::try_into(t)` --- let _: i64 = i32::try_into(0).unwrap(); //~^ unnecessary_fallible_conversions - let _: i64 = i32::try_into(0i32).expect("can't happen"); //~^ unnecessary_fallible_conversions - // --- TryFromFunction `>::try_from(U)` --- let _ = >::try_from(0).unwrap(); //~^ unnecessary_fallible_conversions - let _ = >::try_from(0).expect("can't happen"); //~^ unnecessary_fallible_conversions - // --- TryIntoFunction `>::try_into(U)` --- let _: i64 = >::try_into(0).unwrap(); //~^ unnecessary_fallible_conversions - let _: i64 = >::try_into(0).expect("can't happen"); //~^ unnecessary_fallible_conversions - } diff --git a/tests/ui/unnecessary_fallible_conversions.stderr b/tests/ui/unnecessary_fallible_conversions.stderr index 160917694c44d..ade3aada92897 100644 --- a/tests/ui/unnecessary_fallible_conversions.stderr +++ b/tests/ui/unnecessary_fallible_conversions.stderr @@ -14,7 +14,7 @@ LL + let _: i64 = 0i32.into(); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:10:23 + --> tests/ui/unnecessary_fallible_conversions.rs:9:23 | LL | let _: i64 = 0i32.try_into().expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL + let _: i64 = 0i32.into(); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:16:13 + --> tests/ui/unnecessary_fallible_conversions.rs:14:13 | LL | let _ = i64::try_from(0i32).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL + let _ = i64::from(0i32); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:20:13 + --> tests/ui/unnecessary_fallible_conversions.rs:17:13 | LL | let _ = i64::try_from(0i32).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL + let _ = i64::from(0i32); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:26:18 + --> tests/ui/unnecessary_fallible_conversions.rs:22:18 | LL | let _: i64 = i32::try_into(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +66,7 @@ LL + let _: i64 = i32::into(0); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:30:18 + --> tests/ui/unnecessary_fallible_conversions.rs:25:18 | LL | let _: i64 = i32::try_into(0i32).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL + let _: i64 = i32::into(0i32); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:36:13 + --> tests/ui/unnecessary_fallible_conversions.rs:30:13 | LL | let _ = >::try_from(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,7 +92,7 @@ LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:40:13 + --> tests/ui/unnecessary_fallible_conversions.rs:33:13 | LL | let _ = >::try_from(0).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +105,7 @@ LL + let _ = >::from(0); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:46:18 + --> tests/ui/unnecessary_fallible_conversions.rs:38:18 | LL | let _: i64 = >::try_into(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -118,7 +118,7 @@ LL + let _: i64 = >::into(0); | error: use of a fallible conversion when an infallible one could be used - --> tests/ui/unnecessary_fallible_conversions.rs:50:18 + --> tests/ui/unnecessary_fallible_conversions.rs:41:18 | LL | let _: i64 = >::try_into(0).expect("can't happen"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_filter_map.rs b/tests/ui/unnecessary_filter_map.rs index e05161d207ecd..c4f1b6bc7e3d7 100644 --- a/tests/ui/unnecessary_filter_map.rs +++ b/tests/ui/unnecessary_filter_map.rs @@ -5,9 +5,8 @@ fn main() { let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); //~^ unnecessary_filter_map - let _ = (0..4).filter_map(|x| { - //~^ unnecessary_filter_map + //~^ unnecessary_filter_map if x > 1 { return Some(x); @@ -15,8 +14,7 @@ fn main() { None }); let _ = (0..4).filter_map(|x| match x { - //~^ unnecessary_filter_map - + //~^ unnecessary_filter_map 0 | 1 => None, _ => Some(x), }); @@ -24,7 +22,6 @@ fn main() { let _ = (0..4).filter_map(|x| Some(x + 1)); //~^ unnecessary_filter_map - let _ = (0..4).filter_map(i32::checked_abs); let _ = (0..4).filter_map(Some); diff --git a/tests/ui/unnecessary_filter_map.stderr b/tests/ui/unnecessary_filter_map.stderr index 94435ab3effda..6683444b72730 100644 --- a/tests/ui/unnecessary_filter_map.stderr +++ b/tests/ui/unnecessary_filter_map.stderr @@ -8,7 +8,7 @@ LL | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_filter_map)]` error: this `.filter_map` can be written more simply - --> tests/ui/unnecessary_filter_map.rs:9:13 + --> tests/ui/unnecessary_filter_map.rs:8:13 | LL | let _ = (0..4).filter_map(|x| { | _____________^ @@ -21,25 +21,24 @@ LL | | }); | |______^ help: try instead: `filter` error: this `.filter_map` can be written more simply - --> tests/ui/unnecessary_filter_map.rs:17:13 + --> tests/ui/unnecessary_filter_map.rs:16:13 | LL | let _ = (0..4).filter_map(|x| match x { | _____________^ LL | | -LL | | LL | | 0 | 1 => None, LL | | _ => Some(x), LL | | }); | |______^ help: try instead: `filter` error: this `.filter_map` can be written more simply - --> tests/ui/unnecessary_filter_map.rs:24:13 + --> tests/ui/unnecessary_filter_map.rs:22:13 | LL | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map` error: redundant closure - --> tests/ui/unnecessary_filter_map.rs:32:57 + --> tests/ui/unnecessary_filter_map.rs:29:57 | LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x)); | ^^^^^^^^^^^ help: replace the closure with the function itself: `Some` @@ -48,19 +47,19 @@ LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x)); = help: to override `-D warnings` add `#[allow(clippy::redundant_closure)]` error: filter_map is unnecessary - --> tests/ui/unnecessary_filter_map.rs:32:61 + --> tests/ui/unnecessary_filter_map.rs:29:61 | LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x)); | ^^^^ help: try removing the filter_map error: this `.filter_map` can be written more simply - --> tests/ui/unnecessary_filter_map.rs:32:13 + --> tests/ui/unnecessary_filter_map.rs:29:13 | LL | let _ = vec![Some(10), None].into_iter().filter_map(|x| Some(x)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map` error: this `.filter_map` can be written more simply - --> tests/ui/unnecessary_filter_map.rs:172:14 + --> tests/ui/unnecessary_filter_map.rs:169:14 | LL | let _x = std::iter::once(1).filter_map(|n| (n > 1).then_some(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `filter` diff --git a/tests/ui/unnecessary_find_map.rs b/tests/ui/unnecessary_find_map.rs index f883b4eb38c52..8c8a3799f0216 100644 --- a/tests/ui/unnecessary_find_map.rs +++ b/tests/ui/unnecessary_find_map.rs @@ -5,9 +5,8 @@ fn main() { let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); //~^ unnecessary_find_map - let _ = (0..4).find_map(|x| { - //~^ unnecessary_find_map + //~^ unnecessary_find_map if x > 1 { return Some(x); @@ -15,8 +14,7 @@ fn main() { None }); let _ = (0..4).find_map(|x| match x { - //~^ unnecessary_find_map - + //~^ unnecessary_find_map 0 | 1 => None, _ => Some(x), }); @@ -24,7 +22,6 @@ fn main() { let _ = (0..4).find_map(|x| Some(x + 1)); //~^ unnecessary_find_map - let _ = (0..4).find_map(i32::checked_abs); } diff --git a/tests/ui/unnecessary_find_map.stderr b/tests/ui/unnecessary_find_map.stderr index 079c1092784ef..94e320773a6fe 100644 --- a/tests/ui/unnecessary_find_map.stderr +++ b/tests/ui/unnecessary_find_map.stderr @@ -8,7 +8,7 @@ LL | let _ = (0..4).find_map(|x| if x > 1 { Some(x) } else { None }); = help: to override `-D warnings` add `#[allow(clippy::unnecessary_find_map)]` error: this `.find_map` can be written more simply - --> tests/ui/unnecessary_find_map.rs:9:13 + --> tests/ui/unnecessary_find_map.rs:8:13 | LL | let _ = (0..4).find_map(|x| { | _____________^ @@ -21,25 +21,24 @@ LL | | }); | |______^ help: try instead: `find` error: this `.find_map` can be written more simply - --> tests/ui/unnecessary_find_map.rs:17:13 + --> tests/ui/unnecessary_find_map.rs:16:13 | LL | let _ = (0..4).find_map(|x| match x { | _____________^ LL | | -LL | | LL | | 0 | 1 => None, LL | | _ => Some(x), LL | | }); | |______^ help: try instead: `find` error: this `.find_map` can be written more simply - --> tests/ui/unnecessary_find_map.rs:24:13 + --> tests/ui/unnecessary_find_map.rs:22:13 | LL | let _ = (0..4).find_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `map(..).next()` error: this `.find_map` can be written more simply - --> tests/ui/unnecessary_find_map.rs:37:14 + --> tests/ui/unnecessary_find_map.rs:34:14 | LL | let _x = std::iter::once(1).find_map(|n| (n > 1).then_some(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try instead: `find` diff --git a/tests/ui/unnecessary_fold.fixed b/tests/ui/unnecessary_fold.fixed index 2c3f87513c40d..1c331be75094d 100644 --- a/tests/ui/unnecessary_fold.fixed +++ b/tests/ui/unnecessary_fold.fixed @@ -57,7 +57,7 @@ fn unnecessary_fold_over_multiple_lines() { .map(|x| x + 1) .filter(|x| x % 2 == 0) .any(|x| x > 2); - //~^ unnecessary_fold + //~^ unnecessary_fold } fn issue10000() { diff --git a/tests/ui/unnecessary_fold.rs b/tests/ui/unnecessary_fold.rs index 9540200467637..e2050e37e3b1c 100644 --- a/tests/ui/unnecessary_fold.rs +++ b/tests/ui/unnecessary_fold.rs @@ -57,7 +57,7 @@ fn unnecessary_fold_over_multiple_lines() { .map(|x| x + 1) .filter(|x| x % 2 == 0) .fold(false, |acc, x| acc || x > 2); - //~^ unnecessary_fold + //~^ unnecessary_fold } fn issue10000() { diff --git a/tests/ui/unnecessary_get_then_check.fixed b/tests/ui/unnecessary_get_then_check.fixed index 6aba66b873183..c6da769544e0d 100644 --- a/tests/ui/unnecessary_get_then_check.fixed +++ b/tests/ui/unnecessary_get_then_check.fixed @@ -4,33 +4,33 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; fn main() { let s: HashSet = HashSet::new(); -let _ = s.contains("a"); -//~^ unnecessary_get_then_check -let _ = !s.contains("a"); -//~^ unnecessary_get_then_check + let _ = s.contains("a"); + //~^ unnecessary_get_then_check + let _ = !s.contains("a"); + //~^ unnecessary_get_then_check let s: HashMap = HashMap::new(); -let _ = s.contains_key("a"); -//~^ unnecessary_get_then_check -let _ = !s.contains_key("a"); -//~^ unnecessary_get_then_check + let _ = s.contains_key("a"); + //~^ unnecessary_get_then_check + let _ = !s.contains_key("a"); + //~^ unnecessary_get_then_check let s: BTreeSet = BTreeSet::new(); -let _ = s.contains("a"); -//~^ unnecessary_get_then_check -let _ = !s.contains("a"); -//~^ unnecessary_get_then_check + let _ = s.contains("a"); + //~^ unnecessary_get_then_check + let _ = !s.contains("a"); + //~^ unnecessary_get_then_check let s: BTreeMap = BTreeMap::new(); -let _ = s.contains_key("a"); -//~^ unnecessary_get_then_check -let _ = !s.contains_key("a"); -//~^ unnecessary_get_then_check + let _ = s.contains_key("a"); + //~^ unnecessary_get_then_check + let _ = !s.contains_key("a"); + //~^ unnecessary_get_then_check // Import to check that the generic annotations are kept! let s: HashSet = HashSet::new(); -let _ = s.contains::("a"); -//~^ unnecessary_get_then_check -let _ = !s.contains::("a"); -//~^ unnecessary_get_then_check + let _ = s.contains::("a"); + //~^ unnecessary_get_then_check + let _ = !s.contains::("a"); + //~^ unnecessary_get_then_check } diff --git a/tests/ui/unnecessary_get_then_check.rs b/tests/ui/unnecessary_get_then_check.rs index d56e7d209e4e8..323ccc2136ce9 100644 --- a/tests/ui/unnecessary_get_then_check.rs +++ b/tests/ui/unnecessary_get_then_check.rs @@ -4,33 +4,33 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; fn main() { let s: HashSet = HashSet::new(); -let _ = s.get("a").is_some(); -//~^ unnecessary_get_then_check -let _ = s.get("a").is_none(); -//~^ unnecessary_get_then_check + let _ = s.get("a").is_some(); + //~^ unnecessary_get_then_check + let _ = s.get("a").is_none(); + //~^ unnecessary_get_then_check let s: HashMap = HashMap::new(); -let _ = s.get("a").is_some(); -//~^ unnecessary_get_then_check -let _ = s.get("a").is_none(); -//~^ unnecessary_get_then_check + let _ = s.get("a").is_some(); + //~^ unnecessary_get_then_check + let _ = s.get("a").is_none(); + //~^ unnecessary_get_then_check let s: BTreeSet = BTreeSet::new(); -let _ = s.get("a").is_some(); -//~^ unnecessary_get_then_check -let _ = s.get("a").is_none(); -//~^ unnecessary_get_then_check + let _ = s.get("a").is_some(); + //~^ unnecessary_get_then_check + let _ = s.get("a").is_none(); + //~^ unnecessary_get_then_check let s: BTreeMap = BTreeMap::new(); -let _ = s.get("a").is_some(); -//~^ unnecessary_get_then_check -let _ = s.get("a").is_none(); -//~^ unnecessary_get_then_check + let _ = s.get("a").is_some(); + //~^ unnecessary_get_then_check + let _ = s.get("a").is_none(); + //~^ unnecessary_get_then_check // Import to check that the generic annotations are kept! let s: HashSet = HashSet::new(); -let _ = s.get::("a").is_some(); -//~^ unnecessary_get_then_check -let _ = s.get::("a").is_none(); -//~^ unnecessary_get_then_check + let _ = s.get::("a").is_some(); + //~^ unnecessary_get_then_check + let _ = s.get::("a").is_none(); + //~^ unnecessary_get_then_check } diff --git a/tests/ui/unnecessary_get_then_check.stderr b/tests/ui/unnecessary_get_then_check.stderr index a33409b30c806..5ecb3d4e29dd2 100644 --- a/tests/ui/unnecessary_get_then_check.stderr +++ b/tests/ui/unnecessary_get_then_check.stderr @@ -1,75 +1,75 @@ error: unnecessary use of `get("a").is_some()` - --> tests/ui/unnecessary_get_then_check.rs:7:11 + --> tests/ui/unnecessary_get_then_check.rs:7:15 | -LL | let _ = s.get("a").is_some(); - | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` | = note: `-D clippy::unnecessary-get-then-check` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_get_then_check)]` error: unnecessary use of `get("a").is_none()` - --> tests/ui/unnecessary_get_then_check.rs:9:11 + --> tests/ui/unnecessary_get_then_check.rs:9:15 | -LL | let _ = s.get("a").is_none(); - | --^^^^^^^^^^^^^^^^^^ - | | - | help: replace it with: `!s.contains("a")` +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains("a")` error: unnecessary use of `get("a").is_some()` - --> tests/ui/unnecessary_get_then_check.rs:13:11 + --> tests/ui/unnecessary_get_then_check.rs:13:15 | -LL | let _ = s.get("a").is_some(); - | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` error: unnecessary use of `get("a").is_none()` - --> tests/ui/unnecessary_get_then_check.rs:15:11 + --> tests/ui/unnecessary_get_then_check.rs:15:15 | -LL | let _ = s.get("a").is_none(); - | --^^^^^^^^^^^^^^^^^^ - | | - | help: replace it with: `!s.contains_key("a")` +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains_key("a")` error: unnecessary use of `get("a").is_some()` - --> tests/ui/unnecessary_get_then_check.rs:19:11 + --> tests/ui/unnecessary_get_then_check.rs:19:15 | -LL | let _ = s.get("a").is_some(); - | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains("a")` error: unnecessary use of `get("a").is_none()` - --> tests/ui/unnecessary_get_then_check.rs:21:11 + --> tests/ui/unnecessary_get_then_check.rs:21:15 | -LL | let _ = s.get("a").is_none(); - | --^^^^^^^^^^^^^^^^^^ - | | - | help: replace it with: `!s.contains("a")` +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains("a")` error: unnecessary use of `get("a").is_some()` - --> tests/ui/unnecessary_get_then_check.rs:25:11 + --> tests/ui/unnecessary_get_then_check.rs:25:15 | -LL | let _ = s.get("a").is_some(); - | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` +LL | let _ = s.get("a").is_some(); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `contains_key("a")` error: unnecessary use of `get("a").is_none()` - --> tests/ui/unnecessary_get_then_check.rs:27:11 + --> tests/ui/unnecessary_get_then_check.rs:27:15 | -LL | let _ = s.get("a").is_none(); - | --^^^^^^^^^^^^^^^^^^ - | | - | help: replace it with: `!s.contains_key("a")` +LL | let _ = s.get("a").is_none(); + | --^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains_key("a")` error: unnecessary use of `get::("a").is_some()` - --> tests/ui/unnecessary_get_then_check.rs:32:11 + --> tests/ui/unnecessary_get_then_check.rs:32:15 | -LL | let _ = s.get::("a").is_some(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains::("a")` +LL | let _ = s.get::("a").is_some(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains::("a")` error: unnecessary use of `get::("a").is_none()` - --> tests/ui/unnecessary_get_then_check.rs:34:11 + --> tests/ui/unnecessary_get_then_check.rs:34:15 | -LL | let _ = s.get::("a").is_none(); - | --^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | help: replace it with: `!s.contains::("a")` +LL | let _ = s.get::("a").is_none(); + | --^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: replace it with: `!s.contains::("a")` error: aborting due to 10 previous errors diff --git a/tests/ui/unnecessary_iter_cloned.fixed b/tests/ui/unnecessary_iter_cloned.fixed index 533059d91fcea..aed2dbe1f1ce4 100644 --- a/tests/ui/unnecessary_iter_cloned.fixed +++ b/tests/ui/unnecessary_iter_cloned.fixed @@ -29,7 +29,7 @@ fn main() { // https://github.com/breard-r/acmed/blob/1f0dcc32aadbc5e52de6d23b9703554c0f925113/acmed/src/storage.rs#L262 fn check_files(files: &[(FileType, &std::path::Path)]) -> bool { for (t, path) in files { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned let other = match get_file_path(t) { Ok(p) => p, Err(_) => { @@ -45,7 +45,7 @@ fn check_files(files: &[(FileType, &std::path::Path)]) -> bool { fn check_files_vec(files: Vec<(FileType, &std::path::Path)>) -> bool { for (t, path) in files.iter() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned let other = match get_file_path(t) { Ok(p) => p, Err(_) => { @@ -177,7 +177,7 @@ mod issue_12821 { fn foo() { let v: Vec<_> = "hello".chars().collect(); for c in v.iter() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned println!("{c}"); // should not suggest to remove `&` } @@ -186,9 +186,9 @@ mod issue_12821 { fn bar() { let v: Vec<_> = "hello".chars().collect(); for c in v.iter() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned -let ref_c = c; + let ref_c = c; println!("{ref_c}"); } } @@ -196,9 +196,9 @@ let ref_c = c; fn baz() { let v: Vec<_> = "hello".chars().enumerate().collect(); for (i, c) in v.iter() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned -let ref_c = c; + let ref_c = c; let ref_i = i; println!("{i} {ref_c}"); // should not suggest to remove `&` from `i` } diff --git a/tests/ui/unnecessary_iter_cloned.rs b/tests/ui/unnecessary_iter_cloned.rs index 5e0c2e6d78ec0..12fdd150e4233 100644 --- a/tests/ui/unnecessary_iter_cloned.rs +++ b/tests/ui/unnecessary_iter_cloned.rs @@ -29,7 +29,7 @@ fn main() { // https://github.com/breard-r/acmed/blob/1f0dcc32aadbc5e52de6d23b9703554c0f925113/acmed/src/storage.rs#L262 fn check_files(files: &[(FileType, &std::path::Path)]) -> bool { for (t, path) in files.iter().copied() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned let other = match get_file_path(&t) { Ok(p) => p, Err(_) => { @@ -45,7 +45,7 @@ fn check_files(files: &[(FileType, &std::path::Path)]) -> bool { fn check_files_vec(files: Vec<(FileType, &std::path::Path)>) -> bool { for (t, path) in files.iter().copied() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned let other = match get_file_path(&t) { Ok(p) => p, Err(_) => { @@ -177,7 +177,7 @@ mod issue_12821 { fn foo() { let v: Vec<_> = "hello".chars().collect(); for c in v.iter().cloned() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned println!("{c}"); // should not suggest to remove `&` } @@ -186,9 +186,9 @@ mod issue_12821 { fn bar() { let v: Vec<_> = "hello".chars().collect(); for c in v.iter().cloned() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned -let ref_c = &c; + let ref_c = &c; println!("{ref_c}"); } } @@ -196,9 +196,9 @@ let ref_c = &c; fn baz() { let v: Vec<_> = "hello".chars().enumerate().collect(); for (i, c) in v.iter().cloned() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned -let ref_c = &c; + let ref_c = &c; let ref_i = &i; println!("{i} {ref_c}"); // should not suggest to remove `&` from `i` } diff --git a/tests/ui/unnecessary_iter_cloned.stderr b/tests/ui/unnecessary_iter_cloned.stderr index 61ae9acc35cc3..632c8f3711068 100644 --- a/tests/ui/unnecessary_iter_cloned.stderr +++ b/tests/ui/unnecessary_iter_cloned.stderr @@ -43,7 +43,7 @@ help: remove any references to the binding LL ~ for c in v.iter() { LL | LL | -LL ~ let ref_c = c; +LL ~ let ref_c = c; | error: unnecessary use of `cloned` @@ -57,7 +57,7 @@ help: remove any references to the binding LL ~ for (i, c) in v.iter() { LL | LL | -LL ~ let ref_c = c; +LL ~ let ref_c = c; LL ~ let ref_i = i; | diff --git a/tests/ui/unnecessary_lazy_eval_unfixable.rs b/tests/ui/unnecessary_lazy_eval_unfixable.rs index 54a2d4cee36f1..6d28d544dfe0b 100644 --- a/tests/ui/unnecessary_lazy_eval_unfixable.rs +++ b/tests/ui/unnecessary_lazy_eval_unfixable.rs @@ -13,7 +13,6 @@ fn main() { let _ = Ok(1).unwrap_or_else(|()| 2); //~^ unnecessary_lazy_evaluations - mod e { pub struct E; } @@ -23,7 +22,6 @@ fn main() { let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); //~^ unnecessary_lazy_evaluations - // Fix #6343 let arr = [(Some(1),)]; Some(&0).and_then(|&i| arr[i].0); diff --git a/tests/ui/unnecessary_lazy_eval_unfixable.stderr b/tests/ui/unnecessary_lazy_eval_unfixable.stderr index 11eecdf6fa4a5..0a62b312f71cd 100644 --- a/tests/ui/unnecessary_lazy_eval_unfixable.stderr +++ b/tests/ui/unnecessary_lazy_eval_unfixable.stderr @@ -12,7 +12,7 @@ LL | let _ = Ok(1).unwrap_or(2); | ~~~~~~~~~~~~ error: unnecessary closure used to substitute value for `Result::Err` - --> tests/ui/unnecessary_lazy_eval_unfixable.rs:20:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:19:13 | LL | let _ = Ok(1).unwrap_or_else(|e::E| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | let _ = Ok(1).unwrap_or(2); | ~~~~~~~~~~~~ error: unnecessary closure used to substitute value for `Result::Err` - --> tests/ui/unnecessary_lazy_eval_unfixable.rs:23:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:22:13 | LL | let _ = Ok(1).unwrap_or_else(|SomeStruct { .. }| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ LL | let _ = Ok(1).unwrap_or(2); | ~~~~~~~~~~~~ error: unnecessary closure used with `bool::then` - --> tests/ui/unnecessary_lazy_eval_unfixable.rs:34:13 + --> tests/ui/unnecessary_lazy_eval_unfixable.rs:32:13 | LL | let _ = true.then(|| -> &[u8] { &[] }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_literal_bound.fixed b/tests/ui/unnecessary_literal_bound.fixed index 5ac38a5b76ae3..ec0d2db154cea 100644 --- a/tests/ui/unnecessary_literal_bound.fixed +++ b/tests/ui/unnecessary_literal_bound.fixed @@ -7,7 +7,7 @@ struct Struct<'a> { impl Struct<'_> { // Should warn fn returns_lit(&self) -> &'static str { - //~^ unnecessary_literal_bound + //~^ unnecessary_literal_bound "Hello" } @@ -28,7 +28,7 @@ impl Struct<'_> { // Should warn fn contionally_returns_literals_explicit(&self, cond: bool) -> &'static str { - //~^ unnecessary_literal_bound + //~^ unnecessary_literal_bound if cond { return "Literal"; } @@ -53,7 +53,7 @@ trait ReturnsStr { impl ReturnsStr for u8 { // Should warn, even though not useful without trait refinement fn trait_method(&self) -> &'static str { - //~^ unnecessary_literal_bound + //~^ unnecessary_literal_bound "Literal" } } diff --git a/tests/ui/unnecessary_literal_bound.rs b/tests/ui/unnecessary_literal_bound.rs index 487ca04c6ab3a..713dee4d30a60 100644 --- a/tests/ui/unnecessary_literal_bound.rs +++ b/tests/ui/unnecessary_literal_bound.rs @@ -7,7 +7,7 @@ struct Struct<'a> { impl Struct<'_> { // Should warn fn returns_lit(&self) -> &str { - //~^ unnecessary_literal_bound + //~^ unnecessary_literal_bound "Hello" } @@ -28,7 +28,7 @@ impl Struct<'_> { // Should warn fn contionally_returns_literals_explicit(&self, cond: bool) -> &str { - //~^ unnecessary_literal_bound + //~^ unnecessary_literal_bound if cond { return "Literal"; } @@ -53,7 +53,7 @@ trait ReturnsStr { impl ReturnsStr for u8 { // Should warn, even though not useful without trait refinement fn trait_method(&self) -> &str { - //~^ unnecessary_literal_bound + //~^ unnecessary_literal_bound "Literal" } } diff --git a/tests/ui/unnecessary_literal_unwrap_unfixable.rs b/tests/ui/unnecessary_literal_unwrap_unfixable.rs index 4bb93fc391e65..b6cba4e6a5685 100644 --- a/tests/ui/unnecessary_literal_unwrap_unfixable.rs +++ b/tests/ui/unnecessary_literal_unwrap_unfixable.rs @@ -9,7 +9,6 @@ fn unwrap_option_some() { let _val2 = val.expect("this never happens"); //~^ unnecessary_literal_unwrap - } fn unwrap_option_some_context() { @@ -19,14 +18,12 @@ fn unwrap_option_some_context() { let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); //~^ unnecessary_literal_unwrap - let val = Some::([1, 2, 3].iter().sum()); let _val2 = val.unwrap(); //~^ unnecessary_literal_unwrap let _val2 = val.expect("this never happens"); //~^ unnecessary_literal_unwrap - } fn unwrap_option_none() { @@ -42,7 +39,6 @@ fn unwrap_option_none() { None::<()>.unwrap_or_default(); //~^ unnecessary_literal_unwrap - } fn unwrap_result_ok() { @@ -58,7 +54,6 @@ fn unwrap_result_ok() { let _val2 = val.expect_err("this always happens"); //~^ unnecessary_literal_unwrap - } fn unwrap_result_ok_context() { @@ -74,7 +69,6 @@ fn unwrap_result_ok_context() { let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); //~^ unnecessary_literal_unwrap - let val = Ok::([1, 2, 3].iter().sum()); let _val2 = val.unwrap(); //~^ unnecessary_literal_unwrap @@ -87,7 +81,6 @@ fn unwrap_result_ok_context() { let _val2 = val.expect_err("this always happens"); //~^ unnecessary_literal_unwrap - } fn unwrap_result_err() { @@ -103,7 +96,6 @@ fn unwrap_result_err() { let _val2 = val.expect("this always happens"); //~^ unnecessary_literal_unwrap - } fn unwrap_result_err_context() { @@ -119,7 +111,6 @@ fn unwrap_result_err_context() { let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); //~^ unnecessary_literal_unwrap - let val = Err::<(), usize>([1, 2, 3].iter().sum()); let _val2 = val.unwrap_err(); //~^ unnecessary_literal_unwrap @@ -132,7 +123,6 @@ fn unwrap_result_err_context() { let _val2 = val.expect("this always happens"); //~^ unnecessary_literal_unwrap - } fn unwrap_methods_option() { @@ -145,7 +135,6 @@ fn unwrap_methods_option() { let _val2 = val.unwrap_or_else(|| 2); //~^ unnecessary_literal_unwrap - } fn unwrap_methods_option_context() { @@ -158,7 +147,6 @@ fn unwrap_methods_option_context() { let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); //~^ unnecessary_literal_unwrap - let val = Some::([1, 2, 3].iter().sum()); let _val2 = val.unwrap_or(2); //~^ unnecessary_literal_unwrap @@ -168,7 +156,6 @@ fn unwrap_methods_option_context() { let _val2 = val.unwrap_or_else(|| 2); //~^ unnecessary_literal_unwrap - } fn unwrap_methods_result() { @@ -181,7 +168,6 @@ fn unwrap_methods_result() { let _val2 = val.unwrap_or_else(|_| 2); //~^ unnecessary_literal_unwrap - } fn unwrap_methods_result_context() { @@ -194,7 +180,6 @@ fn unwrap_methods_result_context() { let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); //~^ unnecessary_literal_unwrap - let val = Ok::([1, 2, 3].iter().sum()); let _val2 = val.unwrap_or(2); //~^ unnecessary_literal_unwrap @@ -204,7 +189,6 @@ fn unwrap_methods_result_context() { let _val2 = val.unwrap_or_else(|_| 2); //~^ unnecessary_literal_unwrap - } fn main() { diff --git a/tests/ui/unnecessary_literal_unwrap_unfixable.stderr b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr index b579bb74ef746..4994eeded776e 100644 --- a/tests/ui/unnecessary_literal_unwrap_unfixable.stderr +++ b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr @@ -25,589 +25,589 @@ LL | let val = Some(1); | ^^^^^^^ error: used `unwrap()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:16:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:15:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:16:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:15:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:19:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:18:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:19:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:18:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:24:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:22:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:23:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:21:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:27:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:25:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:23:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:21:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `None` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:34:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:31:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `None` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:33:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:30:15 | LL | let val = None::<()>; | ^^^^^^^^^^ error: used `expect()` on `None` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:37:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:34:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `None` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:33:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:30:15 | LL | let val = None::<()>; | ^^^^^^^^^^ error: used `unwrap_or_default()` on `None` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:40:21 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:37:21 | LL | let _val3: u8 = None.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `Default::default()` error: used `unwrap_or_default()` on `None` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:43:5 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:40:5 | LL | None::<()>.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap_or_default()`: `Default::default()` error: used `unwrap()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:50:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:46:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:49:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:45:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:53:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:49:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:49:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:45:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:56:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:52:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:49:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:45:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:59:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:55:17 | LL | let _val2 = val.expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:49:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:45:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:65:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:65:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:60:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:68:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:63:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:68:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:63:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:71:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:66:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:71:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:66:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:74:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:69:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:74:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:69:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:79:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:73:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:78:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:82:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:76:17 | LL | let _val2 = val.expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:78:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:85:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:79:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:78:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:88:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:82:17 | LL | let _val2 = val.expect_err("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `expect_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:78:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:72:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:95:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:88:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:94:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:87:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:98:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:91:17 | LL | let _val2 = val.expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:94:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:87:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:101:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:94:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:94:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:87:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:104:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:97:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:94:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:87:15 | LL | let val = Err::<(), _>(1); | ^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:110:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:102:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:110:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:102:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:113:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:113:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:105:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:116:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:108:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:116:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:108:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:119:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:111:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:119:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:111:16 | LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_err()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:124:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:115:17 | LL | let _val2 = val.unwrap_err(); | ^^^^^^^^^^^^^^^^ | help: remove the `Err` and `unwrap_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:123:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:114:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect_err()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:127:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:118:17 | LL | let _val2 = val.expect_err("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect_err()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:123:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:114:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:130:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:121:17 | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Err` and `unwrap()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:123:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:114:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `expect()` on `Err` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:133:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:124:17 | LL | let _val2 = val.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Err` and `expect()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:123:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:114:15 | LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:140:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:130:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:139:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:129:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:143:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:133:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:139:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:129:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:146:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:136:17 | LL | let _val2 = val.unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:139:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:129:15 | LL | let val = Some(1); | ^^^^^^^ error: used `unwrap_or()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:152:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:141:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:152:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:141:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:155:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:144:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:155:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:144:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:158:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:147:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:158:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:147:16 | LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:163:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:151:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:162:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:150:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:166:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:154:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_default()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:162:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:150:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Some` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:169:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:157:17 | LL | let _val2 = val.unwrap_or_else(|| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Some` and `unwrap_or_else()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:162:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:150:15 | LL | let val = Some::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:176:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:163:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:175:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:162:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:179:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:166:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:175:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:162:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:182:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:169:17 | LL | let _val2 = val.unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:175:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:162:15 | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:188:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:174:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:188:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:174:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:191:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:177:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:191:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:177:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:194:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:180:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:194:16 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:180:16 | LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:199:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:184:17 | LL | let _val2 = val.unwrap_or(2); | ^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:198:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:183:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_default()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:202:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:187:17 | LL | let _val2 = val.unwrap_or_default(); | ^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_default()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:198:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:183:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: used `unwrap_or_else()` on `Ok` value - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:205:17 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:190:17 | LL | let _val2 = val.unwrap_or_else(|_| 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove the `Ok` and `unwrap_or_else()` - --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:198:15 + --> tests/ui/unnecessary_literal_unwrap_unfixable.rs:183:15 | LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_map_or.fixed b/tests/ui/unnecessary_map_or.fixed index f51da49edabb3..01646faea4b62 100644 --- a/tests/ui/unnecessary_map_or.fixed +++ b/tests/ui/unnecessary_map_or.fixed @@ -16,7 +16,7 @@ fn main() { //~^ unnecessary_map_or let _ = Some(5) == Some(5); let _ = Some(5).is_some_and(|n| { - //~^ unnecessary_map_or + //~^ unnecessary_map_or let _ = n; 6 >= 5 }); diff --git a/tests/ui/unnecessary_map_or.rs b/tests/ui/unnecessary_map_or.rs index a1ae97af2b9f3..10669f2a7f1ad 100644 --- a/tests/ui/unnecessary_map_or.rs +++ b/tests/ui/unnecessary_map_or.rs @@ -15,12 +15,12 @@ fn main() { let _ = Some(5).map_or(true, |n| n != 5); //~^ unnecessary_map_or let _ = Some(5).map_or(false, |n| { - //~^ unnecessary_map_or + //~^ unnecessary_map_or let _ = 1; n == 5 }); let _ = Some(5).map_or(false, |n| { - //~^ unnecessary_map_or + //~^ unnecessary_map_or let _ = n; 6 >= 5 }); diff --git a/tests/ui/unnecessary_operation.fixed b/tests/ui/unnecessary_operation.fixed index ec3e64e15b857..05dfb72f48d2d 100644 --- a/tests/ui/unnecessary_operation.fixed +++ b/tests/ui/unnecessary_operation.fixed @@ -142,5 +142,4 @@ const _: () = { const fn foo() { assert!([42, 55].len() > get_usize()); //~^ unnecessary_operation - } diff --git a/tests/ui/unnecessary_operation.rs b/tests/ui/unnecessary_operation.rs index 3f903cd04ef80..6ef74c3eb1c1e 100644 --- a/tests/ui/unnecessary_operation.rs +++ b/tests/ui/unnecessary_operation.rs @@ -102,11 +102,11 @@ fn main() { [42; 55][get_usize()]; //~^ unnecessary_operation { - //~^ unnecessary_operation + //~^ unnecessary_operation get_number() }; FooString { - //~^ unnecessary_operation + //~^ unnecessary_operation s: String::from("blah"), }; @@ -148,5 +148,4 @@ const _: () = { const fn foo() { [42, 55][get_usize()]; //~^ unnecessary_operation - } diff --git a/tests/ui/unnecessary_result_map_or_else.fixed b/tests/ui/unnecessary_result_map_or_else.fixed index 784a42a04ba86..5d7e3fa355fd0 100644 --- a/tests/ui/unnecessary_result_map_or_else.fixed +++ b/tests/ui/unnecessary_result_map_or_else.fixed @@ -3,19 +3,19 @@ fn main() { let x: Result<(), ()> = Ok(()); -x.unwrap_or_else(|err| err); -//~^ unnecessary_result_map_or_else + x.unwrap_or_else(|err| err); + //~^ unnecessary_result_map_or_else // Type ascribtion. let x: Result<(), ()> = Ok(()); -x.unwrap_or_else(|err: ()| err); -//~^ unnecessary_result_map_or_else + x.unwrap_or_else(|err: ()| err); + //~^ unnecessary_result_map_or_else // Auto-deref. let y = String::new(); let x: Result<&String, &String> = Ok(&y); -let y: &str = x.unwrap_or_else(|err| err); -//~^ unnecessary_result_map_or_else + let y: &str = x.unwrap_or_else(|err| err); + //~^ unnecessary_result_map_or_else // Temporary variable. let x: Result<(), ()> = Ok(()); diff --git a/tests/ui/unnecessary_result_map_or_else.rs b/tests/ui/unnecessary_result_map_or_else.rs index 39b15f6d26d07..d2bab0f9d9c1b 100644 --- a/tests/ui/unnecessary_result_map_or_else.rs +++ b/tests/ui/unnecessary_result_map_or_else.rs @@ -3,25 +3,24 @@ fn main() { let x: Result<(), ()> = Ok(()); -x.map_or_else(|err| err, |n| n); -//~^ unnecessary_result_map_or_else + x.map_or_else(|err| err, |n| n); + //~^ unnecessary_result_map_or_else // Type ascribtion. let x: Result<(), ()> = Ok(()); -x.map_or_else(|err: ()| err, |n: ()| n); -//~^ unnecessary_result_map_or_else + x.map_or_else(|err: ()| err, |n: ()| n); + //~^ unnecessary_result_map_or_else // Auto-deref. let y = String::new(); let x: Result<&String, &String> = Ok(&y); -let y: &str = x.map_or_else(|err| err, |n| n); -//~^ unnecessary_result_map_or_else + let y: &str = x.map_or_else(|err| err, |n| n); + //~^ unnecessary_result_map_or_else // Temporary variable. let x: Result<(), ()> = Ok(()); x.map_or_else( - //~^ unnecessary_result_map_or_else - + //~^ unnecessary_result_map_or_else |err| err, |n| { let tmp = n; diff --git a/tests/ui/unnecessary_result_map_or_else.stderr b/tests/ui/unnecessary_result_map_or_else.stderr index 6334fe5eca687..e6afa50217cc9 100644 --- a/tests/ui/unnecessary_result_map_or_else.stderr +++ b/tests/ui/unnecessary_result_map_or_else.stderr @@ -1,31 +1,31 @@ error: unused "map closure" when calling `Result::map_or_else` value - --> tests/ui/unnecessary_result_map_or_else.rs:6:1 + --> tests/ui/unnecessary_result_map_or_else.rs:6:5 | -LL | x.map_or_else(|err| err, |n| n); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` +LL | x.map_or_else(|err| err, |n| n); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` | = note: `-D clippy::unnecessary-result-map-or-else` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::unnecessary_result_map_or_else)]` error: unused "map closure" when calling `Result::map_or_else` value - --> tests/ui/unnecessary_result_map_or_else.rs:11:1 + --> tests/ui/unnecessary_result_map_or_else.rs:11:5 | -LL | x.map_or_else(|err: ()| err, |n: ()| n); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err: ()| err)` +LL | x.map_or_else(|err: ()| err, |n: ()| n); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err: ()| err)` error: unused "map closure" when calling `Result::map_or_else` value - --> tests/ui/unnecessary_result_map_or_else.rs:17:15 + --> tests/ui/unnecessary_result_map_or_else.rs:17:19 | -LL | let y: &str = x.map_or_else(|err| err, |n| n); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` +LL | let y: &str = x.map_or_else(|err| err, |n| n); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `unwrap_or_else`: `x.unwrap_or_else(|err| err)` error: unused "map closure" when calling `Result::map_or_else` value --> tests/ui/unnecessary_result_map_or_else.rs:22:5 | LL | / x.map_or_else( LL | | -LL | | LL | | |err| err, +LL | | |n| { ... | LL | | }, LL | | ); diff --git a/tests/ui/unnecessary_safety_comment.rs b/tests/ui/unnecessary_safety_comment.rs index 3bdeda2724c62..4440089b3633b 100644 --- a/tests/ui/unnecessary_safety_comment.rs +++ b/tests/ui/unnecessary_safety_comment.rs @@ -21,7 +21,6 @@ mod unsafe_items_invalid_comment { // SAFETY: mod module {} //~^ unnecessary_safety_comment - } mod unnecessary_from_macro { @@ -53,16 +52,13 @@ fn unnecessary_on_stmt_and_expr() -> u32 { let num = 42; //~^ unnecessary_safety_comment - // SAFETY: unnecessary if num > 24 {} //~^ unnecessary_safety_comment - // SAFETY: unnecessary 24 //~^ unnecessary_safety_comment - } mod issue_10084 { diff --git a/tests/ui/unnecessary_safety_comment.stderr b/tests/ui/unnecessary_safety_comment.stderr index 3f9e35b095b95..b56e8b354931c 100644 --- a/tests/ui/unnecessary_safety_comment.stderr +++ b/tests/ui/unnecessary_safety_comment.stderr @@ -61,7 +61,7 @@ LL | // SAFETY: | ^^^^^^^^^^ error: impl has unnecessary safety comment - --> tests/ui/unnecessary_safety_comment.rs:43:13 + --> tests/ui/unnecessary_safety_comment.rs:42:13 | LL | impl T for $t {} | ^^^^^^^^^^^^^^^^ @@ -70,44 +70,44 @@ LL | with_safety_comment!(i32); | ------------------------- in this macro invocation | help: consider removing the safety comment - --> tests/ui/unnecessary_safety_comment.rs:42:13 + --> tests/ui/unnecessary_safety_comment.rs:41:13 | LL | // Safety: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `with_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: expression has unnecessary safety comment - --> tests/ui/unnecessary_safety_comment.rs:63:5 + --> tests/ui/unnecessary_safety_comment.rs:60:5 | LL | 24 | ^^ | help: consider removing the safety comment - --> tests/ui/unnecessary_safety_comment.rs:62:5 + --> tests/ui/unnecessary_safety_comment.rs:59:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ error: statement has unnecessary safety comment - --> tests/ui/unnecessary_safety_comment.rs:53:5 + --> tests/ui/unnecessary_safety_comment.rs:52:5 | LL | let num = 42; | ^^^^^^^^^^^^^ | help: consider removing the safety comment - --> tests/ui/unnecessary_safety_comment.rs:52:5 + --> tests/ui/unnecessary_safety_comment.rs:51:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ error: statement has unnecessary safety comment - --> tests/ui/unnecessary_safety_comment.rs:58:5 + --> tests/ui/unnecessary_safety_comment.rs:56:5 | LL | if num > 24 {} | ^^^^^^^^^^^^^^ | help: consider removing the safety comment - --> tests/ui/unnecessary_safety_comment.rs:57:5 + --> tests/ui/unnecessary_safety_comment.rs:55:5 | LL | // SAFETY: unnecessary | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unnecessary_semicolon.edition2021.fixed b/tests/ui/unnecessary_semicolon.edition2021.fixed index 1dcc6484a1950..f10d804c8ccc4 100644 --- a/tests/ui/unnecessary_semicolon.edition2021.fixed +++ b/tests/ui/unnecessary_semicolon.edition2021.fixed @@ -29,13 +29,11 @@ fn main() { } //~^ unnecessary_semicolon - a.match { 3 => println!("three"), _ => println!("not three"), } //~^ unnecessary_semicolon - } // This is a problem in edition 2021 and below diff --git a/tests/ui/unnecessary_semicolon.edition2021.stderr b/tests/ui/unnecessary_semicolon.edition2021.stderr index 3299442a5c1db..a3b139f73805d 100644 --- a/tests/ui/unnecessary_semicolon.edition2021.stderr +++ b/tests/ui/unnecessary_semicolon.edition2021.stderr @@ -8,13 +8,13 @@ LL | }; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_semicolon)]` error: unnecessary semicolon - --> tests/ui/unnecessary_semicolon.rs:36:6 + --> tests/ui/unnecessary_semicolon.rs:35:6 | LL | }; | ^ help: remove error: unnecessary semicolon - --> tests/ui/unnecessary_semicolon.rs:59:6 + --> tests/ui/unnecessary_semicolon.rs:57:6 | LL | }; | ^ help: remove diff --git a/tests/ui/unnecessary_semicolon.edition2024.fixed b/tests/ui/unnecessary_semicolon.edition2024.fixed index 91eef8022ed24..32a3bb9b40819 100644 --- a/tests/ui/unnecessary_semicolon.edition2024.fixed +++ b/tests/ui/unnecessary_semicolon.edition2024.fixed @@ -29,13 +29,11 @@ fn main() { } //~^ unnecessary_semicolon - a.match { 3 => println!("three"), _ => println!("not three"), } //~^ unnecessary_semicolon - } // This is a problem in edition 2021 and below diff --git a/tests/ui/unnecessary_semicolon.edition2024.stderr b/tests/ui/unnecessary_semicolon.edition2024.stderr index 98adc2f0a0a2e..d5ccae7fdf580 100644 --- a/tests/ui/unnecessary_semicolon.edition2024.stderr +++ b/tests/ui/unnecessary_semicolon.edition2024.stderr @@ -8,19 +8,19 @@ LL | }; = help: to override `-D warnings` add `#[allow(clippy::unnecessary_semicolon)]` error: unnecessary semicolon - --> tests/ui/unnecessary_semicolon.rs:36:6 + --> tests/ui/unnecessary_semicolon.rs:35:6 | LL | }; | ^ help: remove error: unnecessary semicolon - --> tests/ui/unnecessary_semicolon.rs:49:6 + --> tests/ui/unnecessary_semicolon.rs:47:6 | LL | }; | ^ help: remove error: unnecessary semicolon - --> tests/ui/unnecessary_semicolon.rs:59:6 + --> tests/ui/unnecessary_semicolon.rs:57:6 | LL | }; | ^ help: remove diff --git a/tests/ui/unnecessary_semicolon.rs b/tests/ui/unnecessary_semicolon.rs index 6c48bfae14ce3..91b2821802249 100644 --- a/tests/ui/unnecessary_semicolon.rs +++ b/tests/ui/unnecessary_semicolon.rs @@ -29,13 +29,11 @@ fn main() { }; //~^ unnecessary_semicolon - a.match { 3 => println!("three"), _ => println!("not three"), }; //~^ unnecessary_semicolon - } // This is a problem in edition 2021 and below diff --git a/tests/ui/unnecessary_struct_initialization.rs b/tests/ui/unnecessary_struct_initialization.rs index 2b26bc413b8ff..12a444fc878b9 100644 --- a/tests/ui/unnecessary_struct_initialization.rs +++ b/tests/ui/unnecessary_struct_initialization.rs @@ -60,7 +60,7 @@ fn main() { // Should lint: the result of an expression is mutable let h = &mut S { - //~^ unnecessary_struct_initialization + //~^ unnecessary_struct_initialization ..*Box::new(S { f: String::from("foo") }) }; @@ -80,7 +80,7 @@ fn main() { // Should lint: the result of an expression is mutable and temporary let p = &mut T { - //~^ unnecessary_struct_initialization + //~^ unnecessary_struct_initialization ..*Box::new(T { f: 5 }) }; diff --git a/tests/ui/unnecessary_to_owned.fixed b/tests/ui/unnecessary_to_owned.fixed index a03bfb2eafe31..136dafda27ea9 100644 --- a/tests/ui/unnecessary_to_owned.fixed +++ b/tests/ui/unnecessary_to_owned.fixed @@ -296,7 +296,7 @@ fn require_as_ref_slice_str, V: AsRef>(_: U, _: V) {} // https://github.com/breard-r/acmed/blob/1f0dcc32aadbc5e52de6d23b9703554c0f925113/acmed/src/storage.rs#L262 fn check_files(file_types: &[FileType]) -> bool { for t in file_types { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned let path = match get_file_path(t) { Ok(p) => p, Err(_) => { @@ -639,23 +639,23 @@ fn borrow_checks() { fn inner(a: &[&str]) { let mut s = HashSet::from([vec!["a"]]); -s.remove(a); -//~^ unnecessary_to_owned + s.remove(a); + //~^ unnecessary_to_owned } let mut s = HashSet::from(["a".to_string()]); -s.remove("b"); -//~^ unnecessary_to_owned -s.remove("b"); -//~^ unnecessary_to_owned + s.remove("b"); + //~^ unnecessary_to_owned + s.remove("b"); + //~^ unnecessary_to_owned // Should not warn. s.remove("b"); let mut s = HashSet::from([vec!["a"]]); -s.remove(["b"].as_slice()); -//~^ unnecessary_to_owned -s.remove((&["b"]).as_slice()); -//~^ unnecessary_to_owned + s.remove(["b"].as_slice()); + //~^ unnecessary_to_owned + s.remove((&["b"]).as_slice()); + //~^ unnecessary_to_owned // Should not warn. s.remove(&["b"].to_vec().clone()); diff --git a/tests/ui/unnecessary_to_owned.rs b/tests/ui/unnecessary_to_owned.rs index a03b13d475651..0948ac5de3ef9 100644 --- a/tests/ui/unnecessary_to_owned.rs +++ b/tests/ui/unnecessary_to_owned.rs @@ -296,7 +296,7 @@ fn require_as_ref_slice_str, V: AsRef>(_: U, _: V) {} // https://github.com/breard-r/acmed/blob/1f0dcc32aadbc5e52de6d23b9703554c0f925113/acmed/src/storage.rs#L262 fn check_files(file_types: &[FileType]) -> bool { for t in file_types.to_vec() { - //~^ unnecessary_to_owned + //~^ unnecessary_to_owned let path = match get_file_path(&t) { Ok(p) => p, Err(_) => { @@ -639,23 +639,23 @@ fn borrow_checks() { fn inner(a: &[&str]) { let mut s = HashSet::from([vec!["a"]]); -s.remove(&a.to_vec()); -//~^ unnecessary_to_owned + s.remove(&a.to_vec()); + //~^ unnecessary_to_owned } let mut s = HashSet::from(["a".to_string()]); -s.remove(&"b".to_owned()); -//~^ unnecessary_to_owned -s.remove(&"b".to_string()); -//~^ unnecessary_to_owned + s.remove(&"b".to_owned()); + //~^ unnecessary_to_owned + s.remove(&"b".to_string()); + //~^ unnecessary_to_owned // Should not warn. s.remove("b"); let mut s = HashSet::from([vec!["a"]]); -s.remove(&["b"].to_vec()); -//~^ unnecessary_to_owned -s.remove(&(&["b"]).to_vec()); -//~^ unnecessary_to_owned + s.remove(&["b"].to_vec()); + //~^ unnecessary_to_owned + s.remove(&(&["b"]).to_vec()); + //~^ unnecessary_to_owned // Should not warn. s.remove(&["b"].to_vec().clone()); diff --git a/tests/ui/unnecessary_to_owned.stderr b/tests/ui/unnecessary_to_owned.stderr index 23963fd6779aa..f8ad85dbed022 100644 --- a/tests/ui/unnecessary_to_owned.stderr +++ b/tests/ui/unnecessary_to_owned.stderr @@ -557,34 +557,34 @@ LL | IntoFuture::into_future(foo([].to_vec(), &0)); | ^^^^^^^^^^^ help: use: `[]` error: unnecessary use of `to_vec` - --> tests/ui/unnecessary_to_owned.rs:642:10 + --> tests/ui/unnecessary_to_owned.rs:642:18 | -LL | s.remove(&a.to_vec()); - | ^^^^^^^^^^^ help: replace it with: `a` +LL | s.remove(&a.to_vec()); + | ^^^^^^^^^^^ help: replace it with: `a` error: unnecessary use of `to_owned` - --> tests/ui/unnecessary_to_owned.rs:647:10 + --> tests/ui/unnecessary_to_owned.rs:647:14 | -LL | s.remove(&"b".to_owned()); - | ^^^^^^^^^^^^^^^ help: replace it with: `"b"` +LL | s.remove(&"b".to_owned()); + | ^^^^^^^^^^^^^^^ help: replace it with: `"b"` error: unnecessary use of `to_string` - --> tests/ui/unnecessary_to_owned.rs:649:10 + --> tests/ui/unnecessary_to_owned.rs:649:14 | -LL | s.remove(&"b".to_string()); - | ^^^^^^^^^^^^^^^^ help: replace it with: `"b"` +LL | s.remove(&"b".to_string()); + | ^^^^^^^^^^^^^^^^ help: replace it with: `"b"` error: unnecessary use of `to_vec` - --> tests/ui/unnecessary_to_owned.rs:655:10 + --> tests/ui/unnecessary_to_owned.rs:655:14 | -LL | s.remove(&["b"].to_vec()); - | ^^^^^^^^^^^^^^^ help: replace it with: `["b"].as_slice()` +LL | s.remove(&["b"].to_vec()); + | ^^^^^^^^^^^^^^^ help: replace it with: `["b"].as_slice()` error: unnecessary use of `to_vec` - --> tests/ui/unnecessary_to_owned.rs:657:10 + --> tests/ui/unnecessary_to_owned.rs:657:14 | -LL | s.remove(&(&["b"]).to_vec()); - | ^^^^^^^^^^^^^^^^^^ help: replace it with: `(&["b"]).as_slice()` +LL | s.remove(&(&["b"]).to_vec()); + | ^^^^^^^^^^^^^^^^^^ help: replace it with: `(&["b"]).as_slice()` error: aborting due to 88 previous errors diff --git a/tests/ui/unnecessary_to_owned_on_split.fixed b/tests/ui/unnecessary_to_owned_on_split.fixed index be453758ff3ac..f43d92a2d9bab 100644 --- a/tests/ui/unnecessary_to_owned_on_split.fixed +++ b/tests/ui/unnecessary_to_owned_on_split.fixed @@ -31,7 +31,6 @@ fn main() { let _ = Issue12068.as_ref().split('a').next().unwrap(); //~^ unnecessary_to_owned - let _ = [1].split(|x| *x == 2).next().unwrap(); //~^ unnecessary_to_owned @@ -43,5 +42,4 @@ fn main() { let _ = [1].split(|x| *x == 2).next().unwrap(); //~^ unnecessary_to_owned - } diff --git a/tests/ui/unnecessary_to_owned_on_split.rs b/tests/ui/unnecessary_to_owned_on_split.rs index b6317db80d7cf..bdf5f98bf61e3 100644 --- a/tests/ui/unnecessary_to_owned_on_split.rs +++ b/tests/ui/unnecessary_to_owned_on_split.rs @@ -31,7 +31,6 @@ fn main() { let _ = Issue12068.to_string().split('a').next().unwrap(); //~^ unnecessary_to_owned - let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); //~^ unnecessary_to_owned @@ -43,5 +42,4 @@ fn main() { let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); //~^ unnecessary_to_owned - } diff --git a/tests/ui/unnecessary_to_owned_on_split.stderr b/tests/ui/unnecessary_to_owned_on_split.stderr index 32cf52381d830..5e4fbb1035d69 100644 --- a/tests/ui/unnecessary_to_owned_on_split.stderr +++ b/tests/ui/unnecessary_to_owned_on_split.stderr @@ -32,25 +32,25 @@ LL | let _ = Issue12068.to_string().split('a').next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Issue12068.as_ref().split('a')` error: unnecessary use of `to_vec` - --> tests/ui/unnecessary_to_owned_on_split.rs:35:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:34:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_vec` - --> tests/ui/unnecessary_to_owned_on_split.rs:38:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:37:13 | LL | let _ = [1].to_vec().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> tests/ui/unnecessary_to_owned_on_split.rs:41:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:40:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` error: unnecessary use of `to_owned` - --> tests/ui/unnecessary_to_owned_on_split.rs:44:13 + --> tests/ui/unnecessary_to_owned_on_split.rs:43:13 | LL | let _ = [1].to_owned().split(|x| *x == 2).next().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `[1].split(|x| *x == 2)` diff --git a/tests/ui/unnecessary_unsafety_doc.rs b/tests/ui/unnecessary_unsafety_doc.rs index 2fe6c2b23a665..7a847d2e3b501 100644 --- a/tests/ui/unnecessary_unsafety_doc.rs +++ b/tests/ui/unnecessary_unsafety_doc.rs @@ -17,7 +17,7 @@ pub fn destroy_the_planet() { /// /// This function shouldn't be called unless the horsemen are ready pub fn apocalypse(universe: &mut ()) { -//~^ unnecessary_safety_doc + //~^ unnecessary_safety_doc unimplemented!(); } @@ -44,7 +44,7 @@ mod private_mod { /// /// Unnecessary safety! pub fn republished() { - //~^ unnecessary_safety_doc + //~^ unnecessary_safety_doc unimplemented!(); } } @@ -69,7 +69,7 @@ pub trait SafeTrait { /// /// Unnecessary! pub trait DocumentedSafeTrait { -//~^ unnecessary_safety_doc + //~^ unnecessary_safety_doc fn method2(); } @@ -98,7 +98,7 @@ impl Struct { /// /// Unnecessary! pub fn documented() -> Self { - //~^ unnecessary_safety_doc + //~^ unnecessary_safety_doc unimplemented!(); } @@ -126,7 +126,7 @@ macro_rules! very_safe { /// /// Driving is very safe already! pub fn drive() { - //~^ unnecessary_safety_doc + //~^ unnecessary_safety_doc whee() } }; @@ -155,6 +155,6 @@ pub mod __macro { /// # Implementation safety pub trait DocumentedSafeTraitWithImplementationHeader { -//~^ unnecessary_safety_doc + //~^ unnecessary_safety_doc fn method(); } diff --git a/tests/ui/unnecessary_wraps.rs b/tests/ui/unnecessary_wraps.rs index dee51ef67c3d8..4770ef3b48300 100644 --- a/tests/ui/unnecessary_wraps.rs +++ b/tests/ui/unnecessary_wraps.rs @@ -7,8 +7,7 @@ // should be linted fn func1(a: bool, b: bool) -> Option { -//~^ unnecessary_wraps - + //~^ unnecessary_wraps if a && b { return Some(42); @@ -23,7 +22,7 @@ fn func1(a: bool, b: bool) -> Option { // should be linted fn func2(a: bool, b: bool) -> Option { -//~^ unnecessary_wraps + //~^ unnecessary_wraps if a && b { return Some(10); @@ -43,7 +42,7 @@ fn func4(a: bool) -> Option { // should be linted fn func5() -> Option { -//~^ unnecessary_wraps + //~^ unnecessary_wraps Some(1) } @@ -55,7 +54,7 @@ fn func6() -> Option { // should be linted fn func7() -> Result { -//~^ unnecessary_wraps + //~^ unnecessary_wraps Ok(1) } @@ -85,7 +84,7 @@ impl A { // should be linted fn func12() -> Option { - //~^ unnecessary_wraps + //~^ unnecessary_wraps Some(1) } @@ -114,7 +113,7 @@ fn issue_6384(s: &str) -> Option<&str> { // should be linted fn issue_6640_1(a: bool, b: bool) -> Option<()> { -//~^ unnecessary_wraps + //~^ unnecessary_wraps if a && b { return Some(()); @@ -129,7 +128,7 @@ fn issue_6640_1(a: bool, b: bool) -> Option<()> { // should be linted fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { -//~^ unnecessary_wraps + //~^ unnecessary_wraps if a && b { return Ok(()); diff --git a/tests/ui/unnecessary_wraps.stderr b/tests/ui/unnecessary_wraps.stderr index c193c4cf91ad6..53fd8bd44146d 100644 --- a/tests/ui/unnecessary_wraps.stderr +++ b/tests/ui/unnecessary_wraps.stderr @@ -2,6 +2,9 @@ error: this function's return value is unnecessarily wrapped by `Option` --> tests/ui/unnecessary_wraps.rs:9:1 | LL | / fn func1(a: bool, b: bool) -> Option { +LL | | +LL | | +LL | | if a && b { ... | LL | | } | |_^ @@ -24,7 +27,7 @@ LL ~ return 1337; | error: this function's return value is unnecessarily wrapped by `Option` - --> tests/ui/unnecessary_wraps.rs:25:1 + --> tests/ui/unnecessary_wraps.rs:24:1 | LL | / fn func2(a: bool, b: bool) -> Option { LL | | @@ -47,7 +50,7 @@ LL ~ if a { 20 } else { 30 } | error: this function's return value is unnecessarily wrapped by `Option` - --> tests/ui/unnecessary_wraps.rs:45:1 + --> tests/ui/unnecessary_wraps.rs:44:1 | LL | / fn func5() -> Option { LL | | @@ -66,7 +69,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Result` - --> tests/ui/unnecessary_wraps.rs:57:1 + --> tests/ui/unnecessary_wraps.rs:56:1 | LL | / fn func7() -> Result { LL | | @@ -85,7 +88,7 @@ LL | 1 | error: this function's return value is unnecessarily wrapped by `Option` - --> tests/ui/unnecessary_wraps.rs:87:5 + --> tests/ui/unnecessary_wraps.rs:86:5 | LL | / fn func12() -> Option { LL | | @@ -104,7 +107,7 @@ LL | 1 | error: this function's return value is unnecessary - --> tests/ui/unnecessary_wraps.rs:116:1 + --> tests/ui/unnecessary_wraps.rs:115:1 | LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> { LL | | @@ -130,7 +133,7 @@ LL ~ return ; | error: this function's return value is unnecessary - --> tests/ui/unnecessary_wraps.rs:131:1 + --> tests/ui/unnecessary_wraps.rs:130:1 | LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> { LL | | diff --git a/tests/ui/unneeded_field_pattern.rs b/tests/ui/unneeded_field_pattern.rs index e4f6a704024b7..327b64e7c4aab 100644 --- a/tests/ui/unneeded_field_pattern.rs +++ b/tests/ui/unneeded_field_pattern.rs @@ -17,7 +17,6 @@ fn main() { match f { Foo { a: _, b: 0, .. } => {}, //~^ unneeded_field_pattern - Foo { a: _, b: _, c: _ } => {}, //~^ unneeded_field_pattern } diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 27e10f129dd6e..4ea33a5db9e2f 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -9,7 +9,7 @@ LL | Foo { a: _, b: 0, .. } => {}, = help: to override `-D warnings` add `#[allow(clippy::unneeded_field_pattern)]` error: all the struct fields are matched to a wildcard pattern, consider using `..` - --> tests/ui/unneeded_field_pattern.rs:21:9 + --> tests/ui/unneeded_field_pattern.rs:20:9 | LL | Foo { a: _, b: _, c: _ } => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unneeded_struct_pattern.fixed b/tests/ui/unneeded_struct_pattern.fixed index 3f24094ff3162..1fcaa29c51f05 100644 --- a/tests/ui/unneeded_struct_pattern.fixed +++ b/tests/ui/unneeded_struct_pattern.fixed @@ -89,24 +89,24 @@ fn main() { noop(); } if let Custom::NoBrackets = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } if let Custom::NoBrackets = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } if let Custom::NoBrackets | Custom::NoBracketsNonExhaustive = Custom::Init { - //~^ unneeded_struct_pattern - //~| unneeded_struct_pattern + //~^ unneeded_struct_pattern + //~| unneeded_struct_pattern noop(); } if let Custom::NoBracketsNonExhaustive = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } if let Custom::NoBracketsNonExhaustive = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } @@ -123,23 +123,21 @@ fn main() { }; let Custom::NoBrackets = Custom::Init else { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern panic!() }; let Custom::NoBracketsNonExhaustive = Custom::Init else { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern panic!() }; let Custom::NoBracketsNonExhaustive = Custom::Init else { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern panic!() }; enum Refutable { Variant, } - - } fn external_crate() { diff --git a/tests/ui/unneeded_struct_pattern.rs b/tests/ui/unneeded_struct_pattern.rs index 0e6ae51248226..e51311afd5f82 100644 --- a/tests/ui/unneeded_struct_pattern.rs +++ b/tests/ui/unneeded_struct_pattern.rs @@ -80,7 +80,7 @@ fn main() { //~^^^ match_single_binding match Custom::Init { - //~^ match_single_binding + //~^ match_single_binding _ => 0, }; @@ -94,24 +94,24 @@ fn main() { noop(); } if let Custom::NoBrackets {} = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } if let Custom::NoBrackets { .. } = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } if let Custom::NoBrackets {} | Custom::NoBracketsNonExhaustive {} = Custom::Init { - //~^ unneeded_struct_pattern - //~| unneeded_struct_pattern + //~^ unneeded_struct_pattern + //~| unneeded_struct_pattern noop(); } if let Custom::NoBracketsNonExhaustive {} = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } if let Custom::NoBracketsNonExhaustive { .. } = Custom::Init { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern noop(); } @@ -128,23 +128,21 @@ fn main() { }; let Custom::NoBrackets { .. } = Custom::Init else { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern panic!() }; let Custom::NoBracketsNonExhaustive {} = Custom::Init else { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern panic!() }; let Custom::NoBracketsNonExhaustive { .. } = Custom::Init else { - //~^ unneeded_struct_pattern + //~^ unneeded_struct_pattern panic!() }; enum Refutable { Variant, } - - } fn external_crate() { @@ -157,13 +155,13 @@ fn external_crate() { }; match ExhaustiveUnit { - //~^ match_single_binding + //~^ match_single_binding // Exhaustive variant _ => 0, }; match ExhaustiveUnit { - //~^ match_single_binding + //~^ match_single_binding // Exhaustive variant _ => 0, }; diff --git a/tests/ui/unneeded_struct_pattern.stderr b/tests/ui/unneeded_struct_pattern.stderr index 9fd698ebf8611..5630795823c47 100644 --- a/tests/ui/unneeded_struct_pattern.stderr +++ b/tests/ui/unneeded_struct_pattern.stderr @@ -136,7 +136,7 @@ LL | let Custom::NoBracketsNonExhaustive { .. } = Custom::Init else { | ^^^^^^^ help: remove the struct pattern error: this match could be replaced by its body itself - --> tests/ui/unneeded_struct_pattern.rs:159:5 + --> tests/ui/unneeded_struct_pattern.rs:157:5 | LL | / match ExhaustiveUnit { LL | | @@ -146,7 +146,7 @@ LL | | }; | |_____^ help: consider using the match body instead: `0` error: this match could be replaced by its body itself - --> tests/ui/unneeded_struct_pattern.rs:165:5 + --> tests/ui/unneeded_struct_pattern.rs:163:5 | LL | / match ExhaustiveUnit { LL | | diff --git a/tests/ui/unsafe_removed_from_name.rs b/tests/ui/unsafe_removed_from_name.rs index 124206e8e353e..2e1d8b60a0e2f 100644 --- a/tests/ui/unsafe_removed_from_name.rs +++ b/tests/ui/unsafe_removed_from_name.rs @@ -5,12 +5,9 @@ use std::cell::UnsafeCell as TotallySafeCell; //~^ unsafe_removed_from_name - - use std::cell::UnsafeCell as TotallySafeCellAgain; //~^ unsafe_removed_from_name - // Shouldn't error use std::cell::RefCell as ProbablyNotUnsafe; @@ -30,14 +27,11 @@ mod mod_with_some_unsafe_things { use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; //~^ unsafe_removed_from_name - // merged imports use mod_with_some_unsafe_things::{Unsafe as A, Unsafe as B}; //~^ unsafe_removed_from_name //~| unsafe_removed_from_name - - // Shouldn't error use mod_with_some_unsafe_things::Safe as IPromiseItsSafeThisTime; diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index 899d438ea76b6..5268c16ec9ba5 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -8,25 +8,25 @@ LL | use std::cell::UnsafeCell as TotallySafeCell; = help: to override `-D warnings` add `#[allow(clippy::unsafe_removed_from_name)]` error: removed `unsafe` from the name of `UnsafeCell` in use as `TotallySafeCellAgain` - --> tests/ui/unsafe_removed_from_name.rs:10:1 + --> tests/ui/unsafe_removed_from_name.rs:8:1 | LL | use std::cell::UnsafeCell as TotallySafeCellAgain; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `LieAboutModSafety` - --> tests/ui/unsafe_removed_from_name.rs:30:1 + --> tests/ui/unsafe_removed_from_name.rs:27:1 | LL | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `A` - --> tests/ui/unsafe_removed_from_name.rs:35:1 + --> tests/ui/unsafe_removed_from_name.rs:31:1 | LL | use mod_with_some_unsafe_things::{Unsafe as A, Unsafe as B}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed `unsafe` from the name of `Unsafe` in use as `B` - --> tests/ui/unsafe_removed_from_name.rs:35:1 + --> tests/ui/unsafe_removed_from_name.rs:31:1 | LL | use mod_with_some_unsafe_things::{Unsafe as A, Unsafe as B}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unused_async.rs b/tests/ui/unused_async.rs index 225f09ed94e63..5aaf7b9f5b598 100644 --- a/tests/ui/unused_async.rs +++ b/tests/ui/unused_async.rs @@ -10,7 +10,7 @@ mod issue10800 { use std::future::ready; async fn async_block_await() { - //~^ unused_async + //~^ unused_async async { ready(()).await; @@ -46,7 +46,6 @@ mod issue9695 { async fn f3() {} //~^ unused_async - fn needs_async_fn>(_: fn() -> F) {} fn test() { @@ -74,7 +73,7 @@ mod issue13466 { } async fn foo() -> i32 { -//~^ unused_async + //~^ unused_async 4 } @@ -87,7 +86,7 @@ struct S; impl S { async fn unused(&self) -> i32 { - //~^ unused_async + //~^ unused_async 1 } diff --git a/tests/ui/unused_async.stderr b/tests/ui/unused_async.stderr index 5b8d8f5097bea..f95fdd8653001 100644 --- a/tests/ui/unused_async.stderr +++ b/tests/ui/unused_async.stderr @@ -28,7 +28,7 @@ LL | async fn f3() {} = help: consider removing the `async` from this function error: unused `async` for function with no await statements - --> tests/ui/unused_async.rs:76:1 + --> tests/ui/unused_async.rs:75:1 | LL | / async fn foo() -> i32 { LL | | @@ -40,7 +40,7 @@ LL | | } = help: consider removing the `async` from this function error: unused `async` for function with no await statements - --> tests/ui/unused_async.rs:89:5 + --> tests/ui/unused_async.rs:88:5 | LL | / async fn unused(&self) -> i32 { LL | | diff --git a/tests/ui/unused_enumerate_index.fixed b/tests/ui/unused_enumerate_index.fixed index 8c713e273f4ac..258e52971ceab 100644 --- a/tests/ui/unused_enumerate_index.fixed +++ b/tests/ui/unused_enumerate_index.fixed @@ -10,7 +10,7 @@ fn get_enumerate() -> Enumerate> { fn main() { let v = [1, 2, 3]; for x in v.iter() { - //~^ unused_enumerate_index + //~^ unused_enumerate_index println!("{x}"); } @@ -58,7 +58,7 @@ fn main() { let dummy = Dummy3(vec![1, 2, 3].into_iter()); for x in dummy { - //~^ unused_enumerate_index + //~^ unused_enumerate_index println!("{x}"); } diff --git a/tests/ui/unused_enumerate_index.rs b/tests/ui/unused_enumerate_index.rs index 97018ee985e5e..a17e3259a9b07 100644 --- a/tests/ui/unused_enumerate_index.rs +++ b/tests/ui/unused_enumerate_index.rs @@ -10,7 +10,7 @@ fn get_enumerate() -> Enumerate> { fn main() { let v = [1, 2, 3]; for (_, x) in v.iter().enumerate() { - //~^ unused_enumerate_index + //~^ unused_enumerate_index println!("{x}"); } @@ -58,7 +58,7 @@ fn main() { let dummy = Dummy3(vec![1, 2, 3].into_iter()); for (_, x) in dummy.enumerate() { - //~^ unused_enumerate_index + //~^ unused_enumerate_index println!("{x}"); } diff --git a/tests/ui/unused_format_specs.1.fixed b/tests/ui/unused_format_specs.1.fixed index 850240bab6089..05bd1df9a5236 100644 --- a/tests/ui/unused_format_specs.1.fixed +++ b/tests/ui/unused_format_specs.1.fixed @@ -12,20 +12,16 @@ fn main() { println!("{:5}.", format!("")); //~^ unused_format_specs - //prints `abcde`, not `abc` println!("{:.3}", format!("abcde")); //~^ unused_format_specs - println!("{}.", format_args_from_macro!()); //~^ unused_format_specs - let args = format_args!(""); println!("{args}"); //~^ unused_format_specs - } fn should_not_lint() { @@ -56,15 +52,12 @@ fn should_lint_user() { usr_println!(true, "{:.3}", format!("abcde")); //~^ unused_format_specs - usr_println!(true, "{}.", format_args_from_macro!()); //~^ unused_format_specs - let args = format_args!(""); usr_println!(true, "{args}"); //~^ unused_format_specs - } fn should_not_lint_user() { diff --git a/tests/ui/unused_format_specs.2.fixed b/tests/ui/unused_format_specs.2.fixed index f8d5f615e0459..c1f3d4fa20c6f 100644 --- a/tests/ui/unused_format_specs.2.fixed +++ b/tests/ui/unused_format_specs.2.fixed @@ -12,20 +12,16 @@ fn main() { println!("{}.", format_args!("")); //~^ unused_format_specs - //prints `abcde`, not `abc` println!("{}", format_args!("abcde")); //~^ unused_format_specs - println!("{}.", format_args_from_macro!()); //~^ unused_format_specs - let args = format_args!(""); println!("{args}"); //~^ unused_format_specs - } fn should_not_lint() { @@ -56,15 +52,12 @@ fn should_lint_user() { usr_println!(true, "{}", format_args!("abcde")); //~^ unused_format_specs - usr_println!(true, "{}.", format_args_from_macro!()); //~^ unused_format_specs - let args = format_args!(""); usr_println!(true, "{args}"); //~^ unused_format_specs - } fn should_not_lint_user() { diff --git a/tests/ui/unused_format_specs.rs b/tests/ui/unused_format_specs.rs index 777901258a772..b47047ba34e5f 100644 --- a/tests/ui/unused_format_specs.rs +++ b/tests/ui/unused_format_specs.rs @@ -12,20 +12,16 @@ fn main() { println!("{:5}.", format_args!("")); //~^ unused_format_specs - //prints `abcde`, not `abc` println!("{:.3}", format_args!("abcde")); //~^ unused_format_specs - println!("{:5}.", format_args_from_macro!()); //~^ unused_format_specs - let args = format_args!(""); println!("{args:5}"); //~^ unused_format_specs - } fn should_not_lint() { @@ -56,15 +52,12 @@ fn should_lint_user() { usr_println!(true, "{:.3}", format_args!("abcde")); //~^ unused_format_specs - usr_println!(true, "{:5}.", format_args_from_macro!()); //~^ unused_format_specs - let args = format_args!(""); usr_println!(true, "{args:5}"); //~^ unused_format_specs - } fn should_not_lint_user() { diff --git a/tests/ui/unused_format_specs.stderr b/tests/ui/unused_format_specs.stderr index a88a808afe829..704e4987ec4a7 100644 --- a/tests/ui/unused_format_specs.stderr +++ b/tests/ui/unused_format_specs.stderr @@ -17,7 +17,7 @@ LL + println!("{}.", format_args!("")); | error: format specifiers have no effect on `format_args!()` - --> tests/ui/unused_format_specs.rs:17:15 + --> tests/ui/unused_format_specs.rs:16:15 | LL | println!("{:.3}", format_args!("abcde")); | ^^^^^ @@ -33,7 +33,7 @@ LL + println!("{}", format_args!("abcde")); | error: format specifiers have no effect on `format_args!()` - --> tests/ui/unused_format_specs.rs:21:15 + --> tests/ui/unused_format_specs.rs:19:15 | LL | println!("{:5}.", format_args_from_macro!()); | ^^^^ @@ -46,7 +46,7 @@ LL + println!("{}.", format_args_from_macro!()); | error: format specifiers have no effect on `format_args!()` - --> tests/ui/unused_format_specs.rs:26:15 + --> tests/ui/unused_format_specs.rs:23:15 | LL | println!("{args:5}"); | ^^^^^^^^ @@ -59,7 +59,7 @@ LL + println!("{args}"); | error: format specifiers have no effect on `format_args!()` - --> tests/ui/unused_format_specs.rs:52:25 + --> tests/ui/unused_format_specs.rs:48:25 | LL | usr_println!(true, "{:5}.", format_args!("")); | ^^^^ @@ -75,7 +75,7 @@ LL + usr_println!(true, "{}.", format_args!("")); | error: format specifiers have no effect on `format_args!()` - --> tests/ui/unused_format_specs.rs:56:25 + --> tests/ui/unused_format_specs.rs:52:25 | LL | usr_println!(true, "{:.3}", format_args!("abcde")); | ^^^^^ @@ -91,7 +91,7 @@ LL + usr_println!(true, "{}", format_args!("abcde")); | error: format specifiers have no effect on `format_args!()` - --> tests/ui/unused_format_specs.rs:60:25 + --> tests/ui/unused_format_specs.rs:55:25 | LL | usr_println!(true, "{:5}.", format_args_from_macro!()); | ^^^^ @@ -104,7 +104,7 @@ LL + usr_println!(true, "{}.", format_args_from_macro!()); | error: format specifiers have no effect on `format_args!()` - --> tests/ui/unused_format_specs.rs:65:25 + --> tests/ui/unused_format_specs.rs:59:25 | LL | usr_println!(true, "{args:5}"); | ^^^^^^^^ diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index f0531836db1ce..32a50375806a3 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -66,7 +66,7 @@ fn combine_or(file: &str) -> Result<(), Error> { let mut reader = std::fs::File::open(file).unwrap(); let mut result = [0u8; 0]; reader - //~^ unused_io_amount + //~^ unused_io_amount .read(&mut result) .or(Err(Error::Kind)) .or(Err(Error::Kind)) @@ -146,14 +146,14 @@ async fn undetected_bad_async_write(w: &mut W) { fn match_okay_underscore(s: &mut T) { match s.write(b"test") { - //~^ unused_io_amount + //~^ unused_io_amount Ok(_) => todo!(), Err(_) => todo!(), }; let mut buf = [0u8; 4]; match s.read(&mut buf) { - //~^ unused_io_amount + //~^ unused_io_amount Ok(_) => todo!(), Err(_) => todo!(), } @@ -161,7 +161,7 @@ fn match_okay_underscore(s: &mut T) { fn match_okay_underscore_read_expr(s: &mut T) { match s.read(&mut [0u8; 4]) { - //~^ unused_io_amount + //~^ unused_io_amount Ok(_) => todo!(), Err(_) => todo!(), } @@ -169,7 +169,7 @@ fn match_okay_underscore_read_expr(s: &mut T) { fn match_okay_underscore_write_expr(s: &mut T) { match s.write(b"test") { - //~^ unused_io_amount + //~^ unused_io_amount Ok(_) => todo!(), Err(_) => todo!(), } @@ -181,21 +181,21 @@ fn returned_value_should_not_lint(s: &mut T) -> Result< fn if_okay_underscore_read_expr(s: &mut T) { if let Ok(_) = s.read(&mut [0u8; 4]) { - //~^ unused_io_amount + //~^ unused_io_amount todo!() } } fn if_okay_underscore_write_expr(s: &mut T) { if let Ok(_) = s.write(b"test") { - //~^ unused_io_amount + //~^ unused_io_amount todo!() } } fn if_okay_dots_write_expr(s: &mut T) { if let Ok(..) = s.write(b"test") { - //~^ unused_io_amount + //~^ unused_io_amount todo!() } } diff --git a/tests/ui/unused_peekable.rs b/tests/ui/unused_peekable.rs index 8382db3be0050..e7fe297764eb3 100644 --- a/tests/ui/unused_peekable.rs +++ b/tests/ui/unused_peekable.rs @@ -13,19 +13,16 @@ fn invalid() { let peekable = std::iter::empty::().peekable(); //~^ unused_peekable - // Only lint `new_local` let old_local = std::iter::empty::().peekable(); let new_local = old_local; //~^ unused_peekable - // Behind mut ref let mut by_mut_ref_test = std::iter::empty::().peekable(); let by_mut_ref = &mut by_mut_ref_test; //~^ unused_peekable - // Explicitly returns `Peekable` fn returns_peekable() -> Peekable> { std::iter::empty().peekable() @@ -34,7 +31,6 @@ fn invalid() { let peekable_from_fn = returns_peekable(); //~^ unused_peekable - // Using a method not exclusive to `Peekable` let mut peekable_using_iterator_method = std::iter::empty::().peekable(); //~^ unused_peekable @@ -53,7 +49,6 @@ fn invalid() { let _by_ref = by_ref_test.by_ref(); //~^ unused_peekable - let mut peekable_in_for_loop = std::iter::empty::().peekable(); //~^ unused_peekable diff --git a/tests/ui/unused_peekable.stderr b/tests/ui/unused_peekable.stderr index 9b49e32fa8bab..9330d8c58001d 100644 --- a/tests/ui/unused_peekable.stderr +++ b/tests/ui/unused_peekable.stderr @@ -9,7 +9,7 @@ LL | let peekable = std::iter::empty::().peekable(); = help: to override `-D warnings` add `#[allow(clippy::unused_peekable)]` error: `peek` never called on `Peekable` iterator - --> tests/ui/unused_peekable.rs:19:9 + --> tests/ui/unused_peekable.rs:18:9 | LL | let new_local = old_local; | ^^^^^^^^^ @@ -17,7 +17,7 @@ LL | let new_local = old_local; = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> tests/ui/unused_peekable.rs:25:9 + --> tests/ui/unused_peekable.rs:23:9 | LL | let by_mut_ref = &mut by_mut_ref_test; | ^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | let by_mut_ref = &mut by_mut_ref_test; = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> tests/ui/unused_peekable.rs:34:9 + --> tests/ui/unused_peekable.rs:31:9 | LL | let peekable_from_fn = returns_peekable(); | ^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | let peekable_from_fn = returns_peekable(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> tests/ui/unused_peekable.rs:39:13 + --> tests/ui/unused_peekable.rs:35:13 | LL | let mut peekable_using_iterator_method = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | let mut peekable_using_iterator_method = std::iter::empty::().peek = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> tests/ui/unused_peekable.rs:46:9 + --> tests/ui/unused_peekable.rs:42:9 | LL | let passed_along_ref = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | let passed_along_ref = std::iter::empty::().peekable(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> tests/ui/unused_peekable.rs:53:9 + --> tests/ui/unused_peekable.rs:49:9 | LL | let _by_ref = by_ref_test.by_ref(); | ^^^^^^^ @@ -57,7 +57,7 @@ LL | let _by_ref = by_ref_test.by_ref(); = help: consider removing the call to `peekable` error: `peek` never called on `Peekable` iterator - --> tests/ui/unused_peekable.rs:57:13 + --> tests/ui/unused_peekable.rs:52:13 | LL | let mut peekable_in_for_loop = std::iter::empty::().peekable(); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unused_self.rs b/tests/ui/unused_self.rs index fac0b36c33a42..cb80d946acedb 100644 --- a/tests/ui/unused_self.rs +++ b/tests/ui/unused_self.rs @@ -30,12 +30,12 @@ mod unused_self { //~^ unused_self fn unused_with_other_used_args(&self, x: u8, y: u8) -> u8 { - //~^ unused_self + //~^ unused_self x + y } fn unused_self_class_method(&self) { - //~^ unused_self + //~^ unused_self Self::static_method(); } diff --git a/tests/ui/unwrap.rs b/tests/ui/unwrap.rs index 637d2da3750ef..3191b396f99bc 100644 --- a/tests/ui/unwrap.rs +++ b/tests/ui/unwrap.rs @@ -5,7 +5,6 @@ fn unwrap_option() { let opt = Some(0); let _ = opt.unwrap(); //~^ unwrap_used - } fn unwrap_result() { @@ -15,7 +14,6 @@ fn unwrap_result() { let _ = res.unwrap_err(); //~^ unwrap_used - } fn main() { diff --git a/tests/ui/unwrap.stderr b/tests/ui/unwrap.stderr index c568d8308200e..c242541a6bd73 100644 --- a/tests/ui/unwrap.stderr +++ b/tests/ui/unwrap.stderr @@ -10,7 +10,7 @@ LL | let _ = opt.unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `unwrap()` on a `Result` value - --> tests/ui/unwrap.rs:13:13 + --> tests/ui/unwrap.rs:12:13 | LL | let _ = res.unwrap(); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | let _ = res.unwrap(); = help: consider using `expect()` to provide a better panic message error: used `unwrap_err()` on a `Result` value - --> tests/ui/unwrap.rs:16:13 + --> tests/ui/unwrap.rs:15:13 | LL | let _ = res.unwrap_err(); | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unwrap_expect_used.rs b/tests/ui/unwrap_expect_used.rs index c2c9db7753706..d0bb571273b5a 100644 --- a/tests/ui/unwrap_expect_used.rs +++ b/tests/ui/unwrap_expect_used.rs @@ -30,7 +30,6 @@ fn main() { Some(3).expect("Hello world!"); //~^ expect_used - // Don't trigger on unwrap_err on an option Some(3).unwrap_err(); Some(3).expect_err("Hello none!"); diff --git a/tests/ui/unwrap_expect_used.stderr b/tests/ui/unwrap_expect_used.stderr index 7476e372bcbb1..79eac3f58ccb2 100644 --- a/tests/ui/unwrap_expect_used.stderr +++ b/tests/ui/unwrap_expect_used.stderr @@ -19,7 +19,7 @@ LL | Some(3).expect("Hello world!"); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `unwrap()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:47:5 + --> tests/ui/unwrap_expect_used.rs:46:5 | LL | a.unwrap(); | ^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | a.unwrap(); = note: if this value is an `Err`, it will panic error: used `expect()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:50:5 + --> tests/ui/unwrap_expect_used.rs:49:5 | LL | a.expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | a.expect("Hello world!"); = note: if this value is an `Err`, it will panic error: used `unwrap_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:53:5 + --> tests/ui/unwrap_expect_used.rs:52:5 | LL | a.unwrap_err(); | ^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | a.unwrap_err(); = note: if this value is an `Ok`, it will panic error: used `expect_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:56:5 + --> tests/ui/unwrap_expect_used.rs:55:5 | LL | a.expect_err("Hello error!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unwrap_in_result.rs b/tests/ui/unwrap_in_result.rs index 58235d1386588..4e872c67b423e 100644 --- a/tests/ui/unwrap_in_result.rs +++ b/tests/ui/unwrap_in_result.rs @@ -20,7 +20,7 @@ impl A { // should be detected fn bad_divisible_by_3(i_str: String) -> Result { - //~^ unwrap_in_result + //~^ unwrap_in_result // checks whether a string represents a number divisible by 3 let i = i_str.parse::().unwrap(); @@ -32,7 +32,7 @@ impl A { } fn example_option_expect(i_str: String) -> Option { - //~^ unwrap_in_result + //~^ unwrap_in_result let i = i_str.parse::().expect("not a number"); if i % 3 == 0 { @@ -42,7 +42,7 @@ impl A { } fn in_closure(a: Option) -> Option { - //~^ unwrap_in_result + //~^ unwrap_in_result let c = || a.unwrap(); Some(c()) } diff --git a/tests/ui/unwrap_or.fixed b/tests/ui/unwrap_or.fixed index 7a00d346cac51..c794ed577032d 100644 --- a/tests/ui/unwrap_or.fixed +++ b/tests/ui/unwrap_or.fixed @@ -4,12 +4,9 @@ fn main() { let s = Some(String::from("test string")).unwrap_or_else(|| "Fail".to_string()).len(); //~^ or_fun_call - - } fn new_lines() { let s = Some(String::from("test string")).unwrap_or_else(|| "Fail".to_string()).len(); //~^ or_fun_call - } diff --git a/tests/ui/unwrap_or.rs b/tests/ui/unwrap_or.rs index 30779ac1b1097..11a6883b7403f 100644 --- a/tests/ui/unwrap_or.rs +++ b/tests/ui/unwrap_or.rs @@ -4,12 +4,9 @@ fn main() { let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); //~^ or_fun_call - - } fn new_lines() { let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); //~^ or_fun_call - } diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index b2c20a9e9b5e2..e95633680acc1 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -8,7 +8,7 @@ LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()) = help: to override `-D warnings` add `#[allow(clippy::or_fun_call)]` error: function call inside of `unwrap_or` - --> tests/ui/unwrap_or.rs:12:47 + --> tests/ui/unwrap_or.rs:10:47 | LL | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| "Fail".to_string())` diff --git a/tests/ui/upper_case_acronyms.fixed b/tests/ui/upper_case_acronyms.fixed index b8c10b370680f..da44c8e3026e2 100644 --- a/tests/ui/upper_case_acronyms.fixed +++ b/tests/ui/upper_case_acronyms.fixed @@ -8,29 +8,20 @@ enum Flags { NS, // not linted Cwr, //~^ upper_case_acronyms - - Ece, //~^ upper_case_acronyms - Urg, //~^ upper_case_acronyms - Ack, //~^ upper_case_acronyms - Psh, //~^ upper_case_acronyms - Rst, //~^ upper_case_acronyms - Syn, //~^ upper_case_acronyms - Fin, //~^ upper_case_acronyms - } // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of @@ -52,7 +43,6 @@ pub enum ParseError { enum ParseErrorPrivate { Wasd(u8), //~^ upper_case_acronyms - Utf8(std::string::FromUtf8Error), Parse(T, String), } @@ -61,11 +51,9 @@ enum ParseErrorPrivate { struct Json; //~^ upper_case_acronyms - // do lint here enum Yaml { -//~^ upper_case_acronyms - + //~^ upper_case_acronyms Num(u32), Str(String), } @@ -74,7 +62,6 @@ enum Yaml { enum AllowOnField { Disallow, //~^ upper_case_acronyms - #[allow(clippy::upper_case_acronyms)] ALLOW, } diff --git a/tests/ui/upper_case_acronyms.rs b/tests/ui/upper_case_acronyms.rs index 4ad6c6d4c8c86..d223b02acda94 100644 --- a/tests/ui/upper_case_acronyms.rs +++ b/tests/ui/upper_case_acronyms.rs @@ -8,29 +8,20 @@ enum Flags { NS, // not linted CWR, //~^ upper_case_acronyms - - ECE, //~^ upper_case_acronyms - URG, //~^ upper_case_acronyms - ACK, //~^ upper_case_acronyms - PSH, //~^ upper_case_acronyms - RST, //~^ upper_case_acronyms - SYN, //~^ upper_case_acronyms - FIN, //~^ upper_case_acronyms - } // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of @@ -52,7 +43,6 @@ pub enum ParseError { enum ParseErrorPrivate { WASD(u8), //~^ upper_case_acronyms - Utf8(std::string::FromUtf8Error), Parse(T, String), } @@ -61,11 +51,9 @@ enum ParseErrorPrivate { struct JSON; //~^ upper_case_acronyms - // do lint here enum YAML { -//~^ upper_case_acronyms - + //~^ upper_case_acronyms Num(u32), Str(String), } @@ -74,7 +62,6 @@ enum YAML { enum AllowOnField { DISALLOW, //~^ upper_case_acronyms - #[allow(clippy::upper_case_acronyms)] ALLOW, } diff --git a/tests/ui/upper_case_acronyms.stderr b/tests/ui/upper_case_acronyms.stderr index 24e1d808d8ed2..dd548fc143e2c 100644 --- a/tests/ui/upper_case_acronyms.stderr +++ b/tests/ui/upper_case_acronyms.stderr @@ -8,67 +8,67 @@ LL | CWR, = help: to override `-D warnings` add `#[allow(clippy::upper_case_acronyms)]` error: name `ECE` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:13:5 + --> tests/ui/upper_case_acronyms.rs:11:5 | LL | ECE, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` error: name `URG` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:16:5 + --> tests/ui/upper_case_acronyms.rs:13:5 | LL | URG, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` error: name `ACK` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:19:5 + --> tests/ui/upper_case_acronyms.rs:15:5 | LL | ACK, | ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` error: name `PSH` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:22:5 + --> tests/ui/upper_case_acronyms.rs:17:5 | LL | PSH, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` error: name `RST` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:25:5 + --> tests/ui/upper_case_acronyms.rs:19:5 | LL | RST, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` error: name `SYN` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:28:5 + --> tests/ui/upper_case_acronyms.rs:21:5 | LL | SYN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` error: name `FIN` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:31:5 + --> tests/ui/upper_case_acronyms.rs:23:5 | LL | FIN, | ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` error: name `WASD` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:53:5 + --> tests/ui/upper_case_acronyms.rs:44:5 | LL | WASD(u8), | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Wasd` error: name `JSON` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:61:8 + --> tests/ui/upper_case_acronyms.rs:51:8 | LL | struct JSON; | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Json` error: name `YAML` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:66:6 + --> tests/ui/upper_case_acronyms.rs:55:6 | LL | enum YAML { | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Yaml` error: name `DISALLOW` contains a capitalized acronym - --> tests/ui/upper_case_acronyms.rs:75:5 + --> tests/ui/upper_case_acronyms.rs:63:5 | LL | DISALLOW, | ^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `Disallow` diff --git a/tests/ui/use_self.fixed b/tests/ui/use_self.fixed index faabf0e256db5..f15e5e0a5bb42 100644 --- a/tests/ui/use_self.fixed +++ b/tests/ui/use_self.fixed @@ -21,12 +21,12 @@ mod use_self { impl Foo { fn new() -> Self { - //~^ use_self + //~^ use_self Self {} //~^ use_self } fn test() -> Self { - //~^ use_self + //~^ use_self Self::new() //~^ use_self } @@ -34,7 +34,7 @@ mod use_self { impl Default for Foo { fn default() -> Self { - //~^ use_self + //~^ use_self Self::new() //~^ use_self } @@ -78,7 +78,7 @@ mod lifetimes { } fn clone(&self) -> Self { - //~^ use_self + //~^ use_self Foo { foo_str: self.foo_str } } @@ -112,8 +112,8 @@ mod existential { impl Foo { fn bad(foos: &[Self]) -> impl Iterator { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self foos.iter() } @@ -165,7 +165,7 @@ mod nesting { impl Bar { fn bar() -> Self { - //~^ use_self + //~^ use_self Self { foo: Foo {} } //~^ use_self } @@ -179,7 +179,7 @@ mod nesting { // Should lint here fn baz() -> Self { - //~^ use_self + //~^ use_self Self {} //~^ use_self } @@ -286,7 +286,7 @@ mod paths_created_by_lowering { const B: usize = 1; async fn g() -> Self { - //~^ use_self + //~^ use_self Self {} //~^ use_self } @@ -318,7 +318,7 @@ mod generics { impl Foo { // `Self` is applicable here fn foo(value: T) -> Self { - //~^ use_self + //~^ use_self Self { value } //~^ use_self } @@ -578,7 +578,7 @@ mod use_self_in_pat { None => unimplemented!(), } if let Self::Bar = self { - //~^ use_self + //~^ use_self unimplemented!() } } diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index b91856e480977..b6376938611e7 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -21,12 +21,12 @@ mod use_self { impl Foo { fn new() -> Foo { - //~^ use_self + //~^ use_self Foo {} //~^ use_self } fn test() -> Foo { - //~^ use_self + //~^ use_self Foo::new() //~^ use_self } @@ -34,7 +34,7 @@ mod use_self { impl Default for Foo { fn default() -> Foo { - //~^ use_self + //~^ use_self Foo::new() //~^ use_self } @@ -78,7 +78,7 @@ mod lifetimes { } fn clone(&self) -> Foo<'a> { - //~^ use_self + //~^ use_self Foo { foo_str: self.foo_str } } @@ -112,8 +112,8 @@ mod existential { impl Foo { fn bad(foos: &[Foo]) -> impl Iterator { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self foos.iter() } @@ -165,7 +165,7 @@ mod nesting { impl Bar { fn bar() -> Bar { - //~^ use_self + //~^ use_self Bar { foo: Foo {} } //~^ use_self } @@ -179,7 +179,7 @@ mod nesting { // Should lint here fn baz() -> Foo { - //~^ use_self + //~^ use_self Foo {} //~^ use_self } @@ -286,7 +286,7 @@ mod paths_created_by_lowering { const B: usize = 1; async fn g() -> S { - //~^ use_self + //~^ use_self S {} //~^ use_self } @@ -318,7 +318,7 @@ mod generics { impl Foo { // `Self` is applicable here fn foo(value: T) -> Foo { - //~^ use_self + //~^ use_self Foo:: { value } //~^ use_self } @@ -578,7 +578,7 @@ mod use_self_in_pat { None => unimplemented!(), } if let Foo::Bar = self { - //~^ use_self + //~^ use_self unimplemented!() } } diff --git a/tests/ui/use_self_trait.fixed b/tests/ui/use_self_trait.fixed index 2df7eec92f2fc..820282d8da546 100644 --- a/tests/ui/use_self_trait.fixed +++ b/tests/ui/use_self_trait.fixed @@ -17,20 +17,20 @@ struct Bad; impl SelfTrait for Bad { fn refs(p1: &Self) -> &Self { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self p1 } fn ref_refs<'a>(p1: &'a &'a Self) -> &'a &'a Self { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self p1 } fn mut_refs(p1: &mut Self) -> &mut Self { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self p1 } @@ -39,8 +39,8 @@ impl SelfTrait for Bad { //~| use_self fn vals(_: Self) -> Self { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self Self //~^ use_self } @@ -51,8 +51,8 @@ impl Mul for Bad { //~^ use_self fn mul(self, rhs: Self) -> Self { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self rhs } } diff --git a/tests/ui/use_self_trait.rs b/tests/ui/use_self_trait.rs index 48118e59fe673..aa9761e5609fa 100644 --- a/tests/ui/use_self_trait.rs +++ b/tests/ui/use_self_trait.rs @@ -17,20 +17,20 @@ struct Bad; impl SelfTrait for Bad { fn refs(p1: &Bad) -> &Bad { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self p1 } fn ref_refs<'a>(p1: &'a &'a Bad) -> &'a &'a Bad { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self p1 } fn mut_refs(p1: &mut Bad) -> &mut Bad { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self p1 } @@ -39,8 +39,8 @@ impl SelfTrait for Bad { //~| use_self fn vals(_: Bad) -> Bad { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self Bad //~^ use_self } @@ -51,8 +51,8 @@ impl Mul for Bad { //~^ use_self fn mul(self, rhs: Bad) -> Bad { - //~^ use_self - //~| use_self + //~^ use_self + //~| use_self rhs } } diff --git a/tests/ui/useless_asref.fixed b/tests/ui/useless_asref.fixed index 235b496490015..e399bd76fc1ed 100644 --- a/tests/ui/useless_asref.fixed +++ b/tests/ui/useless_asref.fixed @@ -157,7 +157,6 @@ fn foo() { let z = x.clone(); //~^ useless_asref - } mod issue12135 { @@ -189,13 +188,11 @@ mod issue12135 { x.field.clone(); //~^ useless_asref - // https://github.com/rust-lang/rust-clippy/pull/12136#discussion_r1451565223 #[allow(clippy::clone_on_copy)] Some(1).clone(); //~^ useless_asref - x.field.as_ref().map(|v| v.method().clone()) } } diff --git a/tests/ui/useless_asref.rs b/tests/ui/useless_asref.rs index 261bbe18e357d..4c76a2ecf7b09 100644 --- a/tests/ui/useless_asref.rs +++ b/tests/ui/useless_asref.rs @@ -157,7 +157,6 @@ fn foo() { let z = x.as_ref().map(|z| String::clone(z)); //~^ useless_asref - } mod issue12135 { @@ -189,13 +188,11 @@ mod issue12135 { x.field.as_ref().map(|v| Clone::clone(v)); //~^ useless_asref - // https://github.com/rust-lang/rust-clippy/pull/12136#discussion_r1451565223 #[allow(clippy::clone_on_copy)] Some(1).as_ref().map(|&x| x.clone()); //~^ useless_asref - x.field.as_ref().map(|v| v.method().clone()) } } diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 97be7996f0085..d0ca10936fd5c 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -89,25 +89,25 @@ LL | let z = x.as_ref().map(|z| String::clone(z)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.clone()` error: this call to `as_ref.map(...)` does nothing - --> tests/ui/useless_asref.rs:183:9 + --> tests/ui/useless_asref.rs:182:9 | LL | x.field.as_ref().map(|v| v.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> tests/ui/useless_asref.rs:186:9 + --> tests/ui/useless_asref.rs:185:9 | LL | x.field.as_ref().map(Clone::clone); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> tests/ui/useless_asref.rs:189:9 + --> tests/ui/useless_asref.rs:188:9 | LL | x.field.as_ref().map(|v| Clone::clone(v)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.field.clone()` error: this call to `as_ref.map(...)` does nothing - --> tests/ui/useless_asref.rs:195:9 + --> tests/ui/useless_asref.rs:193:9 | LL | Some(1).as_ref().map(|&x| x.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(1).clone()` diff --git a/tests/ui/useless_conversion.fixed b/tests/ui/useless_conversion.fixed index 2b9ef0209047b..489caacf21235 100644 --- a/tests/ui/useless_conversion.fixed +++ b/tests/ui/useless_conversion.fixed @@ -341,7 +341,6 @@ fn direct_application() { let _: Result<(), std::io::Error> = test_issue_3913(); //~^ useless_conversion - let c: ControlFlow<()> = ControlFlow::Continue(()); let _: ControlFlow<()> = c; //~^ useless_conversion @@ -350,7 +349,6 @@ fn direct_application() { let _: ControlFlow<()> = c; //~^ useless_conversion - struct Absorb; impl From<()> for Absorb { fn from(_: ()) -> Self { @@ -365,7 +363,6 @@ fn direct_application() { let _: Vec = [1u32].into_iter().collect(); //~^ useless_conversion - // No lint for those let _: Result = test_issue_3913().map(Into::into); let _: Result<(), Absorb> = test_issue_3913().map_err(Into::into); @@ -376,7 +373,6 @@ fn direct_application() { fn gen_identity(x: [T; 3]) -> Vec { x.into_iter().collect() //~^ useless_conversion - } mod issue11819 { @@ -393,7 +389,6 @@ mod issue11819 { { takes_into_iter(&self.my_field); //~^ useless_conversion - } pub fn with_ref_mut<'a>(&'a mut self) @@ -402,7 +397,6 @@ mod issue11819 { { takes_into_iter(&mut self.my_field); //~^ useless_conversion - } pub fn with_deref(&mut self) @@ -412,7 +406,6 @@ mod issue11819 { { takes_into_iter(*self.my_field); //~^ useless_conversion - } pub fn with_reborrow<'a, Y: 'a>(&'a mut self) @@ -422,7 +415,6 @@ mod issue11819 { { takes_into_iter(&*self.my_field); //~^ useless_conversion - } pub fn with_reborrow_mut<'a, Y: 'a>(&'a mut self) @@ -432,7 +424,6 @@ mod issue11819 { { takes_into_iter(&mut *self.my_field); //~^ useless_conversion - } } } diff --git a/tests/ui/useless_conversion.rs b/tests/ui/useless_conversion.rs index 84b5b12580e51..4f3a3b00ea206 100644 --- a/tests/ui/useless_conversion.rs +++ b/tests/ui/useless_conversion.rs @@ -341,7 +341,6 @@ fn direct_application() { let _: Result<(), std::io::Error> = test_issue_3913().map_err(From::from); //~^ useless_conversion - let c: ControlFlow<()> = ControlFlow::Continue(()); let _: ControlFlow<()> = c.map_break(Into::into); //~^ useless_conversion @@ -350,7 +349,6 @@ fn direct_application() { let _: ControlFlow<()> = c.map_continue(Into::into); //~^ useless_conversion - struct Absorb; impl From<()> for Absorb { fn from(_: ()) -> Self { @@ -365,7 +363,6 @@ fn direct_application() { let _: Vec = [1u32].into_iter().map(Into::into).collect(); //~^ useless_conversion - // No lint for those let _: Result = test_issue_3913().map(Into::into); let _: Result<(), Absorb> = test_issue_3913().map_err(Into::into); @@ -376,7 +373,6 @@ fn direct_application() { fn gen_identity(x: [T; 3]) -> Vec { x.into_iter().map(Into::into).collect() //~^ useless_conversion - } mod issue11819 { @@ -393,7 +389,6 @@ mod issue11819 { { takes_into_iter(self.my_field.into_iter()); //~^ useless_conversion - } pub fn with_ref_mut<'a>(&'a mut self) @@ -402,7 +397,6 @@ mod issue11819 { { takes_into_iter(self.my_field.into_iter()); //~^ useless_conversion - } pub fn with_deref(&mut self) @@ -412,7 +406,6 @@ mod issue11819 { { takes_into_iter(self.my_field.into_iter()); //~^ useless_conversion - } pub fn with_reborrow<'a, Y: 'a>(&'a mut self) @@ -422,7 +415,6 @@ mod issue11819 { { takes_into_iter(self.my_field.into_iter()); //~^ useless_conversion - } pub fn with_reborrow_mut<'a, Y: 'a>(&'a mut self) @@ -432,7 +424,6 @@ mod issue11819 { { takes_into_iter(self.my_field.into_iter()); //~^ useless_conversion - } } } diff --git a/tests/ui/useless_conversion.stderr b/tests/ui/useless_conversion.stderr index 39c625429c66a..3cde2a786e466 100644 --- a/tests/ui/useless_conversion.stderr +++ b/tests/ui/useless_conversion.stderr @@ -269,37 +269,37 @@ LL | let _: Result<(), std::io::Error> = test_issue_3913().map_err(From::fro | ^^^^^^^^^^^^^^^^^^^^ help: consider removing error: useless conversion to the same type: `()` - --> tests/ui/useless_conversion.rs:346:31 + --> tests/ui/useless_conversion.rs:345:31 | LL | let _: ControlFlow<()> = c.map_break(Into::into); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing error: useless conversion to the same type: `()` - --> tests/ui/useless_conversion.rs:350:31 + --> tests/ui/useless_conversion.rs:349:31 | LL | let _: ControlFlow<()> = c.map_continue(Into::into); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing error: useless conversion to the same type: `u32` - --> tests/ui/useless_conversion.rs:365:41 + --> tests/ui/useless_conversion.rs:363:41 | LL | let _: Vec = [1u32].into_iter().map(Into::into).collect(); | ^^^^^^^^^^^^^^^^ help: consider removing error: useless conversion to the same type: `T` - --> tests/ui/useless_conversion.rs:377:18 + --> tests/ui/useless_conversion.rs:374:18 | LL | x.into_iter().map(Into::into).collect() | ^^^^^^^^^^^^^^^^ help: consider removing error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> tests/ui/useless_conversion.rs:394:29 + --> tests/ui/useless_conversion.rs:390:29 | LL | takes_into_iter(self.my_field.into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> tests/ui/useless_conversion.rs:383:32 + --> tests/ui/useless_conversion.rs:379:32 | LL | fn takes_into_iter(_: impl IntoIterator) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -310,13 +310,13 @@ LL + takes_into_iter(&self.my_field); | error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> tests/ui/useless_conversion.rs:403:29 + --> tests/ui/useless_conversion.rs:398:29 | LL | takes_into_iter(self.my_field.into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> tests/ui/useless_conversion.rs:383:32 + --> tests/ui/useless_conversion.rs:379:32 | LL | fn takes_into_iter(_: impl IntoIterator) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -327,13 +327,13 @@ LL + takes_into_iter(&mut self.my_field); | error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> tests/ui/useless_conversion.rs:413:29 + --> tests/ui/useless_conversion.rs:407:29 | LL | takes_into_iter(self.my_field.into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> tests/ui/useless_conversion.rs:383:32 + --> tests/ui/useless_conversion.rs:379:32 | LL | fn takes_into_iter(_: impl IntoIterator) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -344,13 +344,13 @@ LL + takes_into_iter(*self.my_field); | error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> tests/ui/useless_conversion.rs:423:29 + --> tests/ui/useless_conversion.rs:416:29 | LL | takes_into_iter(self.my_field.into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> tests/ui/useless_conversion.rs:383:32 + --> tests/ui/useless_conversion.rs:379:32 | LL | fn takes_into_iter(_: impl IntoIterator) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -361,13 +361,13 @@ LL + takes_into_iter(&*self.my_field); | error: explicit call to `.into_iter()` in function argument accepting `IntoIterator` - --> tests/ui/useless_conversion.rs:433:29 + --> tests/ui/useless_conversion.rs:425:29 | LL | takes_into_iter(self.my_field.into_iter()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` - --> tests/ui/useless_conversion.rs:383:32 + --> tests/ui/useless_conversion.rs:379:32 | LL | fn takes_into_iter(_: impl IntoIterator) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/useless_conversion_try.rs b/tests/ui/useless_conversion_try.rs index 7f469a819ef23..d16506d94aa3c 100644 --- a/tests/ui/useless_conversion_try.rs +++ b/tests/ui/useless_conversion_try.rs @@ -11,7 +11,6 @@ fn test_generic(val: T) -> T { val.try_into().unwrap() //~^ useless_conversion - } fn test_generic2 + Into, U: From>(val: T) { @@ -52,8 +51,7 @@ fn main() { //~^ useless_conversion let _: String = match String::from("_").try_into() { - //~^ useless_conversion - + //~^ useless_conversion Ok(a) => a, Err(_) => String::new(), }; diff --git a/tests/ui/useless_conversion_try.stderr b/tests/ui/useless_conversion_try.stderr index af2199837bf73..1c62426c89526 100644 --- a/tests/ui/useless_conversion_try.stderr +++ b/tests/ui/useless_conversion_try.stderr @@ -20,7 +20,7 @@ LL | val.try_into().unwrap() = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> tests/ui/useless_conversion_try.rs:36:21 + --> tests/ui/useless_conversion_try.rs:35:21 | LL | let _: String = "foo".to_string().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,7 +28,7 @@ LL | let _: String = "foo".to_string().try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> tests/ui/useless_conversion_try.rs:39:21 + --> tests/ui/useless_conversion_try.rs:38:21 | LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | let _: String = TryFrom::try_from("foo".to_string()).unwrap(); = help: consider removing `TryFrom::try_from()` error: useless conversion to the same type: `std::string::String` - --> tests/ui/useless_conversion_try.rs:42:13 + --> tests/ui/useless_conversion_try.rs:41:13 | LL | let _ = String::try_from("foo".to_string()).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | let _ = String::try_from("foo".to_string()).unwrap(); = help: consider removing `String::try_from()` error: useless conversion to the same type: `std::string::String` - --> tests/ui/useless_conversion_try.rs:45:13 + --> tests/ui/useless_conversion_try.rs:44:13 | LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -52,7 +52,7 @@ LL | let _ = String::try_from(format!("A: {:04}", 123)).unwrap(); = help: consider removing `String::try_from()` error: useless conversion to the same type: `std::string::String` - --> tests/ui/useless_conversion_try.rs:48:21 + --> tests/ui/useless_conversion_try.rs:47:21 | LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -60,7 +60,7 @@ LL | let _: String = format!("Hello {}", "world").try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> tests/ui/useless_conversion_try.rs:51:21 + --> tests/ui/useless_conversion_try.rs:50:21 | LL | let _: String = String::new().try_into().unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | let _: String = String::new().try_into().unwrap(); = help: consider removing `.try_into()` error: useless conversion to the same type: `std::string::String` - --> tests/ui/useless_conversion_try.rs:54:27 + --> tests/ui/useless_conversion_try.rs:53:27 | LL | let _: String = match String::from("_").try_into() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/useless_nonzero_new_unchecked.fixed b/tests/ui/useless_nonzero_new_unchecked.fixed index 8e5e105215a91..f7f60bbe3f8dc 100644 --- a/tests/ui/useless_nonzero_new_unchecked.fixed +++ b/tests/ui/useless_nonzero_new_unchecked.fixed @@ -6,7 +6,6 @@ use std::num::{NonZero, NonZeroUsize}; const fn func() -> NonZeroUsize { const { NonZeroUsize::new(3).unwrap() } //~^ useless_nonzero_new_unchecked - } #[clippy::msrv = "1.82"] @@ -38,20 +37,16 @@ fn main() { const _A: NonZeroUsize = NonZeroUsize::new(3).unwrap(); //~^ useless_nonzero_new_unchecked - static _B: NonZero = NonZero::::new(42).unwrap(); //~^ useless_nonzero_new_unchecked - const _C: usize = unsafe { NonZeroUsize::new(3).unwrap().get() }; //~^ useless_nonzero_new_unchecked - const AUX: usize = 3; const _D: NonZeroUsize = NonZeroUsize::new(AUX).unwrap(); //~^ useless_nonzero_new_unchecked - const _X: NonZeroUsize = uns!(NonZeroUsize::new_unchecked(3)); const _Y: NonZeroUsize = unsafe { nzu!() }; } diff --git a/tests/ui/useless_nonzero_new_unchecked.rs b/tests/ui/useless_nonzero_new_unchecked.rs index 43fd1f2e58491..c90a63915efb8 100644 --- a/tests/ui/useless_nonzero_new_unchecked.rs +++ b/tests/ui/useless_nonzero_new_unchecked.rs @@ -6,7 +6,6 @@ use std::num::{NonZero, NonZeroUsize}; const fn func() -> NonZeroUsize { const { unsafe { NonZeroUsize::new_unchecked(3) } } //~^ useless_nonzero_new_unchecked - } #[clippy::msrv = "1.82"] @@ -38,20 +37,16 @@ fn main() { const _A: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(3) }; //~^ useless_nonzero_new_unchecked - static _B: NonZero = unsafe { NonZero::::new_unchecked(42) }; //~^ useless_nonzero_new_unchecked - const _C: usize = unsafe { NonZeroUsize::new_unchecked(3).get() }; //~^ useless_nonzero_new_unchecked - const AUX: usize = 3; const _D: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(AUX) }; //~^ useless_nonzero_new_unchecked - const _X: NonZeroUsize = uns!(NonZeroUsize::new_unchecked(3)); const _Y: NonZeroUsize = unsafe { nzu!() }; } diff --git a/tests/ui/useless_nonzero_new_unchecked.stderr b/tests/ui/useless_nonzero_new_unchecked.stderr index b9fc333dd4f51..adb146167633e 100644 --- a/tests/ui/useless_nonzero_new_unchecked.stderr +++ b/tests/ui/useless_nonzero_new_unchecked.stderr @@ -8,19 +8,19 @@ LL | const { unsafe { NonZeroUsize::new_unchecked(3) } } = help: to override `-D warnings` add `#[allow(clippy::useless_nonzero_new_unchecked)]` error: `NonZeroUsize::new()` and `Option::unwrap()` can be safely used in a `const` context - --> tests/ui/useless_nonzero_new_unchecked.rs:38:30 + --> tests/ui/useless_nonzero_new_unchecked.rs:37:30 | LL | const _A: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(3) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use instead: `NonZeroUsize::new(3).unwrap()` error: `NonZero::::new()` and `Option::unwrap()` can be safely used in a `const` context - --> tests/ui/useless_nonzero_new_unchecked.rs:42:30 + --> tests/ui/useless_nonzero_new_unchecked.rs:40:30 | LL | static _B: NonZero = unsafe { NonZero::::new_unchecked(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use instead: `NonZero::::new(42).unwrap()` error: `NonZeroUsize::new()` and `Option::unwrap()` can be safely used in a `const` context - --> tests/ui/useless_nonzero_new_unchecked.rs:46:32 + --> tests/ui/useless_nonzero_new_unchecked.rs:43:32 | LL | const _C: usize = unsafe { NonZeroUsize::new_unchecked(3).get() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use instead: `NonZeroUsize::new(3).unwrap()` @@ -28,7 +28,7 @@ LL | const _C: usize = unsafe { NonZeroUsize::new_unchecked(3).get() }; = note: the fixed expression does not require an `unsafe` context error: `NonZeroUsize::new()` and `Option::unwrap()` can be safely used in a `const` context - --> tests/ui/useless_nonzero_new_unchecked.rs:51:30 + --> tests/ui/useless_nonzero_new_unchecked.rs:47:30 | LL | const _D: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(AUX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use instead: `NonZeroUsize::new(AUX).unwrap()` diff --git a/tests/ui/useless_vec.rs b/tests/ui/useless_vec.rs index 65aafb66568f9..880809f81d7ae 100644 --- a/tests/ui/useless_vec.rs +++ b/tests/ui/useless_vec.rs @@ -6,8 +6,7 @@ fn foo() { // There should be no suggestion in this case. let _some_variable = vec![ - //~^ useless_vec - + //~^ useless_vec 1, 2, // i'm here to stay 3, 4, // but this one going away ;-; ]; // that is life anyways diff --git a/tests/ui/useless_vec.stderr b/tests/ui/useless_vec.stderr index 39927d0b4654d..e47364fb06d3b 100644 --- a/tests/ui/useless_vec.stderr +++ b/tests/ui/useless_vec.stderr @@ -4,7 +4,6 @@ error: useless use of `vec!` LL | let _some_variable = vec![ | __________________________^ LL | | -LL | | LL | | 1, 2, // i'm here to stay LL | | 3, 4, // but this one going away ;-; LL | | ]; // that is life anyways diff --git a/tests/ui/vec.fixed b/tests/ui/vec.fixed index 5b35b2b262434..f360a8afadf61 100644 --- a/tests/ui/vec.fixed +++ b/tests/ui/vec.fixed @@ -136,7 +136,7 @@ fn issue11075() { } #[allow(clippy::never_loop)] for _string in [repro!(true), repro!(null)] { - //~^ useless_vec + //~^ useless_vec unimplemented!(); } @@ -175,12 +175,12 @@ fn issue11075() { #[clippy::msrv = "1.53"] fn above() { for a in [1, 2, 3] { - //~^ useless_vec + //~^ useless_vec let _: usize = a; } for a in [String::new(), String::new()] { - //~^ useless_vec + //~^ useless_vec let _: String = a; } } @@ -212,8 +212,8 @@ fn issue11861() { // Do not lint the next line this_macro_needs_vec!(vec![1]); -this_macro_doesnt_need_vec!([1]); -//~^ useless_vec + this_macro_doesnt_need_vec!([1]); + //~^ useless_vec macro_rules! m { ($x:expr) => { diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index c82580b2fd1a1..a779d33557cb4 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -136,7 +136,7 @@ fn issue11075() { } #[allow(clippy::never_loop)] for _string in vec![repro!(true), repro!(null)] { - //~^ useless_vec + //~^ useless_vec unimplemented!(); } @@ -175,12 +175,12 @@ fn issue11075() { #[clippy::msrv = "1.53"] fn above() { for a in vec![1, 2, 3] { - //~^ useless_vec + //~^ useless_vec let _: usize = a; } for a in vec![String::new(), String::new()] { - //~^ useless_vec + //~^ useless_vec let _: String = a; } } @@ -212,8 +212,8 @@ fn issue11861() { // Do not lint the next line this_macro_needs_vec!(vec![1]); -this_macro_doesnt_need_vec!(vec![1]); -//~^ useless_vec + this_macro_doesnt_need_vec!(vec![1]); + //~^ useless_vec macro_rules! m { ($x:expr) => { diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index 1063e0e37d89f..806d6617200ff 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -116,10 +116,10 @@ LL | for a in vec![String::new(), String::new()] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]` error: useless use of `vec!` - --> tests/ui/vec.rs:215:29 + --> tests/ui/vec.rs:215:33 | -LL | this_macro_doesnt_need_vec!(vec![1]); - | ^^^^^^^ help: you can use an array directly: `[1]` +LL | this_macro_doesnt_need_vec!(vec![1]); + | ^^^^^^^ help: you can use an array directly: `[1]` error: useless use of `vec!` --> tests/ui/vec.rs:242:14 diff --git a/tests/ui/vec_box_sized.rs b/tests/ui/vec_box_sized.rs index d32081c26a03e..897add423b6d4 100644 --- a/tests/ui/vec_box_sized.rs +++ b/tests/ui/vec_box_sized.rs @@ -39,15 +39,15 @@ mod should_trigger { //~^ vec_box fn allocator_global_defined_vec() -> Vec, std::alloc::Global> { - //~^ vec_box + //~^ vec_box Vec::new() } fn allocator_global_defined_box() -> Vec> { - //~^ vec_box + //~^ vec_box Vec::new() } fn allocator_match() -> Vec, DummyAllocator> { - //~^ vec_box + //~^ vec_box Vec::new_in(DummyAllocator) } } @@ -85,7 +85,7 @@ mod inner_mod { use super::inner::S; pub fn f() -> Vec> { - //~^ vec_box + //~^ vec_box vec![] } } diff --git a/tests/ui/vec_init_then_push.rs b/tests/ui/vec_init_then_push.rs index 31cd84d2cf40d..a32187edfea61 100644 --- a/tests/ui/vec_init_then_push.rs +++ b/tests/ui/vec_init_then_push.rs @@ -5,7 +5,6 @@ fn main() { let mut def_err: Vec = Default::default(); //~^ vec_init_then_push - def_err.push(0); let mut new_err = Vec::::new(); diff --git a/tests/ui/vec_init_then_push.stderr b/tests/ui/vec_init_then_push.stderr index 3be277bb07b9d..1900ad7bd6a0e 100644 --- a/tests/ui/vec_init_then_push.stderr +++ b/tests/ui/vec_init_then_push.stderr @@ -10,7 +10,7 @@ LL | | def_err.push(0); = help: to override `-D warnings` add `#[allow(clippy::vec_init_then_push)]` error: calls to `push` immediately after creation - --> tests/ui/vec_init_then_push.rs:11:5 + --> tests/ui/vec_init_then_push.rs:10:5 | LL | / let mut new_err = Vec::::new(); ... | @@ -18,7 +18,7 @@ LL | | new_err.push(1); | |____________________^ help: consider using the `vec![]` macro: `let mut new_err = vec![..];` error: calls to `push` immediately after creation - --> tests/ui/vec_init_then_push.rs:16:5 + --> tests/ui/vec_init_then_push.rs:15:5 | LL | / let mut cap_err = Vec::with_capacity(2); LL | | @@ -29,7 +29,7 @@ LL | | cap_err.push(2); | |____________________^ help: consider using the `vec![]` macro: `let mut cap_err = vec![..];` error: calls to `push` immediately after creation - --> tests/ui/vec_init_then_push.rs:30:5 + --> tests/ui/vec_init_then_push.rs:29:5 | LL | / new_err = Vec::new(); ... | @@ -37,7 +37,7 @@ LL | | new_err.push(0); | |____________________^ help: consider using the `vec![]` macro: `new_err = vec![..];` error: calls to `push` immediately after creation - --> tests/ui/vec_init_then_push.rs:82:5 + --> tests/ui/vec_init_then_push.rs:81:5 | LL | / let mut v = Vec::new(); LL | | @@ -47,7 +47,7 @@ LL | | v.push(1); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` error: calls to `push` immediately after creation - --> tests/ui/vec_init_then_push.rs:92:5 + --> tests/ui/vec_init_then_push.rs:91:5 | LL | / let mut v = Vec::new(); LL | | @@ -59,7 +59,7 @@ LL | | v.push(0); | |______________^ help: consider using the `vec![]` macro: `let mut v = vec![..];` error: calls to `push` immediately after creation - --> tests/ui/vec_init_then_push.rs:107:5 + --> tests/ui/vec_init_then_push.rs:106:5 | LL | / let mut v2 = Vec::new(); LL | | @@ -71,7 +71,7 @@ LL | | v2.push(0); | |_______________^ help: consider using the `vec![]` macro: `let mut v2 = vec![..];` error: calls to `push` immediately after creation - --> tests/ui/vec_init_then_push.rs:124:5 + --> tests/ui/vec_init_then_push.rs:123:5 | LL | / let mut v = Vec::new(); ... | diff --git a/tests/ui/vec_resize_to_zero.fixed b/tests/ui/vec_resize_to_zero.fixed index f5c0ecd72e001..260943f655e3e 100644 --- a/tests/ui/vec_resize_to_zero.fixed +++ b/tests/ui/vec_resize_to_zero.fixed @@ -7,7 +7,6 @@ fn main() { v.clear(); //~^ vec_resize_to_zero - // not applicable v.resize(2, 5); diff --git a/tests/ui/vec_resize_to_zero.rs b/tests/ui/vec_resize_to_zero.rs index 2b75b475223ce..d6054715143c0 100644 --- a/tests/ui/vec_resize_to_zero.rs +++ b/tests/ui/vec_resize_to_zero.rs @@ -7,7 +7,6 @@ fn main() { v.resize(0, 5); //~^ vec_resize_to_zero - // not applicable v.resize(2, 5); diff --git a/tests/ui/while_float.rs b/tests/ui/while_float.rs index 06dc700c19804..727b954ffcca8 100644 --- a/tests/ui/while_float.rs +++ b/tests/ui/while_float.rs @@ -2,11 +2,11 @@ fn main() { let mut x = 0.0_f32; while x < 42.0_f32 { - //~^ while_float + //~^ while_float x += 0.5; } while x < 42.0 { - //~^ while_float + //~^ while_float x += 1.0; } let mut x = 0; diff --git a/tests/ui/while_let_loop.rs b/tests/ui/while_let_loop.rs index ea442b9b2b5c6..d591ab984cfaf 100644 --- a/tests/ui/while_let_loop.rs +++ b/tests/ui/while_let_loop.rs @@ -4,8 +4,7 @@ fn main() { let y = Some(true); loop { - //~^ while_let_loop - + //~^ while_let_loop if let Some(_x) = y { let _v = 1; @@ -24,7 +23,7 @@ fn main() { } loop { - //~^ while_let_loop + //~^ while_let_loop match y { Some(_x) => true, @@ -33,7 +32,7 @@ fn main() { } loop { - //~^ while_let_loop + //~^ while_let_loop let x = match y { Some(x) => x, @@ -44,7 +43,7 @@ fn main() { } loop { - //~^ while_let_loop + //~^ while_let_loop let x = match y { Some(x) => x, @@ -76,7 +75,7 @@ fn main() { // #675, this used to have a wrong suggestion loop { - //~^ while_let_loop + //~^ while_let_loop let (e, l) = match "".split_whitespace().next() { Some(word) => (word.is_empty(), word.len()), diff --git a/tests/ui/while_let_loop.stderr b/tests/ui/while_let_loop.stderr index 3bd8ab85a92f0..bd482857e675a 100644 --- a/tests/ui/while_let_loop.stderr +++ b/tests/ui/while_let_loop.stderr @@ -2,6 +2,9 @@ error: this loop could be written as a `while let` loop --> tests/ui/while_let_loop.rs:6:5 | LL | / loop { +LL | | +LL | | +LL | | if let Some(_x) = y { ... | LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` @@ -10,7 +13,7 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::while_let_loop)]` error: this loop could be written as a `while let` loop - --> tests/ui/while_let_loop.rs:26:5 + --> tests/ui/while_let_loop.rs:25:5 | LL | / loop { LL | | @@ -22,7 +25,7 @@ LL | | } | |_____^ help: try: `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop - --> tests/ui/while_let_loop.rs:35:5 + --> tests/ui/while_let_loop.rs:34:5 | LL | / loop { LL | | @@ -34,7 +37,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> tests/ui/while_let_loop.rs:46:5 + --> tests/ui/while_let_loop.rs:45:5 | LL | / loop { LL | | @@ -45,7 +48,7 @@ LL | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> tests/ui/while_let_loop.rs:78:5 + --> tests/ui/while_let_loop.rs:77:5 | LL | / loop { LL | | diff --git a/tests/ui/while_let_on_iterator.fixed b/tests/ui/while_let_on_iterator.fixed index bf4950620340e..f9ccefab5898d 100644 --- a/tests/ui/while_let_on_iterator.fixed +++ b/tests/ui/while_let_on_iterator.fixed @@ -13,13 +13,13 @@ fn base() { let mut iter = 1..20; for x in iter { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } let mut iter = 1..20; for x in iter { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } @@ -124,7 +124,7 @@ fn refutable2() { let v = vec![[1], [2], [3]]; let mut it = v.iter(); for x @ [_] in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{:?}", x); } } @@ -145,7 +145,7 @@ fn nested_loops() { loop { let mut y = a.iter(); for _ in y { - //~^ while_let_on_iterator + //~^ while_let_on_iterator // use a for loop here } } @@ -203,7 +203,7 @@ fn issue6491() { let mut it = 1..40; while let Some(n) = it.next() { for m in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -215,10 +215,10 @@ fn issue6491() { // This is fine, inner loop uses a new iterator. let mut it = 1..40; for n in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator let mut it = 1..40; for m in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -228,7 +228,7 @@ fn issue6491() { // Weird binding shouldn't change anything. let (mut it, _) = (1..40, 0); for m in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -238,7 +238,7 @@ fn issue6491() { // Used after the loop, needs &mut. let mut it = 1..40; for m in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -256,7 +256,7 @@ fn issue6231() { let mut opt = Some(0); while let Some(n) = opt.take().or_else(|| it.next()) { for m in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if n % 10 == 0 { break; } @@ -272,7 +272,7 @@ fn issue1924() { fn f(&mut self) -> Option { // Used as a field. for i in self.0.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if !(3..8).contains(&i) { return Some(i); } @@ -305,7 +305,7 @@ fn issue1924() { } // This one is fine, a different field is borrowed for i in self.0.0.0.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if i == 1 { return self.0.1.take(); } else { @@ -335,7 +335,7 @@ fn issue1924() { // Needs &mut, field of the iterator is accessed after the loop let mut it = S2(1..40, 0); for n in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if n == 0 { break; } @@ -348,7 +348,7 @@ fn issue7249() { let mut x = || { // Needs &mut, the closure can be called multiple times for x in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -363,7 +363,7 @@ fn issue7510() { let it = &mut it; // Needs to reborrow `it` as the binding isn't mutable for x in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -375,7 +375,7 @@ fn issue7510() { let it = S(&mut it); // Needs to reborrow `it.0` as the binding isn't mutable for x in it.0.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -411,7 +411,7 @@ fn custom_deref() { let mut s = S2(S1 { x: 0..10 }); for x in s.x.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } } @@ -419,7 +419,7 @@ fn custom_deref() { fn issue_8113() { let mut x = [0..10]; for x in x[0].by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } } @@ -428,7 +428,7 @@ fn fn_once_closure() { let mut it = 0..10; (|| { for x in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -439,7 +439,7 @@ fn fn_once_closure() { let mut it = 0..10; f(|| { for x in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -450,7 +450,7 @@ fn fn_once_closure() { let mut it = 0..10; f2(|| { for x in it.by_ref() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -461,7 +461,7 @@ fn fn_once_closure() { f3(|| { let mut it = 0..10; for x in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -474,7 +474,7 @@ fn fn_once_closure() { let mut it = 0..10; f4(|| { for x in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -485,7 +485,7 @@ fn fn_once_closure() { fn issue13123() { let mut it = 0..20; 'label: for n in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if n % 25 == 0 { break 'label; } @@ -495,7 +495,7 @@ fn issue13123() { fn main() { let mut it = 0..20; for _ in it { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("test"); } } diff --git a/tests/ui/while_let_on_iterator.rs b/tests/ui/while_let_on_iterator.rs index d34b78efc706b..f957f2e5a5238 100644 --- a/tests/ui/while_let_on_iterator.rs +++ b/tests/ui/while_let_on_iterator.rs @@ -13,13 +13,13 @@ fn base() { let mut iter = 1..20; while let Option::Some(x) = iter.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } let mut iter = 1..20; while let Some(x) = iter.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } @@ -124,7 +124,7 @@ fn refutable2() { let v = vec![[1], [2], [3]]; let mut it = v.iter(); while let Some(x @ [_]) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{:?}", x); } } @@ -145,7 +145,7 @@ fn nested_loops() { loop { let mut y = a.iter(); while let Some(_) = y.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator // use a for loop here } } @@ -203,7 +203,7 @@ fn issue6491() { let mut it = 1..40; while let Some(n) = it.next() { while let Some(m) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -215,10 +215,10 @@ fn issue6491() { // This is fine, inner loop uses a new iterator. let mut it = 1..40; while let Some(n) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator let mut it = 1..40; while let Some(m) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -228,7 +228,7 @@ fn issue6491() { // Weird binding shouldn't change anything. let (mut it, _) = (1..40, 0); while let Some(m) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -238,7 +238,7 @@ fn issue6491() { // Used after the loop, needs &mut. let mut it = 1..40; while let Some(m) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if m % 10 == 0 { break; } @@ -256,7 +256,7 @@ fn issue6231() { let mut opt = Some(0); while let Some(n) = opt.take().or_else(|| it.next()) { while let Some(m) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if n % 10 == 0 { break; } @@ -272,7 +272,7 @@ fn issue1924() { fn f(&mut self) -> Option { // Used as a field. while let Some(i) = self.0.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if !(3..8).contains(&i) { return Some(i); } @@ -305,7 +305,7 @@ fn issue1924() { } // This one is fine, a different field is borrowed while let Some(i) = self.0.0.0.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if i == 1 { return self.0.1.take(); } else { @@ -335,7 +335,7 @@ fn issue1924() { // Needs &mut, field of the iterator is accessed after the loop let mut it = S2(1..40, 0); while let Some(n) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if n == 0 { break; } @@ -348,7 +348,7 @@ fn issue7249() { let mut x = || { // Needs &mut, the closure can be called multiple times while let Some(x) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -363,7 +363,7 @@ fn issue7510() { let it = &mut it; // Needs to reborrow `it` as the binding isn't mutable while let Some(x) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -375,7 +375,7 @@ fn issue7510() { let it = S(&mut it); // Needs to reborrow `it.0` as the binding isn't mutable while let Some(x) = it.0.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -411,7 +411,7 @@ fn custom_deref() { let mut s = S2(S1 { x: 0..10 }); while let Some(x) = s.x.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } } @@ -419,7 +419,7 @@ fn custom_deref() { fn issue_8113() { let mut x = [0..10]; while let Some(x) = x[0].next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("{}", x); } } @@ -428,7 +428,7 @@ fn fn_once_closure() { let mut it = 0..10; (|| { while let Some(x) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -439,7 +439,7 @@ fn fn_once_closure() { let mut it = 0..10; f(|| { while let Some(x) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -450,7 +450,7 @@ fn fn_once_closure() { let mut it = 0..10; f2(|| { while let Some(x) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -461,7 +461,7 @@ fn fn_once_closure() { f3(|| { let mut it = 0..10; while let Some(x) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -474,7 +474,7 @@ fn fn_once_closure() { let mut it = 0..10; f4(|| { while let Some(x) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if x % 2 == 0 { break; } @@ -485,7 +485,7 @@ fn fn_once_closure() { fn issue13123() { let mut it = 0..20; 'label: while let Some(n) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator if n % 25 == 0 { break 'label; } @@ -495,7 +495,7 @@ fn issue13123() { fn main() { let mut it = 0..20; while let Some(..) = it.next() { - //~^ while_let_on_iterator + //~^ while_let_on_iterator println!("test"); } } diff --git a/tests/ui/wild_in_or_pats.rs b/tests/ui/wild_in_or_pats.rs index 8d194a38ddf8d..ced13cc50c5d5 100644 --- a/tests/ui/wild_in_or_pats.rs +++ b/tests/ui/wild_in_or_pats.rs @@ -6,7 +6,7 @@ fn main() { dbg!("matched a"); }, "bar" | _ => { - //~^ wildcard_in_or_patterns + //~^ wildcard_in_or_patterns dbg!("matched (bar or) wild"); }, @@ -16,7 +16,7 @@ fn main() { dbg!("matched a"); }, "bar" | "bar2" | _ => { - //~^ wildcard_in_or_patterns + //~^ wildcard_in_or_patterns dbg!("matched (bar or bar2 or) wild"); }, @@ -26,7 +26,7 @@ fn main() { dbg!("matched a"); }, _ | "bar" | _ => { - //~^ wildcard_in_or_patterns + //~^ wildcard_in_or_patterns dbg!("matched (bar or) wild"); }, @@ -36,7 +36,7 @@ fn main() { dbg!("matched a"); }, _ | "bar" => { - //~^ wildcard_in_or_patterns + //~^ wildcard_in_or_patterns dbg!("matched (bar or) wild"); }, @@ -71,7 +71,7 @@ fn main() { dbg!("Change the color"); }, ExhaustiveEnum::Quit | _ => { - //~^ wildcard_in_or_patterns + //~^ wildcard_in_or_patterns dbg!("Quit or other"); }, }; @@ -107,7 +107,7 @@ fn main() { dbg!("On the y axis at {y}"); }, ExhaustiveStruct { x: 1, y: 1 } | _ => { - //~^ wildcard_in_or_patterns + //~^ wildcard_in_or_patterns dbg!("On neither axis: ({x}, {y})"); }, } diff --git a/tests/ui/write_literal.fixed b/tests/ui/write_literal.fixed index b82d77aaa4180..e84f768e33d0c 100644 --- a/tests/ui/write_literal.fixed +++ b/tests/ui/write_literal.fixed @@ -31,7 +31,6 @@ fn main() { write!(v, "Hello world"); //~^ write_literal - writeln!(v, "Hello {} world", world); //~^ write_literal @@ -41,7 +40,6 @@ fn main() { writeln!(v, "a literal {:.4}", 5); //~^ write_literal - // positional args don't change the fact // that we're using a literal -- this should // throw a warning @@ -51,7 +49,6 @@ fn main() { writeln!(v, "world hello"); //~^ write_literal - // named args shouldn't change anything either writeln!(v, "hello world"); //~^ write_literal @@ -59,7 +56,6 @@ fn main() { writeln!(v, "world hello"); //~^ write_literal - // #10128 writeln!(v, "hello {0} world", 2); //~^ write_literal @@ -72,7 +68,6 @@ fn main() { writeln!(v, "hello {0} {1}, world {2}", 2, 3, 4); //~^ write_literal - } fn issue_13959() { diff --git a/tests/ui/write_literal.rs b/tests/ui/write_literal.rs index e9f5990d7ec63..fc29fcbede7e6 100644 --- a/tests/ui/write_literal.rs +++ b/tests/ui/write_literal.rs @@ -31,7 +31,6 @@ fn main() { write!(v, "Hello {}", "world"); //~^ write_literal - writeln!(v, "Hello {} {}", world, "world"); //~^ write_literal @@ -41,7 +40,6 @@ fn main() { writeln!(v, "{} {:.4}", "a literal", 5); //~^ write_literal - // positional args don't change the fact // that we're using a literal -- this should // throw a warning @@ -51,7 +49,6 @@ fn main() { writeln!(v, "{1} {0}", "hello", "world"); //~^ write_literal - // named args shouldn't change anything either writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); //~^ write_literal @@ -59,7 +56,6 @@ fn main() { writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); //~^ write_literal - // #10128 writeln!(v, "{0} {1} {2}", "hello", 2, "world"); //~^ write_literal @@ -72,7 +68,6 @@ fn main() { writeln!(v, "{0} {1} {2}, {3} {4}", "hello", 2, 3, "world", 4); //~^ write_literal - } fn issue_13959() { diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 834162473c589..d53c2a7de2e05 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -13,7 +13,7 @@ LL + write!(v, "Hello world"); | error: literal with an empty format string - --> tests/ui/write_literal.rs:35:39 + --> tests/ui/write_literal.rs:34:39 | LL | writeln!(v, "Hello {} {}", world, "world"); | ^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, "Hello {} world", world); | error: literal with an empty format string - --> tests/ui/write_literal.rs:38:29 + --> tests/ui/write_literal.rs:37:29 | LL | writeln!(v, "Hello {}", "world"); | ^^^^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "Hello world"); | error: literal with an empty format string - --> tests/ui/write_literal.rs:41:29 + --> tests/ui/write_literal.rs:40:29 | LL | writeln!(v, "{} {:.4}", "a literal", 5); | ^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + writeln!(v, "a literal {:.4}", 5); | error: literal with an empty format string - --> tests/ui/write_literal.rs:48:28 + --> tests/ui/write_literal.rs:46:28 | LL | writeln!(v, "{0} {1}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + writeln!(v, "hello world"); | error: literal with an empty format string - --> tests/ui/write_literal.rs:51:28 + --> tests/ui/write_literal.rs:49:28 | LL | writeln!(v, "{1} {0}", "hello", "world"); | ^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + writeln!(v, "world hello"); | error: literal with an empty format string - --> tests/ui/write_literal.rs:56:38 + --> tests/ui/write_literal.rs:53:38 | LL | writeln!(v, "{foo} {bar}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + writeln!(v, "hello world"); | error: literal with an empty format string - --> tests/ui/write_literal.rs:59:38 + --> tests/ui/write_literal.rs:56:38 | LL | writeln!(v, "{bar} {foo}", foo = "hello", bar = "world"); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + writeln!(v, "world hello"); | error: literal with an empty format string - --> tests/ui/write_literal.rs:64:32 + --> tests/ui/write_literal.rs:60:32 | LL | writeln!(v, "{0} {1} {2}", "hello", 2, "world"); | ^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + writeln!(v, "hello {0} world", 2); | error: literal with an empty format string - --> tests/ui/write_literal.rs:67:32 + --> tests/ui/write_literal.rs:63:32 | LL | writeln!(v, "{2} {1} {0}", "hello", 2, "world"); | ^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + writeln!(v, "world {0} hello", 2); | error: literal with an empty format string - --> tests/ui/write_literal.rs:70:39 + --> tests/ui/write_literal.rs:66:39 | LL | writeln!(v, "{0} {1} {2}, {bar}", "hello", 2, 3, bar = 4); | ^^^^^^^ @@ -133,7 +133,7 @@ LL + writeln!(v, "hello {0} {1}, {bar}", 2, 3, bar = 4); | error: literal with an empty format string - --> tests/ui/write_literal.rs:73:41 + --> tests/ui/write_literal.rs:69:41 | LL | writeln!(v, "{0} {1} {2}, {3} {4}", "hello", 2, 3, "world", 4); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +145,7 @@ LL + writeln!(v, "hello {0} {1}, world {2}", 2, 3, 4); | error: literal with an empty format string - --> tests/ui/write_literal.rs:80:23 + --> tests/ui/write_literal.rs:75:23 | LL | writeln!(v, "{}", r#"""#); | ^^^^^^ @@ -157,7 +157,7 @@ LL + writeln!(v, "\""); | error: literal with an empty format string - --> tests/ui/write_literal.rs:85:9 + --> tests/ui/write_literal.rs:80:9 | LL | / r#" LL | | diff --git a/tests/ui/write_literal_2.rs b/tests/ui/write_literal_2.rs index 2edd50c434031..f896782aaf3b5 100644 --- a/tests/ui/write_literal_2.rs +++ b/tests/ui/write_literal_2.rs @@ -10,7 +10,6 @@ fn main() { writeln!(v, "{}", "{hello}"); //~^ write_literal - writeln!(v, r"{}", r"{hello}"); //~^ write_literal @@ -32,14 +31,15 @@ fn main() { "hello \ //~^ write_literal world!", - ); writeln!( v, "some {}\ {} \\ {}", - "1", "2", "3", - //~^ write_literal + "1", + "2", + "3", + //~^^^ write_literal ); writeln!(v, "{}", "\\"); //~^ write_literal diff --git a/tests/ui/write_literal_2.stderr b/tests/ui/write_literal_2.stderr index f3f86586ef850..29803d6a8b185 100644 --- a/tests/ui/write_literal_2.stderr +++ b/tests/ui/write_literal_2.stderr @@ -13,7 +13,7 @@ LL + writeln!(v, "{{hello}}"); | error: literal with an empty format string - --> tests/ui/write_literal_2.rs:14:24 + --> tests/ui/write_literal_2.rs:13:24 | LL | writeln!(v, r"{}", r"{hello}"); | ^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, r"{{hello}}"); | error: literal with an empty format string - --> tests/ui/write_literal_2.rs:17:23 + --> tests/ui/write_literal_2.rs:16:23 | LL | writeln!(v, "{}", '\''); | ^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "'"); | error: literal with an empty format string - --> tests/ui/write_literal_2.rs:20:23 + --> tests/ui/write_literal_2.rs:19:23 | LL | writeln!(v, "{}", '"'); | ^^^ @@ -49,13 +49,13 @@ LL + writeln!(v, "\""); | error: literal with an empty format string - --> tests/ui/write_literal_2.rs:23:24 + --> tests/ui/write_literal_2.rs:22:24 | LL | writeln!(v, r"{}", '"'); | ^^^ error: literal with an empty format string - --> tests/ui/write_literal_2.rs:26:24 + --> tests/ui/write_literal_2.rs:25:24 | LL | writeln!(v, r"{}", '\''); | ^^^^ @@ -67,7 +67,7 @@ LL + writeln!(v, r"'"); | error: literal with an empty format string - --> tests/ui/write_literal_2.rs:32:9 + --> tests/ui/write_literal_2.rs:31:9 | LL | / "hello \ LL | | @@ -82,10 +82,12 @@ LL ~ world!", | error: literal with an empty format string - --> tests/ui/write_literal_2.rs:41:9 + --> tests/ui/write_literal_2.rs:39:9 | -LL | "1", "2", "3", - | ^^^^^^^^^^^^^ +LL | / "1", +LL | | "2", +LL | | "3", + | |___________^ | help: try | diff --git a/tests/ui/write_with_newline.fixed b/tests/ui/write_with_newline.fixed index bd2285d16bcff..40742bbbb4275 100644 --- a/tests/ui/write_with_newline.fixed +++ b/tests/ui/write_with_newline.fixed @@ -12,7 +12,6 @@ fn main() { writeln!(v, "Hello"); //~^ write_with_newline - writeln!(v, "Hello {}", "world"); //~^ write_with_newline @@ -25,7 +24,6 @@ fn main() { writeln!(v); //~^ write_with_newline - // These should be fine write!(v, ""); write!(v, "Hello"); @@ -57,13 +55,11 @@ fn main() { // Literal newlines should also fail writeln!( - //~^ write_with_newline - + //~^ write_with_newline v ); writeln!( - //~^ write_with_newline - + //~^ write_with_newline v ); diff --git a/tests/ui/write_with_newline.rs b/tests/ui/write_with_newline.rs index b70349ae82e64..ad6af69e78137 100644 --- a/tests/ui/write_with_newline.rs +++ b/tests/ui/write_with_newline.rs @@ -12,7 +12,6 @@ fn main() { write!(v, "Hello\n"); //~^ write_with_newline - write!(v, "Hello {}\n", "world"); //~^ write_with_newline @@ -25,7 +24,6 @@ fn main() { write!(v, "\n"); //~^ write_with_newline - // These should be fine write!(v, ""); write!(v, "Hello"); @@ -57,15 +55,13 @@ fn main() { // Literal newlines should also fail write!( - //~^ write_with_newline - + //~^ write_with_newline v, " " ); write!( - //~^ write_with_newline - + //~^ write_with_newline v, r" " diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index 9ab17cfdf3af5..7243b7943df00 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -13,7 +13,7 @@ LL + writeln!(v, "Hello"); | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:16:5 + --> tests/ui/write_with_newline.rs:15:5 | LL | write!(v, "Hello {}\n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + writeln!(v, "Hello {}", "world"); | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:19:5 + --> tests/ui/write_with_newline.rs:18:5 | LL | write!(v, "Hello {} {}\n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL + writeln!(v, "Hello {} {}", "world", "#2"); | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:22:5 + --> tests/ui/write_with_newline.rs:21:5 | LL | write!(v, "{}\n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + writeln!(v, "{}", 1265); | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:25:5 + --> tests/ui/write_with_newline.rs:24:5 | LL | write!(v, "\n"); | ^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + writeln!(v); | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:49:5 + --> tests/ui/write_with_newline.rs:47:5 | LL | write!(v, "\\\n"); | ^^^^^^^^^^^^^^^^^ @@ -73,11 +73,10 @@ LL + writeln!(v, "\\"); | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:59:5 + --> tests/ui/write_with_newline.rs:57:5 | LL | / write!( LL | | -LL | | LL | | v, LL | | " LL | | " @@ -88,16 +87,14 @@ help: use `writeln!` instead | LL ~ writeln!( LL | -LL | LL ~ v | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:66:5 + --> tests/ui/write_with_newline.rs:63:5 | LL | / write!( LL | | -LL | | LL | | v, LL | | r" LL | | " @@ -108,12 +105,11 @@ help: use `writeln!` instead | LL ~ writeln!( LL | -LL | LL ~ v | error: using `write!()` with a format string that ends in a single newline - --> tests/ui/write_with_newline.rs:77:5 + --> tests/ui/write_with_newline.rs:73:5 | LL | write!(v, "\\r\n"); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/wrong_self_convention.rs b/tests/ui/wrong_self_convention.rs index 42d600b67f8e9..840dfe7c6524e 100644 --- a/tests/ui/wrong_self_convention.rs +++ b/tests/ui/wrong_self_convention.rs @@ -16,7 +16,6 @@ impl Foo { fn from_i32(self) {} //~^ wrong_self_convention - pub fn as_i64(self) {} pub fn into_i64(self) {} pub fn is_i64(self) {} @@ -54,7 +53,6 @@ impl Bar { fn from_i32(self) {} //~^ wrong_self_convention - pub fn as_i64(self) {} //~^ wrong_self_convention @@ -70,7 +68,6 @@ impl Bar { pub fn from_i64(self) {} //~^ wrong_self_convention - // test for false positives fn as_(self) {} fn into_(&self) {} @@ -216,7 +213,7 @@ mod issue6727 { } // trigger lint fn to_u64_v2(&self) -> u64 { - //~^ wrong_self_convention + //~^ wrong_self_convention 1 } @@ -227,7 +224,7 @@ mod issue6727 { impl FooNoCopy { // trigger lint fn to_u64(self) -> u64 { - //~^ wrong_self_convention + //~^ wrong_self_convention 2 } diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index fe6d231578b13..e720ddf3fae17 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -9,7 +9,7 @@ LL | fn from_i32(self) {} = help: to override `-D warnings` add `#[allow(clippy::wrong_self_convention)]` error: methods called `from_*` usually take no `self` - --> tests/ui/wrong_self_convention.rs:24:21 + --> tests/ui/wrong_self_convention.rs:23:21 | LL | pub fn from_i64(self) {} | ^^^^ @@ -17,7 +17,7 @@ LL | pub fn from_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> tests/ui/wrong_self_convention.rs:38:15 + --> tests/ui/wrong_self_convention.rs:37:15 | LL | fn as_i32(self) {} | ^^^^ @@ -25,7 +25,7 @@ LL | fn as_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> tests/ui/wrong_self_convention.rs:42:17 + --> tests/ui/wrong_self_convention.rs:41:17 | LL | fn into_i32(&self) {} | ^^^^^ @@ -33,7 +33,7 @@ LL | fn into_i32(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> tests/ui/wrong_self_convention.rs:46:15 + --> tests/ui/wrong_self_convention.rs:45:15 | LL | fn is_i32(self) {} | ^^^^ @@ -41,7 +41,7 @@ LL | fn is_i32(self) {} = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> tests/ui/wrong_self_convention.rs:50:15 + --> tests/ui/wrong_self_convention.rs:49:15 | LL | fn to_i32(self) {} | ^^^^ @@ -49,7 +49,7 @@ LL | fn to_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> tests/ui/wrong_self_convention.rs:54:17 + --> tests/ui/wrong_self_convention.rs:53:17 | LL | fn from_i32(self) {} | ^^^^ @@ -57,7 +57,7 @@ LL | fn from_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> tests/ui/wrong_self_convention.rs:58:19 + --> tests/ui/wrong_self_convention.rs:56:19 | LL | pub fn as_i64(self) {} | ^^^^ @@ -65,7 +65,7 @@ LL | pub fn as_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> tests/ui/wrong_self_convention.rs:61:21 + --> tests/ui/wrong_self_convention.rs:59:21 | LL | pub fn into_i64(&self) {} | ^^^^^ @@ -73,7 +73,7 @@ LL | pub fn into_i64(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> tests/ui/wrong_self_convention.rs:64:19 + --> tests/ui/wrong_self_convention.rs:62:19 | LL | pub fn is_i64(self) {} | ^^^^ @@ -81,7 +81,7 @@ LL | pub fn is_i64(self) {} = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> tests/ui/wrong_self_convention.rs:67:19 + --> tests/ui/wrong_self_convention.rs:65:19 | LL | pub fn to_i64(self) {} | ^^^^ @@ -89,7 +89,7 @@ LL | pub fn to_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> tests/ui/wrong_self_convention.rs:70:21 + --> tests/ui/wrong_self_convention.rs:68:21 | LL | pub fn from_i64(self) {} | ^^^^ @@ -97,7 +97,7 @@ LL | pub fn from_i64(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> tests/ui/wrong_self_convention.rs:117:19 + --> tests/ui/wrong_self_convention.rs:114:19 | LL | fn as_i32(self) {} | ^^^^ @@ -105,7 +105,7 @@ LL | fn as_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> tests/ui/wrong_self_convention.rs:122:25 + --> tests/ui/wrong_self_convention.rs:119:25 | LL | fn into_i32_ref(&self) {} | ^^^^^ @@ -113,7 +113,7 @@ LL | fn into_i32_ref(&self) {} = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> tests/ui/wrong_self_convention.rs:126:19 + --> tests/ui/wrong_self_convention.rs:123:19 | LL | fn is_i32(self) {} | ^^^^ @@ -121,7 +121,7 @@ LL | fn is_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> tests/ui/wrong_self_convention.rs:132:21 + --> tests/ui/wrong_self_convention.rs:129:21 | LL | fn from_i32(self) {} | ^^^^ @@ -129,7 +129,7 @@ LL | fn from_i32(self) {} = help: consider choosing a less ambiguous name error: methods called `as_*` usually take `self` by reference or `self` by mutable reference - --> tests/ui/wrong_self_convention.rs:149:19 + --> tests/ui/wrong_self_convention.rs:146:19 | LL | fn as_i32(self); | ^^^^ @@ -137,7 +137,7 @@ LL | fn as_i32(self); = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> tests/ui/wrong_self_convention.rs:154:25 + --> tests/ui/wrong_self_convention.rs:151:25 | LL | fn into_i32_ref(&self); | ^^^^^ @@ -145,7 +145,7 @@ LL | fn into_i32_ref(&self); = help: consider choosing a less ambiguous name error: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` - --> tests/ui/wrong_self_convention.rs:158:19 + --> tests/ui/wrong_self_convention.rs:155:19 | LL | fn is_i32(self); | ^^^^ @@ -153,7 +153,7 @@ LL | fn is_i32(self); = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> tests/ui/wrong_self_convention.rs:164:21 + --> tests/ui/wrong_self_convention.rs:161:21 | LL | fn from_i32(self); | ^^^^ @@ -161,7 +161,7 @@ LL | fn from_i32(self); = help: consider choosing a less ambiguous name error: methods called `into_*` usually take `self` by value - --> tests/ui/wrong_self_convention.rs:184:25 + --> tests/ui/wrong_self_convention.rs:181:25 | LL | fn into_i32_ref(&self); | ^^^^^ @@ -169,7 +169,7 @@ LL | fn into_i32_ref(&self); = help: consider choosing a less ambiguous name error: methods called `from_*` usually take no `self` - --> tests/ui/wrong_self_convention.rs:192:21 + --> tests/ui/wrong_self_convention.rs:189:21 | LL | fn from_i32(self); | ^^^^ @@ -177,7 +177,7 @@ LL | fn from_i32(self); = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is `Copy`) usually take `self` by value - --> tests/ui/wrong_self_convention.rs:218:22 + --> tests/ui/wrong_self_convention.rs:215:22 | LL | fn to_u64_v2(&self) -> u64 { | ^^^^^ @@ -185,7 +185,7 @@ LL | fn to_u64_v2(&self) -> u64 { = help: consider choosing a less ambiguous name error: methods with the following characteristics: (`to_*` and `self` type is not `Copy`) usually take `self` by reference - --> tests/ui/wrong_self_convention.rs:229:19 + --> tests/ui/wrong_self_convention.rs:226:19 | LL | fn to_u64(self) -> u64 { | ^^^^ diff --git a/tests/ui/wrong_self_convention2.rs b/tests/ui/wrong_self_convention2.rs index 0740af48d7415..0a3e4982a49ac 100644 --- a/tests/ui/wrong_self_convention2.rs +++ b/tests/ui/wrong_self_convention2.rs @@ -52,7 +52,7 @@ mod issue7179 { // lint pub fn from_be_self(self) -> Self { - //~^ wrong_self_convention + //~^ wrong_self_convention S(i32::from_be(self.0)) } @@ -64,7 +64,6 @@ mod issue7179 { // lint fn from_be_self(self) -> Self; //~^ wrong_self_convention - } trait Foo: Sized { diff --git a/tests/ui/wrong_self_conventions_mut.rs b/tests/ui/wrong_self_conventions_mut.rs index 73df332d77cea..eb6f08fff4245 100644 --- a/tests/ui/wrong_self_conventions_mut.rs +++ b/tests/ui/wrong_self_conventions_mut.rs @@ -12,7 +12,7 @@ mod issue6758 { impl Test { // If a method starts with `to_` and not ends with `_mut` it should expect `&self` pub fn to_many(&mut self) -> Option<&mut [T]> { - //~^ wrong_self_convention + //~^ wrong_self_convention match self { Self::Many(data) => Some(data), @@ -22,7 +22,7 @@ mod issue6758 { // If a method starts with `to_` and ends with `_mut` it should expect `&mut self` pub fn to_many_mut(&self) -> Option<&[T]> { - //~^ wrong_self_convention + //~^ wrong_self_convention match self { Self::Many(data) => Some(data), diff --git a/tests/ui/zero_offset.rs b/tests/ui/zero_offset.rs index dd2063ee5d9e0..bedb09536c538 100644 --- a/tests/ui/zero_offset.rs +++ b/tests/ui/zero_offset.rs @@ -5,7 +5,6 @@ fn main() { m.offset(0); //~^ zst_offset - m.wrapping_add(0); //~^ zst_offset @@ -15,7 +14,6 @@ fn main() { m.wrapping_sub(0); //~^ zst_offset - let c = &() as *const (); c.offset(0); //~^ zst_offset @@ -29,7 +27,6 @@ fn main() { c.wrapping_sub(0); //~^ zst_offset - let sized = &1 as *const i32; sized.offset(0); } diff --git a/tests/ui/zero_offset.stderr b/tests/ui/zero_offset.stderr index 4dfde7d4e1b08..b69c7b92d56a6 100644 --- a/tests/ui/zero_offset.stderr +++ b/tests/ui/zero_offset.stderr @@ -7,43 +7,43 @@ LL | m.offset(0); = note: `#[deny(clippy::zst_offset)]` on by default error: offset calculation on zero-sized value - --> tests/ui/zero_offset.rs:9:9 + --> tests/ui/zero_offset.rs:8:9 | LL | m.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> tests/ui/zero_offset.rs:12:9 + --> tests/ui/zero_offset.rs:11:9 | LL | m.sub(0); | ^^^^^^^^ error: offset calculation on zero-sized value - --> tests/ui/zero_offset.rs:15:9 + --> tests/ui/zero_offset.rs:14:9 | LL | m.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> tests/ui/zero_offset.rs:20:9 + --> tests/ui/zero_offset.rs:18:9 | LL | c.offset(0); | ^^^^^^^^^^^ error: offset calculation on zero-sized value - --> tests/ui/zero_offset.rs:23:9 + --> tests/ui/zero_offset.rs:21:9 | LL | c.wrapping_add(0); | ^^^^^^^^^^^^^^^^^ error: offset calculation on zero-sized value - --> tests/ui/zero_offset.rs:26:9 + --> tests/ui/zero_offset.rs:24:9 | LL | c.sub(0); | ^^^^^^^^ error: offset calculation on zero-sized value - --> tests/ui/zero_offset.rs:29:9 + --> tests/ui/zero_offset.rs:27:9 | LL | c.wrapping_sub(0); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/zero_sized_btreemap_values.rs b/tests/ui/zero_sized_btreemap_values.rs index ddcfce672bf9f..cdeea15f28bc8 100644 --- a/tests/ui/zero_sized_btreemap_values.rs +++ b/tests/ui/zero_sized_btreemap_values.rs @@ -5,32 +5,26 @@ const CONST_OK: Option> = None; const CONST_NOT_OK: Option> = None; //~^ zero_sized_map_values - static STATIC_OK: Option> = None; static STATIC_NOT_OK: Option> = None; //~^ zero_sized_map_values - type OkMap = BTreeMap; type NotOkMap = BTreeMap; //~^ zero_sized_map_values - enum TestEnum { Ok(BTreeMap), NotOk(BTreeMap), //~^ zero_sized_map_values - } struct Test { ok: BTreeMap, not_ok: BTreeMap, //~^ zero_sized_map_values - also_not_ok: Vec>, //~^ zero_sized_map_values - } trait TestTrait { @@ -40,7 +34,6 @@ trait TestTrait { fn weird_map(&self, map: BTreeMap); //~^ zero_sized_map_values - } impl Test { @@ -49,7 +42,7 @@ impl Test { } fn not_ok(&self) -> BTreeMap { - //~^ zero_sized_map_values + //~^ zero_sized_map_values todo!() } @@ -68,9 +61,8 @@ impl TestTrait for Test { } fn test(map: BTreeMap, key: &str) -> BTreeMap { -//~^ zero_sized_map_values -//~| zero_sized_map_values - + //~^ zero_sized_map_values + //~| zero_sized_map_values todo!(); } @@ -84,10 +76,8 @@ fn main() { //~^ zero_sized_map_values //~| zero_sized_map_values - let _: BTreeMap = BTreeMap::new(); let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect(); //~^ zero_sized_map_values - } diff --git a/tests/ui/zero_sized_btreemap_values.stderr b/tests/ui/zero_sized_btreemap_values.stderr index f9184dc9ae1f4..40acb0b211f7f 100644 --- a/tests/ui/zero_sized_btreemap_values.stderr +++ b/tests/ui/zero_sized_btreemap_values.stderr @@ -9,7 +9,7 @@ LL | const CONST_NOT_OK: Option> = None; = help: to override `-D warnings` add `#[allow(clippy::zero_sized_map_values)]` error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:10:30 + --> tests/ui/zero_sized_btreemap_values.rs:9:30 | LL | static STATIC_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static STATIC_NOT_OK: Option> = None; = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:15:17 + --> tests/ui/zero_sized_btreemap_values.rs:13:17 | LL | type NotOkMap = BTreeMap; | ^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type NotOkMap = BTreeMap; = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:21:11 + --> tests/ui/zero_sized_btreemap_values.rs:18:11 | LL | NotOk(BTreeMap), | ^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | NotOk(BTreeMap), = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:28:13 + --> tests/ui/zero_sized_btreemap_values.rs:24:13 | LL | not_ok: BTreeMap, | ^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | not_ok: BTreeMap, = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:31:22 + --> tests/ui/zero_sized_btreemap_values.rs:26:22 | LL | also_not_ok: Vec>, | ^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | also_not_ok: Vec>, = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:41:30 + --> tests/ui/zero_sized_btreemap_values.rs:35:30 | LL | fn weird_map(&self, map: BTreeMap); | ^^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn weird_map(&self, map: BTreeMap); = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:51:25 + --> tests/ui/zero_sized_btreemap_values.rs:44:25 | LL | fn not_ok(&self) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn not_ok(&self) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:70:14 + --> tests/ui/zero_sized_btreemap_values.rs:63:14 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:70:50 + --> tests/ui/zero_sized_btreemap_values.rs:63:50 | LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { | ^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | fn test(map: BTreeMap, key: &str) -> BTreeMap { = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:83:35 + --> tests/ui/zero_sized_btreemap_values.rs:75:35 | LL | let _: BTreeMap = BTreeMap::new(); | ^^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: BTreeMap = BTreeMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:83:12 + --> tests/ui/zero_sized_btreemap_values.rs:75:12 | LL | let _: BTreeMap = BTreeMap::new(); | ^^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _: BTreeMap = BTreeMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_btreemap_values.rs:90:12 + --> tests/ui/zero_sized_btreemap_values.rs:81:12 | LL | let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect(); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/zero_sized_hashmap_values.rs b/tests/ui/zero_sized_hashmap_values.rs index 132716da3b279..4beeef421f30e 100644 --- a/tests/ui/zero_sized_hashmap_values.rs +++ b/tests/ui/zero_sized_hashmap_values.rs @@ -5,32 +5,26 @@ const CONST_OK: Option> = None; const CONST_NOT_OK: Option> = None; //~^ zero_sized_map_values - static STATIC_OK: Option> = None; static STATIC_NOT_OK: Option> = None; //~^ zero_sized_map_values - type OkMap = HashMap; type NotOkMap = HashMap; //~^ zero_sized_map_values - enum TestEnum { Ok(HashMap), NotOk(HashMap), //~^ zero_sized_map_values - } struct Test { ok: HashMap, not_ok: HashMap, //~^ zero_sized_map_values - also_not_ok: Vec>, //~^ zero_sized_map_values - } trait TestTrait { @@ -40,7 +34,6 @@ trait TestTrait { fn weird_map(&self, map: HashMap); //~^ zero_sized_map_values - } impl Test { @@ -49,7 +42,7 @@ impl Test { } fn not_ok(&self) -> HashMap { - //~^ zero_sized_map_values + //~^ zero_sized_map_values todo!() } @@ -68,9 +61,8 @@ impl TestTrait for Test { } fn test(map: HashMap, key: &str) -> HashMap { -//~^ zero_sized_map_values -//~| zero_sized_map_values - + //~^ zero_sized_map_values + //~| zero_sized_map_values todo!(); } @@ -84,10 +76,8 @@ fn main() { //~^ zero_sized_map_values //~| zero_sized_map_values - let _: HashMap = HashMap::new(); let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect(); //~^ zero_sized_map_values - } diff --git a/tests/ui/zero_sized_hashmap_values.stderr b/tests/ui/zero_sized_hashmap_values.stderr index 059902047b55f..ed8536acfe8fa 100644 --- a/tests/ui/zero_sized_hashmap_values.stderr +++ b/tests/ui/zero_sized_hashmap_values.stderr @@ -9,7 +9,7 @@ LL | const CONST_NOT_OK: Option> = None; = help: to override `-D warnings` add `#[allow(clippy::zero_sized_map_values)]` error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:10:30 + --> tests/ui/zero_sized_hashmap_values.rs:9:30 | LL | static STATIC_NOT_OK: Option> = None; | ^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | static STATIC_NOT_OK: Option> = None; = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:15:17 + --> tests/ui/zero_sized_hashmap_values.rs:13:17 | LL | type NotOkMap = HashMap; | ^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | type NotOkMap = HashMap; = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:21:11 + --> tests/ui/zero_sized_hashmap_values.rs:18:11 | LL | NotOk(HashMap), | ^^^^^^^^^^^^^^^^^^^ @@ -33,7 +33,7 @@ LL | NotOk(HashMap), = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:28:13 + --> tests/ui/zero_sized_hashmap_values.rs:24:13 | LL | not_ok: HashMap, | ^^^^^^^^^^^^^^^^^^^ @@ -41,7 +41,7 @@ LL | not_ok: HashMap, = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:31:22 + --> tests/ui/zero_sized_hashmap_values.rs:26:22 | LL | also_not_ok: Vec>, | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | also_not_ok: Vec>, = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:41:30 + --> tests/ui/zero_sized_hashmap_values.rs:35:30 | LL | fn weird_map(&self, map: HashMap); | ^^^^^^^^^^^^^^^^^^ @@ -57,7 +57,7 @@ LL | fn weird_map(&self, map: HashMap); = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:51:25 + --> tests/ui/zero_sized_hashmap_values.rs:44:25 | LL | fn not_ok(&self) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | fn not_ok(&self) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:70:14 + --> tests/ui/zero_sized_hashmap_values.rs:63:14 | LL | fn test(map: HashMap, key: &str) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:70:49 + --> tests/ui/zero_sized_hashmap_values.rs:63:49 | LL | fn test(map: HashMap, key: &str) -> HashMap { | ^^^^^^^^^^^^^^^^^^^ @@ -81,7 +81,7 @@ LL | fn test(map: HashMap, key: &str) -> HashMap { = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:83:34 + --> tests/ui/zero_sized_hashmap_values.rs:75:34 | LL | let _: HashMap = HashMap::new(); | ^^^^^^^ @@ -89,7 +89,7 @@ LL | let _: HashMap = HashMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:83:12 + --> tests/ui/zero_sized_hashmap_values.rs:75:12 | LL | let _: HashMap = HashMap::new(); | ^^^^^^^^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL | let _: HashMap = HashMap::new(); = help: consider using a set instead error: map with zero-sized value type - --> tests/ui/zero_sized_hashmap_values.rs:90:12 + --> tests/ui/zero_sized_hashmap_values.rs:81:12 | LL | let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect(); | ^^^^^^^^^^^^^