From 1218145bc9490ca156cc7a26e922c86c2afe67f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 9 Dec 2018 22:06:29 +0100 Subject: [PATCH 1/7] base tests: assert that tests are properly formatted. --- ci/base-tests.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ci/base-tests.sh b/ci/base-tests.sh index 2537f157ad98..6eeab6671cb6 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -27,3 +27,16 @@ cd clippy_dev && cargo test && cd .. # Perform various checks for lint registration ./util/dev update_lints --check cargo +nightly fmt --all -- --check + +# make sure tests are formatted + +# some lints are sensitive to formatting, exclude some files +needs_formatting=false +for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do +rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true +done + +if $needs_reformatting + "Tests need reformatting!" + exit 2 +fi From 435299be3062c67dc3c61b36c5e30bbfa876ee1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 9 Dec 2018 23:26:16 +0100 Subject: [PATCH 2/7] rustfmt tests --- tests/auxiliary/test_macro.rs | 1 - tests/run-pass/associated-constant-ice.rs | 1 - tests/run-pass/cc_seme.rs | 8 +- tests/run-pass/enum-glob-import-crate.rs | 5 +- tests/run-pass/ice-1588.rs | 9 +- tests/run-pass/ice-1782.rs | 16 +- tests/run-pass/ice-1969.rs | 5 +- tests/run-pass/ice-2499.rs | 17 +- tests/run-pass/ice-2594.rs | 3 +- tests/run-pass/ice-2727.rs | 1 - tests/run-pass/ice-2760.rs | 11 +- tests/run-pass/ice-2774.rs | 11 +- tests/run-pass/ice-2865.rs | 3 +- tests/run-pass/ice-3151.rs | 5 +- tests/run-pass/ice-700.rs | 3 - tests/run-pass/ice_exacte_size.rs | 3 - tests/run-pass/if_same_then_else.rs | 3 - tests/run-pass/issue-2862.rs | 1 - tests/run-pass/issue-825.rs | 17 +- tests/run-pass/issues_loop_mut_cond.rs | 1 - tests/run-pass/match_same_arms_const.rs | 5 +- tests/run-pass/mut_mut_macro.rs | 3 - tests/run-pass/needless_borrow_fp.rs | 8 +- .../run-pass/needless_lifetimes_impl_trait.rs | 3 - tests/run-pass/procedural_macro.rs | 4 +- tests/run-pass/regressions.rs | 3 - tests/run-pass/returns.rs | 7 +- tests/run-pass/single-match-else.rs | 3 - .../run-pass/used_underscore_binding_macro.rs | 3 - tests/run-pass/whitelist/conf_whitelisted.rs | 1 - tests/ui-toml/bad_toml/conf_bad_toml.rs | 4 - tests/ui-toml/bad_toml_type/conf_bad_type.rs | 7 +- .../conf_french_blacklisted_name.rs | 4 - tests/ui-toml/toml_trivially_copy/test.rs | 8 +- .../toml_unknown_key/conf_unknown_key.rs | 4 - tests/ui/absurd-extreme-comparisons.rs | 8 +- tests/ui/approx_const.rs | 4 - tests/ui/arithmetic.rs | 9 +- tests/ui/assign_ops.rs | 3 - tests/ui/assign_ops2.rs | 6 - tests/ui/attrs.rs | 23 +-- tests/ui/author.rs | 4 - tests/ui/author/call.rs | 3 - tests/ui/author/for_loop.rs | 1 - tests/ui/author/matches.rs | 1 - tests/ui/bit_masks.rs | 15 +- tests/ui/blacklisted_name.rs | 13 +- tests/ui/block_in_if_condition.rs | 49 ++--- tests/ui/bool_comparison.rs | 52 +++-- tests/ui/booleans.rs | 55 ++++-- tests/ui/borrow_box.rs | 12 +- tests/ui/box_vec.rs | 11 +- tests/ui/builtin-type-shadow.rs | 6 +- tests/ui/bytecount.rs | 4 - tests/ui/cast.rs | 14 +- tests/ui/cast_alignment.rs | 3 - tests/ui/cast_lossless_float.rs | 3 - tests/ui/cast_lossless_integer.rs | 2 - tests/ui/cast_size.rs | 11 +- tests/ui/char_lit_as_u8.rs | 4 - tests/ui/checked_unwrap.rs | 7 +- tests/ui/clone_on_copy_impl.rs | 3 +- tests/ui/clone_on_copy_mut.rs | 3 - tests/ui/cmp_nan.rs | 4 - tests/ui/cmp_null.rs | 7 +- tests/ui/cmp_owned.rs | 6 +- tests/ui/collapsible_if.rs | 1 - tests/ui/complex_types.rs | 16 +- tests/ui/const_static_lifetime.rs | 1 - tests/ui/copies.rs | 181 ++++++++---------- tests/ui/copy_iterator.rs | 3 - tests/ui/cstring.rs | 3 - tests/ui/cyclomatic_complexity.rs | 15 +- tests/ui/cyclomatic_complexity_attr_used.rs | 3 - tests/ui/decimal_literal_representation.rs | 26 ++- tests/ui/default_trait_access.rs | 5 +- tests/ui/deprecated.rs | 8 - tests/ui/derive.rs | 40 ++-- tests/ui/diverging_sub_expression.rs | 12 +- tests/ui/dlist.rs | 11 +- tests/ui/double_comparison.rs | 1 - tests/ui/double_neg.rs | 4 - tests/ui/drop_forget_copy.rs | 23 ++- tests/ui/drop_forget_ref.rs | 4 - tests/ui/duplicate_underscore_argument.rs | 4 - tests/ui/duration_subsec.rs | 3 - tests/ui/else_if_without_else.rs | 21 +- tests/ui/empty_enum.rs | 7 +- tests/ui/entry.rs | 53 +++-- tests/ui/enum_glob_use.rs | 6 +- tests/ui/enum_variants.rs | 16 +- tests/ui/enums_clike.rs | 8 +- tests/ui/erasing_op.rs | 4 - tests/ui/escape_analysis.rs | 24 +-- tests/ui/eta.rs | 31 ++- tests/ui/eval_order_dependence.rs | 98 ++++++++-- tests/ui/excessive_precision.rs | 2 - tests/ui/expect_fun_call.rs | 4 +- tests/ui/explicit_counter_loop.rs | 6 +- tests/ui/explicit_write.rs | 4 - tests/ui/fallible_impl_from.rs | 5 - tests/ui/filter_methods.rs | 42 ++-- tests/ui/float_cmp.rs | 34 ++-- tests/ui/float_cmp_const.rs | 10 +- tests/ui/fn_to_numeric_cast.rs | 6 +- tests/ui/for_loop.rs | 18 +- tests/ui/formatting.rs | 97 ++++------ tests/ui/functions.rs | 19 +- tests/ui/fxhash.rs | 5 +- tests/ui/get_unwrap.rs | 18 +- tests/ui/ice-2636.rs | 1 - tests/ui/identity_conversion.rs | 3 - tests/ui/identity_op.rs | 31 +-- tests/ui/if_not_else.rs | 7 +- tests/ui/impl.rs | 3 - tests/ui/implicit_hasher.rs | 19 +- tests/ui/implicit_return.rs | 12 +- tests/ui/inconsistent_digit_grouping.rs | 13 +- tests/ui/indexing_slicing.rs | 3 - tests/ui/infallible_destructuring_match.rs | 3 - tests/ui/infinite_iter.rs | 27 ++- tests/ui/infinite_loop.rs | 31 +-- tests/ui/inline_fn_without_body.rs | 13 +- tests/ui/int_plus_one.rs | 4 - tests/ui/into_iter_on_ref.rs | 18 +- tests/ui/invalid_ref.rs | 28 ++- tests/ui/invalid_upcast_comparisons.rs | 19 +- tests/ui/issue-3145.rs | 1 - tests/ui/issue_2356.rs | 3 - tests/ui/item_after_statement.rs | 19 +- tests/ui/large_digit_groups.rs | 23 ++- tests/ui/large_enum_variant.rs | 4 - tests/ui/len_zero.rs | 3 - tests/ui/let_if_seq.rs | 22 ++- tests/ui/let_return.rs | 7 +- tests/ui/let_unit.rs | 10 +- tests/ui/lifetimes.rs | 171 ++++++++++++----- tests/ui/lint_without_lint_pass.rs | 4 +- tests/ui/map_clone.rs | 2 - tests/ui/map_flatten.rs | 2 - tests/ui/match_bool.rs | 28 ++- tests/ui/match_overlapping_arm.rs | 30 +-- tests/ui/matches.rs | 51 +++-- tests/ui/mem_discriminant.rs | 5 +- tests/ui/mem_forget.rs | 9 +- tests/ui/mem_replace.rs | 2 - tests/ui/min_max.rs | 10 +- tests/ui/missing-doc.rs | 36 ++-- tests/ui/missing_inline.rs | 15 +- tests/ui/module_inception.rs | 6 +- tests/ui/modulo_one.rs | 3 - tests/ui/mut_from_ref.rs | 3 - tests/ui/mut_mut.rs | 21 +- tests/ui/mut_range_bound.rs | 30 +-- tests/ui/mut_reference.rs | 11 +- tests/ui/mutex_atomic.rs | 4 - tests/ui/needless_bool.rs | 84 ++++++-- tests/ui/needless_borrow.rs | 5 +- tests/ui/needless_borrowed_ref.rs | 8 +- tests/ui/needless_collect.rs | 5 +- tests/ui/needless_continue.rs | 16 +- tests/ui/needless_pass_by_value.rs | 28 +-- tests/ui/needless_pass_by_value_proc_macro.rs | 7 +- tests/ui/needless_range_loop.rs | 7 +- tests/ui/needless_return.rs | 8 +- tests/ui/needless_update.rs | 4 - tests/ui/neg_cmp_op_on_partial_ord.rs | 11 +- tests/ui/neg_multiply.rs | 4 - tests/ui/never_loop.rs | 70 ++++--- tests/ui/new_ret_no_self.rs | 50 +++-- tests/ui/new_without_default.rs | 61 ++++-- tests/ui/no_effect.rs | 25 +-- tests/ui/non_copy_const.rs | 15 +- tests/ui/non_expressive_names.rs | 26 +-- tests/ui/ok_expect.rs | 5 +- tests/ui/ok_if_let.rs | 4 - tests/ui/op_ref.rs | 4 - tests/ui/open_options.rs | 3 - tests/ui/option_map_unit_fn.rs | 79 +++++--- tests/ui/option_option.rs | 8 +- tests/ui/overflow_check_conditional.rs | 78 ++------ tests/ui/panic_unimplemented.rs | 6 +- tests/ui/partialeq_ne_impl.rs | 12 +- tests/ui/patterns.rs | 9 +- tests/ui/precedence.rs | 16 +- tests/ui/print.rs | 3 - tests/ui/print_literal.rs | 17 +- tests/ui/print_with_newline.rs | 3 - tests/ui/println_empty_string.rs | 1 - tests/ui/ptr_arg.rs | 27 ++- tests/ui/ptr_offset_with_cast.rs | 1 - tests/ui/question_mark.rs | 33 ++-- tests/ui/range.rs | 9 +- tests/ui/range_plus_minus_one.rs | 37 ++-- tests/ui/redundant_clone.rs | 5 +- tests/ui/redundant_closure_call.rs | 22 +-- tests/ui/redundant_field_names.rs | 9 +- tests/ui/redundant_pattern_matching.rs | 28 +-- tests/ui/reference.rs | 10 +- tests/ui/regex.rs | 23 +-- tests/ui/replace_consts.rs | 3 +- tests/ui/result_map_unit_fn.rs | 80 +++++--- tests/ui/serde.rs | 15 +- tests/ui/shadow.rs | 24 ++- tests/ui/short_circuit_statement.rs | 4 - tests/ui/single_char_pattern.rs | 3 - tests/ui/single_match.rs | 37 ++-- tests/ui/single_match_else.rs | 5 +- tests/ui/slow_vector_initialization.rs | 6 +- tests/ui/starts_ends_with.rs | 21 +- tests/ui/string_extend.rs | 1 - tests/ui/strings.rs | 3 - tests/ui/stutter.rs | 3 - tests/ui/suspicious_arithmetic_impl.rs | 6 +- tests/ui/swap.rs | 8 +- tests/ui/temporary_assignment.rs | 16 +- tests/ui/toplevel_ref_arg.rs | 28 ++- tests/ui/trailing_zeros.rs | 5 +- tests/ui/transmute.rs | 16 +- tests/ui/transmute_32bit.rs | 3 - tests/ui/transmute_64bit.rs | 5 - tests/ui/trivially_copy_pass_by_ref.rs | 46 ++--- tests/ui/ty_fn_sig.rs | 1 - tests/ui/types.rs | 9 +- tests/ui/unicode.rs | 4 - tests/ui/unit_arg.rs | 11 +- tests/ui/unit_cmp.rs | 23 +-- tests/ui/unknown_clippy_lints.rs | 4 +- tests/ui/unnecessary_clone.rs | 23 +-- tests/ui/unnecessary_filter_map.rs | 8 +- tests/ui/unnecessary_fold.rs | 1 - tests/ui/unnecessary_operation.rs | 24 ++- tests/ui/unnecessary_ref.rs | 3 - tests/ui/unneeded_field_pattern.rs | 13 +- tests/ui/unreadable_literal.rs | 15 +- tests/ui/unsafe_removed_from_name.rs | 13 +- tests/ui/unused_io_amount.rs | 7 +- tests/ui/unused_labels.rs | 13 +- tests/ui/unused_lt.rs | 49 ++--- tests/ui/unwrap_or.rs | 6 +- tests/ui/use_self.rs | 29 ++- tests/ui/used_underscore_binding.rs | 8 +- tests/ui/useless_asref.rs | 37 ++-- tests/ui/useless_attribute.rs | 11 +- tests/ui/vec.rs | 8 +- tests/ui/while_loop.rs | 65 ++++--- tests/ui/write_literal.rs | 17 +- tests/ui/write_with_newline.rs | 3 - tests/ui/writeln_empty_string.rs | 4 - tests/ui/wrong_self_convention.rs | 10 +- tests/ui/zero_div_zero.rs | 10 +- tests/ui/zero_ptr.rs | 4 - 252 files changed, 1882 insertions(+), 1984 deletions(-) diff --git a/tests/auxiliary/test_macro.rs b/tests/auxiliary/test_macro.rs index 497fedff15e4..d5fef5889711 100644 --- a/tests/auxiliary/test_macro.rs +++ b/tests/auxiliary/test_macro.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - pub trait A {} macro_rules! __implicit_hasher_test_macro { diff --git a/tests/run-pass/associated-constant-ice.rs b/tests/run-pass/associated-constant-ice.rs index bc9a0b3b6d52..df84009c8890 100644 --- a/tests/run-pass/associated-constant-ice.rs +++ b/tests/run-pass/associated-constant-ice.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - pub trait Trait { const CONSTANT: u8; } diff --git a/tests/run-pass/cc_seme.rs b/tests/run-pass/cc_seme.rs index 215b4096b560..7e1f13d44609 100644 --- a/tests/run-pass/cc_seme.rs +++ b/tests/run-pass/cc_seme.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[allow(dead_code)] enum Baz { One, @@ -19,7 +18,7 @@ struct Test { b: Baz, } -fn main() { } +fn main() {} pub fn foo() { use Baz::*; @@ -27,10 +26,7 @@ pub fn foo() { match x { Test { t: Some(_), b: One } => unreachable!(), - Test { - t: Some(42), - b: Two, - } => unreachable!(), + Test { t: Some(42), b: Two } => unreachable!(), Test { t: None, .. } => unreachable!(), Test { .. } => unreachable!(), } diff --git a/tests/run-pass/enum-glob-import-crate.rs b/tests/run-pass/enum-glob-import-crate.rs index df8b32cde2bf..6e64f174e4ce 100644 --- a/tests/run-pass/enum-glob-import-crate.rs +++ b/tests/run-pass/enum-glob-import-crate.rs @@ -7,12 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::all)] #![allow(unused_imports)] use std::*; -fn main() { } +fn main() {} diff --git a/tests/run-pass/ice-1588.rs b/tests/run-pass/ice-1588.rs index a54c77cce73c..87f2afaa6023 100644 --- a/tests/run-pass/ice-1588.rs +++ b/tests/run-pass/ice-1588.rs @@ -7,17 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::all)] fn main() { match 1 { - 1 => {} + 1 => {}, 2 => { [0; 1]; - } - _ => {} + }, + _ => {}, } } diff --git a/tests/run-pass/ice-1782.rs b/tests/run-pass/ice-1782.rs index 446aaacb2eee..ddb4367c9140 100644 --- a/tests/run-pass/ice-1782.rs +++ b/tests/run-pass/ice-1782.rs @@ -7,20 +7,28 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(dead_code, unused_variables)] /// Should not trigger an ICE in `SpanlessEq` / `consts::constant` /// /// Issue: https://github.com/rust-lang/rust-clippy/issues/1782 - use std::{mem, ptr}; fn spanless_eq_ice() { let txt = "something"; match txt { - "something" => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255])) }, - _ => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([13, 246, 24, 255])) }, + "something" => unsafe { + ptr::write( + ptr::null_mut() as *mut u32, + mem::transmute::<[u8; 4], _>([0, 0, 0, 255]), + ) + }, + _ => unsafe { + ptr::write( + ptr::null_mut() as *mut u32, + mem::transmute::<[u8; 4], _>([13, 246, 24, 255]), + ) + }, } } diff --git a/tests/run-pass/ice-1969.rs b/tests/run-pass/ice-1969.rs index 848d9743dcd9..2a0cdb19fce3 100644 --- a/tests/run-pass/ice-1969.rs +++ b/tests/run-pass/ice-1969.rs @@ -7,12 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::all)] -fn main() { } +fn main() {} pub trait Convert { type Action: From<*const f64>; diff --git a/tests/run-pass/ice-2499.rs b/tests/run-pass/ice-2499.rs index 30e8fa657f23..804f416800c4 100644 --- a/tests/run-pass/ice-2499.rs +++ b/tests/run-pass/ice-2499.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)] /// Should not trigger an ICE in `SpanlessHash` / `consts::constant` @@ -20,15 +17,17 @@ fn f(s: &[u8]) -> bool { let t = s[0] as char; match t { - 'E' | 'W' => {} - 'T' => if s[0..4] != ['0' as u8; 4] { - return false; - } else { - return true; + 'E' | 'W' => {}, + 'T' => { + if s[0..4] != ['0' as u8; 4] { + return false; + } else { + return true; + } }, _ => { return false; - } + }, } true } diff --git a/tests/run-pass/ice-2594.rs b/tests/run-pass/ice-2594.rs index 738636b5e400..e91b71b3a1c7 100644 --- a/tests/run-pass/ice-2594.rs +++ b/tests/run-pass/ice-2594.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(dead_code, unused_variables)] /// Should not trigger an ICE in `SpanlessHash` / `consts::constant` @@ -21,7 +20,7 @@ fn spanless_hash_ice() { match txt { "something" => { let mut headers = [empty_header; 1]; - } + }, "" => (), _ => (), } diff --git a/tests/run-pass/ice-2727.rs b/tests/run-pass/ice-2727.rs index 420be4c7112e..9d00f2bacd0d 100644 --- a/tests/run-pass/ice-2727.rs +++ b/tests/run-pass/ice-2727.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - pub fn f(new: fn()) { new(); } diff --git a/tests/run-pass/ice-2760.rs b/tests/run-pass/ice-2760.rs index fe7138b7f282..533cc3b952a1 100644 --- a/tests/run-pass/ice-2760.rs +++ b/tests/run-pass/ice-2760.rs @@ -7,11 +7,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -#![allow(unused_variables, clippy::blacklisted_name, - clippy::needless_pass_by_value, dead_code)] +#![allow( + unused_variables, + clippy::blacklisted_name, + clippy::needless_pass_by_value, + dead_code +)] // This should not compile-fail with: // diff --git a/tests/run-pass/ice-2774.rs b/tests/run-pass/ice-2774.rs index 9959ec46d24a..ae51f0362079 100644 --- a/tests/run-pass/ice-2774.rs +++ b/tests/run-pass/ice-2774.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - use std::collections::HashSet; // See https://github.com/rust-lang/rust-clippy/issues/2774 @@ -26,18 +23,14 @@ pub struct Foo {} // This should not cause a 'cannot relate bound region' ICE pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) { let mut foos = HashSet::new(); - foos.extend( - bars.iter().map(|b| &b.foo) - ); + foos.extend(bars.iter().map(|b| &b.foo)); } #[allow(clippy::implicit_hasher)] // Also this should not cause a 'cannot relate bound region' ICE pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) { let mut foos = HashSet::new(); - foos.extend( - bars.iter().map(|b| &b.foo) - ); + foos.extend(bars.iter().map(|b| &b.foo)); } fn main() {} diff --git a/tests/run-pass/ice-2865.rs b/tests/run-pass/ice-2865.rs index 1713915745af..970ac5bd3a81 100644 --- a/tests/run-pass/ice-2865.rs +++ b/tests/run-pass/ice-2865.rs @@ -7,10 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[allow(dead_code)] struct Ice { - size: String + size: String, } impl<'a> From for Ice { diff --git a/tests/run-pass/ice-3151.rs b/tests/run-pass/ice-3151.rs index 8e1b7b9a1780..7a26f4c3925d 100644 --- a/tests/run-pass/ice-3151.rs +++ b/tests/run-pass/ice-3151.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[derive(Clone)] pub struct HashMap { hash_builder: S, @@ -17,7 +16,7 @@ pub struct HashMap { #[derive(Clone)] pub struct RawTable { size: usize, - val: V + val: V, } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/tests/run-pass/ice-700.rs b/tests/run-pass/ice-700.rs index cb6ba21e72b7..b839ac2a2140 100644 --- a/tests/run-pass/ice-700.rs +++ b/tests/run-pass/ice-700.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::all)] fn core() {} diff --git a/tests/run-pass/ice_exacte_size.rs b/tests/run-pass/ice_exacte_size.rs index 74eda792e756..b2b331bd342c 100644 --- a/tests/run-pass/ice_exacte_size.rs +++ b/tests/run-pass/ice_exacte_size.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::all)] #[allow(dead_code)] diff --git a/tests/run-pass/if_same_then_else.rs b/tests/run-pass/if_same_then_else.rs index cc95262fe3ce..0241d2adcf72 100644 --- a/tests/run-pass/if_same_then_else.rs +++ b/tests/run-pass/if_same_then_else.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::if_same_then_else)] fn main() {} diff --git a/tests/run-pass/issue-2862.rs b/tests/run-pass/issue-2862.rs index 298ce088ceaf..a53424920457 100644 --- a/tests/run-pass/issue-2862.rs +++ b/tests/run-pass/issue-2862.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - pub trait FooMap { fn map B>(&self, f: F) -> B; } diff --git a/tests/run-pass/issue-825.rs b/tests/run-pass/issue-825.rs index 576d53757cfc..9f1195a4ac0b 100644 --- a/tests/run-pass/issue-825.rs +++ b/tests/run-pass/issue-825.rs @@ -7,14 +7,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(warnings)] // this should compile in a reasonable amount of time fn rust_type_id(name: &str) { - if "bool" == &name[..] || "uint" == &name[..] || "u8" == &name[..] || "u16" == &name[..] || "u32" == &name[..] - || "f32" == &name[..] || "f64" == &name[..] || "i8" == &name[..] || "i16" == &name[..] - || "i32" == &name[..] || "i64" == &name[..] || "Self" == &name[..] || "str" == &name[..] + if "bool" == &name[..] + || "uint" == &name[..] + || "u8" == &name[..] + || "u16" == &name[..] + || "u32" == &name[..] + || "f32" == &name[..] + || "f64" == &name[..] + || "i8" == &name[..] + || "i16" == &name[..] + || "i32" == &name[..] + || "i64" == &name[..] + || "Self" == &name[..] + || "str" == &name[..] { unreachable!(); } diff --git a/tests/run-pass/issues_loop_mut_cond.rs b/tests/run-pass/issues_loop_mut_cond.rs index 893866a2a345..a81f8f55dc88 100644 --- a/tests/run-pass/issues_loop_mut_cond.rs +++ b/tests/run-pass/issues_loop_mut_cond.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(dead_code)] /// Issue: https://github.com/rust-lang/rust-clippy/issues/2596 diff --git a/tests/run-pass/match_same_arms_const.rs b/tests/run-pass/match_same_arms_const.rs index bd180e9cad99..661f2ac1dc72 100644 --- a/tests/run-pass/match_same_arms_const.rs +++ b/tests/run-pass/match_same_arms_const.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::match_same_arms)] const PRICE_OF_SWEETS: u32 = 5; @@ -21,7 +18,7 @@ pub fn price(thing: &str) -> u32 { "rolo" => PRICE_OF_SWEETS, "advice" => PRICE_OF_KINDNESS, "juice" => PRICE_OF_DRINKS, - _ => panic!() + _ => panic!(), } } diff --git a/tests/run-pass/mut_mut_macro.rs b/tests/run-pass/mut_mut_macro.rs index 8859009479cd..f1a2cad3ae73 100644 --- a/tests/run-pass/mut_mut_macro.rs +++ b/tests/run-pass/mut_mut_macro.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)] #![allow(dead_code)] diff --git a/tests/run-pass/needless_borrow_fp.rs b/tests/run-pass/needless_borrow_fp.rs index ad4b04864e47..81b778557119 100644 --- a/tests/run-pass/needless_borrow_fp.rs +++ b/tests/run-pass/needless_borrow_fp.rs @@ -7,16 +7,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #[deny(clippy::all)] - #[derive(Debug)] pub enum Error { - Type( - &'static str, - ), + Type(&'static str), } fn main() {} diff --git a/tests/run-pass/needless_lifetimes_impl_trait.rs b/tests/run-pass/needless_lifetimes_impl_trait.rs index 0514d7ab0089..9648f530c2a8 100644 --- a/tests/run-pass/needless_lifetimes_impl_trait.rs +++ b/tests/run-pass/needless_lifetimes_impl_trait.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::needless_lifetimes)] #![allow(dead_code)] diff --git a/tests/run-pass/procedural_macro.rs b/tests/run-pass/procedural_macro.rs index a9c9dd06b426..9ac47599ea06 100644 --- a/tests/run-pass/procedural_macro.rs +++ b/tests/run-pass/procedural_macro.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[macro_use] extern crate clippy_mini_macro_test; @@ -17,6 +16,5 @@ fn main() { println!("{:?}", x); } - #[derive(ClippyMiniMacroTest, Debug)] -struct Foo; \ No newline at end of file +struct Foo; diff --git a/tests/run-pass/regressions.rs b/tests/run-pass/regressions.rs index 9be3bab185c4..b109eecf624e 100644 --- a/tests/run-pass/regressions.rs +++ b/tests/run-pass/regressions.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::blacklisted_name)] pub fn foo(bar: *const u8) { diff --git a/tests/run-pass/returns.rs b/tests/run-pass/returns.rs index cc7678d603bc..045cf001eb23 100644 --- a/tests/run-pass/returns.rs +++ b/tests/run-pass/returns.rs @@ -7,11 +7,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[deny(warnings)] fn cfg_return() -> i32 { - #[cfg(unix)] return 1; - #[cfg(not(unix))] return 2; + #[cfg(unix)] + return 1; + #[cfg(not(unix))] + return 2; } #[deny(warnings)] diff --git a/tests/run-pass/single-match-else.rs b/tests/run-pass/single-match-else.rs index cf032c657031..80fc88f30df5 100644 --- a/tests/run-pass/single-match-else.rs +++ b/tests/run-pass/single-match-else.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::single_match_else)] fn main() { diff --git a/tests/run-pass/used_underscore_binding_macro.rs b/tests/run-pass/used_underscore_binding_macro.rs index 68bd69220620..8b6c6557b494 100644 --- a/tests/run-pass/used_underscore_binding_macro.rs +++ b/tests/run-pass/used_underscore_binding_macro.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::useless_attribute)] //issue #2910 #[macro_use] diff --git a/tests/run-pass/whitelist/conf_whitelisted.rs b/tests/run-pass/whitelist/conf_whitelisted.rs index 168f09a095a9..e7f5ddb561fc 100644 --- a/tests/run-pass/whitelist/conf_whitelisted.rs +++ b/tests/run-pass/whitelist/conf_whitelisted.rs @@ -7,5 +7,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn main() {} diff --git a/tests/ui-toml/bad_toml/conf_bad_toml.rs b/tests/ui-toml/bad_toml/conf_bad_toml.rs index 10c0f0004e45..31781277ae8b 100644 --- a/tests/ui-toml/bad_toml/conf_bad_toml.rs +++ b/tests/ui-toml/bad_toml/conf_bad_toml.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - // error-pattern: error reading Clippy's configuration file - - - fn main() {} diff --git a/tests/ui-toml/bad_toml_type/conf_bad_type.rs b/tests/ui-toml/bad_toml_type/conf_bad_type.rs index 021a839d9ef5..2307bfff21ca 100644 --- a/tests/ui-toml/bad_toml_type/conf_bad_type.rs +++ b/tests/ui-toml/bad_toml_type/conf_bad_type.rs @@ -7,10 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a `Vec < String >` but is a `integer` - - - +// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a +// `Vec < String >` but is a `integer` fn main() {} diff --git a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs index ad81b82b2c53..b00a21b3f2f7 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(dead_code)] #![allow(clippy::single_match)] #![allow(unused_variables)] diff --git a/tests/ui-toml/toml_trivially_copy/test.rs b/tests/ui-toml/toml_trivially_copy/test.rs index eb09d6dfc5c6..39de0de0dc72 100644 --- a/tests/ui-toml/toml_trivially_copy/test.rs +++ b/tests/ui-toml/toml_trivially_copy/test.rs @@ -7,8 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #![allow(clippy::many_single_char_names)] #[derive(Copy, Clone)] @@ -17,11 +15,9 @@ struct Foo(u8); #[derive(Copy, Clone)] struct Bar(u32); -fn good(a: &mut u32, b: u32, c: &Bar, d: &u32) { -} +fn good(a: &mut u32, b: u32, c: &Bar, d: &u32) {} -fn bad(x: &u16, y: &Foo) { -} +fn bad(x: &u16, y: &Foo) {} fn main() { let (mut a, b, c, d, x, y) = (0, 0, Bar(0), 0, 0, Foo(0)); diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs b/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs index 60e8e4fc29a3..c8e6268e95dc 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - // error-pattern: error reading Clippy's configuration file: unknown key `foobar` - - - fn main() {} diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index a93027162e56..666c43257063 100644 --- a/tests/ui/absurd-extreme-comparisons.rs +++ b/tests/ui/absurd-extreme-comparisons.rs @@ -8,7 +8,13 @@ // except according to those terms. #![warn(clippy::absurd_extreme_comparisons)] -#![allow(unused, clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::needless_pass_by_value)] +#![allow( + unused, + clippy::eq_op, + clippy::no_effect, + clippy::unnecessary_operation, + clippy::needless_pass_by_value +)] #[rustfmt::skip] fn main() { diff --git a/tests/ui/approx_const.rs b/tests/ui/approx_const.rs index b2f50cc2ce36..8eefb6af01d8 100644 --- a/tests/ui/approx_const.rs +++ b/tests/ui/approx_const.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::approx_constant)] #[allow(unused, clippy::shadow_unrelated, clippy::similar_names, clippy::unreadable_literal)] fn main() { diff --git a/tests/ui/arithmetic.rs b/tests/ui/arithmetic.rs index 39aef5a4a56a..00de38039a73 100644 --- a/tests/ui/arithmetic.rs +++ b/tests/ui/arithmetic.rs @@ -7,9 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![warn(clippy::integer_arithmetic, clippy::float_arithmetic)] -#![allow(unused, clippy::shadow_reuse, clippy::shadow_unrelated, clippy::no_effect, clippy::unnecessary_operation)] +#![allow( + unused, + clippy::shadow_reuse, + clippy::shadow_unrelated, + clippy::no_effect, + clippy::unnecessary_operation +)] #[rustfmt::skip] fn main() { diff --git a/tests/ui/assign_ops.rs b/tests/ui/assign_ops.rs index 419e63b2c62b..75cd75438239 100644 --- a/tests/ui/assign_ops.rs +++ b/tests/ui/assign_ops.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #[allow(dead_code, unused_assignments)] #[warn(clippy::assign_op_pattern)] fn main() { diff --git a/tests/ui/assign_ops2.rs b/tests/ui/assign_ops2.rs index 4f9fbc80aaa1..24d0d77a20da 100644 --- a/tests/ui/assign_ops2.rs +++ b/tests/ui/assign_ops2.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[allow(unused_assignments)] #[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)] fn main() { @@ -65,6 +61,4 @@ fn cow_add_assign() { // this should not as cow Add is not commutative buf = cows + buf; println!("{}", buf); - } - diff --git a/tests/ui/attrs.rs b/tests/ui/attrs.rs index 1d0c23905bd8..413c30a19453 100644 --- a/tests/ui/attrs.rs +++ b/tests/ui/attrs.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::inline_always, clippy::deprecated_semver)] #[inline(always)] @@ -30,22 +26,27 @@ fn false_positive_stmt() { #[inline(always)] fn empty_and_false_positive_stmt() { - ; unreachable!(); } #[deprecated(since = "forever")] -pub const SOME_CONST : u8 = 42; +pub const SOME_CONST: u8 = 42; #[deprecated(since = "1")] -pub const ANOTHER_CONST : u8 = 23; +pub const ANOTHER_CONST: u8 = 23; #[deprecated(since = "0.1.1")] -pub const YET_ANOTHER_CONST : u8 = 0; +pub const YET_ANOTHER_CONST: u8 = 0; fn main() { test_attr_lint(); - if false { false_positive_expr() } - if false { false_positive_stmt() } - if false { empty_and_false_positive_stmt() } + if false { + false_positive_expr() + } + if false { + false_positive_stmt() + } + if false { + empty_and_false_positive_stmt() + } } diff --git a/tests/ui/author.rs b/tests/ui/author.rs index f151d50f2f2b..4b7729e23b1f 100644 --- a/tests/ui/author.rs +++ b/tests/ui/author.rs @@ -7,11 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - fn main() { - #[clippy::author] let x: char = 0x45 as char; } diff --git a/tests/ui/author/call.rs b/tests/ui/author/call.rs index 3dcf8da5c729..40cc0d7a9194 100644 --- a/tests/ui/author/call.rs +++ b/tests/ui/author/call.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - fn main() { #[clippy::author] let _ = ::std::cmp::min(3, 4); diff --git a/tests/ui/author/for_loop.rs b/tests/ui/author/for_loop.rs index a27322b32059..4acd0b452bbb 100644 --- a/tests/ui/author/for_loop.rs +++ b/tests/ui/author/for_loop.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![feature(stmt_expr_attributes)] fn main() { diff --git a/tests/ui/author/matches.rs b/tests/ui/author/matches.rs index 956404f34901..4c220dded8a4 100644 --- a/tests/ui/author/matches.rs +++ b/tests/ui/author/matches.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![feature(tool_attributes)] fn main() { diff --git a/tests/ui/bit_masks.rs b/tests/ui/bit_masks.rs index db5a6885c9e6..bda952db723a 100644 --- a/tests/ui/bit_masks.rs +++ b/tests/ui/bit_masks.rs @@ -7,15 +7,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - -const THREE_BITS : i64 = 7; -const EVEN_MORE_REDIRECTION : i64 = THREE_BITS; +const THREE_BITS: i64 = 7; +const EVEN_MORE_REDIRECTION: i64 = THREE_BITS; #[warn(clippy::bad_bit_mask)] -#[allow(clippy::ineffective_bit_mask, clippy::identity_op, clippy::no_effect, clippy::unnecessary_operation)] +#[allow( + clippy::ineffective_bit_mask, + clippy::identity_op, + clippy::no_effect, + clippy::unnecessary_operation +)] fn main() { let x = 5; diff --git a/tests/ui/blacklisted_name.rs b/tests/ui/blacklisted_name.rs index 285438810d9c..fef73e9d84fc 100644 --- a/tests/ui/blacklisted_name.rs +++ b/tests/ui/blacklisted_name.rs @@ -7,11 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - -#![allow(dead_code, clippy::similar_names, clippy::single_match, clippy::toplevel_ref_arg, unused_mut, unused_variables)] +#![allow( + dead_code, + clippy::similar_names, + clippy::single_match, + clippy::toplevel_ref_arg, + unused_mut, + unused_variables +)] #![warn(clippy::blacklisted_name)] fn test(foo: ()) {} diff --git a/tests/ui/block_in_if_condition.rs b/tests/ui/block_in_if_condition.rs index 946118118412..eaaf5e050bfa 100644 --- a/tests/ui/block_in_if_condition.rs +++ b/tests/ui/block_in_if_condition.rs @@ -7,33 +7,28 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::block_in_if_condition_expr)] #![warn(clippy::block_in_if_condition_stmt)] #![allow(unused, clippy::let_and_return)] #![warn(clippy::nonminimal_bool)] - macro_rules! blocky { - () => {{true}} + () => {{ + true + }}; } macro_rules! blocky_too { () => {{ let r = true; r - }} + }}; } fn macro_if() { - if blocky!() { - } + if blocky!() {} - if blocky_too!() { - } + if blocky_too!() {} } fn condition_has_block() -> i32 { @@ -55,7 +50,7 @@ fn condition_has_block_with_single_expression() -> i32 { } } -fn predicate bool, T>(pfn: F, val:T) -> bool { +fn predicate bool, T>(pfn: F, val: T) -> bool { pfn(val) } @@ -65,11 +60,24 @@ fn pred_test() { // this is a sneaky case, where the block isn't directly in the condition, but is actually // inside a closure that the condition is using. same principle applies. add some extra // expressions to make sure linter isn't confused by them. - if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) { - } - - if predicate(|x| { let target = 3; x == target }, v) { - } + if v == 3 + && sky == "blue" + && predicate( + |x| { + let target = 3; + x == target + }, + v, + ) + {} + + if predicate( + |x| { + let target = 3; + x == target + }, + v, + ) {} } fn condition_is_normal() -> i32 { @@ -82,9 +90,7 @@ fn condition_is_normal() -> i32 { } fn closure_without_block() { - if predicate(|x| x == 3, 6) { - - } + if predicate(|x| x == 3, 6) {} } fn condition_is_unsafe_block() { @@ -96,8 +102,7 @@ fn condition_is_unsafe_block() { } } -fn main() { -} +fn main() {} fn macro_in_closure() { let option = Some(true); diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index 8ab8b3f92813..30b5acf2d976 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -7,19 +7,47 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::bool_comparison)] fn main() { let x = true; - if x == true { "yes" } else { "no" }; - if x == false { "yes" } else { "no" }; - if true == x { "yes" } else { "no" }; - if false == x { "yes" } else { "no" }; - if x != true { "yes" } else { "no" }; - if x != false { "yes" } else { "no" }; - if true != x { "yes" } else { "no" }; - if false != x { "yes" } else { "no" }; + if x == true { + "yes" + } else { + "no" + }; + if x == false { + "yes" + } else { + "no" + }; + if true == x { + "yes" + } else { + "no" + }; + if false == x { + "yes" + } else { + "no" + }; + if x != true { + "yes" + } else { + "no" + }; + if x != false { + "yes" + } else { + "no" + }; + if true != x { + "yes" + } else { + "no" + }; + if false != x { + "yes" + } else { + "no" + }; } diff --git a/tests/ui/booleans.rs b/tests/ui/booleans.rs index e63b6a75e8f2..8eb1b52577ce 100644 --- a/tests/ui/booleans.rs +++ b/tests/ui/booleans.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::nonminimal_bool, clippy::logic_bug)] #[allow(unused, clippy::many_single_char_names)] @@ -71,58 +68,78 @@ fn methods_with_negation() { // Simplified versions of https://github.com/rust-lang/rust-clippy/issues/2638 // clippy::nonminimal_bool should only check the built-in Result and Some type, not // any other types like the following. -enum CustomResultOk { Ok, Err(E) } -enum CustomResultErr { Ok, Err(E) } -enum CustomSomeSome { Some(T), None } -enum CustomSomeNone { Some(T), None } +enum CustomResultOk { + Ok, + Err(E), +} +enum CustomResultErr { + Ok, + Err(E), +} +enum CustomSomeSome { + Some(T), + None, +} +enum CustomSomeNone { + Some(T), + None, +} impl CustomResultOk { - pub fn is_ok(&self) -> bool { true } + pub fn is_ok(&self) -> bool { + true + } } impl CustomResultErr { - pub fn is_err(&self) -> bool { true } + pub fn is_err(&self) -> bool { + true + } } impl CustomSomeSome { - pub fn is_some(&self) -> bool { true } + pub fn is_some(&self) -> bool { + true + } } impl CustomSomeNone { - pub fn is_none(&self) -> bool { true } + pub fn is_none(&self) -> bool { + true + } } fn dont_warn_for_custom_methods_with_negation() { let res = CustomResultOk::Err("Error"); // Should not warn and suggest 'is_err()' because the type does not // implement is_err(). - if !res.is_ok() { } + if !res.is_ok() {} let res = CustomResultErr::Err("Error"); // Should not warn and suggest 'is_ok()' because the type does not // implement is_ok(). - if !res.is_err() { } + if !res.is_err() {} let res = CustomSomeSome::Some("thing"); // Should not warn and suggest 'is_none()' because the type does not // implement is_none(). - if !res.is_some() { } + if !res.is_some() {} let res = CustomSomeNone::Some("thing"); // Should not warn and suggest 'is_some()' because the type does not // implement is_some(). - if !res.is_none() { } + if !res.is_none() {} } // Only Built-in Result and Some types should suggest the negated alternative fn warn_for_built_in_methods_with_negation() { let res: Result = Ok(1); - if !res.is_ok() { } - if !res.is_err() { } + if !res.is_ok() {} + if !res.is_err() {} let res = Some(1); - if !res.is_some() { } - if !res.is_none() { } + if !res.is_some() {} + if !res.is_none() {} } #[allow(clippy::neg_cmp_op_on_partial_ord)] diff --git a/tests/ui/borrow_box.rs b/tests/ui/borrow_box.rs index dbcd42a692ce..cf204150f8b1 100644 --- a/tests/ui/borrow_box.rs +++ b/tests/ui/borrow_box.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![deny(clippy::borrowed_box)] #![allow(clippy::blacklisted_name)] #![allow(unused_variables)] @@ -25,7 +21,7 @@ pub fn test2() { } struct Test3<'a> { - foo: &'a Box + foo: &'a Box, } trait Test4 { @@ -49,7 +45,7 @@ pub fn test6() { } struct Test7<'a> { - foo: &'a Box + foo: &'a Box, } trait Test8 { @@ -71,7 +67,7 @@ pub fn test10() { } struct Test11<'a> { - foo: &'a Box + foo: &'a Box, } trait Test12 { @@ -84,7 +80,7 @@ impl<'a> Test12 for Test11<'a> { } } -fn main(){ +fn main() { test1(&mut Box::new(false)); test2(); test5(&mut (Box::new(false) as Box)); diff --git a/tests/ui/box_vec.rs b/tests/ui/box_vec.rs index bf505c85abc7..485230540972 100644 --- a/tests/ui/box_vec.rs +++ b/tests/ui/box_vec.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![allow(clippy::boxed_local, clippy::needless_pass_by_value)] #![allow(clippy::blacklisted_name)] @@ -18,7 +14,7 @@ macro_rules! boxit { ($init:expr, $x:ty) => { let _: Box<$x> = Box::new($init); - } + }; } fn test_macro() { @@ -28,7 +24,8 @@ pub fn test(foo: Box>) { println!("{:?}", foo.get(0)) } -pub fn test2(foo: Box)>) { // pass if #31 is fixed +pub fn test2(foo: Box)>) { + // pass if #31 is fixed foo(vec![1, 2, 3]) } @@ -36,7 +33,7 @@ pub fn test_local_not_linted() { let _: Box>; } -fn main(){ +fn main() { test(Box::new(Vec::new())); test2(Box::new(|v| println!("{:?}", v))); test_macro(); diff --git a/tests/ui/builtin-type-shadow.rs b/tests/ui/builtin-type-shadow.rs index e43a2789ce1d..66a7e318f8af 100644 --- a/tests/ui/builtin-type-shadow.rs +++ b/tests/ui/builtin-type-shadow.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::builtin_type_shadow)] fn foo(a: u32) -> u32 { @@ -17,5 +14,4 @@ fn foo(a: u32) -> u32 { // ^ rustc's type error } -fn main() { -} +fn main() {} diff --git a/tests/ui/bytecount.rs b/tests/ui/bytecount.rs index 170666d1f18f..6bc9b5ddecd0 100644 --- a/tests/ui/bytecount.rs +++ b/tests/ui/bytecount.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[deny(clippy::naive_bytecount)] fn main() { let x = vec![0_u8; 16]; diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index 9976a4aa96a0..45e878e9d800 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -7,11 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - -#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)] +#[warn( + clippy::cast_precision_loss, + clippy::cast_possible_truncation, + clippy::cast_sign_loss, + clippy::cast_possible_wrap, + clippy::cast_lossless +)] #[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { // Test clippy::cast_precision_loss @@ -49,7 +51,7 @@ fn main() { false as bool; &1i32 as &i32; // Should not trigger - let v = vec!(1); + let v = vec![1]; &v as &[i32]; 1.0 as f64; 1 as u64; diff --git a/tests/ui/cast_alignment.rs b/tests/ui/cast_alignment.rs index a1a2e1c9a8fd..efc56ea2bbc1 100644 --- a/tests/ui/cast_alignment.rs +++ b/tests/ui/cast_alignment.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - //! Test casts for alignment issues #![feature(libc)] diff --git a/tests/ui/cast_lossless_float.rs b/tests/ui/cast_lossless_float.rs index 468774dd88be..e52a756c003d 100644 --- a/tests/ui/cast_lossless_float.rs +++ b/tests/ui/cast_lossless_float.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #[warn(clippy::cast_lossless)] #[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs index 4f7432de6206..593ffdd27663 100644 --- a/tests/ui/cast_lossless_integer.rs +++ b/tests/ui/cast_lossless_integer.rs @@ -7,8 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #[warn(clippy::cast_lossless)] #[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { diff --git a/tests/ui/cast_size.rs b/tests/ui/cast_size.rs index fddf9669a8f7..8f691104c517 100644 --- a/tests/ui/cast_size.rs +++ b/tests/ui/cast_size.rs @@ -7,10 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)] +#[warn( + clippy::cast_precision_loss, + clippy::cast_possible_truncation, + clippy::cast_sign_loss, + clippy::cast_possible_wrap, + clippy::cast_lossless +)] #[allow(clippy::no_effect, clippy::unnecessary_operation)] fn main() { // Casting from *size diff --git a/tests/ui/char_lit_as_u8.rs b/tests/ui/char_lit_as_u8.rs index d684fcf57467..663962afeaef 100644 --- a/tests/ui/char_lit_as_u8.rs +++ b/tests/ui/char_lit_as_u8.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::char_lit_as_u8)] #![allow(unused_variables)] fn main() { diff --git a/tests/ui/checked_unwrap.rs b/tests/ui/checked_unwrap.rs index 383fd82240bc..4d250a80e903 100644 --- a/tests/ui/checked_unwrap.rs +++ b/tests/ui/checked_unwrap.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] #![allow(clippy::if_same_then_else)] @@ -43,11 +40,11 @@ fn main() { if x.is_ok() { x = Err(()); x.unwrap(); // not unnecessary because of mutation of x - // it will always panic but the lint is not smart enough to see this (it only checks if conditions). + // it will always panic but the lint is not smart enough to see this (it only checks if conditions). } else { x = Ok(()); x.unwrap_err(); // not unnecessary because of mutation of x - // it will always panic but the lint is not smart enough to see this (it only checks if conditions). + // it will always panic but the lint is not smart enough to see this (it only checks if conditions). } } diff --git a/tests/ui/clone_on_copy_impl.rs b/tests/ui/clone_on_copy_impl.rs index a1353abd92b0..058cbf7a16cb 100644 --- a/tests/ui/clone_on_copy_impl.rs +++ b/tests/ui/clone_on_copy_impl.rs @@ -7,9 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use std::marker::PhantomData; use std::fmt; +use std::marker::PhantomData; pub struct Key { #[doc(hidden)] diff --git a/tests/ui/clone_on_copy_mut.rs b/tests/ui/clone_on_copy_mut.rs index 81d70eb9458a..82f411d5c9db 100644 --- a/tests/ui/clone_on_copy_mut.rs +++ b/tests/ui/clone_on_copy_mut.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - pub fn dec_read_dec(i: &mut i32) -> i32 { *i -= 1; let ret = *i; diff --git a/tests/ui/cmp_nan.rs b/tests/ui/cmp_nan.rs index 4b62d0e53f1c..d6bdb5894d50 100644 --- a/tests/ui/cmp_nan.rs +++ b/tests/ui/cmp_nan.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::cmp_nan)] #[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)] fn main() { diff --git a/tests/ui/cmp_null.rs b/tests/ui/cmp_null.rs index 03f0367a640f..37615c9e1136 100644 --- a/tests/ui/cmp_null.rs +++ b/tests/ui/cmp_null.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::cmp_null)] #![allow(unused_mut)] @@ -17,12 +14,12 @@ use std::ptr; fn main() { let x = 0; - let p : *const usize = &x; + let p: *const usize = &x; if p == ptr::null() { println!("This is surprising!"); } let mut y = 0; - let mut m : *mut usize = &mut y; + let mut m: *mut usize = &mut y; if m == ptr::null_mut() { println!("This is surprising, too!"); } diff --git a/tests/ui/cmp_owned.rs b/tests/ui/cmp_owned.rs index dc3d62ddfa69..53de5136105c 100644 --- a/tests/ui/cmp_owned.rs +++ b/tests/ui/cmp_owned.rs @@ -7,14 +7,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::cmp_owned)] #[allow(clippy::unnecessary_operation)] fn main() { - fn with_to_string(x : &str) { + fn with_to_string(x: &str) { x != "foo".to_string(); "foo".to_string() != x; diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index bd6e0c079468..6828743abf37 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[rustfmt::skip] #[warn(clippy::collapsible_if)] fn main() { diff --git a/tests/ui/complex_types.rs b/tests/ui/complex_types.rs index e735bf8e4875..9d75de62d74a 100644 --- a/tests/ui/complex_types.rs +++ b/tests/ui/complex_types.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::all)] #![allow(unused, clippy::needless_pass_by_value)] #![feature(associated_type_defaults)] @@ -32,19 +29,21 @@ enum E { impl S { const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); - fn impl_method(&self, p: Vec>>) { } + fn impl_method(&self, p: Vec>>) {} } trait T { const A: Vec>>; type B = Vec>>; fn method(&self, p: Vec>>); - fn def_method(&self, p: Vec>>) { } + fn def_method(&self, p: Vec>>) {} } -fn test1() -> Vec>> { vec![] } +fn test1() -> Vec>> { + vec![] +} -fn test2(_x: Vec>>) { } +fn test2(_x: Vec>>) {} fn test3() { let _y: Vec>> = vec![]; @@ -67,5 +66,4 @@ struct D { ), } -fn main() { -} +fn main() {} diff --git a/tests/ui/const_static_lifetime.rs b/tests/ui/const_static_lifetime.rs index 2b6a5dc249a9..3e1aa94f9694 100644 --- a/tests/ui/const_static_lifetime.rs +++ b/tests/ui/const_static_lifetime.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[derive(Debug)] struct Foo {} diff --git a/tests/ui/copies.rs b/tests/ui/copies.rs index 5c4bbecf8220..00e1d726207a 100644 --- a/tests/ui/copies.rs +++ b/tests/ui/copies.rs @@ -7,13 +7,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(clippy::blacklisted_name, clippy::collapsible_if, clippy::cyclomatic_complexity, clippy::eq_op, clippy::needless_continue, - clippy::needless_return, clippy::never_loop, clippy::no_effect, clippy::zero_divided_by_zero, clippy::unused_unit)] - - +#![allow( + clippy::blacklisted_name, + clippy::collapsible_if, + clippy::cyclomatic_complexity, + clippy::eq_op, + clippy::needless_continue, + clippy::needless_return, + clippy::never_loop, + clippy::no_effect, + clippy::zero_divided_by_zero, + clippy::unused_unit +)] fn bar(_: T) {} -fn foo() -> bool { unimplemented!() } +fn foo() -> bool { + unimplemented!() +} struct Foo { bar: u8, @@ -37,8 +47,8 @@ fn if_same_then_else() -> Result<&'static str, ()> { ..10; 0..=10; foo(); - } - else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block Foo { bar: 42 }; 0..10; ..; @@ -50,30 +60,26 @@ fn if_same_then_else() -> Result<&'static str, ()> { if true { Foo { bar: 42 }; - } - else { + } else { Foo { bar: 43 }; } if true { (); - } - else { + } else { () } if true { 0..10; - } - else { + } else { 0..=10; } if true { foo(); foo(); - } - else { + } else { foo(); } @@ -84,18 +90,19 @@ fn if_same_then_else() -> Result<&'static str, ()> { if true { a += 7; } - a = -31-a; + a = -31 - a; a - } - _ => { //~ ERROR match arms have same body + }, + _ => { + //~ ERROR match arms have same body foo(); let mut a = 42 + [23].len() as i32; if true { a += 7; } - a = -31-a; + a = -31 - a; a - } + }, }; let _ = match Abc::A { @@ -110,8 +117,8 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = if true { 42 - } - else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block 42 }; @@ -124,8 +131,8 @@ fn if_same_then_else() -> Result<&'static str, ()> { continue; } } - } - else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block for _ in &[42] { let foo: &Option<_> = &Some::(42); if true { @@ -137,25 +144,19 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - let bar = if true { - 42 - } - else { - 43 - }; + let bar = if true { 42 } else { 43 }; - while foo() { break; } - bar + 1; - } - else { //~ ERROR same body as `if` block - let bar = if true { - 42 + while foo() { + break; } - else { - 43 - }; + bar + 1; + } else { + //~ ERROR same body as `if` block + let bar = if true { 42 } else { 43 }; - while foo() { break; } + while foo() { + break; + } bar + 1; } @@ -166,11 +167,9 @@ fn if_same_then_else() -> Result<&'static str, ()> { 10..=15 => 3, _ => 4, }; - } - else if false { + } else if false { foo(); - } - else if foo() { + } else if foo() { let _ = match 42 { 42 => 1, a if a > 0 => 2, @@ -181,64 +180,57 @@ fn if_same_then_else() -> Result<&'static str, ()> { if true { if let Some(a) = Some(42) {} - } - else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block if let Some(a) = Some(42) {} } if true { if let (1, .., 3) = (1, 2, 3) {} - } - else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block if let (1, .., 3) = (1, 2, 3) {} } if true { if let (1, .., 3) = (1, 2, 3) {} - } - else { + } else { if let (.., 3) = (1, 2, 3) {} } if true { if let (1, .., 3) = (1, 2, 3) {} - } - else { + } else { if let (.., 4) = (1, 2, 3) {} } if true { if let (1, .., 3) = (1, 2, 3) {} - } - else { + } else { if let (.., 1, 3) = (1, 2, 3) {} } if true { if let Some(42) = None {} - } - else { + } else { if let Option::Some(42) = None {} } if true { if let Some(42) = None:: {} - } - else { + } else { if let Some(42) = None {} } if true { if let Some(42) = None:: {} - } - else { + } else { if let Some(42) = None:: {} } if true { if let Some(a) = Some(42) {} - } - else { + } else { if let Some(a) = Some(43) {} } @@ -290,39 +282,34 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = if true { 0.0 - } else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block 0.0 }; let _ = if true { -0.0 - } else { //~ ERROR same body as `if` block - -0.0 - }; - - let _ = if true { - 0.0 } else { + //~ ERROR same body as `if` block -0.0 }; + let _ = if true { 0.0 } else { -0.0 }; + // Different NaNs - let _ = if true { - 0.0 / 0.0 - } else { - std::f32::NAN - }; + let _ = if true { 0.0 / 0.0 } else { std::f32::NAN }; // Same NaNs let _ = if true { std::f32::NAN - } else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block std::f32::NAN }; let _ = match Some(()) { Some(()) => 0.0, - None => -0.0 + None => -0.0, }; match (Some(42), Some("")) { @@ -333,20 +320,18 @@ fn if_same_then_else() -> Result<&'static str, ()> { if true { try!(Ok("foo")); - } - else { //~ ERROR same body as `if` block + } else { + //~ ERROR same body as `if` block try!(Ok("foo")); } if true { let foo = ""; return Ok(&foo[0..]); - } - else if false { + } else if false { let foo = "bar"; return Ok(&foo[0..]); - } - else { + } else { let foo = ""; return Ok(&foo[0..]); } @@ -359,22 +344,20 @@ fn ifs_same_cond() { let b = false; if b { - } - else if b { //~ ERROR ifs same condition + } else if b { + //~ ERROR ifs same condition } if a == 1 { - } - else if a == 1 { //~ ERROR ifs same condition + } else if a == 1 { + //~ ERROR ifs same condition } - if 2*a == 1 { - } - else if 2*a == 2 { - } - else if 2*a == 1 { //~ ERROR ifs same condition - } - else if a == 1 { + if 2 * a == 1 { + } else if 2 * a == 2 { + } else if 2 * a == 1 { + //~ ERROR ifs same condition + } else if a == 1 { } // See #659 @@ -387,14 +370,14 @@ fn ifs_same_cond() { }; let mut v = vec![1]; - if v.pop() == None { // ok, functions - } - else if v.pop() == None { + if v.pop() == None { + // ok, functions + } else if v.pop() == None { } - if v.len() == 42 { // ok, functions - } - else if v.len() == 42 { + if v.len() == 42 { + // ok, functions + } else if v.len() == 42 { } } diff --git a/tests/ui/copy_iterator.rs b/tests/ui/copy_iterator.rs index b5684f183ebe..22d3e1388981 100644 --- a/tests/ui/copy_iterator.rs +++ b/tests/ui/copy_iterator.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::copy_iterator)] #[derive(Copy, Clone)] diff --git a/tests/ui/cstring.rs b/tests/ui/cstring.rs index 6121166debeb..5fe915a83689 100644 --- a/tests/ui/cstring.rs +++ b/tests/ui/cstring.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - fn main() {} #[allow(clippy::result_unwrap_used)] diff --git a/tests/ui/cyclomatic_complexity.rs b/tests/ui/cyclomatic_complexity.rs index a9a2391f1506..fff677629246 100644 --- a/tests/ui/cyclomatic_complexity.rs +++ b/tests/ui/cyclomatic_complexity.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(clippy::all)] #![warn(clippy::cyclomatic_complexity)] #![allow(unused)] @@ -181,8 +180,8 @@ fn bar() { #[test] #[clippy::cyclomatic_complexity = "0"] -/// Tests are usually complex but simple at the same time. `clippy::cyclomatic_complexity` used to give -/// lots of false-positives in tests. +/// Tests are usually complex but simple at the same time. `clippy::cyclomatic_complexity` used to +/// give lots of false-positives in tests. fn dont_warn_on_tests() { match 99 { 0 => println!("hi"), @@ -278,7 +277,6 @@ fn cake() { println!("whee"); } - #[clippy::cyclomatic_complexity = "0"] pub fn read_file(input_path: &str) -> String { use std::fs::File; @@ -288,7 +286,7 @@ pub fn read_file(input_path: &str) -> String { Ok(f) => f, Err(err) => { panic!("Can't open {}: {}", input_path, err); - } + }, }; let mut bytes = Vec::new(); @@ -297,14 +295,14 @@ pub fn read_file(input_path: &str) -> String { Ok(..) => {}, Err(_) => { panic!("Can't read {}", input_path); - } + }, }; match String::from_utf8(bytes) { Ok(contents) => contents, Err(_) => { panic!("{} is not UTF-8 encoded", input_path); - } + }, } } @@ -313,8 +311,7 @@ enum Void {} #[clippy::cyclomatic_complexity = "0"] fn void(void: Void) { if true { - match void { - } + match void {} } } diff --git a/tests/ui/cyclomatic_complexity_attr_used.rs b/tests/ui/cyclomatic_complexity_attr_used.rs index 63d4e65a9776..b1da9649f901 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.rs +++ b/tests/ui/cyclomatic_complexity_attr_used.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::cyclomatic_complexity)] #![warn(unused)] diff --git a/tests/ui/decimal_literal_representation.rs b/tests/ui/decimal_literal_representation.rs index c52fcd826ca3..c196b27a3a6c 100644 --- a/tests/ui/decimal_literal_representation.rs +++ b/tests/ui/decimal_literal_representation.rs @@ -7,24 +7,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::decimal_literal_representation)] #[allow(unused_variables)] fn main() { - let good = ( // Hex: - 127, // 0x7F - 256, // 0x100 - 511, // 0x1FF - 2048, // 0x800 - 4090, // 0xFFA - 16_371, // 0x3FF3 - 61_683, // 0xF0F3 - 2_131_750_925, // 0x7F0F_F00D + let good = ( + // Hex: + 127, // 0x7F + 256, // 0x100 + 511, // 0x1FF + 2048, // 0x800 + 4090, // 0xFFA + 16_371, // 0x3FF3 + 61_683, // 0xF0F3 + 2_131_750_925, // 0x7F0F_F00D ); - let bad = ( // Hex: + let bad = ( + // Hex: 32_773, // 0x8005 65_280, // 0xFF00 2_131_750_927, // 0x7F0F_F00F diff --git a/tests/ui/default_trait_access.rs b/tests/ui/default_trait_access.rs index 331ad03f9a24..eaa367b0cb3d 100644 --- a/tests/ui/default_trait_access.rs +++ b/tests/ui/default_trait_access.rs @@ -7,14 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::default_trait_access)] +use std::default; use std::default::Default as D2; use std::string; -use std::default; fn main() { let s1: String = Default::default(); diff --git a/tests/ui/deprecated.rs b/tests/ui/deprecated.rs index a7e95ad5dde4..7a1657424ed5 100644 --- a/tests/ui/deprecated.rs +++ b/tests/ui/deprecated.rs @@ -7,18 +7,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(str_to_string)] - #[warn(string_to_string)] - #[warn(unstable_as_slice)] - #[warn(unstable_as_mut_slice)] - #[warn(misaligned_transmute)] fn main() {} diff --git a/tests/ui/derive.rs b/tests/ui/derive.rs index 521a2e323fc0..a6020b61337a 100644 --- a/tests/ui/derive.rs +++ b/tests/ui/derive.rs @@ -7,11 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(untagged_unions)] - #![allow(dead_code)] #![warn(clippy::expl_impl_clone_on_copy)] @@ -21,21 +17,27 @@ use std::hash::{Hash, Hasher}; struct Foo; impl PartialEq for Foo { - fn eq(&self, _: &u64) -> bool { true } + fn eq(&self, _: &u64) -> bool { + true + } } #[derive(Hash)] struct Bar; impl PartialEq for Bar { - fn eq(&self, _: &Bar) -> bool { true } + fn eq(&self, _: &Bar) -> bool { + true + } } #[derive(Hash)] struct Baz; impl PartialEq for Baz { - fn eq(&self, _: &Baz) -> bool { true } + fn eq(&self, _: &Baz) -> bool { + true + } } #[derive(PartialEq)] @@ -49,7 +51,9 @@ impl Hash for Bah { struct Qux; impl Clone for Qux { - fn clone(&self) -> Self { Qux } + fn clone(&self) -> Self { + Qux + } } // looks like unions don't support deriving Clone for now @@ -60,9 +64,7 @@ union Union { impl Clone for Union { fn clone(&self) -> Self { - Union { - a: 42, - } + Union { a: 42 } } } @@ -73,7 +75,9 @@ struct Lt<'a> { } impl<'a> Clone for Lt<'a> { - fn clone(&self) -> Self { unimplemented!() } + fn clone(&self) -> Self { + unimplemented!() + } } // Ok, `Clone` cannot be derived because of the big array @@ -83,7 +87,9 @@ struct BigArray { } impl Clone for BigArray { - fn clone(&self) -> Self { unimplemented!() } + fn clone(&self) -> Self { + unimplemented!() + } } // Ok, function pointers are not always Clone @@ -93,7 +99,9 @@ struct FnPtr { } impl Clone for FnPtr { - fn clone(&self) -> Self { unimplemented!() } + fn clone(&self) -> Self { + unimplemented!() + } } // Ok, generics @@ -103,7 +111,9 @@ struct Generic { } impl Clone for Generic { - fn clone(&self) -> Self { unimplemented!() } + fn clone(&self) -> Self { + unimplemented!() + } } fn main() {} diff --git a/tests/ui/diverging_sub_expression.rs b/tests/ui/diverging_sub_expression.rs index a47c96759ac4..3399dba71896 100644 --- a/tests/ui/diverging_sub_expression.rs +++ b/tests/ui/diverging_sub_expression.rs @@ -7,21 +7,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(never_type)] - #![warn(clippy::diverging_sub_expression)] #![allow(clippy::match_same_arms, clippy::logic_bug)] #[allow(clippy::empty_loop)] -fn diverge() -> ! { loop {} } +fn diverge() -> ! { + loop {} +} struct A; impl A { - fn foo(&self) -> ! { diverge() } + fn foo(&self) -> ! { + diverge() + } } #[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)] diff --git a/tests/ui/dlist.rs b/tests/ui/dlist.rs index cf16777b77a3..dfc8be24a8bd 100644 --- a/tests/ui/dlist.rs +++ b/tests/ui/dlist.rs @@ -7,13 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(alloc)] #![feature(associated_type_defaults)] - - #![warn(clippy::linkedlist)] #![allow(dead_code, clippy::needless_pass_by_value)] @@ -23,13 +18,13 @@ use alloc::collections::linked_list::LinkedList; trait Foo { type Baz = LinkedList; fn foo(LinkedList); - const BAR : Option>; + const BAR: Option>; } // ok, we don’t want to warn for implementations, see #605 impl Foo for LinkedList { fn foo(_: LinkedList) {} - const BAR : Option> = None; + const BAR: Option> = None; } struct Bar; @@ -49,7 +44,7 @@ pub fn test_local_not_linted() { let _: LinkedList; } -fn main(){ +fn main() { test(LinkedList::new()); test_local_not_linted(); } diff --git a/tests/ui/double_comparison.rs b/tests/ui/double_comparison.rs index 555f35884f9b..70b837a75b68 100644 --- a/tests/ui/double_comparison.rs +++ b/tests/ui/double_comparison.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn main() { let x = 1; let y = 2; diff --git a/tests/ui/double_neg.rs b/tests/ui/double_neg.rs index 3785c09060bf..7d65122cb5e6 100644 --- a/tests/ui/double_neg.rs +++ b/tests/ui/double_neg.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::double_neg)] fn main() { let x = 1; diff --git a/tests/ui/drop_forget_copy.rs b/tests/ui/drop_forget_copy.rs index 44e9ae0e044c..2ea8954ff59c 100644 --- a/tests/ui/drop_forget_copy.rs +++ b/tests/ui/drop_forget_copy.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::drop_copy, clippy::forget_copy)] #![allow(clippy::toplevel_ref_arg, clippy::drop_ref, clippy::forget_ref, unused_mut)] @@ -18,18 +14,21 @@ use std::mem::{drop, forget}; use std::vec::Vec; #[derive(Copy, Clone)] -struct SomeStruct { -} +struct SomeStruct {} struct AnotherStruct { x: u8, y: u8, - z: Vec + z: Vec, } impl Clone for AnotherStruct { - fn clone(& self) -> AnotherStruct { - AnotherStruct{x: self.x, y: self.y, z: self.z.clone()} + fn clone(&self) -> AnotherStruct { + AnotherStruct { + x: self.x, + y: self.y, + z: self.z.clone(), + } } } @@ -52,7 +51,11 @@ fn main() { forget(s4); forget(s5); - let a1 = AnotherStruct {x: 255, y: 0, z: vec![1, 2, 3]}; + let a1 = AnotherStruct { + x: 255, + y: 0, + z: vec![1, 2, 3], + }; let a2 = &a1; let mut a3 = a1.clone(); let ref a4 = a1; diff --git a/tests/ui/drop_forget_ref.rs b/tests/ui/drop_forget_ref.rs index 0aee38d3cbff..6821d4033227 100644 --- a/tests/ui/drop_forget_ref.rs +++ b/tests/ui/drop_forget_ref.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::drop_ref, clippy::forget_ref)] #![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)] diff --git a/tests/ui/duplicate_underscore_argument.rs b/tests/ui/duplicate_underscore_argument.rs index 27329965f0c3..da4e2a6dc8ab 100644 --- a/tests/ui/duplicate_underscore_argument.rs +++ b/tests/ui/duplicate_underscore_argument.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::duplicate_underscore_argument)] #[allow(dead_code, unused)] diff --git a/tests/ui/duration_subsec.rs b/tests/ui/duration_subsec.rs index c8db599a840d..8c2dade34c0f 100644 --- a/tests/ui/duration_subsec.rs +++ b/tests/ui/duration_subsec.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::duration_subsec)] use std::time::Duration; diff --git a/tests/ui/else_if_without_else.rs b/tests/ui/else_if_without_else.rs index caaa024ff6bc..0776eae310c2 100644 --- a/tests/ui/else_if_without_else.rs +++ b/tests/ui/else_if_without_else.rs @@ -7,15 +7,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::all)] #![warn(clippy::else_if_without_else)] -fn bla1() -> bool { unimplemented!() } -fn bla2() -> bool { unimplemented!() } -fn bla3() -> bool { unimplemented!() } +fn bla1() -> bool { + unimplemented!() +} +fn bla2() -> bool { + unimplemented!() +} +fn bla3() -> bool { + unimplemented!() +} fn main() { if bla1() { @@ -48,7 +51,8 @@ fn main() { if bla1() { println!("if"); - } else if bla2() { //~ ERROR else if without else + } else if bla2() { + //~ ERROR else if without else println!("else if"); } @@ -56,7 +60,8 @@ fn main() { println!("if"); } else if bla2() { println!("else if 1"); - } else if bla3() { //~ ERROR else if without else + } else if bla3() { + //~ ERROR else if without else println!("else if 2"); } } diff --git a/tests/ui/empty_enum.rs b/tests/ui/empty_enum.rs index b60f5491a93a..b47afc822f8c 100644 --- a/tests/ui/empty_enum.rs +++ b/tests/ui/empty_enum.rs @@ -7,14 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(dead_code)] #![warn(clippy::empty_enum)] enum Empty {} -fn main() { -} +fn main() {} diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index 0ee6d7992220..6c8267166502 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -7,11 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused, clippy::needless_pass_by_value)] - #![warn(clippy::map_entry)] use std::collections::{BTreeMap, HashMap}; @@ -20,36 +16,65 @@ use std::hash::Hash; fn foo() {} fn insert_if_absent0(m: &mut HashMap, k: K, v: V) { - if !m.contains_key(&k) { m.insert(k, v); } + if !m.contains_key(&k) { + m.insert(k, v); + } } fn insert_if_absent1(m: &mut HashMap, k: K, v: V) { - if !m.contains_key(&k) { foo(); m.insert(k, v); } + if !m.contains_key(&k) { + foo(); + m.insert(k, v); + } } fn insert_if_absent2(m: &mut HashMap, k: K, v: V) { - if !m.contains_key(&k) { m.insert(k, v) } else { None }; + if !m.contains_key(&k) { + m.insert(k, v) + } else { + None + }; } fn insert_if_present2(m: &mut HashMap, k: K, v: V) { - if m.contains_key(&k) { None } else { m.insert(k, v) }; + if m.contains_key(&k) { + None + } else { + m.insert(k, v) + }; } fn insert_if_absent3(m: &mut HashMap, k: K, v: V) { - if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; + if !m.contains_key(&k) { + foo(); + m.insert(k, v) + } else { + None + }; } fn insert_if_present3(m: &mut HashMap, k: K, v: V) { - if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; + if m.contains_key(&k) { + None + } else { + foo(); + m.insert(k, v) + }; } fn insert_in_btreemap(m: &mut BTreeMap, k: K, v: V) { - if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; + if !m.contains_key(&k) { + foo(); + m.insert(k, v) + } else { + None + }; } fn insert_other_if_absent(m: &mut HashMap, k: K, o: K, v: V) { - if !m.contains_key(&k) { m.insert(o, v); } + if !m.contains_key(&k) { + m.insert(o, v); + } } -fn main() { -} +fn main() {} diff --git a/tests/ui/enum_glob_use.rs b/tests/ui/enum_glob_use.rs index 9b7d4518c66e..dde2896e415d 100644 --- a/tests/ui/enum_glob_use.rs +++ b/tests/ui/enum_glob_use.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::all, clippy::pedantic)] #![allow(unused_imports, dead_code, clippy::missing_docs_in_private_items)] @@ -34,8 +31,7 @@ mod tests { } #[allow(non_snake_case)] -mod CamelCaseName { -} +mod CamelCaseName {} use CamelCaseName::*; diff --git a/tests/ui/enum_variants.rs b/tests/ui/enum_variants.rs index 34c69854b75c..0c8f3a36a3d9 100644 --- a/tests/ui/enum_variants.rs +++ b/tests/ui/enum_variants.rs @@ -7,19 +7,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(non_ascii_idents)] - #![warn(clippy::all, clippy::pub_enum_variant_names)] enum FakeCallType { - CALL, CREATE + CALL, + CREATE, } enum FakeCallType2 { - CALL, CREATELL + CALL, + CREATELL, } enum Foo { @@ -49,7 +47,8 @@ enum BadCallType { CallTypeDestroy, } -enum TwoCallType { // no error +enum TwoCallType { + // no error CallTypeCall, CallTypeCreate, } @@ -60,7 +59,8 @@ enum Consts { ConstantLie, } -enum Two { // no error here +enum Two { + // no error here ConstantInt, ConstantInfer, } diff --git a/tests/ui/enums_clike.rs b/tests/ui/enums_clike.rs index 5513a9506aac..9c1cf8e8614a 100644 --- a/tests/ui/enums_clike.rs +++ b/tests/ui/enums_clike.rs @@ -7,14 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - // ignore-x86 - #![warn(clippy::all)] - #![allow(unused)] #[repr(usize)] @@ -62,5 +57,4 @@ trait Trait { } */ -fn main() { -} +fn main() {} diff --git a/tests/ui/erasing_op.rs b/tests/ui/erasing_op.rs index 696c58f98ae3..d71662131943 100644 --- a/tests/ui/erasing_op.rs +++ b/tests/ui/erasing_op.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[allow(clippy::no_effect)] #[warn(clippy::erasing_op)] fn main() { diff --git a/tests/ui/escape_analysis.rs b/tests/ui/escape_analysis.rs index b35071546e76..cc65c6e63066 100644 --- a/tests/ui/escape_analysis.rs +++ b/tests/ui/escape_analysis.rs @@ -8,7 +8,6 @@ // except according to those terms. #![feature(box_syntax)] - #![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)] #![warn(clippy::boxed_local)] @@ -16,7 +15,7 @@ struct A; impl A { - fn foo(&self){} + fn foo(&self) {} } trait Z { @@ -29,8 +28,7 @@ impl Z for A { } } -fn main() { -} +fn main() {} fn ok_box_trait(boxed_trait: &Box) { let boxed_local = boxed_trait; @@ -85,11 +83,9 @@ fn nowarn_pass() { take_box(&bx); // fn needs &Box } - fn take_box(x: &Box) {} fn take_ref(x: &A) {} - fn nowarn_ref_take() { // false positive, should actually warn let x = box A; @@ -100,14 +96,15 @@ fn nowarn_ref_take() { fn nowarn_match() { let x = box A; // moved into a match match x { - y => drop(y) + y => drop(y), } } fn warn_match() { let x = box A; - match &x { // not moved - ref y => () + match &x { + // not moved + ref y => (), } } @@ -115,12 +112,12 @@ fn nowarn_large_array() { // should not warn, is large array // and should not be on stack let x = box [1; 10000]; - match &x { // not moved - ref y => () + match &x { + // not moved + ref y => (), } } - /// ICE regression test pub trait Foo { type Item; @@ -134,8 +131,7 @@ pub struct PeekableSeekable { _peeked: I::Item, } -pub fn new(_needs_name: Box>) -> () { -} +pub fn new(_needs_name: Box>) -> () {} /// Regression for #916, #1123 /// diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index dd41433d2db9..7b39d1c4054e 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -7,10 +7,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -#![allow(unused, clippy::no_effect, clippy::redundant_closure_call, clippy::many_single_char_names, clippy::needless_pass_by_value, clippy::option_map_unit_fn, clippy::trivially_copy_pass_by_ref)] +#![allow( + unused, + clippy::no_effect, + clippy::redundant_closure_call, + clippy::many_single_char_names, + clippy::needless_pass_by_value, + clippy::option_map_unit_fn, + clippy::trivially_copy_pass_by_ref +)] #![warn(clippy::redundant_closure, clippy::needless_borrow)] fn main() { @@ -32,25 +37,31 @@ fn main() { Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref> { Box::new(v) }); } -fn meta(f: F) where F: Fn(u8) { +fn meta(f: F) +where + F: Fn(u8), +{ f(1u8) } -fn foo(_: u8) { -} +fn foo(_: u8) {} fn foo2(_: u8) -> u8 { 1u8 } fn all(x: &[X], y: &X, f: F) -> bool -where F: Fn(&X, &X) -> bool { +where + F: Fn(&X, &X) -> bool, +{ x.iter().all(|e| f(e, y)) } -fn below(x: &u8, y: &u8) -> bool { x < y } +fn below(x: &u8, y: &u8) -> bool { + x < y +} -unsafe fn unsafe_fn(_: u8) { } +unsafe fn unsafe_fn(_: u8) {} fn divergent(_: u8) -> ! { unimplemented!() diff --git a/tests/ui/eval_order_dependence.rs b/tests/ui/eval_order_dependence.rs index ee8f834fe564..82110d5e4f39 100644 --- a/tests/ui/eval_order_dependence.rs +++ b/tests/ui/eval_order_dependence.rs @@ -7,52 +7,112 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::eval_order_dependence)] -#[allow(unused_assignments, unused_variables, clippy::many_single_char_names, clippy::no_effect, dead_code, clippy::blacklisted_name)] +#[allow( + unused_assignments, + unused_variables, + clippy::many_single_char_names, + clippy::no_effect, + dead_code, + clippy::blacklisted_name +)] fn main() { let mut x = 0; - let a = { x = 1; 1 } + x; + let a = { + x = 1; + 1 + } + x; // Example from iss#277 - x += { x = 20; 2 }; + x += { + x = 20; + 2 + }; // Does it work in weird places? // ...in the base for a struct expression? - struct Foo { a: i32, b: i32 }; + struct Foo { + a: i32, + b: i32, + }; let base = Foo { a: 4, b: 5 }; - let foo = Foo { a: x, .. { x = 6; base } }; + let foo = Foo { + a: x, + ..{ + x = 6; + base + } + }; // ...inside a closure? let closure = || { let mut x = 0; - x += { x = 20; 2 }; + x += { + x = 20; + 2 + }; }; // ...not across a closure? let mut y = 0; - let b = (y, || { y = 1 }); + let b = (y, || y = 1); // && and || evaluate left-to-right. - let a = { x = 1; true } && (x == 3); - let a = { x = 1; true } || (x == 3); + let a = { + x = 1; + true + } && (x == 3); + let a = { + x = 1; + true + } || (x == 3); // Make sure we don't get confused by alpha conversion. - let a = { let mut x = 1; x = 2; 1 } + x; + let a = { + let mut x = 1; + x = 2; + 1 + } + x; // No warning if we don't read the variable... - x = { x = 20; 2 }; + x = { + x = 20; + 2 + }; // ...if the assignment is in a closure... - let b = { || { x = 1; }; 1 } + x; + let b = { + || { + x = 1; + }; + 1 + } + x; // ... or the access is under an address. - let b = ({ let p = &x; 1 }, { x = 1; x }); + let b = ( + { + let p = &x; + 1 + }, + { + x = 1; + x + }, + ); // Limitation: l-values other than simple variables don't trigger // the warning. let mut tup = (0, 0); - let c = { tup.0 = 1; 1 } + tup.0; + let c = { + tup.0 = 1; + 1 + } + tup.0; // Limitation: you can get away with a read under address-of. let mut z = 0; - let b = (&{ z = x; x }, { x = 3; x }); + let b = ( + &{ + z = x; + x + }, + { + x = 3; + x + }, + ); } diff --git a/tests/ui/excessive_precision.rs b/tests/ui/excessive_precision.rs index 5945298da9f4..59b252a3a80a 100644 --- a/tests/ui/excessive_precision.rs +++ b/tests/ui/excessive_precision.rs @@ -7,8 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #![warn(clippy::excessive_precision)] #![allow(clippy::print_literal)] diff --git a/tests/ui/expect_fun_call.rs b/tests/ui/expect_fun_call.rs index cf764c43694a..8afffa4d8434 100644 --- a/tests/ui/expect_fun_call.rs +++ b/tests/ui/expect_fun_call.rs @@ -16,7 +16,9 @@ fn expect_fun_call() { struct Foo; impl Foo { - fn new() -> Self { Foo } + fn new() -> Self { + Foo + } fn expect(&self, msg: &str) { panic!("{}", msg) diff --git a/tests/ui/explicit_counter_loop.rs b/tests/ui/explicit_counter_loop.rs index eaed606b89e9..75d905659d9b 100644 --- a/tests/ui/explicit_counter_loop.rs +++ b/tests/ui/explicit_counter_loop.rs @@ -26,9 +26,11 @@ fn main() { mod issue_1219 { pub fn test() { // should not trigger the lint because variable is used after the loop #473 - let vec = vec![1,2,3]; + let vec = vec![1, 2, 3]; let mut index = 0; - for _v in &vec { index += 1 } + for _v in &vec { + index += 1 + } println!("index: {}", index); // should not trigger the lint because the count is conditional #1219 diff --git a/tests/ui/explicit_write.rs b/tests/ui/explicit_write.rs index 8c1e35daa488..10a4bca9f492 100644 --- a/tests/ui/explicit_write.rs +++ b/tests/ui/explicit_write.rs @@ -7,12 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::explicit_write)] - fn stdout() -> String { String::new() } diff --git a/tests/ui/fallible_impl_from.rs b/tests/ui/fallible_impl_from.rs index f50d5999de61..0d8c369660b8 100644 --- a/tests/ui/fallible_impl_from.rs +++ b/tests/ui/fallible_impl_from.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::fallible_impl_from)] // docs example @@ -20,7 +17,6 @@ impl From for Foo { } } - struct Valid(Vec); impl<'a> From<&'a str> for Valid { @@ -34,7 +30,6 @@ impl From for Valid { } } - struct Invalid; impl From for Invalid { diff --git a/tests/ui/filter_methods.rs b/tests/ui/filter_methods.rs index 33441d728cae..7ca74fd4b995 100644 --- a/tests/ui/filter_methods.rs +++ b/tests/ui/filter_methods.rs @@ -7,31 +7,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::missing_docs_in_private_items)] fn main() { - let _: Vec<_> = vec![5; 6].into_iter() - .filter(|&x| x == 0) - .map(|x| x * 2) - .collect(); - - let _: Vec<_> = vec![5_i8; 6].into_iter() - .filter(|&x| x == 0) - .flat_map(|x| x.checked_mul(2)) - .collect(); - - let _: Vec<_> = vec![5_i8; 6].into_iter() - .filter_map(|x| x.checked_mul(2)) - .flat_map(|x| x.checked_mul(2)) - .collect(); - - let _: Vec<_> = vec![5_i8; 6].into_iter() - .filter_map(|x| x.checked_mul(2)) - .map(|x| x.checked_mul(2)) - .collect(); + let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect(); + + let _: Vec<_> = vec![5_i8; 6] + .into_iter() + .filter(|&x| x == 0) + .flat_map(|x| x.checked_mul(2)) + .collect(); + + let _: Vec<_> = vec![5_i8; 6] + .into_iter() + .filter_map(|x| x.checked_mul(2)) + .flat_map(|x| x.checked_mul(2)) + .collect(); + + let _: Vec<_> = vec![5_i8; 6] + .into_iter() + .filter_map(|x| x.checked_mul(2)) + .map(|x| x.checked_mul(2)) + .collect(); } diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index 5619539fb5a0..2d55e30a2d3d 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -7,31 +7,41 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::float_cmp)] #![allow(unused, clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)] use std::ops::Add; -const ZERO : f32 = 0.0; -const ONE : f32 = ZERO + 1.0; +const ZERO: f32 = 0.0; +const ONE: f32 = ZERO + 1.0; -fn twice(x : T) -> T where T : Add, T : Copy { +fn twice(x: T) -> T +where + T: Add, + T: Copy, +{ x + x } fn eq_fl(x: f32, y: f32) -> bool { - if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn + if x.is_nan() { + y.is_nan() + } else { + x == y + } // no error, inside "eq" fn } fn fl_eq(x: f32, y: f32) -> bool { - if x.is_nan() { y.is_nan() } else { x == y } // no error, inside "eq" fn + if x.is_nan() { + y.is_nan() + } else { + x == y + } // no error, inside "eq" fn } -struct X { val: f32 } +struct X { + val: f32, +} impl PartialEq for X { fn eq(&self, o: &X) -> bool { @@ -59,7 +69,7 @@ fn main() { ONE as f64 != 2.0; ONE as f64 != 0.0; // no error, comparison with zero is ok - let x : f64 = 1.0; + let x: f64 = 1.0; x == 1.0; x != 0f64; // no error, comparison with zero is ok @@ -71,7 +81,7 @@ fn main() { x <= 0.0; x >= 0.0; - let xs : [f32; 1] = [0.0]; + let xs: [f32; 1] = [0.0]; let a: *const f32 = xs.as_ptr(); let b: *const f32 = xs.as_ptr(); diff --git a/tests/ui/float_cmp_const.rs b/tests/ui/float_cmp_const.rs index 7cca1df65aed..e02671e0dcc1 100644 --- a/tests/ui/float_cmp_const.rs +++ b/tests/ui/float_cmp_const.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::float_cmp_const)] #![allow(clippy::float_cmp)] #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] @@ -19,7 +15,11 @@ const ONE: f32 = 1.0; const TWO: f32 = 2.0; fn eq_one(x: f32) -> bool { - if x.is_nan() { false } else { x == ONE } // no error, inside "eq" fn + if x.is_nan() { + false + } else { + x == ONE + } // no error, inside "eq" fn } fn main() { diff --git a/tests/ui/fn_to_numeric_cast.rs b/tests/ui/fn_to_numeric_cast.rs index 50796e13ef67..9b48a965cb31 100644 --- a/tests/ui/fn_to_numeric_cast.rs +++ b/tests/ui/fn_to_numeric_cast.rs @@ -7,13 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - // only-64bit - #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] -fn foo() -> String { String::new() } +fn foo() -> String { + String::new() +} fn test_function_to_numeric_cast() { let _ = foo as i8; diff --git a/tests/ui/for_loop.rs b/tests/ui/for_loop.rs index 513a3c0ee421..4747269bccdd 100644 --- a/tests/ui/for_loop.rs +++ b/tests/ui/for_loop.rs @@ -25,10 +25,22 @@ impl Unrelated { } } -#[warn(clippy::needless_range_loop, clippy::explicit_iter_loop, clippy::explicit_into_iter_loop, clippy::iter_next_loop, clippy::reverse_range_loop, - clippy::for_kv_map)] +#[warn( + clippy::needless_range_loop, + clippy::explicit_iter_loop, + clippy::explicit_into_iter_loop, + clippy::iter_next_loop, + clippy::reverse_range_loop, + clippy::for_kv_map +)] #[warn(clippy::unused_collect)] -#[allow(clippy::linkedlist, clippy::shadow_unrelated, clippy::unnecessary_mut_passed, clippy::cyclomatic_complexity, clippy::similar_names)] +#[allow( + clippy::linkedlist, + clippy::shadow_unrelated, + clippy::unnecessary_mut_passed, + clippy::cyclomatic_complexity, + clippy::similar_names +)] #[allow(clippy::many_single_char_names, unused_variables, clippy::into_iter_on_array)] fn main() { const MAX_LEN: usize = 42; diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 88f6e497d12e..875a74d25081 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -7,82 +7,74 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![allow(unused_variables)] #![allow(unused_assignments)] #![allow(clippy::if_same_then_else)] #![allow(clippy::deref_addrof)] -fn foo() -> bool { true } +fn foo() -> bool { + true +} fn main() { // weird `else if` formatting: - if foo() { - } if foo() { - } + if foo() {} + if foo() {} - let _ = { // if as the last expression + let _ = { + // if as the last expression let _ = 0; + if foo() {} if foo() { - } if foo() { - } - else { + } else { } }; - let _ = { // if in the middle of a block + let _ = { + // if in the middle of a block + if foo() {} if foo() { - } if foo() { - } - else { + } else { } let _ = 0; }; if foo() { - } else - if foo() { // the span of the above error should continue here + } else if foo() { + // the span of the above error should continue here } if foo() { - } - else - if foo() { // the span of the above error should continue here + } else if foo() { + // the span of the above error should continue here } // those are ok: - if foo() { - } - if foo() { - } + if foo() {} + if foo() {} if foo() { } else if foo() { } if foo() { - } - else if foo() { + } else if foo() { } if foo() { + } else if foo() { } - else if - foo() {} // weird op_eq formatting: let mut a = 42; - a =- 35; - a =* &191; + a = -35; + a = *&191; let mut b = true; - b =! false; + b = !false; // those are ok: a = -35; @@ -91,37 +83,30 @@ fn main() { // possible missing comma in an array let _ = &[ - -1, -2, -3 // <= no comma here - -4, -5, -6 + -1, + -2, + -3 // <= no comma here + -4, + -5, + -6, ]; let _ = &[ - -1, -2, -3 // <= no comma here - *4, -5, -6 + -1, + -2, + -3 // <= no comma here + *4, + -5, + -6, ]; // those are ok: - let _ = &[ - -1, -2, -3, - -4, -5, -6 - ]; - let _ = &[ - -1, -2, -3, - -4, -5, -6, - ]; - let _ = &[ - 1 + 2, 3 + - 4, 5 + 6, - ]; + let _ = &[-1, -2, -3, -4, -5, -6]; + let _ = &[-1, -2, -3, -4, -5, -6]; + let _ = &[1 + 2, 3 + 4, 5 + 6]; // don't lint for bin op without unary equiv // issue 3244 - vec![ - 1 - / 2, - ]; + vec![1 / 2]; // issue 3396 - vec![ - true - | false, - ]; + vec![true | false]; } diff --git a/tests/ui/functions.rs b/tests/ui/functions.rs index f5ba0f791eeb..419632948157 100644 --- a/tests/ui/functions.rs +++ b/tests/ui/functions.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![allow(dead_code)] #![allow(unused_unsafe)] @@ -18,11 +14,20 @@ // TOO_MANY_ARGUMENTS fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {} -fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) { -} +fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} // don't lint extern fns -extern fn extern_fn(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} +extern "C" fn extern_fn( + _one: u32, + _two: u32, + _three: &str, + _four: bool, + _five: f32, + _six: f32, + _seven: bool, + _eight: (), +) { +} pub trait Foo { fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool); diff --git a/tests/ui/fxhash.rs b/tests/ui/fxhash.rs index fe4b80807c09..2299714132f5 100644 --- a/tests/ui/fxhash.rs +++ b/tests/ui/fxhash.rs @@ -7,16 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::default_hash_types)] #![feature(rustc_private)] extern crate rustc_data_structures; -use std::collections::{HashMap, HashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use std::collections::{HashMap, HashSet}; fn main() { let _map: HashMap = HashMap::default(); diff --git a/tests/ui/get_unwrap.rs b/tests/ui/get_unwrap.rs index 7b672c0748ce..e8789db6fc1a 100644 --- a/tests/ui/get_unwrap.rs +++ b/tests/ui/get_unwrap.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(unused_mut)] use std::collections::BTreeMap; @@ -20,8 +19,12 @@ struct GetFalsePositive { } impl GetFalsePositive { - fn get(&self, pos: usize) -> Option<&u32> { self.arr.get(pos) } - fn get_mut(&mut self, pos: usize) -> Option<&mut u32> { self.arr.get_mut(pos) } + fn get(&self, pos: usize) -> Option<&u32> { + self.arr.get(pos) + } + fn get_mut(&mut self, pos: usize) -> Option<&mut u32> { + self.arr.get_mut(pos) + } } fn main() { @@ -33,7 +36,8 @@ fn main() { let mut some_btreemap: BTreeMap = BTreeMap::from_iter(vec![(1, 'a'), (2, 'b')]); let mut false_positive = GetFalsePositive { arr: [0, 1, 2] }; - { // Test `get().unwrap()` + { + // Test `get().unwrap()` let _ = boxed_slice.get(1).unwrap(); let _ = some_slice.get(0).unwrap(); let _ = some_vec.get(0).unwrap(); @@ -43,7 +47,8 @@ fn main() { let _ = false_positive.get(0).unwrap(); } - { // Test `get_mut().unwrap()` + { + // Test `get_mut().unwrap()` *boxed_slice.get_mut(0).unwrap() = 1; *some_slice.get_mut(0).unwrap() = 1; *some_vec.get_mut(0).unwrap() = 1; @@ -54,7 +59,8 @@ fn main() { *false_positive.get_mut(0).unwrap() = 1; } - { // Test `get().unwrap().foo()` and `get_mut().unwrap().bar()` + { + // Test `get().unwrap().foo()` and `get_mut().unwrap().bar()` let _ = some_vec.get(0..1).unwrap().to_vec(); let _ = some_vec.get_mut(0..1).unwrap().to_vec(); } diff --git a/tests/ui/ice-2636.rs b/tests/ui/ice-2636.rs index 3ef9ea8f69fb..caf8c89390dd 100644 --- a/tests/ui/ice-2636.rs +++ b/tests/ui/ice-2636.rs @@ -29,4 +29,3 @@ fn main() { let a = Foo::A; test_hash!(&a, A => 0, B => 1, C => 2); } - diff --git a/tests/ui/identity_conversion.rs b/tests/ui/identity_conversion.rs index b5cb92c6d5a1..6ba191b0b843 100644 --- a/tests/ui/identity_conversion.rs +++ b/tests/ui/identity_conversion.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::identity_conversion)] fn test_generic(val: T) -> T { diff --git a/tests/ui/identity_op.rs b/tests/ui/identity_op.rs index 07a4ef8f3eb2..c8874250a043 100644 --- a/tests/ui/identity_op.rs +++ b/tests/ui/identity_op.rs @@ -7,15 +7,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - -const ONE : i64 = 1; -const NEG_ONE : i64 = -1; -const ZERO : i64 = 0; - -#[allow(clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::double_parens)] +const ONE: i64 = 1; +const NEG_ONE: i64 = -1; +const ZERO: i64 = 0; + +#[allow( + clippy::eq_op, + clippy::no_effect, + clippy::unnecessary_operation, + clippy::double_parens +)] #[warn(clippy::identity_op)] fn main() { let x = 0; @@ -25,19 +26,19 @@ fn main() { x + 1; 0 + x; 1 + x; - x - ZERO; //no error, as we skip lookups (for now) + x - ZERO; //no error, as we skip lookups (for now) x | (0); - ((ZERO)) | x; //no error, as we skip lookups (for now) + (ZERO) | x; //no error, as we skip lookups (for now) x * 1; 1 * x; - x / ONE; //no error, as we skip lookups (for now) + x / ONE; //no error, as we skip lookups (for now) - x / 2; //no false positive + x / 2; //no false positive - x & NEG_ONE; //no error, as we skip lookups (for now) + x & NEG_ONE; //no error, as we skip lookups (for now) -1 & x; - let u : u8 = 0; + let u: u8 = 0; u & 255; } diff --git a/tests/ui/if_not_else.rs b/tests/ui/if_not_else.rs index 23895c0ab52f..0179381fdc3d 100644 --- a/tests/ui/if_not_else.rs +++ b/tests/ui/if_not_else.rs @@ -7,13 +7,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::all)] #![warn(clippy::if_not_else)] -fn bla() -> bool { unimplemented!() } +fn bla() -> bool { + unimplemented!() +} fn main() { if !bla() { diff --git a/tests/ui/impl.rs b/tests/ui/impl.rs index 38c0a484091c..398a8ccce44f 100644 --- a/tests/ui/impl.rs +++ b/tests/ui/impl.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(dead_code)] #![warn(clippy::multiple_inherent_impl)] diff --git a/tests/ui/implicit_hasher.rs b/tests/ui/implicit_hasher.rs index a6be909c0cc2..ddcd8bcd755a 100644 --- a/tests/ui/implicit_hasher.rs +++ b/tests/ui/implicit_hasher.rs @@ -7,12 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(unused)] -use std::collections::{HashMap, HashSet}; use std::cmp::Eq; -use std::hash::{Hash, BuildHasher}; +use std::collections::{HashMap, HashSet}; +use std::hash::{BuildHasher, Hash}; pub trait Foo: Sized { fn make() -> (Self, Self); @@ -49,7 +48,6 @@ impl Foo for HashMap { } } - impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::new(), HashSet::with_capacity(10)) @@ -72,8 +70,7 @@ impl Foo for HashSet { } } -pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { -} +pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} macro_rules! gen { (impl) => { @@ -85,19 +82,19 @@ macro_rules! gen { }; (fn $name:ident) => { - pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { - } - } + pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} + }; } -gen!(impl); +gen!(impl ); gen!(fn bar); // When the macro is in a different file, the suggestion spans can't be combined properly // and should not cause an ICE // See #2707 #[macro_use] -#[path = "../auxiliary/test_macro.rs"] pub mod test_macro; +#[path = "../auxiliary/test_macro.rs"] +pub mod test_macro; __implicit_hasher_test_macro!(impl for HashMap where V: test_macro::A); fn main() {} diff --git a/tests/ui/implicit_return.rs b/tests/ui/implicit_return.rs index 73cf2908833c..3bff92cf492b 100644 --- a/tests/ui/implicit_return.rs +++ b/tests/ui/implicit_return.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::implicit_return)] fn test_end_of_fn() -> bool { @@ -34,9 +30,7 @@ fn test_if_block() -> bool { fn test_match(x: bool) -> bool { match x { true => false, - false => { - true - } + false => true, } } @@ -48,9 +42,7 @@ fn test_loop() -> bool { } fn test_closure() { - let _ = || { - true - }; + let _ = || true; let _ = || true; } diff --git a/tests/ui/inconsistent_digit_grouping.rs b/tests/ui/inconsistent_digit_grouping.rs index 941fbe5154aa..31e34135bfc9 100644 --- a/tests/ui/inconsistent_digit_grouping.rs +++ b/tests/ui/inconsistent_digit_grouping.rs @@ -7,12 +7,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #[warn(clippy::inconsistent_digit_grouping)] #[allow(unused_variables)] fn main() { - let good = (123, 1_234, 1_2345_6789, 123_f32, 1_234.12_f32, 1_234.123_4_f32, 1.123_456_7_f32); + let good = ( + 123, + 1_234, + 1_2345_6789, + 123_f32, + 1_234.12_f32, + 1_234.123_4_f32, + 1.123_456_7_f32, + ); let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); } diff --git a/tests/ui/indexing_slicing.rs b/tests/ui/indexing_slicing.rs index ff154091bb82..a9e697e519f8 100644 --- a/tests/ui/indexing_slicing.rs +++ b/tests/ui/indexing_slicing.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(plugin)] #![warn(clippy::indexing_slicing)] #![warn(clippy::out_of_bounds_indexing)] diff --git a/tests/ui/infallible_destructuring_match.rs b/tests/ui/infallible_destructuring_match.rs index 62036cbc107e..37ae19497d18 100644 --- a/tests/ui/infallible_destructuring_match.rs +++ b/tests/ui/infallible_destructuring_match.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(exhaustive_patterns, never_type)] #![allow(clippy::let_and_return)] diff --git a/tests/ui/infinite_iter.rs b/tests/ui/infinite_iter.rs index 68c10acb2bef..8f41e3ae98d9 100644 --- a/tests/ui/infinite_iter.rs +++ b/tests/ui/infinite_iter.rs @@ -7,12 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - use std::iter::repeat; #[allow(clippy::trivially_copy_pass_by_ref)] -fn square_is_lower_64(x: &u32) -> bool { x * x < 64 } +fn square_is_lower_64(x: &u32) -> bool { + x * x < 64 +} #[allow(clippy::maybe_infinite_iter)] #[deny(clippy::infinite_iter)] @@ -20,10 +19,17 @@ fn infinite_iters() { repeat(0_u8).collect::>(); // infinite iter (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter (0..8_u64).chain(0..).max(); // infinite iter - (0_usize..).chain([0usize, 1, 2].iter().cloned()).skip_while(|x| *x != 42).min(); // infinite iter - (0..8_u32).rev().cycle().map(|x| x + 1_u32).for_each(|x| println!("{}", x)); // infinite iter + (0_usize..) + .chain([0usize, 1, 2].iter().cloned()) + .skip_while(|x| *x != 42) + .min(); // infinite iter + (0..8_u32) + .rev() + .cycle() + .map(|x| x + 1_u32) + .for_each(|x| println!("{}", x)); // infinite iter (0..3_u32).flat_map(|x| x..).sum::(); // infinite iter - (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter + (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter (0..42_u64).by_ref().last(); // not an infinite, because ranges are double-ended (0..).next(); // iterator is not exhausted @@ -33,7 +39,12 @@ fn infinite_iters() { fn potential_infinite_iters() { (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter - (1..).scan(0, |state, x| { *state += x; Some(*state) }).min(); // maybe infinite iter + (1..) + .scan(0, |state, x| { + *state += x; + Some(*state) + }) + .min(); // maybe infinite iter (0..).find(|x| *x == 24); // maybe infinite iter (0..).position(|x| x == 24); // maybe infinite iter (0..).any(|x| x == 24); // maybe infinite iter diff --git a/tests/ui/infinite_loop.rs b/tests/ui/infinite_loop.rs index 869b34e8adec..f93103215932 100644 --- a/tests/ui/infinite_loop.rs +++ b/tests/ui/infinite_loop.rs @@ -7,17 +7,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::trivially_copy_pass_by_ref)] - -fn fn_val(i: i32) -> i32 { unimplemented!() } -fn fn_constref(i: &i32) -> i32 { unimplemented!() } -fn fn_mutref(i: &mut i32) { unimplemented!() } -fn fooi() -> i32 { unimplemented!() } -fn foob() -> bool { unimplemented!() } +fn fn_val(i: i32) -> i32 { + unimplemented!() +} +fn fn_constref(i: &i32) -> i32 { + unimplemented!() +} +fn fn_mutref(i: &mut i32) { + unimplemented!() +} +fn fooi() -> i32 { + unimplemented!() +} +fn foob() -> bool { + unimplemented!() +} #[allow(clippy::many_single_char_names)] fn immutable_condition() { @@ -143,12 +149,15 @@ fn consts() { use std::cell::Cell; -fn maybe_i_mutate(i: &Cell) { unimplemented!() } +fn maybe_i_mutate(i: &Cell) { + unimplemented!() +} fn internally_mutable() { let b = Cell::new(true); - while b.get() { // b cannot be silently coerced to `bool` + while b.get() { + // b cannot be silently coerced to `bool` maybe_i_mutate(&b); println!("OK - Method call within condition"); } diff --git a/tests/ui/inline_fn_without_body.rs b/tests/ui/inline_fn_without_body.rs index 8434d33f65ed..d97e6d69941f 100644 --- a/tests/ui/inline_fn_without_body.rs +++ b/tests/ui/inline_fn_without_body.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::inline_fn_without_body)] #![allow(clippy::inline_always)] @@ -18,15 +14,14 @@ trait Foo { #[inline] fn default_inline(); - #[inline(always)]fn always_inline(); + #[inline(always)] + fn always_inline(); #[inline(never)] fn never_inline(); #[inline] - fn has_body() { - } + fn has_body() {} } -fn main() { -} +fn main() {} diff --git a/tests/ui/int_plus_one.rs b/tests/ui/int_plus_one.rs index 8a0405321d06..ce6cd7888ee8 100644 --- a/tests/ui/int_plus_one.rs +++ b/tests/ui/int_plus_one.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[allow(clippy::no_effect, clippy::unnecessary_operation)] #[warn(clippy::int_plus_one)] fn main() { diff --git a/tests/ui/into_iter_on_ref.rs b/tests/ui/into_iter_on_ref.rs index 72aa6341a50b..212234f03465 100644 --- a/tests/ui/into_iter_on_ref.rs +++ b/tests/ui/into_iter_on_ref.rs @@ -5,21 +5,21 @@ struct X; use std::collections::*; fn main() { - for _ in &[1,2,3] {} + for _ in &[1, 2, 3] {} for _ in vec![X, X] {} for _ in &vec![X, X] {} - for _ in [1,2,3].into_iter() {} //~ ERROR equivalent to .iter() + for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter() - let _ = [1,2,3].into_iter(); //~ ERROR equivalent to .iter() - let _ = vec![1,2,3].into_iter(); - let _ = (&vec![1,2,3]).into_iter(); //~ WARN equivalent to .iter() - let _ = vec![1,2,3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() + let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter() + let _ = vec![1, 2, 3].into_iter(); + let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() + let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter() - let _ = (&&&&&&&[1,2,3]).into_iter(); //~ ERROR equivalent to .iter() - let _ = (&&&&mut &&&[1,2,3]).into_iter(); //~ ERROR equivalent to .iter() - let _ = (&mut &mut &mut [1,2,3]).into_iter(); //~ ERROR equivalent to .iter_mut() + let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() + let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() + let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter() let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut() diff --git a/tests/ui/invalid_ref.rs b/tests/ui/invalid_ref.rs index 9fb6c7fd4b74..0ec356280b63 100644 --- a/tests/ui/invalid_ref.rs +++ b/tests/ui/invalid_ref.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(unused)] #![feature(core_intrinsics)] @@ -18,8 +14,8 @@ extern crate core; use std::intrinsics::{init, uninit}; fn main() { - let x = 1; - unsafe { + let x = 1; + unsafe { ref_to_zeroed_std(&x); ref_to_zeroed_core(&x); ref_to_zeroed_intr(&x); @@ -34,43 +30,41 @@ fn main() { } unsafe fn ref_to_zeroed_std(t: &T) { - let ref_zero: &T = std::mem::zeroed(); // warning + let ref_zero: &T = std::mem::zeroed(); // warning } unsafe fn ref_to_zeroed_core(t: &T) { - let ref_zero: &T = core::mem::zeroed(); // warning + let ref_zero: &T = core::mem::zeroed(); // warning } unsafe fn ref_to_zeroed_intr(t: &T) { - let ref_zero: &T = std::intrinsics::init(); // warning + let ref_zero: &T = std::intrinsics::init(); // warning } unsafe fn ref_to_uninit_std(t: &T) { - let ref_uninit: &T = std::mem::uninitialized(); // warning + let ref_uninit: &T = std::mem::uninitialized(); // warning } unsafe fn ref_to_uninit_core(t: &T) { - let ref_uninit: &T = core::mem::uninitialized(); // warning + let ref_uninit: &T = core::mem::uninitialized(); // warning } unsafe fn ref_to_uninit_intr(t: &T) { - let ref_uninit: &T = std::intrinsics::uninit(); // warning + let ref_uninit: &T = std::intrinsics::uninit(); // warning } fn some_ref() { - let some_ref = &1; + let some_ref = &1; } unsafe fn std_zeroed_no_ref() { - let mem_zero: usize = std::mem::zeroed(); // no warning + let mem_zero: usize = std::mem::zeroed(); // no warning } unsafe fn core_zeroed_no_ref() { - let mem_zero: usize = core::mem::zeroed(); // no warning + let mem_zero: usize = core::mem::zeroed(); // no warning } unsafe fn intr_init_no_ref() { let mem_zero: usize = std::intrinsics::init(); // no warning } - - diff --git a/tests/ui/invalid_upcast_comparisons.rs b/tests/ui/invalid_upcast_comparisons.rs index 3e62f11006d4..60f877b1ebe6 100644 --- a/tests/ui/invalid_upcast_comparisons.rs +++ b/tests/ui/invalid_upcast_comparisons.rs @@ -7,14 +7,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::invalid_upcast_comparisons)] -#![allow(unused, clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::cast_lossless)] - -fn mk_value() -> T { unimplemented!() } +#![allow( + unused, + clippy::eq_op, + clippy::no_effect, + clippy::unnecessary_operation, + clippy::cast_lossless +)] + +fn mk_value() -> T { + unimplemented!() +} fn main() { let u32: u32 = mk_value(); @@ -55,7 +59,6 @@ fn main() { 1337 != (u8 as i32); 1337 != (u8 as u32); - // Those are Ok: (u8 as u32) > 20; 42 == (u8 as i32); diff --git a/tests/ui/issue-3145.rs b/tests/ui/issue-3145.rs index 74a11925a764..5c6392811b9c 100644 --- a/tests/ui/issue-3145.rs +++ b/tests/ui/issue-3145.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn main() { println!("{}" a); //~ERROR expected token: `,` } diff --git a/tests/ui/issue_2356.rs b/tests/ui/issue_2356.rs index 070808f7b698..a54da0b6a969 100644 --- a/tests/ui/issue_2356.rs +++ b/tests/ui/issue_2356.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::while_let_on_iterator)] use std::iter::Iterator; diff --git a/tests/ui/item_after_statement.rs b/tests/ui/item_after_statement.rs index a4cc42f0d722..fca19350558b 100644 --- a/tests/ui/item_after_statement.rs +++ b/tests/ui/item_after_statement.rs @@ -7,24 +7,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::items_after_statements)] fn ok() { - fn foo() { println!("foo"); } + fn foo() { + println!("foo"); + } foo(); } fn last() { foo(); - fn foo() { println!("foo"); } + fn foo() { + println!("foo"); + } } fn main() { foo(); - fn foo() { println!("foo"); } + fn foo() { + println!("foo"); + } foo(); } @@ -33,7 +36,9 @@ fn mac() { println!("{}", a); // do not lint this, because it needs to be after `a` macro_rules! b { - () => {{ a = 6 }} + () => {{ + a = 6 + }}; } b!(); println!("{}", a); diff --git a/tests/ui/large_digit_groups.rs b/tests/ui/large_digit_groups.rs index aad5c2050410..80153efcb93b 100644 --- a/tests/ui/large_digit_groups.rs +++ b/tests/ui/large_digit_groups.rs @@ -7,12 +7,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #[warn(clippy::large_digit_groups)] #[allow(unused_variables)] fn main() { - let good = (0b1011_i64, 0o1_234_u32, 0x1_234_567, 1_2345_6789, 1234_f32, 1_234.12_f32, 1_234.123_f32, 1.123_4_f32); - let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); + let good = ( + 0b1011_i64, + 0o1_234_u32, + 0x1_234_567, + 1_2345_6789, + 1234_f32, + 1_234.12_f32, + 1_234.123_f32, + 1.123_4_f32, + ); + let bad = ( + 0b1_10110_i64, + 0x1_23456_78901_usize, + 1_23456_f32, + 1_23456.12_f32, + 1_23456.12345_f32, + 1_23456.12345_6_f32, + ); } diff --git a/tests/ui/large_enum_variant.rs b/tests/ui/large_enum_variant.rs index 419cb0ab4281..29a73e68d43d 100644 --- a/tests/ui/large_enum_variant.rs +++ b/tests/ui/large_enum_variant.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(dead_code)] #![allow(unused_variables)] #![warn(clippy::large_enum_variant)] diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs index bc82e0bca046..7f4ba4f15233 100644 --- a/tests/ui/len_zero.rs +++ b/tests/ui/len_zero.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::len_without_is_empty, clippy::len_zero)] #![allow(dead_code, unused)] diff --git a/tests/ui/let_if_seq.rs b/tests/ui/let_if_seq.rs index 080fa3b24b87..26fdc46ac17b 100644 --- a/tests/ui/let_if_seq.rs +++ b/tests/ui/let_if_seq.rs @@ -7,15 +7,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - -#![allow(unused_variables, unused_assignments, clippy::similar_names, clippy::blacklisted_name)] +#![allow( + unused_variables, + unused_assignments, + clippy::similar_names, + clippy::blacklisted_name +)] #![warn(clippy::useless_let_if_seq)] -fn f() -> bool { true } -fn g(x: i32) -> i32 { x + 1 } +fn f() -> bool { + true +} +fn g(x: i32) -> i32 { + x + 1 +} fn issue985() -> i32 { let mut x = 42; @@ -73,8 +78,7 @@ fn main() { if f() { f(); bar = 42; - } - else { + } else { f(); } diff --git a/tests/ui/let_return.rs b/tests/ui/let_return.rs index 317aaf42b5c7..eb0121333768 100644 --- a/tests/ui/let_return.rs +++ b/tests/ui/let_return.rs @@ -7,11 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused)] - #![warn(clippy::let_and_return)] fn test() -> i32 { @@ -52,5 +48,4 @@ fn test_nowarn_4() -> i32 { x } -fn main() { -} +fn main() {} diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index d77bc8712bf9..89cb190cc96e 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -7,23 +7,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::let_unit_value)] #![allow(unused_variables)] macro_rules! let_and_return { ($n:expr) => {{ let ret = $n; - }} + }}; } fn main() { let _x = println!("x"); - let _y = 1; // this is fine - let _z = ((), 1); // this as well + let _y = 1; // this is fine + let _z = ((), 1); // this as well if true { let _a = (); } diff --git a/tests/ui/lifetimes.rs b/tests/ui/lifetimes.rs index 77f25afe0236..110868404bda 100644 --- a/tests/ui/lifetimes.rs +++ b/tests/ui/lifetimes.rs @@ -7,63 +7,89 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::needless_lifetimes, clippy::extra_unused_lifetimes)] #![allow(dead_code, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)] -fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } +fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} -fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } +fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} -fn same_lifetime_on_input<'a>(_x: &'a u8, _y: &'a u8) { } // no error, same lifetime on two params +fn same_lifetime_on_input<'a>(_x: &'a u8, _y: &'a u8) {} // no error, same lifetime on two params -fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) { } // no error, static involved +fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) {} // no error, static involved -fn mut_and_static_input(_x: &mut u8, _y: &'static str) { } +fn mut_and_static_input(_x: &mut u8, _y: &'static str) {} -fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } +fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { + x +} -fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 { x } // no error, multiple input refs +fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 { + x +} // no error, multiple input refs -fn multiple_in_and_out_2<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { x } // no error, multiple input refs +fn multiple_in_and_out_2<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 { + x +} // no error, multiple input refs -fn in_static_and_out<'a>(x: &'a u8, _y: &'static u8) -> &'a u8 { x } // no error, static involved +fn in_static_and_out<'a>(x: &'a u8, _y: &'static u8) -> &'a u8 { + x +} // no error, static involved -fn deep_reference_1<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { Ok(x) } // no error +fn deep_reference_1<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { + Ok(x) +} // no error -fn deep_reference_2<'a>(x: Result<&'a u8, &'a u8>) -> &'a u8 { x.unwrap() } // no error, two input refs +fn deep_reference_2<'a>(x: Result<&'a u8, &'a u8>) -> &'a u8 { + x.unwrap() +} // no error, two input refs -fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) } +fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { + Ok(x) +} // where clause, but without lifetimes -fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> where T: Copy { Ok(x) } +fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> +where + T: Copy, +{ + Ok(x) +} type Ref<'r> = &'r u8; -fn lifetime_param_1<'a>(_x: Ref<'a>, _y: &'a u8) { } // no error, same lifetime on two params +fn lifetime_param_1<'a>(_x: Ref<'a>, _y: &'a u8) {} // no error, same lifetime on two params -fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) { } +fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} -fn lifetime_param_3<'a, 'b: 'a>(_x: Ref<'a>, _y: &'b u8) { } // no error, bounded lifetime +fn lifetime_param_3<'a, 'b: 'a>(_x: Ref<'a>, _y: &'b u8) {} // no error, bounded lifetime -fn lifetime_param_4<'a, 'b>(_x: Ref<'a>, _y: &'b u8) where 'b: 'a { } // no error, bounded lifetime +fn lifetime_param_4<'a, 'b>(_x: Ref<'a>, _y: &'b u8) +where + 'b: 'a, +{ +} // no error, bounded lifetime struct Lt<'a, I: 'static> { - x: &'a I + x: &'a I, } fn fn_bound<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> - where F: Fn(Lt<'a, I>) -> Lt<'a, I> // no error, fn bound references 'a -{ unreachable!() } +where + F: Fn(Lt<'a, I>) -> Lt<'a, I>, // no error, fn bound references 'a +{ + unreachable!() +} fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> - where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I> -{ unreachable!() } +where + for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I>, +{ + unreachable!() +} -fn fn_bound_3<'a, F: FnOnce(&'a i32)>(x: &'a i32, f: F) { // no error, see below +fn fn_bound_3<'a, F: FnOnce(&'a i32)>(x: &'a i32, f: F) { + // no error, see below f(x); } @@ -76,7 +102,11 @@ fn fn_bound_3_cannot_elide() { // no error, multiple input refs fn fn_bound_4<'a, F: FnOnce() -> &'a ()>(cond: bool, x: &'a (), f: F) -> &'a () { - if cond { x } else { f() } + if cond { + x + } else { + f() + } } struct X { @@ -84,13 +114,17 @@ struct X { } impl X { - fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } + fn self_and_out<'s>(&'s self) -> &'s u8 { + &self.x + } - fn self_and_in_out<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { &self.x } // no error, multiple input refs + fn self_and_in_out<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 { + &self.x + } // no error, multiple input refs - fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { } + fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} - fn self_and_same_in<'s>(&'s self, _x: &'s u8) { } // no error, same lifetimes on two params + fn self_and_same_in<'s>(&'s self, _x: &'s u8) {} // no error, same lifetimes on two params } struct Foo<'a>(&'a u8); @@ -104,50 +138,80 @@ fn already_elided<'a>(_: &u8, _: &'a u8) -> &'a u8 { unimplemented!() } -fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } +fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { + unimplemented!() +} // no warning, two input lifetimes (named on the reference, anonymous on Foo) -fn struct_with_lt2<'a>(_foo: &'a Foo) -> &'a str { unimplemented!() } +fn struct_with_lt2<'a>(_foo: &'a Foo) -> &'a str { + unimplemented!() +} // no warning, two input lifetimes (anonymous on the reference, named on Foo) -fn struct_with_lt3<'a>(_foo: &Foo<'a> ) -> &'a str { unimplemented!() } +fn struct_with_lt3<'a>(_foo: &Foo<'a>) -> &'a str { + unimplemented!() +} // no warning, two input lifetimes -fn struct_with_lt4<'a, 'b>(_foo: &'a Foo<'b> ) -> &'a str { unimplemented!() } +fn struct_with_lt4<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str { + unimplemented!() +} trait WithLifetime<'a> {} type WithLifetimeAlias<'a> = WithLifetime<'a>; // should not warn because it won't build without the lifetime -fn trait_obj_elided<'a>(_arg: &'a WithLifetime) -> &'a str { unimplemented!() } +fn trait_obj_elided<'a>(_arg: &'a WithLifetime) -> &'a str { + unimplemented!() +} // this 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 Drop) -> &'a str { unimplemented!() } +fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { + unimplemented!() +} type FooAlias<'a> = Foo<'a>; -fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } +fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { + unimplemented!() +} // no warning, two input lifetimes (named on the reference, anonymous on Foo) -fn alias_with_lt2<'a>(_foo: &'a FooAlias) -> &'a str { unimplemented!() } +fn alias_with_lt2<'a>(_foo: &'a FooAlias) -> &'a str { + unimplemented!() +} // no warning, two input lifetimes (anonymous on the reference, named on Foo) -fn alias_with_lt3<'a>(_foo: &FooAlias<'a> ) -> &'a str { unimplemented!() } +fn alias_with_lt3<'a>(_foo: &FooAlias<'a>) -> &'a str { + unimplemented!() +} // no warning, two input lifetimes -fn alias_with_lt4<'a, 'b>(_foo: &'a FooAlias<'b> ) -> &'a str { unimplemented!() } +fn alias_with_lt4<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str { + unimplemented!() +} -fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } +fn named_input_elided_output<'a>(_arg: &'a str) -> &str { + unimplemented!() +} -fn elided_input_named_output<'a>(_arg: &str) -> &'a str { unimplemented!() } +fn elided_input_named_output<'a>(_arg: &str) -> &'a str { + unimplemented!() +} -fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } -fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) { unimplemented!() } +fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { + unimplemented!() +} +fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) { + unimplemented!() +} // don't warn on these, see #292 -fn trait_bound_bug<'a, T: WithLifetime<'a>>() { unimplemented!() } +fn trait_bound_bug<'a, T: WithLifetime<'a>>() { + unimplemented!() +} // #740 struct Test { @@ -160,7 +224,6 @@ impl Test { } } - trait LintContext<'a> {} fn f<'a, T: LintContext<'a>>(_: &T) {} @@ -172,9 +235,11 @@ fn test<'a>(x: &'a [u8]) -> u8 { // #3284 - Give a hint regarding lifetime in return type -struct Cow<'a> { x: &'a str, } -fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { unimplemented!() } - - -fn main() { +struct Cow<'a> { + x: &'a str, } +fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { + unimplemented!() +} + +fn main() {} diff --git a/tests/ui/lint_without_lint_pass.rs b/tests/ui/lint_without_lint_pass.rs index c7e11840a37c..1f2fcd8faf61 100644 --- a/tests/ui/lint_without_lint_pass.rs +++ b/tests/ui/lint_without_lint_pass.rs @@ -1,5 +1,4 @@ #![deny(clippy::internal)] - #![feature(rustc_private)] #[macro_use] @@ -28,5 +27,4 @@ impl lint::LintPass for Pass { } } -fn main() { -} +fn main() {} diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index 162d8a484b43..e6fb37f81205 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -7,8 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::missing_docs_in_private_items)] diff --git a/tests/ui/map_flatten.rs b/tests/ui/map_flatten.rs index 1b5c20069d17..99b90a0df796 100644 --- a/tests/ui/map_flatten.rs +++ b/tests/ui/map_flatten.rs @@ -7,8 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::missing_docs_in_private_items)] diff --git a/tests/ui/match_bool.rs b/tests/ui/match_bool.rs index 7548b83764d1..fe5e94cf4589 100644 --- a/tests/ui/match_bool.rs +++ b/tests/ui/match_bool.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn match_bool() { let test: bool = true; @@ -24,31 +23,40 @@ fn match_bool() { match test { true => (), - false => { println!("Noooo!"); } + false => { + println!("Noooo!"); + }, }; match test { - false => { println!("Noooo!"); } + false => { + println!("Noooo!"); + }, _ => (), }; match test && test { - false => { println!("Noooo!"); } + false => { + println!("Noooo!"); + }, _ => (), }; match test { - false => { println!("Noooo!"); } - true => { println!("Yes!"); } + false => { + println!("Noooo!"); + }, + true => { + println!("Yes!"); + }, }; // Not linted match option { - 1 ... 10 => 1, - 11 ... 20 => 2, + 1...10 => 1, + 11...20 => 2, _ => 3, }; } -fn main() { -} +fn main() {} diff --git a/tests/ui/match_overlapping_arm.rs b/tests/ui/match_overlapping_arm.rs index 1f2c3f8a8910..5350f933ae57 100644 --- a/tests/ui/match_overlapping_arm.rs +++ b/tests/ui/match_overlapping_arm.rs @@ -14,54 +14,54 @@ /// Tests for match_overlapping_arm fn overlapping() { - const FOO : u64 = 2; + const FOO: u64 = 2; match 42 { - 0 ... 10 => println!("0 ... 10"), - 0 ... 11 => println!("0 ... 11"), + 0...10 => println!("0 ... 10"), + 0...11 => println!("0 ... 11"), _ => (), } match 42 { - 0 ... 5 => println!("0 ... 5"), - 6 ... 7 => println!("6 ... 7"), - FOO ... 11 => println!("0 ... 11"), + 0...5 => println!("0 ... 5"), + 6...7 => println!("6 ... 7"), + FOO...11 => println!("0 ... 11"), _ => (), } match 42 { 2 => println!("2"), - 0 ... 5 => println!("0 ... 5"), + 0...5 => println!("0 ... 5"), _ => (), } match 42 { 2 => println!("2"), - 0 ... 2 => println!("0 ... 2"), + 0...2 => println!("0 ... 2"), _ => (), } match 42 { - 0 ... 10 => println!("0 ... 10"), - 11 ... 50 => println!("11 ... 50"), + 0...10 => println!("0 ... 10"), + 11...50 => println!("11 ... 50"), _ => (), } match 42 { 2 => println!("2"), - 0 .. 2 => println!("0 .. 2"), + 0..2 => println!("0 .. 2"), _ => (), } match 42 { - 0 .. 10 => println!("0 .. 10"), - 10 .. 50 => println!("10 .. 50"), + 0..10 => println!("0 .. 10"), + 10..50 => println!("10 .. 50"), _ => (), } match 42 { - 0 .. 11 => println!("0 .. 11"), - 0 ... 11 => println!("0 ... 11"), + 0..11 => println!("0 .. 11"), + 0...11 => println!("0 ... 11"), _ => (), } diff --git a/tests/ui/matches.rs b/tests/ui/matches.rs index e5b8f6f4c1cf..8038433c5641 100644 --- a/tests/ui/matches.rs +++ b/tests/ui/matches.rs @@ -7,18 +7,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #![feature(exclusive_range_pattern)] - - #![warn(clippy::all)] #![allow(unused, clippy::redundant_pattern_matching)] #![warn(clippy::match_same_arms)] - -fn dummy() { -} +fn dummy() {} fn ref_pats() { { @@ -27,12 +21,13 @@ fn ref_pats() { &Some(v) => println!("{:?}", v), &None => println!("none"), } - match v { // this doesn't trigger, we have a different pattern + match v { + // this doesn't trigger, we have a different pattern &Some(v) => println!("some"), other => println!("other"), } } - let tup =& (1, 2); + let tup = &(1, 2); match tup { &(v, 1) => println!("{}", v), _ => println!("none"), @@ -66,73 +61,77 @@ fn match_wild_err_arm() { match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => panic!("err") + Err(_) => panic!("err"), } match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => {panic!()} + Err(_) => panic!(), } match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => {panic!();} + Err(_) => { + panic!(); + }, } // allowed when not with `panic!` block match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => println!("err") + Err(_) => println!("err"), } // allowed when used with `unreachable!` match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => {unreachable!()} + Err(_) => unreachable!(), } match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => unreachable!() + Err(_) => unreachable!(), } match x { Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => {unreachable!();} + Err(_) => { + unreachable!(); + }, } // no warning because of the guard match x { - Ok(x) if x*x == 64 => println!("ok"), + Ok(x) if x * x == 64 => println!("ok"), Ok(_) => println!("ok"), - Err(_) => println!("err") + Err(_) => println!("err"), } // this used to be a false positive, see #1996 match x { Ok(3) => println!("ok"), - Ok(x) if x*x == 64 => println!("ok 64"), + Ok(x) if x * x == 64 => println!("ok 64"), Ok(_) => println!("ok"), - Err(_) => println!("err") + Err(_) => println!("err"), } match (x, Some(1i32)) { (Ok(x), Some(_)) => println!("ok {}", x), (Ok(_), Some(x)) => println!("ok {}", x), - _ => println!("err") + _ => println!("err"), } // no warning because of the different types for x match (x, Some(1.0f64)) { (Ok(x), Some(_)) => println!("ok {}", x), (Ok(_), Some(x)) => println!("ok {}", x), - _ => println!("err") + _ => println!("err"), } // because of a bug, no warning was generated for this case before #2251 @@ -140,7 +139,9 @@ fn match_wild_err_arm() { Ok(_tmp) => println!("ok"), Ok(3) => println!("ok"), Ok(_) => println!("ok"), - Err(_) => {unreachable!();} + Err(_) => { + unreachable!(); + }, } } @@ -156,8 +157,6 @@ fn match_as_ref() { None => None, Some(ref mut v) => Some(v), }; - } -fn main() { -} +fn main() {} diff --git a/tests/ui/mem_discriminant.rs b/tests/ui/mem_discriminant.rs index 5ddd90ac8b57..9d2d6f9503a1 100644 --- a/tests/ui/mem_discriminant.rs +++ b/tests/ui/mem_discriminant.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![deny(clippy::mem_discriminant_non_enum)] use std::mem; @@ -35,7 +34,9 @@ fn main() { mem::discriminant(&rro); macro_rules! mem_discriminant_but_in_a_macro { - ($param:expr) => (mem::discriminant($param)) + ($param:expr) => { + mem::discriminant($param) + }; } mem_discriminant_but_in_a_macro!(&rro); diff --git a/tests/ui/mem_forget.rs b/tests/ui/mem_forget.rs index 266c5c267f8c..b46f7007cd02 100644 --- a/tests/ui/mem_forget.rs +++ b/tests/ui/mem_forget.rs @@ -7,16 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - - -use std::sync::Arc; use std::rc::Rc; +use std::sync::Arc; -use std::mem::forget as forgetSomething; use std::mem as memstuff; +use std::mem::forget as forgetSomething; #[warn(clippy::mem_forget)] #[allow(clippy::forget_copy)] diff --git a/tests/ui/mem_replace.rs b/tests/ui/mem_replace.rs index 2b6e6f2ce67a..edd3c0318571 100644 --- a/tests/ui/mem_replace.rs +++ b/tests/ui/mem_replace.rs @@ -7,8 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)] use std::mem; diff --git a/tests/ui/min_max.rs b/tests/ui/min_max.rs index b4ca46231e02..cf68bb611008 100644 --- a/tests/ui/min_max.rs +++ b/tests/ui/min_max.rs @@ -7,17 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] -use std::cmp::{min, max}; -use std::cmp::min as my_min; use std::cmp::max as my_max; +use std::cmp::min as my_min; +use std::cmp::{max, min}; -const LARGE : usize = 3; +const LARGE: usize = 3; fn main() { let x; diff --git a/tests/ui/missing-doc.rs b/tests/ui/missing-doc.rs index 6e7dfbfa37a5..5de2ada5a41c 100644 --- a/tests/ui/missing-doc.rs +++ b/tests/ui/missing-doc.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - /* This file incorporates work covered by the following copyright and * permission notice: * Copyright 2013 The Rust Project Developers. See the COPYRIGHT @@ -23,17 +20,14 @@ * except according to those terms. */ - - #![warn(clippy::missing_docs_in_private_items)] - // When denying at the crate level, be sure to not get random warnings from the // injected intrinsics by the compiler. #![allow(dead_code)] #![feature(associated_type_defaults)] //! Some garbage docs for the crate here -#![doc="More garbage"] +#![doc = "More garbage"] type Typedef = String; pub type PubTypedef = String; @@ -61,7 +55,8 @@ pub mod pub_module_no_dox {} pub fn foo() {} pub fn foo2() {} fn foo3() {} -#[allow(clippy::missing_docs_in_private_items)] pub fn foo4() {} +#[allow(clippy::missing_docs_in_private_items)] +pub fn foo4() {} /// dox pub trait A { @@ -84,7 +79,7 @@ pub trait C { #[allow(clippy::missing_docs_in_private_items)] pub trait D { - fn dummy(&self) { } + fn dummy(&self) {} } /// dox @@ -110,7 +105,8 @@ impl PubFoo { /// dox pub fn foo1() {} fn foo2() {} - #[allow(clippy::missing_docs_in_private_items)] pub fn foo3() {} + #[allow(clippy::missing_docs_in_private_items)] + pub fn foo3() {} } #[allow(clippy::missing_docs_in_private_items)] @@ -136,17 +132,12 @@ mod a { } enum Baz { - BazA { - a: isize, - b: isize - }, - BarB + BazA { a: isize, b: isize }, + BarB, } pub enum PubBaz { - PubBazA { - a: isize, - }, + PubBazA { a: isize }, } /// dox @@ -160,15 +151,12 @@ pub enum PubBaz2 { #[allow(clippy::missing_docs_in_private_items)] pub enum PubBaz3 { - PubBaz3A { - b: isize - }, + PubBaz3A { b: isize }, } #[doc(hidden)] pub fn baz() {} - const FOO: u32 = 0; /// dox pub const FOO1: u32 = 0; @@ -178,7 +166,6 @@ pub const FOO2: u32 = 0; pub const FOO3: u32 = 0; pub const FOO4: u32 = 0; - static BAR: u32 = 0; /// dox pub static BAR1: u32 = 0; @@ -188,7 +175,6 @@ pub static BAR2: u32 = 0; pub static BAR3: u32 = 0; pub static BAR4: u32 = 0; - mod internal_impl { /// dox pub fn documented() {} @@ -206,9 +192,9 @@ mod internal_impl { /// dox pub mod public_interface { pub use internal_impl::documented as foo; + pub use internal_impl::globbed::*; pub use internal_impl::undocumented1 as bar; pub use internal_impl::{documented, undocumented2}; - pub use internal_impl::globbed::*; } fn main() {} diff --git a/tests/ui/missing_inline.rs b/tests/ui/missing_inline.rs index 0b86c4e5cfe0..c9e946e14e65 100644 --- a/tests/ui/missing_inline.rs +++ b/tests/ui/missing_inline.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - /* This file incorporates work covered by the following copyright and * permission notice: * Copyright 2013 The Rust Project Developers. See the COPYRIGHT @@ -32,7 +29,7 @@ type Typedef = String; pub type PubTypedef = String; struct Foo {} // ok -pub struct PubFoo { } // ok +pub struct PubFoo {} // ok enum FooE {} // ok pub enum PubFooE {} // ok @@ -41,8 +38,10 @@ pub mod pub_module {} // ok fn foo() {} pub fn pub_foo() {} // missing #[inline] -#[inline] pub fn pub_foo_inline() {} // ok -#[inline(always)] pub fn pub_foo_inline_always() {} // ok +#[inline] +pub fn pub_foo_inline() {} // ok +#[inline(always)] +pub fn pub_foo_inline_always() {} // ok #[allow(clippy::missing_inline_in_public_items)] pub fn pub_foo_no_inline() {} @@ -52,11 +51,11 @@ trait Bar { fn Bar_b() {} // ok } - pub trait PubBar { fn PubBar_a(); // ok fn PubBar_b() {} // missing #[inline] - #[inline] fn PubBar_c() {} // ok + #[inline] + fn PubBar_c() {} // ok } // none of these need inline because Foo is not exported diff --git a/tests/ui/module_inception.rs b/tests/ui/module_inception.rs index 0676c4c29f02..730055931c4a 100644 --- a/tests/ui/module_inception.rs +++ b/tests/ui/module_inception.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::module_inception)] mod foo { @@ -27,8 +24,7 @@ mod foo { // No warning. See . mod bar { #[allow(clippy::module_inception)] - mod bar { - } + mod bar {} } fn main() {} diff --git a/tests/ui/modulo_one.rs b/tests/ui/modulo_one.rs index f1576447708a..f7c0c16abade 100644 --- a/tests/ui/modulo_one.rs +++ b/tests/ui/modulo_one.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::modulo_one)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/mut_from_ref.rs b/tests/ui/mut_from_ref.rs index 0a68d449d922..8a9da42083df 100644 --- a/tests/ui/mut_from_ref.rs +++ b/tests/ui/mut_from_ref.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused, clippy::trivially_copy_pass_by_ref)] #![warn(clippy::mut_from_ref)] diff --git a/tests/ui/mut_mut.rs b/tests/ui/mut_mut.rs index bed872902af5..e8239007cb3c 100644 --- a/tests/ui/mut_mut.rs +++ b/tests/ui/mut_mut.rs @@ -7,26 +7,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(unused, clippy::no_effect, clippy::unnecessary_operation)] #![warn(clippy::mut_mut)] - - - -fn fun(x : &mut &mut u32) -> bool { +fn fun(x: &mut &mut u32) -> bool { **x > 0 } -fn less_fun(x : *mut *mut u32) { - let y = x; +fn less_fun(x: *mut *mut u32) { + let y = x; } macro_rules! mut_ptr { - ($p:expr) => { &mut $p } + ($p:expr) => { + &mut $p + }; } #[allow(unused_mut, unused_variables)] @@ -37,12 +32,12 @@ fn main() { } if fun(x) { - let y : &mut &mut u32 = &mut &mut 2; + let y: &mut &mut u32 = &mut &mut 2; **y + **x; } if fun(x) { - let y : &mut &mut &mut u32 = &mut &mut &mut 2; + let y: &mut &mut &mut u32 = &mut &mut &mut 2; ***y + **x; } diff --git a/tests/ui/mut_range_bound.rs b/tests/ui/mut_range_bound.rs index edc86b5d6acb..23dddcdd158d 100644 --- a/tests/ui/mut_range_bound.rs +++ b/tests/ui/mut_range_bound.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(unused)] fn main() { @@ -25,29 +21,38 @@ fn main() { fn mut_range_bound_upper() { let mut m = 4; - for i in 0..m { m = 5; } // warning + for i in 0..m { + m = 5; + } // warning } fn mut_range_bound_lower() { let mut m = 4; - for i in m..10 { m *= 2; } // warning + for i in m..10 { + m *= 2; + } // warning } fn mut_range_bound_both() { let mut m = 4; let mut n = 6; - for i in m..n { m = 5; n = 7; } // warning (1 for each mutated bound) + for i in m..n { + m = 5; + n = 7; + } // warning (1 for each mutated bound) } fn mut_range_bound_no_mutation() { let mut m = 4; - for i in 0..m { continue; } // no warning + for i in 0..m { + continue; + } // no warning } fn mut_borrow_range_bound() { let mut m = 4; for i in 0..m { - let n = &mut m; // warning + let n = &mut m; // warning *n += 1; } } @@ -55,12 +60,13 @@ fn mut_borrow_range_bound() { fn immut_borrow_range_bound() { let mut m = 4; for i in 0..m { - let n = &m; // should be no warning? + let n = &m; // should be no warning? } } - fn immut_range_bound() { let m = 4; - for i in 0..m { continue; } // no warning + for i in 0..m { + continue; + } // no warning } diff --git a/tests/ui/mut_reference.rs b/tests/ui/mut_reference.rs index d63b854fd09e..882ed7e1dd32 100644 --- a/tests/ui/mut_reference.rs +++ b/tests/ui/mut_reference.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(unused_variables, clippy::trivially_copy_pass_by_ref)] fn takes_an_immutable_reference(a: &i32) {} @@ -19,11 +15,9 @@ fn takes_a_mutable_reference(a: &mut i32) {} struct MyStruct; impl MyStruct { - fn takes_an_immutable_reference(&self, a: &i32) { - } + fn takes_an_immutable_reference(&self, a: &i32) {} - fn takes_a_mutable_reference(&self, a: &mut i32) { - } + fn takes_a_mutable_reference(&self, a: &mut i32) {} } #[warn(clippy::unnecessary_mut_passed)] @@ -37,7 +31,6 @@ fn main() { let my_struct = MyStruct; my_struct.takes_an_immutable_reference(&mut 42); - // No error // Functions diff --git a/tests/ui/mutex_atomic.rs b/tests/ui/mutex_atomic.rs index 87b4ac9d8e30..5c4e180408cf 100644 --- a/tests/ui/mutex_atomic.rs +++ b/tests/ui/mutex_atomic.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![warn(clippy::mutex_integer)] diff --git a/tests/ui/needless_bool.rs b/tests/ui/needless_bool.rs index 98c2e0767d6a..c82f102c294e 100644 --- a/tests/ui/needless_bool.rs +++ b/tests/ui/needless_bool.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![warn(clippy::needless_bool)] use std::cell::Cell; @@ -38,12 +37,36 @@ macro_rules! bool_comparison_trigger { fn main() { let x = true; let y = false; - if x { true } else { true }; - if x { false } else { false }; - if x { true } else { false }; - if x { false } else { true }; - if x && y { false } else { true }; - if x { x } else { false }; // would also be questionable, but we don't catch this yet + if x { + true + } else { + true + }; + if x { + false + } else { + false + }; + if x { + true + } else { + false + }; + if x { + false + } else { + true + }; + if x && y { + false + } else { + true + }; + if x { + x + } else { + false + }; // would also be questionable, but we don't catch this yet bool_ret(x); bool_ret2(x); bool_ret3(x); @@ -57,50 +80,73 @@ fn main() { #[allow(clippy::if_same_then_else, clippy::needless_return)] fn bool_ret(x: bool) -> bool { - if x { return true } else { return true }; + if x { + return true; + } else { + return true; + }; } #[allow(clippy::if_same_then_else, clippy::needless_return)] fn bool_ret2(x: bool) -> bool { - if x { return false } else { return false }; + if x { + return false; + } else { + return false; + }; } #[allow(clippy::needless_return)] fn bool_ret3(x: bool) -> bool { - if x { return true } else { return false }; + if x { + return true; + } else { + return false; + }; } #[allow(clippy::needless_return)] fn bool_ret5(x: bool, y: bool) -> bool { - if x && y { return true } else { return false }; + if x && y { + return true; + } else { + return false; + }; } #[allow(clippy::needless_return)] fn bool_ret4(x: bool) -> bool { - if x { return false } else { return true }; + if x { + return false; + } else { + return true; + }; } #[allow(clippy::needless_return)] fn bool_ret6(x: bool, y: bool) -> bool { - if x && y { return false } else { return true }; + if x && y { + return false; + } else { + return true; + }; } fn needless_bool(x: bool) { - if x == true { }; + if x == true {}; } fn needless_bool2(x: bool) { - if x == false { }; + if x == false {}; } fn needless_bool3(x: bool) { - bool_comparison_trigger! { test_one: false, false; test_three: false, false; test_two: true, true; } - - if x == true { }; - if x == false { }; + + if x == true {}; + if x == false {}; } diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index 29e6ccca94d5..bfc6e82cb558 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - use std::borrow::Cow; #[allow(clippy::trivially_copy_pass_by_ref)] @@ -41,7 +38,7 @@ fn main() { }; } -fn f(y: &T) -> T { +fn f(y: &T) -> T { *y } diff --git a/tests/ui/needless_borrowed_ref.rs b/tests/ui/needless_borrowed_ref.rs index ca3e60bd7e74..3897c86f53a6 100644 --- a/tests/ui/needless_borrowed_ref.rs +++ b/tests/ui/needless_borrowed_ref.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::needless_borrowed_reference)] #[allow(unused_variables)] fn main() { @@ -51,8 +47,6 @@ fn foo(a: &Animal, b: &Animal) { match (a, b) { (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' // ^ and ^ should *not* be linted - (&Animal::Dog(ref a), &Animal::Dog(_)) => () - // ^ should *not* be linted + (&Animal::Dog(ref a), &Animal::Dog(_)) => (), // ^ should *not* be linted } } - diff --git a/tests/ui/needless_collect.rs b/tests/ui/needless_collect.rs index 91ebd354146c..df449e3184fe 100644 --- a/tests/ui/needless_collect.rs +++ b/tests/ui/needless_collect.rs @@ -7,10 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -use std::collections::{HashMap, HashSet, BTreeSet}; +use std::collections::{BTreeSet, HashMap, HashSet}; #[warn(clippy::needless_collect)] #[allow(unused_variables, clippy::iter_cloned_collect)] diff --git a/tests/ui/needless_continue.rs b/tests/ui/needless_continue.rs index 3d91132ea627..6d9b9499dce3 100644 --- a/tests/ui/needless_continue.rs +++ b/tests/ui/needless_continue.rs @@ -7,16 +7,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - macro_rules! zero { - ($x:expr) => ($x == 0); + ($x:expr) => { + $x == 0 + }; } macro_rules! nonzero { - ($x:expr) => (!zero!($x)); + ($x:expr) => { + !zero!($x) + }; } #[warn(clippy::needless_continue)] @@ -27,9 +27,9 @@ fn main() { if i % 2 == 0 && i % 3 == 0 { println!("{}", i); - println!("{}", i+1); + println!("{}", i + 1); if i % 5 == 0 { - println!("{}", i+2); + println!("{}", i + 2); } let i = 0; println!("bar {} ", i); diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index 48b7b42cc8c8..ec9df9fb3d38 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -7,11 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::needless_pass_by_value)] -#![allow(dead_code, clippy::single_match, clippy::redundant_pattern_matching, clippy::many_single_char_names, clippy::option_option)] +#![allow( + dead_code, + clippy::single_match, + clippy::redundant_pattern_matching, + clippy::many_single_char_names, + clippy::option_option +)] use std::borrow::Borrow; use std::convert::AsRef; @@ -92,24 +95,19 @@ struct S(T, U); impl S { fn foo( - self, // taking `self` by value is always allowed + self, + // taking `self` by value is always allowed s: String, t: String, ) -> usize { s.len() + t.capacity() } - fn bar( - _t: T, // Ok, since `&T: Serialize` too + fn bar(_t: T // Ok, since `&T: Serialize` too ) { } - fn baz( - &self, - _u: U, - _s: Self, - ) { - } + fn baz(&self, _u: U, _s: Self) {} } trait FalsePositive { @@ -120,7 +118,9 @@ trait FalsePositive { } // shouldn't warn on extern funcs -extern "C" fn ext(x: String) -> usize { x.len() } +extern "C" fn ext(x: String) -> usize { + x.len() +} // whitelist RangeArgument fn range>(range: T) { diff --git a/tests/ui/needless_pass_by_value_proc_macro.rs b/tests/ui/needless_pass_by_value_proc_macro.rs index f8f279ccb66e..28f71d98fe7f 100644 --- a/tests/ui/needless_pass_by_value_proc_macro.rs +++ b/tests/ui/needless_pass_by_value_proc_macro.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![crate_type = "proc-macro"] #![warn(clippy::needless_pass_by_value)] @@ -18,4 +15,6 @@ extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro_derive(Foo)] -pub fn foo(_input: TokenStream) -> TokenStream { unimplemented!() } +pub fn foo(_input: TokenStream) -> TokenStream { + unimplemented!() +} diff --git a/tests/ui/needless_range_loop.rs b/tests/ui/needless_range_loop.rs index c1992bba5480..f3d47eede48b 100644 --- a/tests/ui/needless_range_loop.rs +++ b/tests/ui/needless_range_loop.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn calc_idx(i: usize) -> usize { (i + i + 20) % 4 } @@ -51,7 +50,7 @@ fn main() { let g = vec![1, 2, 3, 4, 5, 6]; let glen = g.len(); for i in 0..glen { - let x: u32 = g[i+1..].iter().sum(); + let x: u32 = g[i + 1..].iter().sum(); println!("{}", g[i] + x); } assert_eq!(g, vec![20, 18, 15, 11, 6, 0]); @@ -59,7 +58,7 @@ fn main() { let mut g = vec![1, 2, 3, 4, 5, 6]; let glen = g.len(); for i in 0..glen { - g[i] = g[i+1..].iter().sum(); + g[i] = g[i + 1..].iter().sum(); } assert_eq!(g, vec![20, 18, 15, 11, 6, 0]); @@ -77,7 +76,7 @@ fn main() { vec[i] += 1; } - let arr = [1,2,3]; + let arr = [1, 2, 3]; for i in 0..3 { println!("{}", arr[i]); diff --git a/tests/ui/needless_return.rs b/tests/ui/needless_return.rs index 9380f7c48a5b..101be5946f4c 100644 --- a/tests/ui/needless_return.rs +++ b/tests/ui/needless_return.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::needless_return)] fn test_end_of_fn() -> bool { @@ -22,7 +18,7 @@ fn test_end_of_fn() -> bool { } fn test_no_semicolon() -> bool { - return true + return true; } fn test_if_block() -> bool { @@ -38,7 +34,7 @@ fn test_match(x: bool) -> bool { true => return false, false => { return true; - } + }, } } diff --git a/tests/ui/needless_update.rs b/tests/ui/needless_update.rs index 974f3603fc68..891c446b0ea3 100644 --- a/tests/ui/needless_update.rs +++ b/tests/ui/needless_update.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::needless_update)] #![allow(clippy::no_effect)] diff --git a/tests/ui/neg_cmp_op_on_partial_ord.rs b/tests/ui/neg_cmp_op_on_partial_ord.rs index 6d26d2ec6d1c..6c132f85f0a2 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.rs +++ b/tests/ui/neg_cmp_op_on_partial_ord.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - //! This test case utilizes `f64` an easy example for `PartialOrd` only types //! but the lint itself actually validates any expression where the left //! operand implements `PartialOrd` but not `Ord`. @@ -18,13 +15,11 @@ use std::cmp::Ordering; #[warn(clippy::neg_cmp_op_on_partial_ord)] fn main() { - let a_value = 1.0; let another_value = 7.0; // --- Bad --- - // Not Less but potentially Greater, Equal or Uncomparable. let _not_less = !(a_value < another_value); @@ -37,12 +32,10 @@ fn main() { // Not Greater or Equal but potentially Less or Uncomparable. let _not_greater_or_equal = !(a_value >= another_value); - // --- Good --- - let _not_less = match a_value.partial_cmp(&another_value) { - None | Some(Ordering::Greater) | Some(Ordering::Equal) => true, + None | Some(Ordering::Greater) | Some(Ordering::Equal) => true, _ => false, }; let _not_less_or_equal = match a_value.partial_cmp(&another_value) { @@ -58,10 +51,8 @@ fn main() { _ => false, }; - // --- Should not trigger --- - let _ = a_value < another_value; let _ = a_value <= another_value; let _ = a_value > another_value; diff --git a/tests/ui/neg_multiply.rs b/tests/ui/neg_multiply.rs index 446af7bbe948..f5f7525922c4 100644 --- a/tests/ui/neg_multiply.rs +++ b/tests/ui/neg_multiply.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::neg_multiply)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] diff --git a/tests/ui/never_loop.rs b/tests/ui/never_loop.rs index b952b1197dd5..d5a108b0b275 100644 --- a/tests/ui/never_loop.rs +++ b/tests/ui/never_loop.rs @@ -7,17 +7,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -#![allow(clippy::single_match, unused_assignments, unused_variables, clippy::while_immutable_condition)] +#![allow( + clippy::single_match, + unused_assignments, + unused_variables, + clippy::while_immutable_condition +)] fn test1() { let mut x = 0; - loop { // clippy::never_loop + loop { + // clippy::never_loop x += 1; if x == 1 { - return + return; } break; } @@ -28,16 +31,17 @@ fn test2() { loop { x += 1; if x == 1 { - break + break; } } } fn test3() { let mut x = 0; - loop { // never loops + loop { + // never loops x += 1; - break + break; } } @@ -54,24 +58,29 @@ fn test4() { fn test5() { let i = 0; - loop { // never loops - while i == 0 { // never loops - break + loop { + // never loops + while i == 0 { + // never loops + break; } - return - } + return; + } } fn test6() { let mut x = 0; 'outer: loop { x += 1; - loop { // never loops - if x == 5 { break } - continue 'outer - } - return - } + loop { + // never loops + if x == 5 { + break; + } + continue 'outer; + } + return; + } } fn test7() { @@ -82,7 +91,7 @@ fn test7() { 1 => continue, _ => (), } - return + return; } } @@ -99,13 +108,15 @@ fn test8() { fn test9() { let x = Some(1); - while let Some(y) = x { // never loops - return + while let Some(y) = x { + // never loops + return; } } fn test10() { - for x in 0..10 { // never loops + for x in 0..10 { + // never loops match x { 1 => break, _ => return, @@ -118,7 +129,7 @@ fn test11 i32>(mut f: F) { return match f() { 1 => continue, _ => (), - } + }; } } @@ -138,7 +149,8 @@ pub fn test12(a: bool, b: bool) { pub fn test13() { let mut a = true; - loop { // infinite loop + loop { + // infinite loop while a { if true { a = false; @@ -151,11 +163,12 @@ pub fn test13() { pub fn test14() { let mut a = true; - 'outer: while a { // never loops + 'outer: while a { + // never loops while a { if a { a = false; - continue + continue; } } break 'outer; @@ -187,4 +200,3 @@ fn main() { test13(); test14(); } - diff --git a/tests/ui/new_ret_no_self.rs b/tests/ui/new_ret_no_self.rs index bed43f550f21..a31f046c0841 100644 --- a/tests/ui/new_ret_no_self.rs +++ b/tests/ui/new_ret_no_self.rs @@ -1,7 +1,7 @@ #![warn(clippy::new_ret_no_self)] #![allow(dead_code, clippy::trivially_copy_pass_by_ref)] -fn main(){} +fn main() {} trait R { type Item; @@ -96,82 +96,106 @@ struct TupleReturnerOk; impl TupleReturnerOk { // should not trigger lint - pub fn new() -> (Self, u32) { unimplemented!(); } + pub fn new() -> (Self, u32) { + unimplemented!(); + } } struct TupleReturnerOk2; impl TupleReturnerOk2 { // should not trigger lint (it doesn't matter which element in the tuple is Self) - pub fn new() -> (u32, Self) { unimplemented!(); } + pub fn new() -> (u32, Self) { + unimplemented!(); + } } struct TupleReturnerOk3; impl TupleReturnerOk3 { // should not trigger lint (tuple can contain multiple Self) - pub fn new() -> (Self, Self) { unimplemented!(); } + pub fn new() -> (Self, Self) { + unimplemented!(); + } } struct TupleReturnerBad; impl TupleReturnerBad { // should trigger lint - pub fn new() -> (u32, u32) { unimplemented!(); } + pub fn new() -> (u32, u32) { + unimplemented!(); + } } struct MutPointerReturnerOk; impl MutPointerReturnerOk { // should not trigger lint - pub fn new() -> *mut Self { unimplemented!(); } + pub fn new() -> *mut Self { + unimplemented!(); + } } struct MutPointerReturnerOk2; impl MutPointerReturnerOk2 { // should not trigger lint - pub fn new() -> *const Self { unimplemented!(); } + pub fn new() -> *const Self { + unimplemented!(); + } } struct MutPointerReturnerBad; impl MutPointerReturnerBad { // should trigger lint - pub fn new() -> *mut V { unimplemented!(); } + pub fn new() -> *mut V { + unimplemented!(); + } } struct GenericReturnerOk; impl GenericReturnerOk { // should not trigger lint - pub fn new() -> Option { unimplemented!(); } + pub fn new() -> Option { + unimplemented!(); + } } struct GenericReturnerBad; impl GenericReturnerBad { // should trigger lint - pub fn new() -> Option { unimplemented!(); } + pub fn new() -> Option { + unimplemented!(); + } } struct NestedReturnerOk; impl NestedReturnerOk { // should not trigger lint - pub fn new() -> (Option, u32) { unimplemented!(); } + pub fn new() -> (Option, u32) { + unimplemented!(); + } } struct NestedReturnerOk2; impl NestedReturnerOk2 { // should not trigger lint - pub fn new() -> ((Self, u32), u32) { unimplemented!(); } + pub fn new() -> ((Self, u32), u32) { + unimplemented!(); + } } struct NestedReturnerOk3; impl NestedReturnerOk3 { // should not trigger lint - pub fn new() -> Option<(Self, u32)> { unimplemented!(); } + pub fn new() -> Option<(Self, u32)> { + unimplemented!(); + } } diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index 16b9bd5c71bf..a1818e037a70 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -7,41 +7,46 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(const_fn)] - - #![allow(dead_code)] #![warn(clippy::new_without_default, clippy::new_without_default_derive)] pub struct Foo; impl Foo { - pub fn new() -> Foo { Foo } + pub fn new() -> Foo { + Foo + } } pub struct Bar; impl Bar { - pub fn new() -> Self { Bar } + pub fn new() -> Self { + Bar + } } pub struct Ok; impl Ok { - pub fn new() -> Self { Ok } + pub fn new() -> Self { + Ok + } } impl Default for Ok { - fn default() -> Self { Ok } + fn default() -> Self { + Ok + } } pub struct Params; impl Params { - pub fn new(_: u32) -> Self { Params } + pub fn new(_: u32) -> Self { + Params + } } pub struct GenericsOk { @@ -49,11 +54,15 @@ pub struct GenericsOk { } impl Default for GenericsOk { - fn default() -> Self { unimplemented!(); } + fn default() -> Self { + unimplemented!(); + } } impl<'c, V> GenericsOk { - pub fn new() -> GenericsOk { unimplemented!() } + pub fn new() -> GenericsOk { + unimplemented!() + } } pub struct LtOk<'a> { @@ -61,11 +70,15 @@ pub struct LtOk<'a> { } impl<'b> Default for LtOk<'b> { - fn default() -> Self { unimplemented!(); } + fn default() -> Self { + unimplemented!(); + } } impl<'c> LtOk<'c> { - pub fn new() -> LtOk<'c> { unimplemented!() } + pub fn new() -> LtOk<'c> { + unimplemented!() + } } pub struct LtKo<'a> { @@ -73,26 +86,34 @@ pub struct LtKo<'a> { } impl<'c> LtKo<'c> { - pub fn new() -> LtKo<'c> { unimplemented!() } + pub fn new() -> LtKo<'c> { + unimplemented!() + } // FIXME: that suggestion is missing lifetimes } struct Private; impl Private { - fn new() -> Private { unimplemented!() } // We don't lint private items + fn new() -> Private { + unimplemented!() + } // We don't lint private items } struct Const; impl Const { - pub const fn new() -> Const { Const } // const fns can't be implemented via Default + pub const fn new() -> Const { + Const + } // const fns can't be implemented via Default } pub struct IgnoreGenericNew; impl IgnoreGenericNew { - pub fn new() -> Self { IgnoreGenericNew } // the derived Default does not make sense here as the result depends on T + pub fn new() -> Self { + IgnoreGenericNew + } // the derived Default does not make sense here as the result depends on T } pub trait TraitWithNew: Sized { @@ -104,7 +125,9 @@ pub trait TraitWithNew: Sized { pub struct IgnoreUnsafeNew; impl IgnoreUnsafeNew { - pub unsafe fn new() -> Self { IgnoreUnsafeNew } + pub unsafe fn new() -> Self { + IgnoreUnsafeNew + } } #[derive(Default)] diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index bee3aeb6f7f2..6b51c50dcde9 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -7,12 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(box_syntax)] - - #![warn(clippy::no_effect)] #![allow(dead_code)] #![allow(path_statements)] @@ -23,7 +18,7 @@ struct Unit; struct Tuple(i32); struct Struct { - field: i32 + field: i32, } enum Enum { Tuple(i32), @@ -34,7 +29,7 @@ impl Drop for DropUnit { fn drop(&mut self) {} } struct DropStruct { - field: i32 + field: i32, } impl Drop for DropStruct { fn drop(&mut self) {} @@ -58,11 +53,19 @@ union Union { b: f64, } -fn get_number() -> i32 { 0 } -fn get_struct() -> Struct { Struct { field: 0 } } -fn get_drop_struct() -> DropStruct { DropStruct { field: 0 } } +fn get_number() -> i32 { + 0 +} +fn get_struct() -> Struct { + Struct { field: 0 } +} +fn get_drop_struct() -> DropStruct { + DropStruct { field: 0 } +} -unsafe fn unsafe_fn() -> i32 { 0 } +unsafe fn unsafe_fn() -> i32 { + 0 +} fn main() { let s = get_struct(); diff --git a/tests/ui/non_copy_const.rs b/tests/ui/non_copy_const.rs index 5cbb610fea34..591e1994ee3e 100644 --- a/tests/ui/non_copy_const.rs +++ b/tests/ui/non_copy_const.rs @@ -7,17 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(const_string_new, const_vec_new)] #![allow(clippy::ref_in_deref, dead_code)] -use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; -use std::cell::Cell; -use std::sync::Once; use std::borrow::Cow; +use std::cell::Cell; use std::fmt::Display; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::sync::Once; const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable const CELL: Cell = Cell::new(6); //~ ERROR interior mutable @@ -25,7 +22,9 @@ const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::n //~^ ERROR interior mutable macro_rules! declare_const { - ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; + ($name:ident: $ty:ty = $e:expr) => { + const $name: $ty = $e; + }; } declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable @@ -136,7 +135,7 @@ fn main() { let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability let _ = ATOMIC_TUPLE.1.into_iter(); let _ = ATOMIC_TUPLE.2; - let _ = &{ATOMIC_TUPLE}; + let _ = &{ ATOMIC_TUPLE }; CELL.set(2); //~ ERROR interior mutability assert_eq!(CELL.get(), 6); //~ ERROR interior mutability diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 67fded144856..86c9edc821d7 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -7,13 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -#![warn(clippy::all,clippy::similar_names)] +#![warn(clippy::all, clippy::similar_names)] #![allow(unused, clippy::println_empty_string)] - struct Foo { apple: i32, bpple: i32, @@ -29,7 +25,6 @@ fn main() { let cpple: i32; - let a_bar: i32; let b_bar: i32; let c_bar: i32; @@ -54,7 +49,6 @@ fn main() { let blubx: i32; let bluby: i32; - let cake: i32; let cakes: i32; let coke: i32; @@ -81,7 +75,6 @@ fn main() { let parsed: i32; let parsee: i32; - let setter: i32; let getter: i32; let tx1: i32; @@ -92,8 +85,10 @@ fn main() { fn foo() { let Foo { apple, bpple } = unimplemented!(); - let Foo { apple: spring, - bpple: sprang } = unimplemented!(); + let Foo { + apple: spring, + bpple: sprang, + } = unimplemented!(); } #[derive(Clone, Debug)] @@ -132,7 +127,6 @@ fn bla() { { let e: i32; let f: i32; - } match 5 { 1 => println!(""), @@ -149,18 +143,18 @@ fn underscores_and_numbers() { let _1 = 1; //~ERROR Consider a more descriptive name let ____1 = 1; //~ERROR Consider a more descriptive name let __1___2 = 12; //~ERROR Consider a more descriptive name - let _1_ok= 1; + let _1_ok = 1; } fn issue2927() { - let args = 1; - format!("{:?}", 2); + let args = 1; + format!("{:?}", 2); } fn issue3078() { match "a" { stringify!(a) => {}, - _ => {} + _ => {}, } } @@ -171,7 +165,7 @@ impl Bar { let _1 = 1; let ____1 = 1; let __1___2 = 12; - let _1_ok= 1; + let _1_ok = 1; } } diff --git a/tests/ui/ok_expect.rs b/tests/ui/ok_expect.rs index 5d333a72cc0e..b121aae788c3 100644 --- a/tests/ui/ok_expect.rs +++ b/tests/ui/ok_expect.rs @@ -7,14 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - use std::io; struct MyError(()); // doesn't implement Debug #[derive(Debug)] struct MyErrorWithParam { - x: T + x: T, } fn main() { @@ -26,7 +25,7 @@ fn main() { // the error type implements `Debug` let res2: Result = Ok(0); res2.ok().expect("oh noes!"); - let res3: Result>= Ok(0); + let res3: Result> = Ok(0); res3.ok().expect("whoof"); let res4: Result = Ok(0); res4.ok().expect("argh"); diff --git a/tests/ui/ok_if_let.rs b/tests/ui/ok_if_let.rs index b318a90d8832..3ede64ce3aa0 100644 --- a/tests/ui/ok_if_let.rs +++ b/tests/ui/ok_if_let.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::if_let_some_result)] fn str_to_int(x: &str) -> i32 { diff --git a/tests/ui/op_ref.rs b/tests/ui/op_ref.rs index bacf9f1057bb..1112b6794cfe 100644 --- a/tests/ui/op_ref.rs +++ b/tests/ui/op_ref.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(unused_variables, clippy::blacklisted_name)] use std::collections::HashSet; diff --git a/tests/ui/open_options.rs b/tests/ui/open_options.rs index 6b891d72e8ba..f4d0af94b3fe 100644 --- a/tests/ui/open_options.rs +++ b/tests/ui/open_options.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - use std::fs::OpenOptions; #[allow(unused_must_use)] diff --git a/tests/ui/option_map_unit_fn.rs b/tests/ui/option_map_unit_fn.rs index b023181fcf7a..5200ff694a07 100644 --- a/tests/ui/option_map_unit_fn.rs +++ b/tests/ui/option_map_unit_fn.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::option_map_unit_fn)] #![allow(unused)] @@ -39,7 +36,7 @@ fn option_map_unit_fn() { let x = HasOption { field: Some(10) }; x.field.map(plus_one); - let _ : Option<()> = x.field.map(do_nothing); + let _: Option<()> = x.field.map(do_nothing); x.field.map(do_nothing); @@ -48,47 +45,68 @@ fn option_map_unit_fn() { x.field.map(diverge); let captured = 10; - if let Some(value) = x.field { do_nothing(value + captured) }; - let _ : Option<()> = x.field.map(|value| do_nothing(value + captured)); + if let Some(value) = x.field { + do_nothing(value + captured) + }; + let _: Option<()> = x.field.map(|value| do_nothing(value + captured)); x.field.map(|value| x.do_option_nothing(value + captured)); - x.field.map(|value| { x.do_option_plus_one(value + captured); }); - + x.field.map(|value| { + x.do_option_plus_one(value + captured); + }); x.field.map(|value| do_nothing(value + captured)); - x.field.map(|value| { do_nothing(value + captured) }); - - x.field.map(|value| { do_nothing(value + captured); }); + x.field.map(|value| do_nothing(value + captured)); - x.field.map(|value| { { do_nothing(value + captured); } }); + x.field.map(|value| { + do_nothing(value + captured); + }); + x.field.map(|value| { + do_nothing(value + captured); + }); x.field.map(|value| diverge(value + captured)); - x.field.map(|value| { diverge(value + captured) }); - - x.field.map(|value| { diverge(value + captured); }); + x.field.map(|value| diverge(value + captured)); - x.field.map(|value| { { diverge(value + captured); } }); + x.field.map(|value| { + diverge(value + captured); + }); + x.field.map(|value| { + diverge(value + captured); + }); x.field.map(|value| plus_one(value + captured)); - x.field.map(|value| { plus_one(value + captured) }); - x.field.map(|value| { let y = plus_one(value + captured); }); - - x.field.map(|value| { plus_one(value + captured); }); - - x.field.map(|value| { { plus_one(value + captured); } }); + x.field.map(|value| plus_one(value + captured)); + x.field.map(|value| { + let y = plus_one(value + captured); + }); + x.field.map(|value| { + plus_one(value + captured); + }); - x.field.map(|ref value| { do_nothing(value + captured) }); + x.field.map(|value| { + plus_one(value + captured); + }); + x.field.map(|ref value| do_nothing(value + captured)); - x.field.map(|value| { do_nothing(value); do_nothing(value) }); + x.field.map(|value| { + do_nothing(value); + do_nothing(value) + }); - x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); + x.field.map(|value| { + if value > 0 { + do_nothing(value); + do_nothing(value) + } + }); // Suggestion for the let block should be `{ ... }` as it's too difficult to build a // proper suggestion for these cases @@ -96,9 +114,13 @@ fn option_map_unit_fn() { do_nothing(value); do_nothing(value) }); - x.field.map(|value| { do_nothing(value); do_nothing(value); }); + x.field.map(|value| { + do_nothing(value); + do_nothing(value); + }); - // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them + // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let + // variable name for them Some(42).map(diverge); "12".parse::().ok().map(diverge); Some(plus_one(1)).map(do_nothing); @@ -108,5 +130,4 @@ fn option_map_unit_fn() { y.map(do_nothing); } -fn main() { -} +fn main() {} diff --git a/tests/ui/option_option.rs b/tests/ui/option_option.rs index 3cb4fdc27eb7..fcfd4e6ea56d 100644 --- a/tests/ui/option_option.rs +++ b/tests/ui/option_option.rs @@ -7,9 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -fn input(_: Option>) { -} +fn input(_: Option>) {} fn output() -> Option> { None @@ -40,7 +38,7 @@ trait Trait { enum Enum { Tuple(Option>), - Struct{x: Option>}, + Struct { x: Option> }, } // The lint allows this @@ -69,5 +67,3 @@ fn main() { // The lint allows this let expr = Some(Some(true)); } - - diff --git a/tests/ui/overflow_check_conditional.rs b/tests/ui/overflow_check_conditional.rs index 82fdfe14ab6d..a5cff3df9d7e 100644 --- a/tests/ui/overflow_check_conditional.rs +++ b/tests/ui/overflow_check_conditional.rs @@ -7,65 +7,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(clippy::many_single_char_names)] #![warn(clippy::overflow_check_conditional)] fn main() { - let a: u32 = 1; - let b: u32 = 2; - let c: u32 = 3; - if a + b < a { - - } - if a > a + b { - - } - if a + b < b { - - } - if b > a + b { - - } - if a - b > b { - - } - if b < a - b { - - } - if a - b > a { - - } - if a < a - b { - - } - if a + b < c { - - } - if c > a + b { - - } - if a - b < c { - - } - if c > a - b { - - } - let i = 1.1; - let j = 2.2; - if i + j < i { - - } - if i - j < i { - - } - if i > i + j { - - } - if i - j < i { - - } + let a: u32 = 1; + let b: u32 = 2; + let c: u32 = 3; + if a + b < a {} + if a > a + b {} + if a + b < b {} + if b > a + b {} + if a - b > b {} + if b < a - b {} + if a - b > a {} + if a < a - b {} + if a + b < c {} + if c > a + b {} + if a - b < c {} + if c > a - b {} + let i = 1.1; + let j = 2.2; + if i + j < i {} + if i - j < i {} + if i > i + j {} + if i - j < i {} } diff --git a/tests/ui/panic_unimplemented.rs b/tests/ui/panic_unimplemented.rs index ede2e8f063b0..93dec197ff5f 100644 --- a/tests/ui/panic_unimplemented.rs +++ b/tests/ui/panic_unimplemented.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::panic_params, clippy::unimplemented)] fn missing() { @@ -46,7 +42,7 @@ fn ok_bracket() { } } -const ONE : u32= 1; +const ONE: u32 = 1; fn ok_nomsg() { assert!({ 1 == ONE }); diff --git a/tests/ui/partialeq_ne_impl.rs b/tests/ui/partialeq_ne_impl.rs index 45aa0decd58c..3f9f91c81b1d 100644 --- a/tests/ui/partialeq_ne_impl.rs +++ b/tests/ui/partialeq_ne_impl.rs @@ -7,17 +7,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(dead_code)] struct Foo; impl PartialEq for Foo { - fn eq(&self, _: &Foo) -> bool { true } - fn ne(&self, _: &Foo) -> bool { false } + fn eq(&self, _: &Foo) -> bool { + true + } + fn ne(&self, _: &Foo) -> bool { + false + } } fn main() {} diff --git a/tests/ui/patterns.rs b/tests/ui/patterns.rs index 41e9ec8ca81e..e10afdb86b82 100644 --- a/tests/ui/patterns.rs +++ b/tests/ui/patterns.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused)] #![warn(clippy::all)] @@ -17,10 +14,10 @@ fn main() { let v = Some(true); match v { Some(x) => (), - y @ _ => (), + y @ _ => (), } match v { - Some(x) => (), - y @ None => (), // no error + Some(x) => (), + y @ None => (), // no error } } diff --git a/tests/ui/precedence.rs b/tests/ui/precedence.rs index 4b404022ed41..82009cd3873a 100644 --- a/tests/ui/precedence.rs +++ b/tests/ui/precedence.rs @@ -7,21 +7,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::precedence)] #[allow(clippy::identity_op)] #[allow(clippy::eq_op)] macro_rules! trip { - ($a:expr) => { - match $a & 0b1111_1111i8 { - 0 => println!("a is zero ({})", $a), - _ => println!("a is {}", $a), - } - }; + ($a:expr) => { + match $a & 0b1111_1111i8 { + 0 => println!("a is zero ({})", $a), + _ => println!("a is {}", $a), + } + }; } fn main() { diff --git a/tests/ui/print.rs b/tests/ui/print.rs index 5fa2cfcc315b..a43482cba626 100644 --- a/tests/ui/print.rs +++ b/tests/ui/print.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::print_literal, clippy::write_literal)] #![warn(clippy::print_stdout, clippy::use_debug)] diff --git a/tests/ui/print_literal.rs b/tests/ui/print_literal.rs index 0df26f6d25f4..74756384067a 100644 --- a/tests/ui/print_literal.rs +++ b/tests/ui/print_literal.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::print_literal)] fn main() { @@ -18,17 +15,17 @@ fn main() { println!("Hello"); let world = "world"; println!("Hello {}", world); - println!("Hello {world}", world=world); + println!("Hello {world}", world = world); println!("3 in hex is {:X}", 3); println!("2 + 1 = {:.4}", 3); println!("2 + 1 = {:5.4}", 3); println!("Debug test {:?}", "hello, world"); println!("{0:8} {1:>8}", "hello", "world"); println!("{1:8} {0:>8}", "hello", "world"); - println!("{foo:8} {bar:>8}", foo="hello", bar="world"); - println!("{bar:8} {foo:>8}", foo="hello", bar="world"); - println!("{number:>width$}", number=1, width=6); - println!("{number:>0width$}", number=1, width=6); + println!("{foo:8} {bar:>8}", foo = "hello", bar = "world"); + println!("{bar:8} {foo:>8}", foo = "hello", bar = "world"); + println!("{number:>width$}", number = 1, width = 6); + println!("{number:>0width$}", number = 1, width = 6); // these should throw warnings println!("{} of {:b} people know binary, the other half doesn't", 1, 2); @@ -45,6 +42,6 @@ fn main() { println!("{1} {0}", "hello", "world"); // named args shouldn't change anything either - println!("{foo} {bar}", foo="hello", bar="world"); - println!("{bar} {foo}", foo="hello", bar="world"); + println!("{foo} {bar}", foo = "hello", bar = "world"); + println!("{bar} {foo}", foo = "hello", bar = "world"); } diff --git a/tests/ui/print_with_newline.rs b/tests/ui/print_with_newline.rs index 2dd08a5b88d8..351fd60bc367 100644 --- a/tests/ui/print_with_newline.rs +++ b/tests/ui/print_with_newline.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::print_literal)] #![warn(clippy::print_with_newline)] diff --git a/tests/ui/println_empty_string.rs b/tests/ui/println_empty_string.rs index afc37b1bec75..19a0389762a6 100644 --- a/tests/ui/println_empty_string.rs +++ b/tests/ui/println_empty_string.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn main() { println!(); println!(""); diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs index df0bde149607..0d7a829888e5 100644 --- a/tests/ui/ptr_arg.rs +++ b/tests/ui/ptr_arg.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused, clippy::many_single_char_names)] #![warn(clippy::ptr_arg)] @@ -19,7 +16,8 @@ fn do_vec(x: &Vec) { //Nothing here } -fn do_vec_mut(x: &mut Vec) { // no error here +fn do_vec_mut(x: &mut Vec) { + // no error here //Nothing here } @@ -27,12 +25,12 @@ fn do_str(x: &String) { //Nothing here either } -fn do_str_mut(x: &mut String) { // no error here +fn do_str_mut(x: &mut String) { + // no error here //Nothing here either } -fn main() { -} +fn main() {} trait Foo { type Item; @@ -62,9 +60,7 @@ fn str_cloned(x: &String) -> String { let a = x.clone(); let b = x.clone(); let c = b.clone(); - let d = a.clone() - .clone() - .clone(); + let d = a.clone().clone().clone(); x.clone() } @@ -75,13 +71,14 @@ fn false_positive_capacity(x: &Vec, y: &String) { } fn false_positive_capacity_too(x: &String) -> String { - if x.capacity() > 1024 { panic!("Too large!"); } + if x.capacity() > 1024 { + panic!("Too large!"); + } x.clone() } #[allow(dead_code)] -fn test_cow_with_ref(c: &Cow<[i32]>) { -} +fn test_cow_with_ref(c: &Cow<[i32]>) {} #[allow(dead_code)] fn test_cow(c: Cow<[i32]>) { @@ -93,4 +90,6 @@ trait Foo2 { } // no error for &self references where self is of type String (#2293) -impl Foo2 for String { fn do_string(&self) {} } +impl Foo2 for String { + fn do_string(&self) {} +} diff --git a/tests/ui/ptr_offset_with_cast.rs b/tests/ui/ptr_offset_with_cast.rs index a6f86a230f37..2c9e47d3f328 100644 --- a/tests/ui/ptr_offset_with_cast.rs +++ b/tests/ui/ptr_offset_with_cast.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn main() { let vec = vec![b'a', b'b', b'c']; let ptr = vec.as_ptr(); diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs index a39ea00cb8b8..7f1d06fbd29e 100644 --- a/tests/ui/question_mark.rs +++ b/tests/ui/question_mark.rs @@ -7,18 +7,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn some_func(a: Option) -> Option { - if a.is_none() { - return None - } + if a.is_none() { + return None; + } - a + a } pub enum SeemsOption { Some(T), - None + None, } impl SeemsOption { @@ -39,25 +38,25 @@ fn returns_something_similar_to_option(a: SeemsOption) -> SeemsOption } pub struct SomeStruct { - pub opt: Option, + pub opt: Option, } impl SomeStruct { - pub fn func(&self) -> Option { - if (self.opt).is_none() { - return None; - } + pub fn func(&self) -> Option { + if (self.opt).is_none() { + return None; + } - self.opt - } + self.opt + } } fn main() { - some_func(Some(42)); - some_func(None); + some_func(Some(42)); + some_func(None); - let some_struct = SomeStruct { opt: Some(54) }; - some_struct.func(); + let some_struct = SomeStruct { opt: Some(54) }; + some_struct.func(); let so = SeemsOption::Some(45); returns_something_similar_to_option(so); diff --git a/tests/ui/range.rs b/tests/ui/range.rs index 8b7f0673e244..1eab67e20d0f 100644 --- a/tests/ui/range.rs +++ b/tests/ui/range.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - struct NotARange; impl NotARange { fn step_by(&self, _: u32) {} @@ -31,13 +28,13 @@ fn main() { let y = NotARange; y.step_by(0); - let v1 = vec![1,2,3]; - let v2 = vec![4,5]; + let v1 = vec![1, 2, 3]; + let v2 = vec![4, 5]; let _x = v1.iter().zip(0..v1.len()); let _y = v1.iter().zip(0..v2.len()); // No error // check const eval - let _ = v1.iter().step_by(2/3); + let _ = v1.iter().step_by(2 / 3); } #[allow(unused)] diff --git a/tests/ui/range_plus_minus_one.rs b/tests/ui/range_plus_minus_one.rs index 602743d69142..d8c955ba73f5 100644 --- a/tests/ui/range_plus_minus_one.rs +++ b/tests/ui/range_plus_minus_one.rs @@ -7,38 +7,35 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - fn f() -> usize { 42 } #[warn(clippy::range_plus_one)] fn main() { - for _ in 0..2 { } - for _ in 0..=2 { } + for _ in 0..2 {} + for _ in 0..=2 {} - for _ in 0..3+1 { } - for _ in 0..=3+1 { } + for _ in 0..3 + 1 {} + for _ in 0..=3 + 1 {} - for _ in 0..1+5 { } - for _ in 0..=1+5 { } + for _ in 0..1 + 5 {} + for _ in 0..=1 + 5 {} - for _ in 1..1+1 { } - for _ in 1..=1+1 { } + for _ in 1..1 + 1 {} + for _ in 1..=1 + 1 {} - for _ in 0..13+13 { } - for _ in 0..=13-7 { } + for _ in 0..13 + 13 {} + for _ in 0..=13 - 7 {} - for _ in 0..(1+f()) { } - for _ in 0..=(1+f()) { } + for _ in 0..(1 + f()) {} + for _ in 0..=(1 + f()) {} - let _ = ..11-1; - let _ = ..=11-1; - let _ = ..=(11-1); - let _ = (1..11+1); - let _ = (f()+1)..(f()+1); + let _ = ..11 - 1; + let _ = ..=11 - 1; + let _ = ..=(11 - 1); + let _ = (1..11 + 1); + let _ = (f() + 1)..(f() + 1); let mut vec: Vec<()> = std::vec::Vec::new(); vec.drain(..); diff --git a/tests/ui/redundant_clone.rs b/tests/ui/redundant_clone.rs index deedde382316..d55898748be1 100644 --- a/tests/ui/redundant_clone.rs +++ b/tests/ui/redundant_clone.rs @@ -9,8 +9,8 @@ #![warn(clippy::redundant_clone)] -use std::path::Path; use std::ffi::OsString; +use std::path::Path; fn main() { let _ = ["lorem", "ipsum"].join(" ").to_string(); @@ -33,7 +33,8 @@ fn main() { let _ = OsString::new().to_os_string(); // Check that lint level works - #[allow(clippy::redundant_clone)] let _ = String::new().to_string(); + #[allow(clippy::redundant_clone)] + let _ = String::new().to_string(); } #[derive(Clone)] diff --git a/tests/ui/redundant_closure_call.rs b/tests/ui/redundant_closure_call.rs index e68cdc2c1d17..46c56922974e 100644 --- a/tests/ui/redundant_closure_call.rs +++ b/tests/ui/redundant_closure_call.rs @@ -7,27 +7,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::redundant_closure_call)] fn main() { - let a = (|| 42)(); + let a = (|| 42)(); - let mut i = 1; - let mut k = (|m| m+1)(i); + let mut i = 1; + let mut k = (|m| m + 1)(i); - k = (|a,b| a*b)(1,5); + k = (|a, b| a * b)(1, 5); - let closure = || 32; - i = closure(); + let closure = || 32; + i = closure(); - let closure = |i| i+1; - i = closure(3); + let closure = |i| i + 1; + i = closure(3); - i = closure(4); + i = closure(4); #[allow(clippy::needless_return)] (|| return 2)(); diff --git a/tests/ui/redundant_field_names.rs b/tests/ui/redundant_field_names.rs index 41e90bba368a..68adba92f8a2 100644 --- a/tests/ui/redundant_field_names.rs +++ b/tests/ui/redundant_field_names.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::redundant_field_names)] #![allow(unused_variables)] #![feature(inclusive_range, inclusive_range_fields, inclusive_range_methods)] @@ -17,7 +14,7 @@ #[macro_use] extern crate derive_new; -use std::ops::{Range, RangeFrom, RangeTo, RangeInclusive, RangeToInclusive}; +use std::ops::{Range, RangeFrom, RangeInclusive, RangeTo, RangeToInclusive}; mod foo { pub const BAR: u8 = 0; @@ -46,8 +43,8 @@ fn main() { gender: gender, age: age, - name, //should be ok - buzz: fizz, //should be ok + name, //should be ok + buzz: fizz, //should be ok foo: foo::BAR, //should be ok }; diff --git a/tests/ui/redundant_pattern_matching.rs b/tests/ui/redundant_pattern_matching.rs index 50838584f66e..3744695a5354 100644 --- a/tests/ui/redundant_pattern_matching.rs +++ b/tests/ui/redundant_pattern_matching.rs @@ -7,39 +7,27 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![warn(clippy::redundant_pattern_matching)] - fn main() { if let Ok(_) = Ok::(42) {} - if let Err(_) = Err::(42) { - } + if let Err(_) = Err::(42) {} - if let None = None::<()> { - } + if let None = None::<()> {} - if let Some(_) = Some(42) { - } + if let Some(_) = Some(42) {} - if Ok::(42).is_ok() { - } + if Ok::(42).is_ok() {} - if Err::(42).is_err() { - } + if Err::(42).is_err() {} - if None::.is_none() { - } + if None::.is_none() {} - if Some(42).is_some() { - } + if Some(42).is_some() {} - if let Ok(x) = Ok::(42) { + if let Ok(x) = Ok::(42) { println!("{}", x); } diff --git a/tests/ui/reference.rs b/tests/ui/reference.rs index bd0fdd5d5ea3..583829aae418 100644 --- a/tests/ui/reference.rs +++ b/tests/ui/reference.rs @@ -7,15 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - fn get_number() -> usize { 10 } -fn get_reference(n : &usize) -> &usize { +fn get_reference(n: &usize) -> &usize { n } @@ -32,7 +28,7 @@ fn main() { let b = *get_reference(&a); - let bytes : Vec = vec![1, 2, 3, 4]; + let bytes: Vec = vec![1, 2, 3, 4]; let b = *&bytes[1..2][0]; //This produces a suggestion of 'let b = (a);' which @@ -41,7 +37,7 @@ fn main() { let b = *(&a); - let b = *((&a)); + let b = *(&a); let b = *&&a; diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs index 2623438c4c4f..2d9c34828500 100644 --- a/tests/ui/regex.rs +++ b/tests/ui/regex.rs @@ -7,17 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(unused)] #![warn(clippy::invalid_regex, clippy::trivial_regex, clippy::regex_macro)] extern crate regex; -use regex::{Regex, RegexSet, RegexBuilder}; -use regex::bytes::{Regex as BRegex, RegexSet as BRegexSet, RegexBuilder as BRegexBuilder}; +use regex::bytes::{Regex as BRegex, RegexBuilder as BRegexBuilder, RegexSet as BRegexSet}; +use regex::{Regex, RegexBuilder, RegexSet}; const OPENING_PAREN: &str = "("; const NOT_A_REAL_REGEX: &str = "foobar"; @@ -37,24 +33,15 @@ fn syntax_error() { let closing_paren = ")"; let not_linted = Regex::new(closing_paren); - let set = RegexSet::new(&[ - r"[a-z]+@[a-z]+\.(com|org|net)", - r"[a-z]+\.(com|org|net)", - ]); + let set = RegexSet::new(&[r"[a-z]+@[a-z]+\.(com|org|net)", r"[a-z]+\.(com|org|net)"]); let bset = BRegexSet::new(&[ r"[a-z]+@[a-z]+\.(com|org|net)", r"[a-z]+\.(com|org|net)", r".", // regression test ]); - let set_error = RegexSet::new(&[ - OPENING_PAREN, - r"[a-z]+\.(com|org|net)", - ]); - let bset_error = BRegexSet::new(&[ - OPENING_PAREN, - r"[a-z]+\.(com|org|net)", - ]); + let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); + let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+\.(com|org|net)"]); let raw_string_error = Regex::new(r"[...\/...]"); let raw_string_error = Regex::new(r#"[...\/...]"#); diff --git a/tests/ui/replace_consts.rs b/tests/ui/replace_consts.rs index 7da1f212a751..ca3d3b13edc0 100644 --- a/tests/ui/replace_consts.rs +++ b/tests/ui/replace_consts.rs @@ -7,13 +7,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![feature(integer_atomics)] #![allow(clippy::blacklisted_name)] #![deny(clippy::replace_consts)] use std::sync::atomic::*; -use std::sync::{ONCE_INIT, Once}; +use std::sync::{Once, ONCE_INIT}; #[rustfmt::skip] fn bad() { diff --git a/tests/ui/result_map_unit_fn.rs b/tests/ui/result_map_unit_fn.rs index f24e52b10fdb..043b3efd45e7 100644 --- a/tests/ui/result_map_unit_fn.rs +++ b/tests/ui/result_map_unit_fn.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(never_type)] #![warn(clippy::result_map_unit_fn)] #![allow(unused)] @@ -40,7 +37,7 @@ fn result_map_unit_fn() { let x = HasResult { field: Ok(10) }; x.field.map(plus_one); - let _ : Result<(), usize> = x.field.map(do_nothing); + let _: Result<(), usize> = x.field.map(do_nothing); x.field.map(do_nothing); @@ -49,47 +46,68 @@ fn result_map_unit_fn() { x.field.map(diverge); let captured = 10; - if let Ok(value) = x.field { do_nothing(value + captured) }; - let _ : Result<(), usize> = x.field.map(|value| do_nothing(value + captured)); + if let Ok(value) = x.field { + do_nothing(value + captured) + }; + let _: Result<(), usize> = x.field.map(|value| do_nothing(value + captured)); x.field.map(|value| x.do_result_nothing(value + captured)); - x.field.map(|value| { x.do_result_plus_one(value + captured); }); - + x.field.map(|value| { + x.do_result_plus_one(value + captured); + }); x.field.map(|value| do_nothing(value + captured)); - x.field.map(|value| { do_nothing(value + captured) }); - - x.field.map(|value| { do_nothing(value + captured); }); + x.field.map(|value| do_nothing(value + captured)); - x.field.map(|value| { { do_nothing(value + captured); } }); + x.field.map(|value| { + do_nothing(value + captured); + }); + x.field.map(|value| { + do_nothing(value + captured); + }); x.field.map(|value| diverge(value + captured)); - x.field.map(|value| { diverge(value + captured) }); - - x.field.map(|value| { diverge(value + captured); }); + x.field.map(|value| diverge(value + captured)); - x.field.map(|value| { { diverge(value + captured); } }); + x.field.map(|value| { + diverge(value + captured); + }); + x.field.map(|value| { + diverge(value + captured); + }); x.field.map(|value| plus_one(value + captured)); - x.field.map(|value| { plus_one(value + captured) }); - x.field.map(|value| { let y = plus_one(value + captured); }); - - x.field.map(|value| { plus_one(value + captured); }); - - x.field.map(|value| { { plus_one(value + captured); } }); + x.field.map(|value| plus_one(value + captured)); + x.field.map(|value| { + let y = plus_one(value + captured); + }); + x.field.map(|value| { + plus_one(value + captured); + }); - x.field.map(|ref value| { do_nothing(value + captured) }); + x.field.map(|value| { + plus_one(value + captured); + }); + x.field.map(|ref value| do_nothing(value + captured)); - x.field.map(|value| { do_nothing(value); do_nothing(value) }); + x.field.map(|value| { + do_nothing(value); + do_nothing(value) + }); - x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); + x.field.map(|value| { + if value > 0 { + do_nothing(value); + do_nothing(value) + } + }); // Suggestion for the let block should be `{ ... }` as it's too difficult to build a // proper suggestion for these cases @@ -97,9 +115,13 @@ fn result_map_unit_fn() { do_nothing(value); do_nothing(value) }); - x.field.map(|value| { do_nothing(value); do_nothing(value); }); + x.field.map(|value| { + do_nothing(value); + do_nothing(value); + }); - // The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let variable name for them + // The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let + // variable name for them let res: Result = Ok(42).map(diverge); "12".parse::().map(diverge); @@ -110,6 +132,4 @@ fn result_map_unit_fn() { y.map(do_nothing); } -fn main() { -} - +fn main() {} diff --git a/tests/ui/serde.rs b/tests/ui/serde.rs index 47be8423d7b4..c52fd065dbef 100644 --- a/tests/ui/serde.rs +++ b/tests/ui/serde.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::serde_api_misuse)] #![allow(dead_code)] @@ -25,13 +22,15 @@ impl<'de> serde::de::Visitor<'de> for A { } fn visit_str(self, _v: &str) -> Result - where E: serde::de::Error, + where + E: serde::de::Error, { unimplemented!() } fn visit_string(self, _v: String) -> Result - where E: serde::de::Error, + where + E: serde::de::Error, { unimplemented!() } @@ -47,11 +46,11 @@ impl<'de> serde::de::Visitor<'de> for B { } fn visit_string(self, _v: String) -> Result - where E: serde::de::Error, + where + E: serde::de::Error, { unimplemented!() } } -fn main() { -} +fn main() {} diff --git a/tests/ui/shadow.rs b/tests/ui/shadow.rs index aa29bd1d79cf..e960a6252be9 100644 --- a/tests/ui/shadow.rs +++ b/tests/ui/shadow.rs @@ -7,16 +7,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - -#![warn(clippy::all, clippy::pedantic, clippy::shadow_same, clippy::shadow_reuse, clippy::shadow_unrelated)] +#![warn( + clippy::all, + clippy::pedantic, + clippy::shadow_same, + clippy::shadow_reuse, + clippy::shadow_unrelated +)] #![allow(unused_parens, unused_variables, clippy::missing_docs_in_private_items)] -fn id(x: T) -> T { x } +fn id(x: T) -> T { + x +} -fn first(x: (isize, isize)) -> isize { x.0 } +fn first(x: (isize, isize)) -> isize { + x.0 +} fn main() { let mut x = 1; @@ -35,7 +41,9 @@ fn main() { let o = Some(1_u8); - if let Some(p) = o { assert_eq!(1, p); } + if let Some(p) = o { + assert_eq!(1, p); + } match o { Some(p) => p, // no error, because the p above is in its own scope None => 0, diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs index 67999a74e5eb..efe9920dd88c 100644 --- a/tests/ui/short_circuit_statement.rs +++ b/tests/ui/short_circuit_statement.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::short_circuit_statement)] fn main() { diff --git a/tests/ui/single_char_pattern.rs b/tests/ui/single_char_pattern.rs index c3d846997ec7..5277841fe325 100644 --- a/tests/ui/single_char_pattern.rs +++ b/tests/ui/single_char_pattern.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - use std::collections::HashSet; fn main() { diff --git a/tests/ui/single_match.rs b/tests/ui/single_match.rs index dca68e179e74..5a1bde3de324 100644 --- a/tests/ui/single_match.rs +++ b/tests/ui/single_match.rs @@ -7,20 +7,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::single_match)] -fn dummy() { -} +fn dummy() {} -fn single_match(){ +fn single_match() { let x = Some(1u8); match x { - Some(y) => { println!("{:?}", y); } - _ => () + Some(y) => { + println!("{:?}", y); + }, + _ => (), }; let x = Some(1u8); @@ -29,19 +27,19 @@ fn single_match(){ // We suggest `if let Some(y) = x { .. }` because the macro // is expanded before we can do anything. Some(y) => println!("{:?}", y), - _ => () + _ => (), } - let z = (1u8,1u8); + let z = (1u8, 1u8); match z { (2...3, 7...9) => dummy(), - _ => {} + _ => {}, }; // Not linted (pattern guards used) match x { Some(y) if y == 0 => println!("{:?}", y), - _ => () + _ => (), } // Not linted (no block with statements in the single arm) @@ -51,22 +49,25 @@ fn single_match(){ } } -enum Foo { Bar, Baz(u8) } -use Foo::*; +enum Foo { + Bar, + Baz(u8), +} use std::borrow::Cow; +use Foo::*; fn single_match_know_enum() { let x = Some(1u8); - let y : Result<_, i8> = Ok(1i8); + let y: Result<_, i8> = Ok(1i8); match x { Some(y) => dummy(), - None => () + None => (), }; match y { Ok(y) => dummy(), - Err(..) => () + Err(..) => (), }; let c = Cow::Borrowed(""); @@ -89,4 +90,4 @@ fn single_match_know_enum() { } } -fn main() { } +fn main() {} diff --git a/tests/ui/single_match_else.rs b/tests/ui/single_match_else.rs index a7c28c578a4c..18c26f7fc263 100644 --- a/tests/ui/single_match_else.rs +++ b/tests/ui/single_match_else.rs @@ -20,7 +20,10 @@ static NODE: ExprNode = ExprNode::Unicorns; fn unwrap_addr() -> Option<&'static ExprNode> { match ExprNode::Butterflies { ExprNode::ExprAddrOf => Some(&NODE), - _ => { let x = 5; None }, + _ => { + let x = 5; + None + }, } } diff --git a/tests/ui/slow_vector_initialization.rs b/tests/ui/slow_vector_initialization.rs index 5364bf70ff09..cf11384467c3 100644 --- a/tests/ui/slow_vector_initialization.rs +++ b/tests/ui/slow_vector_initialization.rs @@ -62,13 +62,11 @@ fn resize_vector() { vec1.resize(10, 0); } -fn do_stuff(vec: &mut Vec) { - -} +fn do_stuff(vec: &mut Vec) {} fn extend_vector_with_manipulations_between() { let len = 300; - let mut vec1:Vec = Vec::with_capacity(len); + let mut vec1: Vec = Vec::with_capacity(len); do_stuff(&mut vec1); vec1.extend(repeat(0).take(len)); } diff --git a/tests/ui/starts_ends_with.rs b/tests/ui/starts_ends_with.rs index 5c09e8f1f283..529c2487f542 100644 --- a/tests/ui/starts_ends_with.rs +++ b/tests/ui/starts_ends_with.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(dead_code)] fn main() {} @@ -22,22 +19,28 @@ fn starts_with() { fn chars_cmp_with_unwrap() { let s = String::from("foo"); - if s.chars().next().unwrap() == 'f' { // s.starts_with('f') + if s.chars().next().unwrap() == 'f' { + // s.starts_with('f') // Nothing here } - if s.chars().next_back().unwrap() == 'o' { // s.ends_with('o') + if s.chars().next_back().unwrap() == 'o' { + // s.ends_with('o') // Nothing here } - if s.chars().last().unwrap() == 'o' { // s.ends_with('o') + if s.chars().last().unwrap() == 'o' { + // s.ends_with('o') // Nothing here } - if s.chars().next().unwrap() != 'f' { // !s.starts_with('f') + if s.chars().next().unwrap() != 'f' { + // !s.starts_with('f') // Nothing here } - if s.chars().next_back().unwrap() != 'o' { // !s.ends_with('o') + if s.chars().next_back().unwrap() != 'o' { + // !s.ends_with('o') // Nothing here } - if s.chars().last().unwrap() != 'o' { // !s.ends_with('o') + if s.chars().last().unwrap() != 'o' { + // !s.ends_with('o') // Nothing here } } diff --git a/tests/ui/string_extend.rs b/tests/ui/string_extend.rs index a0cf9c469065..56b466ede20a 100644 --- a/tests/ui/string_extend.rs +++ b/tests/ui/string_extend.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #[derive(Copy, Clone)] struct HasChars; diff --git a/tests/ui/strings.rs b/tests/ui/strings.rs index d2062b356dc0..e15e80c1928e 100644 --- a/tests/ui/strings.rs +++ b/tests/ui/strings.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #[warn(clippy::string_add)] #[allow(clippy::string_add_assign)] fn add_only() { diff --git a/tests/ui/stutter.rs b/tests/ui/stutter.rs index 17d528d10500..922487d671d0 100644 --- a/tests/ui/stutter.rs +++ b/tests/ui/stutter.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::stutter)] #![allow(dead_code)] diff --git a/tests/ui/suspicious_arithmetic_impl.rs b/tests/ui/suspicious_arithmetic_impl.rs index 5e7608565ed1..ed845b7647a5 100644 --- a/tests/ui/suspicious_arithmetic_impl.rs +++ b/tests/ui/suspicious_arithmetic_impl.rs @@ -7,12 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::suspicious_arithmetic_impl)] -use std::ops::{Add, AddAssign, Mul, Sub, Div}; +use std::ops::{Add, AddAssign, Div, Mul, Sub}; #[derive(Copy, Clone)] struct Foo(u32); diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index 90c2aec98759..e9f227d47a07 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![allow(clippy::blacklisted_name, unused_assignments)] @@ -54,7 +50,7 @@ fn main() { a = b; b = a; - ; let t = a; +; let t = a; a = b; b = t; @@ -63,7 +59,7 @@ fn main() { c.0 = a; a = c.0; - ; let t = c.0; +; let t = c.0; c.0 = a; a = t; } diff --git a/tests/ui/temporary_assignment.rs b/tests/ui/temporary_assignment.rs index 9c4365bef409..79c090f05722 100644 --- a/tests/ui/temporary_assignment.rs +++ b/tests/ui/temporary_assignment.rs @@ -7,29 +7,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::temporary_assignment)] use std::ops::{Deref, DerefMut}; struct Struct { - field: i32 + field: i32, } struct Wrapper<'a> { - inner: &'a mut Struct + inner: &'a mut Struct, } impl<'a> Deref for Wrapper<'a> { type Target = Struct; - fn deref(&self) -> &Struct { self.inner } + fn deref(&self) -> &Struct { + self.inner + } } impl<'a> DerefMut for Wrapper<'a> { - fn deref_mut(&mut self) -> &mut Struct { self.inner } + fn deref_mut(&mut self) -> &mut Struct { + self.inner + } } fn main() { diff --git a/tests/ui/toplevel_ref_arg.rs b/tests/ui/toplevel_ref_arg.rs index 09ee79f6d8bb..b051746bbd49 100644 --- a/tests/ui/toplevel_ref_arg.rs +++ b/tests/ui/toplevel_ref_arg.rs @@ -7,32 +7,28 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![allow(unused)] fn the_answer(ref mut x: u8) { - *x = 42; + *x = 42; } fn main() { - let mut x = 0; - the_answer(x); - // Closures should not warn - let y = |ref x| { println!("{:?}", x) }; - y(1u8); + let mut x = 0; + the_answer(x); + // Closures should not warn + let y = |ref x| println!("{:?}", x); + y(1u8); - let ref x = 1; + let ref x = 1; - let ref y: (&_, u8) = (&1, 2); + let ref y: (&_, u8) = (&1, 2); - let ref z = 1 + 2; + let ref z = 1 + 2; - let ref mut z = 1 + 2; + let ref mut z = 1 + 2; - let (ref x, _) = (1,2); // okay, not top level - println!("The answer is {}.", x); + let (ref x, _) = (1, 2); // okay, not top level + println!("The answer is {}.", x); } diff --git a/tests/ui/trailing_zeros.rs b/tests/ui/trailing_zeros.rs index 7ed076225e2a..9afb3399c594 100644 --- a/tests/ui/trailing_zeros.rs +++ b/tests/ui/trailing_zeros.rs @@ -7,14 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![feature(stmt_expr_attributes)] - #![allow(unused_parens)] fn main() { let x: i32 = 42; - let _ = #[clippy::author] (x & 0b1111 == 0); // suggest trailing_zeros + let _ = #[clippy::author] + (x & 0b1111 == 0); // suggest trailing_zeros let _ = x & 0b1_1111 == 0; // suggest trailing_zeros let _ = x & 0b1_1010 == 0; // do not lint let _ = x & 1 == 0; // do not lint diff --git a/tests/ui/transmute.rs b/tests/ui/transmute.rs index 285c07a97240..b27014201cd7 100644 --- a/tests/ui/transmute.rs +++ b/tests/ui/transmute.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(dead_code)] extern crate core; @@ -101,11 +97,11 @@ fn useless() { let _: *const usize = std::mem::transmute(5_isize); - let _ = 5_isize as *const usize; + let _ = 5_isize as *const usize; - let _: *const usize = std::mem::transmute(1+1usize); + let _: *const usize = std::mem::transmute(1 + 1usize); - let _ = (1+1_usize) as *const usize; + let _ = (1 + 1_usize) as *const usize; } } @@ -201,9 +197,7 @@ fn transmute_ptr_to_ptr() { let s = "hello world".to_owned(); let lp = LifetimeParam { s: &s }; let _: &LifetimeParam<'static> = unsafe { std::mem::transmute(&lp) }; - let _: &GenericParam<&LifetimeParam<'static>> = unsafe { - std::mem::transmute(&GenericParam { t: &lp}) - }; + let _: &GenericParam<&LifetimeParam<'static>> = unsafe { std::mem::transmute(&GenericParam { t: &lp }) }; } -fn main() { } +fn main() {} diff --git a/tests/ui/transmute_32bit.rs b/tests/ui/transmute_32bit.rs index 59d3d82ccaec..dd96e2dabe16 100644 --- a/tests/ui/transmute_32bit.rs +++ b/tests/ui/transmute_32bit.rs @@ -7,11 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - //ignore-x86_64 - - #[warn(wrong_transmute)] fn main() { unsafe { diff --git a/tests/ui/transmute_64bit.rs b/tests/ui/transmute_64bit.rs index 8620628fdceb..fbc298e3a062 100644 --- a/tests/ui/transmute_64bit.rs +++ b/tests/ui/transmute_64bit.rs @@ -7,14 +7,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - //ignore-x86 //no-ignore-x86_64 - - #[warn(clippy::wrong_transmute)] fn main() { unsafe { diff --git a/tests/ui/trivially_copy_pass_by_ref.rs b/tests/ui/trivially_copy_pass_by_ref.rs index 2a0dc22bfef3..94e0113e56ca 100644 --- a/tests/ui/trivially_copy_pass_by_ref.rs +++ b/tests/ui/trivially_copy_pass_by_ref.rs @@ -7,10 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -#![allow(clippy::many_single_char_names, clippy::blacklisted_name, clippy::redundant_field_names)] +#![allow( + clippy::many_single_char_names, + clippy::blacklisted_name, + clippy::redundant_field_names +)] #[derive(Copy, Clone)] struct Foo(u32); @@ -20,7 +21,10 @@ struct Bar([u8; 24]); #[derive(Copy, Clone)] pub struct Color { - pub r: u8, pub g: u8, pub b: u8, pub a: u8, + pub r: u8, + pub g: u8, + pub b: u8, + pub a: u8, } struct FooRef<'a> { @@ -29,8 +33,7 @@ struct FooRef<'a> { type Baz = u32; -fn good(a: &mut u32, b: u32, c: &Bar) { -} +fn good(a: &mut u32, b: u32, c: &Bar) {} fn good_return_implicit_lt_ref(foo: &Foo) -> &u32 { &foo.0 @@ -42,33 +45,24 @@ fn good_return_explicit_lt_ref<'a>(foo: &'a Foo) -> &'a u32 { } fn good_return_implicit_lt_struct(foo: &Foo) -> FooRef { - FooRef { - foo, - } + FooRef { foo } } #[allow(clippy::needless_lifetimes)] fn good_return_explicit_lt_struct<'a>(foo: &'a Foo) -> FooRef<'a> { - FooRef { - foo, - } + FooRef { foo } } -fn bad(x: &u32, y: &Foo, z: &Baz) { -} +fn bad(x: &u32, y: &Foo, z: &Baz) {} impl Foo { - fn good(self, a: &mut u32, b: u32, c: &Bar) { - } + fn good(self, a: &mut u32, b: u32, c: &Bar) {} - fn good2(&mut self) { - } + fn good2(&mut self) {} - fn bad(&self, x: &u32, y: &Foo, z: &Baz) { - } + fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} - fn bad2(x: &u32, y: &Foo, z: &Baz) { - } + fn bad2(x: &u32, y: &Foo, z: &Baz) {} } impl AsRef for Foo { @@ -78,11 +72,9 @@ impl AsRef for Foo { } impl Bar { - fn good(&self, a: &mut u32, b: u32, c: &Bar) { - } + fn good(&self, a: &mut u32, b: u32, c: &Bar) {} - fn bad2(x: &u32, y: &Foo, z: &Baz) { - } + fn bad2(x: &u32, y: &Foo, z: &Baz) {} } trait MyTrait { diff --git a/tests/ui/ty_fn_sig.rs b/tests/ui/ty_fn_sig.rs index 82b5deda3ba8..17027306367d 100644 --- a/tests/ui/ty_fn_sig.rs +++ b/tests/ui/ty_fn_sig.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - // Regression test pub fn retry(f: F) { diff --git a/tests/ui/types.rs b/tests/ui/types.rs index 03676f69ab43..f0ede2fd48c9 100644 --- a/tests/ui/types.rs +++ b/tests/ui/types.rs @@ -7,14 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - // should not warn on lossy casting in constant types // because not supported yet -const C : i32 = 42; -const C_I64 : i64 = C as i64; +const C: i32 = 42; +const C_I64: i64 = C as i64; fn main() { // should suggest i64::from(c) - let c : i32 = 42; - let c_i64 : i64 = c as i64; + let c: i32 = 42; + let c_i64: i64 = c as i64; } diff --git a/tests/ui/unicode.rs b/tests/ui/unicode.rs index 8de17fea2201..0e1200db227f 100644 --- a/tests/ui/unicode.rs +++ b/tests/ui/unicode.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[warn(clippy::zero_width_space)] fn zero() { print!("Here >​< is a ZWS, and ​another"); diff --git a/tests/ui/unit_arg.rs b/tests/ui/unit_arg.rs index 058c6563c5ad..571882ced0f7 100644 --- a/tests/ui/unit_arg.rs +++ b/tests/ui/unit_arg.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::unit_arg)] #![allow(clippy::no_effect)] @@ -33,7 +30,9 @@ impl Bar { fn bad() { foo({}); - foo({ 1; }); + foo({ + 1; + }); foo(foo(1)); foo({ foo(1); @@ -41,7 +40,9 @@ fn bad() { }); foo3({}, 2, 2); let b = Bar; - b.bar({ 1; }); + b.bar({ + 1; + }); } fn ok() { diff --git a/tests/ui/unit_cmp.rs b/tests/ui/unit_cmp.rs index 10eb0c70c545..0bc87f43c151 100644 --- a/tests/ui/unit_cmp.rs +++ b/tests/ui/unit_cmp.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::unit_cmp)] #![allow(clippy::no_effect, clippy::unnecessary_operation)] @@ -19,13 +15,18 @@ pub struct ContainsUnit(()); // should be fine fn main() { // this is fine - if true == false { - } + if true == false {} // this warns - if { true; } == { false; } { - } - - if { true; } > { false; } { - } + if { + true; + } == { + false; + } {} + + if { + true; + } > { + false; + } {} } diff --git a/tests/ui/unknown_clippy_lints.rs b/tests/ui/unknown_clippy_lints.rs index d0b4ae9f5329..e583614a93c8 100644 --- a/tests/ui/unknown_clippy_lints.rs +++ b/tests/ui/unknown_clippy_lints.rs @@ -11,6 +11,4 @@ #![warn(clippy::pedantic)] #[warn(clippy::if_not_els)] -fn main() { - -} +fn main() {} diff --git a/tests/ui/unnecessary_clone.rs b/tests/ui/unnecessary_clone.rs index 28cad1d881fd..40c4b4961e94 100644 --- a/tests/ui/unnecessary_clone.rs +++ b/tests/ui/unnecessary_clone.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::clone_on_ref_ptr)] #![allow(unused)] @@ -70,14 +67,14 @@ fn clone_on_double_ref() { let y = &&x; let z: &Vec<_> = y.clone(); - println!("{:p} {:p}",*y, z); + println!("{:p} {:p}", *y, z); } fn iter_clone_collect() { - let v = [1,2,3,4,5]; - let v2 : Vec = v.iter().cloned().collect(); - let v3 : HashSet = v.iter().cloned().collect(); - let v4 : VecDeque = v.iter().cloned().collect(); + let v = [1, 2, 3, 4, 5]; + let v2: Vec = v.iter().cloned().collect(); + let v3: HashSet = v.iter().cloned().collect(); + let v4: VecDeque = v.iter().cloned().collect(); } mod many_derefs { @@ -92,9 +89,11 @@ mod many_derefs { ($src:ident, $dst:ident) => { impl std::ops::Deref for $src { type Target = $dst; - fn deref(&self) -> &Self::Target { &$dst } + fn deref(&self) -> &Self::Target { + &$dst + } } - } + }; } impl_deref!(A, B); @@ -102,7 +101,9 @@ mod many_derefs { impl_deref!(C, D); impl std::ops::Deref for D { type Target = &'static E; - fn deref(&self) -> &Self::Target { &&E } + fn deref(&self) -> &Self::Target { + &&E + } } fn go1() { diff --git a/tests/ui/unnecessary_filter_map.rs b/tests/ui/unnecessary_filter_map.rs index 8b74ca3a4255..a0c183a58cca 100644 --- a/tests/ui/unnecessary_filter_map.rs +++ b/tests/ui/unnecessary_filter_map.rs @@ -7,10 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - fn main() { let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); - let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None }); + let _ = (0..4).filter_map(|x| { + if x > 1 { + return Some(x); + }; + None + }); let _ = (0..4).filter_map(|x| match x { 0 | 1 => None, _ => Some(x), diff --git a/tests/ui/unnecessary_fold.rs b/tests/ui/unnecessary_fold.rs index e8d84ecea8c6..4b4a6ee044c0 100644 --- a/tests/ui/unnecessary_fold.rs +++ b/tests/ui/unnecessary_fold.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - /// Calls which should trigger the `UNNECESSARY_FOLD` lint fn unnecessary_fold() { // Can be replaced by .any diff --git a/tests/ui/unnecessary_operation.rs b/tests/ui/unnecessary_operation.rs index de44047c8671..34e1112f0067 100644 --- a/tests/ui/unnecessary_operation.rs +++ b/tests/ui/unnecessary_operation.rs @@ -13,14 +13,14 @@ struct Tuple(i32); struct Struct { - field: i32 + field: i32, } enum Enum { Tuple(i32), Struct { field: i32 }, } struct DropStruct { - field: i32 + field: i32, } impl Drop for DropStruct { fn drop(&mut self) {} @@ -40,9 +40,15 @@ struct FooString { s: String, } -fn get_number() -> i32 { 0 } -fn get_struct() -> Struct { Struct { field: 0 } } -fn get_drop_struct() -> DropStruct { DropStruct { field: 0 } } +fn get_number() -> i32 { + 0 +} +fn get_struct() -> Struct { + Struct { field: 0 } +} +fn get_drop_struct() -> DropStruct { + DropStruct { field: 0 } +} fn main() { Tuple(get_number()); @@ -63,8 +69,12 @@ fn main() { (42, get_number()).1; [get_number(); 55]; [42; 55][get_number() as usize]; - {get_number()}; - FooString { s: String::from("blah"), }; + { + get_number() + }; + FooString { + s: String::from("blah"), + }; // Do not warn DropTuple(get_number()); diff --git a/tests/ui/unnecessary_ref.rs b/tests/ui/unnecessary_ref.rs index adc628fe8b6c..31aa367e5064 100644 --- a/tests/ui/unnecessary_ref.rs +++ b/tests/ui/unnecessary_ref.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![feature(tool_attributes)] #![feature(stmt_expr_attributes)] diff --git a/tests/ui/unneeded_field_pattern.rs b/tests/ui/unneeded_field_pattern.rs index 128a3fee4290..14676c1e76fb 100644 --- a/tests/ui/unneeded_field_pattern.rs +++ b/tests/ui/unneeded_field_pattern.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::unneeded_field_pattern)] #[allow(dead_code, unused)] @@ -24,13 +20,12 @@ fn main() { let f = Foo { a: 0, b: 0, c: 0 }; match f { - Foo { a: _, b: 0, .. } => {} - - Foo { a: _, b: _, c: _ } => {} + Foo { a: _, b: 0, .. } => {}, + Foo { a: _, b: _, c: _ } => {}, } match f { - Foo { b: 0, .. } => {} // should be OK - Foo { .. } => {} // and the Force might be with this one + Foo { b: 0, .. } => {}, // should be OK + Foo { .. } => {}, // and the Force might be with this one } } diff --git a/tests/ui/unreadable_literal.rs b/tests/ui/unreadable_literal.rs index 9142b3d29112..ad29fcf8fe41 100644 --- a/tests/ui/unreadable_literal.rs +++ b/tests/ui/unreadable_literal.rs @@ -7,13 +7,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #[warn(clippy::unreadable_literal)] #[allow(unused_variables)] fn main() { - let good = (0b1011_i64, 0o1_234_u32, 0x1_234_567, 65536, 1_2345_6789, 1234_f32, 1_234.12_f32, 1_234.123_f32, 1.123_4_f32); + let good = ( + 0b1011_i64, + 0o1_234_u32, + 0x1_234_567, + 65536, + 1_2345_6789, + 1234_f32, + 1_234.12_f32, + 1_234.123_f32, + 1.123_4_f32, + ); let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); let good_sci = 1.1234e1; let bad_sci = 1.123456e1; diff --git a/tests/ui/unsafe_removed_from_name.rs b/tests/ui/unsafe_removed_from_name.rs index 9c1800467d3f..bfab077375d2 100644 --- a/tests/ui/unsafe_removed_from_name.rs +++ b/tests/ui/unsafe_removed_from_name.rs @@ -7,23 +7,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused_imports)] #![allow(dead_code)] #![warn(clippy::unsafe_removed_from_name)] -use std::cell::{UnsafeCell as TotallySafeCell}; +use std::cell::UnsafeCell as TotallySafeCell; use std::cell::UnsafeCell as TotallySafeCellAgain; // Shouldn't error -use std::cell::{UnsafeCell as SuperDangerousUnsafeCell}; -use std::cell::{UnsafeCell as Dangerunsafe}; -use std::cell::UnsafeCell as Bombsawayunsafe; -use std::cell::{RefCell as ProbablyNotUnsafe}; +use std::cell::RefCell as ProbablyNotUnsafe; use std::cell::RefCell as RefCellThatCantBeUnsafe; +use std::cell::UnsafeCell as SuperDangerousUnsafeCell; +use std::cell::UnsafeCell as Dangerunsafe; +use std::cell::UnsafeCell as Bombsawayunsafe; mod mod_with_some_unsafe_things { pub struct Safe {} diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index a47a6ccfdf67..a125d0397af8 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(dead_code)] #![warn(clippy::unused_io_amount)] @@ -37,5 +33,4 @@ fn unwrap(s: &mut T) { s.read(&mut buf).unwrap(); } -fn main() { -} +fn main() {} diff --git a/tests/ui/unused_labels.rs b/tests/ui/unused_labels.rs index d7d843dfc259..8db29dcf3fcb 100644 --- a/tests/ui/unused_labels.rs +++ b/tests/ui/unused_labels.rs @@ -7,16 +7,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![allow(dead_code, clippy::items_after_statements, clippy::never_loop)] #![warn(clippy::unused_label)] fn unused_label() { 'label: for i in 1..2 { - if i > 4 { continue } + if i > 4 { + continue; + } } } @@ -26,9 +24,10 @@ fn foo() { } } - fn bla() { - 'a: loop { break } + 'a: loop { + break; + } fn blub() {} } diff --git a/tests/ui/unused_lt.rs b/tests/ui/unused_lt.rs index de13864421e1..99e80103f1f0 100644 --- a/tests/ui/unused_lt.rs +++ b/tests/ui/unused_lt.rs @@ -7,25 +7,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - -#![allow(unused, dead_code, clippy::needless_lifetimes, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)] +#![allow( + unused, + dead_code, + clippy::needless_lifetimes, + clippy::needless_pass_by_value, + clippy::trivially_copy_pass_by_ref +)] #![warn(clippy::extra_unused_lifetimes)] -fn empty() { - -} - - -fn used_lt<'a>(x: &'a u8) { - -} - +fn empty() {} -fn unused_lt<'a>(x: u8) { +fn used_lt<'a>(x: &'a u8) {} -} +fn unused_lt<'a>(x: u8) {} fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { // 'a is useless here since it's not directly bound @@ -39,19 +34,14 @@ fn lt_return_only<'a>() -> &'a u8 { panic!() } -fn unused_lt_blergh<'a>(x: Option>) { - -} - +fn unused_lt_blergh<'a>(x: Option>) {} trait Foo<'a> { fn x(&self, a: &'a u8); } impl<'a> Foo<'a> for u8 { - fn x(&self, a: &'a u8) { - - } + fn x(&self, a: &'a u8) {} } struct Bar; @@ -61,20 +51,23 @@ impl Bar { } // test for #489 (used lifetimes in bounds) -pub fn parse<'a, I: Iterator>(_it: &mut I) { +pub fn parse<'a, I: Iterator>(_it: &mut I) { unimplemented!() } -pub fn parse2<'a, I>(_it: &mut I) where I: Iterator{ +pub fn parse2<'a, I>(_it: &mut I) +where + I: Iterator, +{ unimplemented!() } -struct X { x: u32 } +struct X { + x: u32, +} impl X { fn self_ref_with_lifetime<'a>(&'a self) {} fn explicit_self_with_lifetime<'a>(self: &'a Self) {} } -fn main() { - -} +fn main() {} diff --git a/tests/ui/unwrap_or.rs b/tests/ui/unwrap_or.rs index 80965635a089..8573f78d43b7 100644 --- a/tests/ui/unwrap_or.rs +++ b/tests/ui/unwrap_or.rs @@ -7,8 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - #![warn(clippy::all)] fn main() { @@ -16,7 +14,5 @@ fn main() { } fn new_lines() { - let s = Some(String::from("test string")) - .unwrap_or("Fail".to_string()) - .len(); + let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); } diff --git a/tests/ui/use_self.rs b/tests/ui/use_self.rs index 60dc2d54d05d..c21df403035f 100644 --- a/tests/ui/use_self.rs +++ b/tests/ui/use_self.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::use_self)] #![allow(dead_code)] #![allow(clippy::should_implement_trait)] @@ -57,21 +54,24 @@ mod better { //todo the lint does not handle lifetimed struct //the following module should trigger the lint on the third method only mod lifetimes { - struct Foo<'a>{foo_str: &'a str} + struct Foo<'a> { + foo_str: &'a str, + } impl<'a> Foo<'a> { - // Cannot use `Self` as return type, because the function is actually `fn foo<'b>(s: &'b str) -> Foo<'b>` + // Cannot use `Self` as return type, because the function is actually `fn foo<'b>(s: &'b str) -> + // Foo<'b>` fn foo(s: &str) -> Foo { Foo { foo_str: s } } // cannot replace with `Self`, because that's `Foo<'a>` fn bar() -> Foo<'static> { - Foo { foo_str: "foo"} + Foo { foo_str: "foo" } } // `Self` is applicable here fn clone(&self) -> Foo<'a> { - Foo {foo_str: self.foo_str} + Foo { foo_str: self.foo_str } } } } @@ -105,8 +105,7 @@ mod traits { p1 } - fn nested(_p1: Box, _p2: (&u8, &Bad)) { - } + fn nested(_p1: Box, _p2: (&u8, &Bad)) {} fn vals(_: Bad) -> Bad { Bad::default() @@ -137,8 +136,7 @@ mod traits { p1 } - fn nested(_p1: Box, _p2: (&u8, &Self)) { - } + fn nested(_p1: Box, _p2: (&u8, &Self)) {} fn vals(_: Self) -> Self { Self::default() @@ -175,8 +173,7 @@ mod traits { p1 } - fn nested(_p1: Box, _p2: (&Self, &Self)) { - } + fn nested(_p1: Box, _p2: (&Self, &Self)) {} fn vals(_: Self) -> Self { Self::default() @@ -210,11 +207,11 @@ mod existential { struct Foo; impl Foo { - fn bad(foos: &[Self]) -> impl Iterator { + fn bad(foos: &[Self]) -> impl Iterator { foos.iter() } - fn good(foos: &[Self]) -> impl Iterator { + fn good(foos: &[Self]) -> impl Iterator { foos.iter() } } @@ -239,7 +236,7 @@ mod issue3425 { A, } impl Enum { - fn a () { + fn a() { use self::Enum::*; } } diff --git a/tests/ui/used_underscore_binding.rs b/tests/ui/used_underscore_binding.rs index b6b055e58bc4..bd20cc5f48a7 100644 --- a/tests/ui/used_underscore_binding.rs +++ b/tests/ui/used_underscore_binding.rs @@ -7,11 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::all)] - #![allow(clippy::blacklisted_name)] #![warn(clippy::used_underscore_binding)] @@ -19,7 +15,7 @@ macro_rules! test_macro { () => {{ let _foo = 42; _foo + 1 - }} + }}; } /// Test that we lint if we use a binding with a single leading underscore @@ -74,7 +70,7 @@ fn _fn_test() {} struct _StructTest; enum _EnumTest { _Empty, - _Value(_StructTest) + _Value(_StructTest), } /// Test that we do not lint for non-variable bindings diff --git a/tests/ui/useless_asref.rs b/tests/ui/useless_asref.rs index a5e9caf3a671..34c0f5095dbd 100644 --- a/tests/ui/useless_asref.rs +++ b/tests/ui/useless_asref.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![deny(clippy::useless_asref)] #![allow(clippy::trivially_copy_pass_by_ref)] use std::fmt::Debug; @@ -18,7 +15,9 @@ struct FakeAsRef; #[allow(clippy::should_implement_trait)] impl FakeAsRef { - fn as_ref(&self) -> &Self { self } + fn as_ref(&self) -> &Self { + self + } } struct MoreRef; @@ -29,14 +28,22 @@ impl<'a, 'b, 'c> AsRef<&'a &'b &'c MoreRef> for MoreRef { } } -fn foo_rstr(x: &str) { println!("{:?}", x); } -fn foo_rslice(x: &[i32]) { println!("{:?}", x); } -fn foo_mrslice(x: &mut [i32]) { println!("{:?}", x); } -fn foo_rrrrmr(_: &&&&MoreRef) { println!("so many refs"); } +fn foo_rstr(x: &str) { + println!("{:?}", x); +} +fn foo_rslice(x: &[i32]) { + println!("{:?}", x); +} +fn foo_mrslice(x: &mut [i32]) { + println!("{:?}", x); +} +fn foo_rrrrmr(_: &&&&MoreRef) { + println!("so many refs"); +} fn not_ok() { let rstr: &str = "hello"; - let mut mrslice: &mut [i32] = &mut [1,2,3]; + let mut mrslice: &mut [i32] = &mut [1, 2, 3]; { let rslice: &[i32] = &*mrslice; @@ -75,8 +82,8 @@ fn not_ok() { fn ok() { let string = "hello".to_owned(); - let mut arr = [1,2,3]; - let mut vec = vec![1,2,3]; + let mut arr = [1, 2, 3]; + let mut vec = vec![1, 2, 3]; { foo_rstr(string.as_ref()); @@ -109,8 +116,12 @@ fn ok() { generic_ok(&mut arr); } -fn foo_mrt(t: &mut T) { println!("{:?}", t); } -fn foo_rt(t: &T) { println!("{:?}", t); } +fn foo_mrt(t: &mut T) { + println!("{:?}", t); +} +fn foo_rt(t: &T) { + println!("{:?}", t); +} fn generic_not_ok + AsRef + Debug + ?Sized>(mrt: &mut T) { foo_mrt(mrt.as_mut()); diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index 9fb84866ef6b..4ee6520443d2 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -7,15 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![warn(clippy::useless_attribute)] #[allow(dead_code)] #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] -#[cfg_attr(feature = "cargo-clippy", - allow(dead_code))] +#[cfg_attr(feature = "cargo-clippy", allow(dead_code))] #[allow(unused_imports)] #[allow(unused_extern_crates)] #[macro_use] @@ -26,7 +22,10 @@ extern crate clippy_lints; use std::collections; // don't lint on deprecated for `use` items -mod foo { #[deprecated] pub struct Bar; } +mod foo { + #[deprecated] + pub struct Bar; +} #[allow(deprecated)] pub use foo::Bar; diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index e74aded57281..a7ccda375bfd 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::useless_vec)] #[derive(Debug)] @@ -37,10 +33,10 @@ fn main() { on_slice(&vec![1, 2]); on_slice(&[1, 2]); - on_slice(&vec ![1, 2]); + on_slice(&vec![1, 2]); on_slice(&[1, 2]); - on_slice(&vec!(1, 2)); + on_slice(&vec![1, 2]); on_slice(&[1, 2]); on_slice(&vec![1; 2]); diff --git a/tests/ui/while_loop.rs b/tests/ui/while_loop.rs index 3cc7c52df5de..e4c7047df917 100644 --- a/tests/ui/while_loop.rs +++ b/tests/ui/while_loop.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::while_let_loop, clippy::empty_loop, clippy::while_let_on_iterator)] #![allow(dead_code, clippy::never_loop, unused, clippy::cyclomatic_complexity)] @@ -20,10 +16,11 @@ fn main() { if let Some(_x) = y { let _v = 1; } else { - break + break; } } - loop { // no error, break is not in else clause + loop { + // no error, break is not in else clause if let Some(_x) = y { let _v = 1; } @@ -32,13 +29,13 @@ fn main() { loop { match y { Some(_x) => true, - None => break + None => break, }; } loop { let x = match y { Some(x) => x, - None => break + None => break, }; let _x = x; let _str = "foo"; @@ -48,19 +45,25 @@ fn main() { Some(x) => x, None => break, }; - { let _a = "bar"; }; - { let _b = "foobar"; } + { + let _a = "bar"; + }; + { + let _b = "foobar"; + } } - loop { // no error, else branch does something other than break + loop { + // no error, else branch does something other than break match y { Some(_x) => true, _ => { let _z = 1; break; - } + }, }; } - while let Some(x) = y { // no error, obviously + while let Some(x) = y { + // no error, obviously println!("{}", x); } @@ -68,7 +71,7 @@ fn main() { loop { let (e, l) = match "".split_whitespace().next() { Some(word) => (word.is_empty(), word.len()), - None => break + None => break, }; let _ = (e, l); @@ -91,7 +94,8 @@ fn main() { while let None = iter.next() {} // this is fine (if nonsensical) let mut iter = 1..20; - if let Some(x) = iter.next() { // also fine + if let Some(x) = iter.next() { + // also fine println!("{}", x) } @@ -109,7 +113,9 @@ fn main() { // or this let mut iter = 1u32..20; - while let Some(x) = iter.next() {break;} + while let Some(x) = iter.next() { + break; + } println!("Remaining iter {:?}", iter); // or this @@ -128,7 +134,7 @@ fn no_panic(slice: &[T]) { loop { let _ = match iter.next() { Some(ele) => ele, - None => break + None => break, }; loop {} } @@ -143,8 +149,8 @@ fn issue1017() { Err(_) => len = 0, Ok(length) => { len = length; - break - } + break; + }, } } } @@ -155,20 +161,17 @@ fn refutable() { let mut b = a.iter(); // consume all the 42s - while let Some(&42) = b.next() { - } + while let Some(&42) = b.next() {} let a = [(1, 2, 3)]; let mut b = a.iter(); - while let Some(&(1, 2, 3)) = b.next() { - } + while let Some(&(1, 2, 3)) = b.next() {} let a = [Some(42)]; let mut b = a.iter(); - while let Some(&None) = b.next() { - } + while let Some(&None) = b.next() {} /* This gives “refutable pattern in `for` loop binding: `&_` not covered” for &42 in b {} @@ -177,20 +180,22 @@ fn refutable() { // */ let mut y = a.iter(); - loop { // x is reused, so don't lint here - while let Some(v) = y.next() { - } + loop { + // x is reused, so don't lint here + while let Some(v) = y.next() {} } let mut y = a.iter(); for _ in 0..2 { - while let Some(v) = y.next() { // y is reused, don't lint + while let Some(v) = y.next() { + // y is reused, don't lint } } loop { let mut y = a.iter(); - while let Some(v) = y.next() { // use a for loop here + while let Some(v) = y.next() { + // use a for loop here } } diff --git a/tests/ui/write_literal.rs b/tests/ui/write_literal.rs index 7917479ed67c..0ba1943e6d8e 100644 --- a/tests/ui/write_literal.rs +++ b/tests/ui/write_literal.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused_must_use)] #![warn(clippy::write_literal)] @@ -23,17 +20,17 @@ fn main() { writeln!(&mut v, "Hello"); let world = "world"; writeln!(&mut v, "Hello {}", world); - writeln!(&mut v, "Hello {world}", world=world); + writeln!(&mut v, "Hello {world}", world = world); writeln!(&mut v, "3 in hex is {:X}", 3); writeln!(&mut v, "2 + 1 = {:.4}", 3); writeln!(&mut v, "2 + 1 = {:5.4}", 3); writeln!(&mut v, "Debug test {:?}", "hello, world"); writeln!(&mut v, "{0:8} {1:>8}", "hello", "world"); writeln!(&mut v, "{1:8} {0:>8}", "hello", "world"); - writeln!(&mut v, "{foo:8} {bar:>8}", foo="hello", bar="world"); - writeln!(&mut v, "{bar:8} {foo:>8}", foo="hello", bar="world"); - writeln!(&mut v, "{number:>width$}", number=1, width=6); - writeln!(&mut v, "{number:>0width$}", number=1, width=6); + writeln!(&mut v, "{foo:8} {bar:>8}", foo = "hello", bar = "world"); + writeln!(&mut v, "{bar:8} {foo:>8}", foo = "hello", bar = "world"); + writeln!(&mut v, "{number:>width$}", number = 1, width = 6); + writeln!(&mut v, "{number:>0width$}", number = 1, width = 6); // these should throw warnings writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); @@ -50,6 +47,6 @@ fn main() { writeln!(&mut v, "{1} {0}", "hello", "world"); // named args shouldn't change anything either - writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); - writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); + writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); + writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); } diff --git a/tests/ui/write_with_newline.rs b/tests/ui/write_with_newline.rs index e9fcff0b3dd6..dbfa02d20a1f 100644 --- a/tests/ui/write_with_newline.rs +++ b/tests/ui/write_with_newline.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(clippy::write_literal)] #![warn(clippy::write_with_newline)] diff --git a/tests/ui/writeln_empty_string.rs b/tests/ui/writeln_empty_string.rs index e272a5af88b3..71b5df48bfaa 100644 --- a/tests/ui/writeln_empty_string.rs +++ b/tests/ui/writeln_empty_string.rs @@ -7,9 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - #![allow(unused_must_use)] #![warn(clippy::writeln_empty_string)] use std::io::Write; @@ -27,5 +24,4 @@ fn main() { writeln!(&mut v); writeln!(&mut v, " "); write!(&mut v, ""); - } diff --git a/tests/ui/wrong_self_convention.rs b/tests/ui/wrong_self_convention.rs index d1c7424c8d79..3c69c9ad03ff 100644 --- a/tests/ui/wrong_self_convention.rs +++ b/tests/ui/wrong_self_convention.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::wrong_self_convention)] #![warn(clippy::wrong_pub_self_convention)] #![allow(dead_code, clippy::trivially_copy_pass_by_ref)] @@ -21,7 +17,6 @@ fn main() {} struct Foo; impl Foo { - fn as_i32(self) {} fn as_u32(&self) {} fn into_i32(self) {} @@ -39,14 +34,13 @@ impl Foo { #[allow(clippy::wrong_self_convention)] pub fn from_cake(self) {} - fn as_x>(_: F) { } - fn as_y>(_: F) { } + fn as_x>(_: F) {} + fn as_y>(_: F) {} } struct Bar; impl Bar { - fn as_i32(self) {} fn as_u32(&self) {} fn into_i32(&self) {} diff --git a/tests/ui/zero_div_zero.rs b/tests/ui/zero_div_zero.rs index 4e2272c8e090..68e9437273f6 100644 --- a/tests/ui/zero_div_zero.rs +++ b/tests/ui/zero_div_zero.rs @@ -7,20 +7,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[allow(unused_variables)] #[warn(clippy::zero_divided_by_zero)] fn main() { let nan = 0.0 / 0.0; let f64_nan = 0.0 / 0.0f64; let other_f64_nan = 0.0f64 / 0.0; - let one_more_f64_nan = 0.0f64/0.0f64; + let one_more_f64_nan = 0.0f64 / 0.0f64; let zero = 0.0; let other_zero = 0.0; let other_nan = zero / other_zero; // fine - this lint doesn't propegate constants. - let not_nan = 2.0/0.0; // not an error: 2/0 = inf - let also_not_nan = 0.0/2.0; // not an error: 0/2 = 0 + let not_nan = 2.0 / 0.0; // not an error: 2/0 = inf + let also_not_nan = 0.0 / 2.0; // not an error: 0/2 = 0 } diff --git a/tests/ui/zero_ptr.rs b/tests/ui/zero_ptr.rs index fbe4f950da53..9930b8a4c6b8 100644 --- a/tests/ui/zero_ptr.rs +++ b/tests/ui/zero_ptr.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #[allow(unused_variables)] fn main() { let x = 0 as *const usize; From 7bcc2cd9c8d2933d4a72e090db72f65a4cfb749e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 10 Dec 2018 06:27:19 +0100 Subject: [PATCH 3/7] update test stderr --- ci/base-tests.sh | 9 +- .../conf_french_blacklisted_name.stderr | 28 +- tests/ui-toml/toml_trivially_copy/test.stderr | 8 +- tests/ui/absurd-extreme-comparisons.stderr | 72 ++-- tests/ui/approx_const.stderr | 76 ++-- tests/ui/arithmetic.stderr | 46 +-- tests/ui/assign_ops.stderr | 36 +- tests/ui/assign_ops2.stderr | 76 ++-- tests/ui/attrs.stderr | 12 +- tests/ui/author/matches.stderr | 8 +- tests/ui/bit_masks.stderr | 68 +-- tests/ui/blacklisted_name.stderr | 56 +-- tests/ui/block_in_if_condition.stderr | 42 +- tests/ui/bool_comparison.stderr | 30 +- tests/ui/booleans.stderr | 132 +++--- tests/ui/borrow_box.stderr | 20 +- tests/ui/box_vec.stderr | 4 +- tests/ui/builtin-type-shadow.stderr | 10 +- tests/ui/bytecount.stderr | 16 +- tests/ui/cast.stderr | 112 ++--- tests/ui/cast_alignment.stderr | 8 +- tests/ui/cast_lossless_float.stderr | 40 +- tests/ui/cast_lossless_integer.stderr | 72 ++-- tests/ui/cast_size.stderr | 76 ++-- tests/ui/char_lit_as_u8.stderr | 4 +- tests/ui/checked_unwrap.stderr | 226 +++++----- tests/ui/cmp_nan.stderr | 48 +-- tests/ui/cmp_null.stderr | 8 +- tests/ui/cmp_owned.stderr | 36 +- tests/ui/collapsible_if.stderr | 304 +++++++------- tests/ui/complex_types.stderr | 60 +-- tests/ui/const_static_lifetime.stderr | 52 +-- tests/ui/copies.stderr | 391 +++++++++--------- tests/ui/copy_iterator.stderr | 14 +- tests/ui/cstring.stderr | 8 +- tests/ui/cyclomatic_complexity.stderr | 273 ++++++------ .../ui/cyclomatic_complexity_attr_used.stderr | 16 +- .../ui/decimal_literal_representation.stderr | 20 +- tests/ui/default_trait_access.stderr | 32 +- tests/ui/deprecated.stderr | 20 +- tests/ui/derive.stderr | 120 +++--- tests/ui/dlist.stderr | 26 +- tests/ui/double_comparison.stderr | 32 +- tests/ui/double_neg.stderr | 4 +- tests/ui/drop_forget_copy.stderr | 48 +-- tests/ui/drop_forget_ref.stderr | 144 +++---- tests/ui/duplicate_underscore_argument.stderr | 4 +- tests/ui/duration_subsec.stderr | 20 +- tests/ui/else_if_without_else.stderr | 18 +- tests/ui/empty_enum.stderr | 8 +- tests/ui/entry.stderr | 70 +++- tests/ui/enum_glob_use.stderr | 8 +- tests/ui/enum_variants.stderr | 52 +-- tests/ui/enums_clike.stderr | 32 +- tests/ui/erasing_op.stderr | 12 +- tests/ui/escape_analysis.stderr | 8 +- tests/ui/eta.stderr | 20 +- tests/ui/eval_order_dependence.stderr | 44 +- tests/ui/excessive_precision.stderr | 72 ++-- tests/ui/expect_fun_call.stderr | 24 +- tests/ui/explicit_counter_loop.stderr | 8 +- tests/ui/explicit_write.stderr | 24 +- tests/ui/fallible_impl_from.stderr | 84 ++-- tests/ui/filter_methods.stderr | 42 +- tests/ui/float_cmp.stderr | 24 +- tests/ui/for_loop.stderr | 278 ++++++------- tests/ui/formatting.stderr | 85 +--- tests/ui/functions.stderr | 51 ++- tests/ui/fxhash.stderr | 24 +- tests/ui/get_unwrap.stderr | 48 +-- tests/ui/identity_conversion.stderr | 44 +- tests/ui/identity_op.stderr | 32 +- tests/ui/if_not_else.stderr | 24 +- tests/ui/impl.stderr | 32 +- tests/ui/implicit_hasher.stderr | 80 ++-- tests/ui/implicit_return.stderr | 36 +- tests/ui/inconsistent_digit_grouping.stderr | 20 +- tests/ui/indexing_slicing.stderr | 172 ++++---- .../ui/infallible_destructuring_match.stderr | 24 +- tests/ui/infinite_iter.stderr | 79 ++-- tests/ui/infinite_loop.stderr | 36 +- tests/ui/inline_fn_without_body.stderr | 20 +- tests/ui/int_plus_one.stderr | 24 +- tests/ui/into_iter_on_ref.stderr | 42 +- tests/ui/invalid_ref.stderr | 24 +- tests/ui/invalid_upcast_comparisons.stderr | 108 ++--- tests/ui/issue-3145.stderr | 4 +- tests/ui/issue_2356.stderr | 8 +- tests/ui/item_after_statement.stderr | 16 +- tests/ui/large_digit_groups.stderr | 36 +- tests/ui/large_enum_variant.stderr | 42 +- tests/ui/len_zero.stderr | 112 ++--- tests/ui/let_if_seq.stderr | 50 +-- tests/ui/let_return.stderr | 16 +- tests/ui/let_unit.stderr | 8 +- tests/ui/lifetimes.stderr | 124 +++--- tests/ui/lint_without_lint_pass.stderr | 12 +- tests/ui/map_clone.stderr | 12 +- tests/ui/map_flatten.stderr | 4 +- tests/ui/match_bool.stderr | 111 +++-- tests/ui/match_overlapping_arm.stderr | 32 +- tests/ui/matches.stderr | 222 +++++----- tests/ui/mem_discriminant.stderr | 56 +-- tests/ui/mem_forget.stderr | 12 +- tests/ui/mem_replace.stderr | 8 +- tests/ui/min_max.stderr | 28 +- tests/ui/missing-doc.stderr | 218 +++++----- tests/ui/missing_inline.stderr | 24 +- tests/ui/module_inception.stderr | 16 +- tests/ui/modulo_one.stderr | 4 +- tests/ui/mut_from_ref.stderr | 40 +- tests/ui/mut_mut.stderr | 52 +-- tests/ui/mut_range_bound.stderr | 28 +- tests/ui/mut_reference.stderr | 12 +- tests/ui/mutex_atomic.stderr | 28 +- tests/ui/needless_bool.stderr | 146 ++++--- tests/ui/needless_borrow.stderr | 24 +- tests/ui/needless_borrowed_ref.stderr | 16 +- tests/ui/needless_collect.stderr | 16 +- tests/ui/needless_continue.stderr | 4 +- tests/ui/needless_pass_by_value.stderr | 96 ++--- tests/ui/needless_range_loop.stderr | 48 +-- tests/ui/needless_return.stderr | 34 +- tests/ui/needless_update.stderr | 4 +- tests/ui/neg_cmp_op_on_partial_ord.stderr | 16 +- tests/ui/neg_multiply.stderr | 8 +- tests/ui/never_loop.stderr | 112 ++--- tests/ui/new_ret_no_self.stderr | 24 +- tests/ui/new_without_default.stderr | 38 +- tests/ui/no_effect.stderr | 104 ++--- tests/ui/non_copy_const.stderr | 158 +++---- tests/ui/non_expressive_names.stderr | 114 ++--- tests/ui/ok_expect.stderr | 20 +- tests/ui/ok_if_let.stderr | 12 +- tests/ui/op_ref.stderr | 10 +- tests/ui/open_options.stderr | 28 +- tests/ui/option_map_unit_fn.stderr | 250 ++++++----- tests/ui/option_option.stderr | 38 +- tests/ui/overflow_check_conditional.stderr | 32 +- tests/ui/panic_unimplemented.stderr | 20 +- tests/ui/partialeq_ne_impl.stderr | 8 +- tests/ui/patterns.stderr | 4 +- tests/ui/precedence.stderr | 36 +- tests/ui/print.stderr | 36 +- tests/ui/print_literal.stderr | 64 +-- tests/ui/print_with_newline.stderr | 16 +- tests/ui/println_empty_string.stderr | 8 +- tests/ui/ptr_arg.stderr | 48 +-- tests/ui/ptr_offset_with_cast.stderr | 8 +- tests/ui/question_mark.stderr | 18 +- tests/ui/range.stderr | 26 +- tests/ui/range_plus_minus_one.stderr | 48 +-- tests/ui/redundant_clone.stderr | 8 +- tests/ui/redundant_closure_call.stderr | 24 +- tests/ui/redundant_field_names.stderr | 28 +- tests/ui/redundant_pattern_matching.stderr | 88 ++-- tests/ui/reference.stderr | 46 +-- tests/ui/regex.stderr | 96 ++--- tests/ui/replace_consts.stderr | 144 +++---- tests/ui/result_map_unit_fn.stderr | 246 ++++++----- tests/ui/serde.stderr | 7 +- tests/ui/shadow.stderr | 92 ++--- tests/ui/short_circuit_statement.stderr | 12 +- tests/ui/single_char_pattern.stderr | 80 ++-- tests/ui/single_match.stderr | 78 ++-- tests/ui/single_match_else.stderr | 16 +- tests/ui/starts_ends_with.stderr | 46 +-- tests/ui/string_extend.stderr | 12 +- tests/ui/strings.stderr | 44 +- tests/ui/stutter.stderr | 20 +- tests/ui/suspicious_arithmetic_impl.stderr | 8 +- tests/ui/swap.stderr | 56 +-- tests/ui/toplevel_ref_arg.stderr | 28 +- tests/ui/trailing_zeros.stderr | 10 +- tests/ui/transmute.stderr | 158 +++---- tests/ui/transmute_64bit.stderr | 8 +- tests/ui/trivially_copy_pass_by_ref.stderr | 60 +-- tests/ui/types.stderr | 6 +- tests/ui/unicode.stderr | 12 +- tests/ui/unit_arg.stderr | 52 +-- tests/ui/unit_cmp.stderr | 22 +- tests/ui/unnecessary_clone.stderr | 58 +-- tests/ui/unnecessary_filter_map.stderr | 30 +- tests/ui/unnecessary_fold.stderr | 20 +- tests/ui/unnecessary_operation.stderr | 88 ++-- tests/ui/unnecessary_ref.stderr | 8 +- tests/ui/unneeded_field_pattern.stderr | 8 +- tests/ui/unreadable_literal.stderr | 20 +- tests/ui/unsafe_removed_from_name.stderr | 14 +- tests/ui/unused_io_amount.stderr | 24 +- tests/ui/unused_labels.stderr | 26 +- tests/ui/unused_lt.stderr | 12 +- tests/ui/unwrap_or.stderr | 10 +- tests/ui/use_self.stderr | 58 +-- tests/ui/used_underscore_binding.stderr | 20 +- tests/ui/useless_asref.stderr | 48 +-- tests/ui/useless_attribute.stderr | 16 +- tests/ui/vec.stderr | 26 +- tests/ui/while_loop.stderr | 112 ++--- tests/ui/write_literal.stderr | 64 +-- tests/ui/write_with_newline.stderr | 16 +- tests/ui/writeln_empty_string.stderr | 8 +- tests/ui/wrong_self_convention.stderr | 48 +-- tests/ui/zero_div_zero.stderr | 36 +- tests/ui/zero_ptr.stderr | 8 +- 205 files changed, 5203 insertions(+), 4909 deletions(-) diff --git a/ci/base-tests.sh b/ci/base-tests.sh index 6eeab6671cb6..dfc5ad99e0c1 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -28,6 +28,9 @@ cd clippy_dev && cargo test && cd .. ./util/dev update_lints --check cargo +nightly fmt --all -- --check + +#avoid loop spam +set +ex # make sure tests are formatted # some lints are sensitive to formatting, exclude some files @@ -36,7 +39,9 @@ for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/fo rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true done -if $needs_reformatting - "Tests need reformatting!" +if [ "${needs_reformatting}" = true] ; then + echo "Tests need reformatting!" exit 2 fi + +set -ex diff --git a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr index dd414657c28e..e67cdd8f9dd5 100644 --- a/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr +++ b/tests/ui-toml/toml_blacklist/conf_french_blacklisted_name.stderr @@ -1,45 +1,45 @@ error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:19:9 + --> $DIR/conf_french_blacklisted_name.rs:15:9 | -19 | fn test(toto: ()) {} +15 | fn test(toto: ()) {} | ^^^^ | = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:22:9 + --> $DIR/conf_french_blacklisted_name.rs:18:9 | -22 | let toto = 42; +18 | let toto = 42; | ^^^^ error: use of a blacklisted/placeholder name `tata` - --> $DIR/conf_french_blacklisted_name.rs:23:9 + --> $DIR/conf_french_blacklisted_name.rs:19:9 | -23 | let tata = 42; +19 | let tata = 42; | ^^^^ error: use of a blacklisted/placeholder name `titi` - --> $DIR/conf_french_blacklisted_name.rs:24:9 + --> $DIR/conf_french_blacklisted_name.rs:20:9 | -24 | let titi = 42; +20 | let titi = 42; | ^^^^ error: use of a blacklisted/placeholder name `toto` - --> $DIR/conf_french_blacklisted_name.rs:30:10 + --> $DIR/conf_french_blacklisted_name.rs:26:10 | -30 | (toto, Some(tata), titi @ Some(_)) => (), +26 | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `tata` - --> $DIR/conf_french_blacklisted_name.rs:30:21 + --> $DIR/conf_french_blacklisted_name.rs:26:21 | -30 | (toto, Some(tata), titi @ Some(_)) => (), +26 | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: use of a blacklisted/placeholder name `titi` - --> $DIR/conf_french_blacklisted_name.rs:30:28 + --> $DIR/conf_french_blacklisted_name.rs:26:28 | -30 | (toto, Some(tata), titi @ Some(_)) => (), +26 | (toto, Some(tata), titi @ Some(_)) => (), | ^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui-toml/toml_trivially_copy/test.stderr b/tests/ui-toml/toml_trivially_copy/test.stderr index ad3ca831fd7e..efa9223bde81 100644 --- a/tests/ui-toml/toml_trivially_copy/test.stderr +++ b/tests/ui-toml/toml_trivially_copy/test.stderr @@ -1,15 +1,15 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:23:11 + --> $DIR/test.rs:20:11 | -23 | fn bad(x: &u16, y: &Foo) { +20 | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `u16` | = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/test.rs:23:20 + --> $DIR/test.rs:20:20 | -23 | fn bad(x: &u16, y: &Foo) { +20 | fn bad(x: &u16, y: &Foo) {} | ^^^^ help: consider passing by value instead: `Foo` error: aborting due to 2 previous errors diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index 895794da71a7..00f7086dc551 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -1,144 +1,144 @@ error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:17:5 + --> $DIR/absurd-extreme-comparisons.rs:23:5 | -17 | u <= 0; +23 | u <= 0; | ^^^^^^ | = note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings` = help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:18:5 + --> $DIR/absurd-extreme-comparisons.rs:24:5 | -18 | u <= Z; +24 | u <= Z; | ^^^^^^ | = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == Z instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:19:5 + --> $DIR/absurd-extreme-comparisons.rs:25:5 | -19 | u < Z; +25 | u < Z; | ^^^^^ | = help: because Z is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:20:5 + --> $DIR/absurd-extreme-comparisons.rs:26:5 | -20 | Z >= u; +26 | Z >= u; | ^^^^^^ | = help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using Z == u instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:21:5 + --> $DIR/absurd-extreme-comparisons.rs:27:5 | -21 | Z > u; +27 | Z > u; | ^^^^^ | = help: because Z is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:22:5 + --> $DIR/absurd-extreme-comparisons.rs:28:5 | -22 | u > std::u32::MAX; +28 | u > std::u32::MAX; | ^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:23:5 + --> $DIR/absurd-extreme-comparisons.rs:29:5 | -23 | u >= std::u32::MAX; +29 | u >= std::u32::MAX; | ^^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == std::u32::MAX instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:24:5 + --> $DIR/absurd-extreme-comparisons.rs:30:5 | -24 | std::u32::MAX < u; +30 | std::u32::MAX < u; | ^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:25:5 + --> $DIR/absurd-extreme-comparisons.rs:31:5 | -25 | std::u32::MAX <= u; +31 | std::u32::MAX <= u; | ^^^^^^^^^^^^^^^^^^ | = help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using std::u32::MAX == u instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:26:5 + --> $DIR/absurd-extreme-comparisons.rs:32:5 | -26 | 1-1 > u; +32 | 1-1 > u; | ^^^^^^^ | = help: because 1-1 is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:27:5 + --> $DIR/absurd-extreme-comparisons.rs:33:5 | -27 | u >= !0; +33 | u >= !0; | ^^^^^^^ | = help: because !0 is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == !0 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:28:5 + --> $DIR/absurd-extreme-comparisons.rs:34:5 | -28 | u <= 12 - 2*6; +34 | u <= 12 - 2*6; | ^^^^^^^^^^^^^ | = help: because 12 - 2*6 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 12 - 2*6 instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:30:5 + --> $DIR/absurd-extreme-comparisons.rs:36:5 | -30 | i < -127 - 1; +36 | i < -127 - 1; | ^^^^^^^^^^^^ | = help: because -127 - 1 is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:31:5 + --> $DIR/absurd-extreme-comparisons.rs:37:5 | -31 | std::i8::MAX >= i; +37 | std::i8::MAX >= i; | ^^^^^^^^^^^^^^^^^ | = help: because std::i8::MAX is the maximum value for this type, this comparison is always true error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:32:5 + --> $DIR/absurd-extreme-comparisons.rs:38:5 | -32 | 3-7 < std::i32::MIN; +38 | 3-7 < std::i32::MIN; | ^^^^^^^^^^^^^^^^^^^ | = help: because std::i32::MIN is the minimum value for this type, this comparison is always false error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:34:5 + --> $DIR/absurd-extreme-comparisons.rs:40:5 | -34 | b >= true; +40 | b >= true; | ^^^^^^^^^ | = help: because true is the maximum value for this type, the case where the two sides are not equal never occurs, consider using b == true instead error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false - --> $DIR/absurd-extreme-comparisons.rs:35:5 + --> $DIR/absurd-extreme-comparisons.rs:41:5 | -35 | false > b; +41 | false > b; | ^^^^^^^^^ | = help: because false is the minimum value for this type, this comparison is always false error: <-comparison of unit values detected. This will always be false - --> $DIR/absurd-extreme-comparisons.rs:38:5 + --> $DIR/absurd-extreme-comparisons.rs:44:5 | -38 | () < {}; +44 | () < {}; | ^^^^^^^ | = note: #[deny(clippy::unit_cmp)] on by default diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index a765ffb64de3..cee7fe6919a3 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,117 +1,117 @@ error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly - --> $DIR/approx_const.rs:17:16 + --> $DIR/approx_const.rs:13:16 | -17 | let my_e = 2.7182; +13 | let my_e = 2.7182; | ^^^^^^ | = note: `-D clippy::approx-constant` implied by `-D warnings` error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly - --> $DIR/approx_const.rs:18:20 + --> $DIR/approx_const.rs:14:20 | -18 | let almost_e = 2.718; +14 | let almost_e = 2.718; | ^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found. Consider using it directly - --> $DIR/approx_const.rs:21:24 + --> $DIR/approx_const.rs:17:24 | -21 | let my_1_frac_pi = 0.3183; +17 | let my_1_frac_pi = 0.3183; | ^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:24:28 + --> $DIR/approx_const.rs:20:28 | -24 | let my_frac_1_sqrt_2 = 0.70710678; +20 | let my_frac_1_sqrt_2 = 0.70710678; | ^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:25:32 + --> $DIR/approx_const.rs:21:32 | -25 | let almost_frac_1_sqrt_2 = 0.70711; +21 | let almost_frac_1_sqrt_2 = 0.70711; | ^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found. Consider using it directly - --> $DIR/approx_const.rs:28:24 + --> $DIR/approx_const.rs:24:24 | -28 | let my_frac_2_pi = 0.63661977; +24 | let my_frac_2_pi = 0.63661977; | ^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found. Consider using it directly - --> $DIR/approx_const.rs:31:27 + --> $DIR/approx_const.rs:27:27 | -31 | let my_frac_2_sq_pi = 1.128379; +27 | let my_frac_2_sq_pi = 1.128379; | ^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found. Consider using it directly - --> $DIR/approx_const.rs:34:24 + --> $DIR/approx_const.rs:30:24 | -34 | let my_frac_pi_2 = 1.57079632679; +30 | let my_frac_pi_2 = 1.57079632679; | ^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found. Consider using it directly - --> $DIR/approx_const.rs:37:24 + --> $DIR/approx_const.rs:33:24 | -37 | let my_frac_pi_3 = 1.04719755119; +33 | let my_frac_pi_3 = 1.04719755119; | ^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found. Consider using it directly - --> $DIR/approx_const.rs:40:24 + --> $DIR/approx_const.rs:36:24 | -40 | let my_frac_pi_4 = 0.785398163397; +36 | let my_frac_pi_4 = 0.785398163397; | ^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found. Consider using it directly - --> $DIR/approx_const.rs:43:24 + --> $DIR/approx_const.rs:39:24 | -43 | let my_frac_pi_6 = 0.523598775598; +39 | let my_frac_pi_6 = 0.523598775598; | ^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found. Consider using it directly - --> $DIR/approx_const.rs:46:24 + --> $DIR/approx_const.rs:42:24 | -46 | let my_frac_pi_8 = 0.3926990816987; +42 | let my_frac_pi_8 = 0.3926990816987; | ^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LN_10` found. Consider using it directly - --> $DIR/approx_const.rs:49:20 + --> $DIR/approx_const.rs:45:20 | -49 | let my_ln_10 = 2.302585092994046; +45 | let my_ln_10 = 2.302585092994046; | ^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LN_2` found. Consider using it directly - --> $DIR/approx_const.rs:52:19 + --> $DIR/approx_const.rs:48:19 | -52 | let my_ln_2 = 0.6931471805599453; +48 | let my_ln_2 = 0.6931471805599453; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LOG10_E` found. Consider using it directly - --> $DIR/approx_const.rs:55:22 + --> $DIR/approx_const.rs:51:22 | -55 | let my_log10_e = 0.4342944819032518; +51 | let my_log10_e = 0.4342944819032518; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LOG2_E` found. Consider using it directly - --> $DIR/approx_const.rs:58:21 + --> $DIR/approx_const.rs:54:21 | -58 | let my_log2_e = 1.4426950408889634; +54 | let my_log2_e = 1.4426950408889634; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly - --> $DIR/approx_const.rs:61:17 + --> $DIR/approx_const.rs:57:17 | -61 | let my_pi = 3.1415; +57 | let my_pi = 3.1415; | ^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly - --> $DIR/approx_const.rs:62:21 + --> $DIR/approx_const.rs:58:21 | -62 | let almost_pi = 3.14; +58 | let almost_pi = 3.14; | ^^^^ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it directly - --> $DIR/approx_const.rs:65:18 + --> $DIR/approx_const.rs:61:18 | -65 | let my_sq2 = 1.4142; +61 | let my_sq2 = 1.4142; | ^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr index f3a1db16b48b..1dff9941bb2d 100644 --- a/tests/ui/arithmetic.stderr +++ b/tests/ui/arithmetic.stderr @@ -1,72 +1,72 @@ error: integer arithmetic detected - --> $DIR/arithmetic.rs:17:5 + --> $DIR/arithmetic.rs:22:5 | -17 | 1 + i; +22 | 1 + i; | ^^^^^ | = note: `-D clippy::integer-arithmetic` implied by `-D warnings` error: integer arithmetic detected - --> $DIR/arithmetic.rs:18:5 + --> $DIR/arithmetic.rs:23:5 | -18 | i * 2; +23 | i * 2; | ^^^^^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:19:5 + --> $DIR/arithmetic.rs:24:5 | -19 | / 1 % -20 | | i / 2; // no error, this is part of the expression in the preceding line +24 | / 1 % +25 | | i / 2; // no error, this is part of the expression in the preceding line | |_________^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:21:5 + --> $DIR/arithmetic.rs:26:5 | -21 | i - 2 + 2 - i; +26 | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: integer arithmetic detected - --> $DIR/arithmetic.rs:22:5 + --> $DIR/arithmetic.rs:27:5 | -22 | -i; +27 | -i; | ^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:32:5 + --> $DIR/arithmetic.rs:37:5 | -32 | f * 2.0; +37 | f * 2.0; | ^^^^^^^ | = note: `-D clippy::float-arithmetic` implied by `-D warnings` error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:34:5 + --> $DIR/arithmetic.rs:39:5 | -34 | 1.0 + f; +39 | 1.0 + f; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:35:5 + --> $DIR/arithmetic.rs:40:5 | -35 | f * 2.0; +40 | f * 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:36:5 + --> $DIR/arithmetic.rs:41:5 | -36 | f / 2.0; +41 | f / 2.0; | ^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:37:5 + --> $DIR/arithmetic.rs:42:5 | -37 | f - 2.0 * 4.2; +42 | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ error: floating-point arithmetic detected - --> $DIR/arithmetic.rs:38:5 + --> $DIR/arithmetic.rs:43:5 | -38 | -f; +43 | -f; | ^^ error: aborting due to 11 previous errors diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 20ed51334ab6..7acbdc899846 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,57 +1,57 @@ error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:17:5 + --> $DIR/assign_ops.rs:14:5 | -17 | a = a + 1; +14 | a = a + 1; | ^^^^^^^^^ help: replace it with: `a += 1` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:18:5 + --> $DIR/assign_ops.rs:15:5 | -18 | a = 1 + a; +15 | a = 1 + a; | ^^^^^^^^^ help: replace it with: `a += 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:19:5 + --> $DIR/assign_ops.rs:16:5 | -19 | a = a - 1; +16 | a = a - 1; | ^^^^^^^^^ help: replace it with: `a -= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:20:5 + --> $DIR/assign_ops.rs:17:5 | -20 | a = a * 99; +17 | a = a * 99; | ^^^^^^^^^^ help: replace it with: `a *= 99` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:21:5 + --> $DIR/assign_ops.rs:18:5 | -21 | a = 42 * a; +18 | a = 42 * a; | ^^^^^^^^^^ help: replace it with: `a *= 42` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:22:5 + --> $DIR/assign_ops.rs:19:5 | -22 | a = a / 2; +19 | a = a / 2; | ^^^^^^^^^ help: replace it with: `a /= 2` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:23:5 + --> $DIR/assign_ops.rs:20:5 | -23 | a = a % 5; +20 | a = a % 5; | ^^^^^^^^^ help: replace it with: `a %= 5` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:24:5 + --> $DIR/assign_ops.rs:21:5 | -24 | a = a & 1; +21 | a = a & 1; | ^^^^^^^^^ help: replace it with: `a &= 1` error: manual implementation of an assign operation - --> $DIR/assign_ops.rs:30:5 + --> $DIR/assign_ops.rs:27:5 | -30 | s = s + "bla"; +27 | s = s + "bla"; | ^^^^^^^^^^^^^ help: replace it with: `s += "bla"` error: aborting due to 9 previous errors diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index bd49c3cdd807..26ff079ad62e 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -1,135 +1,135 @@ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:18:5 + --> $DIR/assign_ops2.rs:14:5 | -18 | a += a + 1; +14 | a += a + 1; | ^^^^^^^^^^ | = note: `-D clippy::misrefactored-assign-op` implied by `-D warnings` help: Did you mean a = a + 1 or a = a + a + 1? Consider replacing it with | -18 | a += 1; +14 | a += 1; | ^^^^^^ help: or | -18 | a = a + a + 1; +14 | a = a + a + 1; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:19:5 + --> $DIR/assign_ops2.rs:15:5 | -19 | a += 1 + a; +15 | a += 1 + a; | ^^^^^^^^^^ help: Did you mean a = a + 1 or a = a + 1 + a? Consider replacing it with | -19 | a += 1; +15 | a += 1; | ^^^^^^ help: or | -19 | a = a + 1 + a; +15 | a = a + 1 + a; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:20:5 + --> $DIR/assign_ops2.rs:16:5 | -20 | a -= a - 1; +16 | a -= a - 1; | ^^^^^^^^^^ help: Did you mean a = a - 1 or a = a - (a - 1)? Consider replacing it with | -20 | a -= 1; +16 | a -= 1; | ^^^^^^ help: or | -20 | a = a - (a - 1); +16 | a = a - (a - 1); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:21:5 + --> $DIR/assign_ops2.rs:17:5 | -21 | a *= a * 99; +17 | a *= a * 99; | ^^^^^^^^^^^ help: Did you mean a = a * 99 or a = a * a * 99? Consider replacing it with | -21 | a *= 99; +17 | a *= 99; | ^^^^^^^ help: or | -21 | a = a * a * 99; +17 | a = a * a * 99; | ^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:22:5 + --> $DIR/assign_ops2.rs:18:5 | -22 | a *= 42 * a; +18 | a *= 42 * a; | ^^^^^^^^^^^ help: Did you mean a = a * 42 or a = a * 42 * a? Consider replacing it with | -22 | a *= 42; +18 | a *= 42; | ^^^^^^^ help: or | -22 | a = a * 42 * a; +18 | a = a * 42 * a; | ^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:23:5 + --> $DIR/assign_ops2.rs:19:5 | -23 | a /= a / 2; +19 | a /= a / 2; | ^^^^^^^^^^ help: Did you mean a = a / 2 or a = a / (a / 2)? Consider replacing it with | -23 | a /= 2; +19 | a /= 2; | ^^^^^^ help: or | -23 | a = a / (a / 2); +19 | a = a / (a / 2); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:24:5 + --> $DIR/assign_ops2.rs:20:5 | -24 | a %= a % 5; +20 | a %= a % 5; | ^^^^^^^^^^ help: Did you mean a = a % 5 or a = a % (a % 5)? Consider replacing it with | -24 | a %= 5; +20 | a %= 5; | ^^^^^^ help: or | -24 | a = a % (a % 5); +20 | a = a % (a % 5); | ^^^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:25:5 + --> $DIR/assign_ops2.rs:21:5 | -25 | a &= a & 1; +21 | a &= a & 1; | ^^^^^^^^^^ help: Did you mean a = a & 1 or a = a & a & 1? Consider replacing it with | -25 | a &= 1; +21 | a &= 1; | ^^^^^^ help: or | -25 | a = a & a & 1; +21 | a = a & a & 1; | ^^^^^^^^^^^^^ error: variable appears on both sides of an assignment operation - --> $DIR/assign_ops2.rs:26:5 + --> $DIR/assign_ops2.rs:22:5 | -26 | a *= a * a; +22 | a *= a * a; | ^^^^^^^^^^ help: Did you mean a = a * a or a = a * a * a? Consider replacing it with | -26 | a *= a; +22 | a *= a; | ^^^^^^ help: or | -26 | a = a * a * a; +22 | a = a * a * a; | ^^^^^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/assign_ops2.rs:63:5 + --> $DIR/assign_ops2.rs:59:5 | -63 | buf = buf + cows.clone(); +59 | buf = buf + cows.clone(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index a361d0968f50..1331fa2912c7 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,23 +1,23 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea - --> $DIR/attrs.rs:16:1 + --> $DIR/attrs.rs:12:1 | -16 | #[inline(always)] +12 | #[inline(always)] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::inline-always` implied by `-D warnings` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:37:14 + --> $DIR/attrs.rs:32:14 | -37 | #[deprecated(since = "forever")] +32 | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::deprecated-semver` implied by `-D warnings` error: the since field must contain a semver-compliant version - --> $DIR/attrs.rs:40:14 + --> $DIR/attrs.rs:35:14 | -40 | #[deprecated(since = "1")] +35 | #[deprecated(since = "1")] | ^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/author/matches.stderr b/tests/ui/author/matches.stderr index d78a173316b8..4b895b0b8e3d 100644 --- a/tests/ui/author/matches.stderr +++ b/tests/ui/author/matches.stderr @@ -1,14 +1,14 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/matches.rs:19:13 + --> $DIR/matches.rs:18:13 | -19 | x +18 | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned - --> $DIR/matches.rs:18:21 + --> $DIR/matches.rs:17:21 | -18 | let x = 3; +17 | let x = 3; | ^ error: aborting due to previous error diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index f0f450fc1692..853f5a992f3b 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -1,109 +1,109 @@ error: &-masking with zero - --> $DIR/bit_masks.rs:22:5 + --> $DIR/bit_masks.rs:23:5 | -22 | x & 0 == 0; +23 | x & 0 == 0; | ^^^^^^^^^^ | = note: `-D clippy::bad-bit-mask` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:22:5 + --> $DIR/bit_masks.rs:23:5 | -22 | x & 0 == 0; +23 | x & 0 == 0; | ^^^^^ | = note: #[deny(clippy::erasing_op)] on by default error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:25:5 + --> $DIR/bit_masks.rs:26:5 | -25 | x & 2 == 1; +26 | x & 2 == 1; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:29:5 + --> $DIR/bit_masks.rs:30:5 | -29 | x | 3 == 2; +30 | x | 3 == 2; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 1` will never be higher than `1` - --> $DIR/bit_masks.rs:31:5 + --> $DIR/bit_masks.rs:32:5 | -31 | x & 1 > 1; +32 | x & 1 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:35:5 + --> $DIR/bit_masks.rs:36:5 | -35 | x | 2 > 1; +36 | x | 2 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ & 7` can never be equal to `8` - --> $DIR/bit_masks.rs:42:5 + --> $DIR/bit_masks.rs:43:5 | -42 | x & THREE_BITS == 8; +43 | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ error: incompatible bit mask: `_ | 7` will never be lower than `7` - --> $DIR/bit_masks.rs:43:5 + --> $DIR/bit_masks.rs:44:5 | -43 | x | EVEN_MORE_REDIRECTION < 7; +44 | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: &-masking with zero - --> $DIR/bit_masks.rs:45:5 + --> $DIR/bit_masks.rs:46:5 | -45 | 0 & x == 0; +46 | 0 & x == 0; | ^^^^^^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/bit_masks.rs:45:5 + --> $DIR/bit_masks.rs:46:5 | -45 | 0 & x == 0; +46 | 0 & x == 0; | ^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` - --> $DIR/bit_masks.rs:49:5 + --> $DIR/bit_masks.rs:50:5 | -49 | 1 < 2 | x; +50 | 1 < 2 | x; | ^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` - --> $DIR/bit_masks.rs:50:5 + --> $DIR/bit_masks.rs:51:5 | -50 | 2 == 3 | x; +51 | 2 == 3 | x; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 2` can never be equal to `1` - --> $DIR/bit_masks.rs:51:5 + --> $DIR/bit_masks.rs:52:5 | -51 | 1 == x & 2; +52 | 1 == x & 2; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:62:5 + --> $DIR/bit_masks.rs:63:5 | -62 | x | 1 > 3; +63 | x | 1 > 3; | ^^^^^^^^^ | = note: `-D clippy::ineffective-bit-mask` implied by `-D warnings` error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly - --> $DIR/bit_masks.rs:63:5 + --> $DIR/bit_masks.rs:64:5 | -63 | x | 1 < 4; +64 | x | 1 < 4; | ^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly - --> $DIR/bit_masks.rs:64:5 + --> $DIR/bit_masks.rs:65:5 | -64 | x | 1 <= 3; +65 | x | 1 <= 3; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly - --> $DIR/bit_masks.rs:65:5 + --> $DIR/bit_masks.rs:66:5 | -65 | x | 1 >= 8; +66 | x | 1 >= 8; | ^^^^^^^^^^ error: aborting due to 17 previous errors diff --git a/tests/ui/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index 1e253eba1408..707d36b24b27 100644 --- a/tests/ui/blacklisted_name.stderr +++ b/tests/ui/blacklisted_name.stderr @@ -1,87 +1,87 @@ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:17:9 + --> $DIR/blacklisted_name.rs:20:9 | -17 | fn test(foo: ()) {} +20 | fn test(foo: ()) {} | ^^^ | = note: `-D clippy::blacklisted-name` implied by `-D warnings` error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:20:9 + --> $DIR/blacklisted_name.rs:23:9 | -20 | let foo = 42; +23 | let foo = 42; | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:21:9 + --> $DIR/blacklisted_name.rs:24:9 | -21 | let bar = 42; +24 | let bar = 42; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:22:9 + --> $DIR/blacklisted_name.rs:25:9 | -22 | let baz = 42; +25 | let baz = 42; | ^^^ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:28:10 + --> $DIR/blacklisted_name.rs:31:10 | -28 | (foo, Some(bar), baz @ Some(_)) => (), +31 | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:28:20 + --> $DIR/blacklisted_name.rs:31:20 | -28 | (foo, Some(bar), baz @ Some(_)) => (), +31 | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:28:26 + --> $DIR/blacklisted_name.rs:31:26 | -28 | (foo, Some(bar), baz @ Some(_)) => (), +31 | (foo, Some(bar), baz @ Some(_)) => (), | ^^^ error: use of a blacklisted/placeholder name `foo` - --> $DIR/blacklisted_name.rs:33:19 + --> $DIR/blacklisted_name.rs:36:19 | -33 | fn issue_1647(mut foo: u8) { +36 | fn issue_1647(mut foo: u8) { | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:34:13 + --> $DIR/blacklisted_name.rs:37:13 | -34 | let mut bar = 0; +37 | let mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:35:21 + --> $DIR/blacklisted_name.rs:38:21 | -35 | if let Some(mut baz) = Some(42) {} +38 | if let Some(mut baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:39:13 + --> $DIR/blacklisted_name.rs:42:13 | -39 | let ref bar = 0; +42 | let ref bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:40:21 + --> $DIR/blacklisted_name.rs:43:21 | -40 | if let Some(ref baz) = Some(42) {} +43 | if let Some(ref baz) = Some(42) {} | ^^^ error: use of a blacklisted/placeholder name `bar` - --> $DIR/blacklisted_name.rs:44:17 + --> $DIR/blacklisted_name.rs:47:17 | -44 | let ref mut bar = 0; +47 | let ref mut bar = 0; | ^^^ error: use of a blacklisted/placeholder name `baz` - --> $DIR/blacklisted_name.rs:45:25 + --> $DIR/blacklisted_name.rs:48:25 | -45 | if let Some(ref mut baz) = Some(42) {} +48 | if let Some(ref mut baz) = Some(42) {} | ^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index b0036d1ee23b..d83cef26a8b5 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -1,11 +1,11 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let' - --> $DIR/block_in_if_condition.rs:40:8 + --> $DIR/block_in_if_condition.rs:35:8 | -40 | if { +35 | if { | ________^ -41 | | let x = 3; -42 | | x == 3 -43 | | } { +36 | | let x = 3; +37 | | x == 3 +38 | | } { | |_____^ | = note: `-D clippy::block-in-if-condition-stmt` implied by `-D warnings` @@ -19,9 +19,9 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste } ... error: omit braces around single expression condition - --> $DIR/block_in_if_condition.rs:51:8 + --> $DIR/block_in_if_condition.rs:46:8 | -51 | if { true } { +46 | if { true } { | ^^^^^^^^ | = note: `-D clippy::block-in-if-condition-expr` implied by `-D warnings` @@ -31,21 +31,29 @@ error: omit braces around single expression condition } ... error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let' - --> $DIR/block_in_if_condition.rs:68:49 - | -68 | if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/block_in_if_condition.rs:66:17 + | +66 | |x| { + | _________________^ +67 | | let target = 3; +68 | | x == target +69 | | }, + | |_____________^ error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let' - --> $DIR/block_in_if_condition.rs:71:22 - | -71 | if predicate(|x| { let target = 3; x == target }, v) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/block_in_if_condition.rs:75:13 + | +75 | |x| { + | _____________^ +76 | | let target = 3; +77 | | x == target +78 | | }, + | |_________^ error: this boolean expression can be simplified - --> $DIR/block_in_if_condition.rs:77:8 + --> $DIR/block_in_if_condition.rs:85:8 | -77 | if true && x == 3 { +85 | if true && x == 3 { | ^^^^^^^^^^^^^^ help: try: `x == 3` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` diff --git a/tests/ui/bool_comparison.stderr b/tests/ui/bool_comparison.stderr index b4a1545b49e6..d136bc656b6d 100644 --- a/tests/ui/bool_comparison.stderr +++ b/tests/ui/bool_comparison.stderr @@ -1,7 +1,7 @@ error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:17:8 + --> $DIR/bool_comparison.rs:13:8 | -17 | if x == true { "yes" } else { "no" }; +13 | if x == true { | ^^^^^^^^^ help: try simplifying it as shown: `x` | = note: `-D clippy::bool-comparison` implied by `-D warnings` @@ -9,43 +9,43 @@ error: equality checks against true are unnecessary error: equality checks against false can be replaced by a negation --> $DIR/bool_comparison.rs:18:8 | -18 | if x == false { "yes" } else { "no" }; +18 | if x == false { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/bool_comparison.rs:19:8 + --> $DIR/bool_comparison.rs:23:8 | -19 | if true == x { "yes" } else { "no" }; +23 | if true == x { | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/bool_comparison.rs:20:8 + --> $DIR/bool_comparison.rs:28:8 | -20 | if false == x { "yes" } else { "no" }; +28 | if false == x { | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:21:8 + --> $DIR/bool_comparison.rs:33:8 | -21 | if x != true { "yes" } else { "no" }; +33 | if x != true { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:22:8 + --> $DIR/bool_comparison.rs:38:8 | -22 | if x != false { "yes" } else { "no" }; +38 | if x != false { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: inequality checks against true can be replaced by a negation - --> $DIR/bool_comparison.rs:23:8 + --> $DIR/bool_comparison.rs:43:8 | -23 | if true != x { "yes" } else { "no" }; +43 | if true != x { | ^^^^^^^^^ help: try simplifying it as shown: `!x` error: inequality checks against false are unnecessary - --> $DIR/bool_comparison.rs:24:8 + --> $DIR/bool_comparison.rs:48:8 | -24 | if false != x { "yes" } else { "no" }; +48 | if false != x { | ^^^^^^^^^^ help: try simplifying it as shown: `x` error: aborting due to 8 previous errors diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index 01f821f511f6..45205b978ef6 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -1,202 +1,202 @@ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:22:13 + --> $DIR/booleans.rs:19:13 | -22 | let _ = a && b || a; +19 | let _ = a && b || a; | ^^^^^^^^^^^ help: it would look like the following: `a` | = note: `-D clippy::logic-bug` implied by `-D warnings` help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:22:18 + --> $DIR/booleans.rs:19:18 | -22 | let _ = a && b || a; +19 | let _ = a && b || a; | ^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:24:13 + --> $DIR/booleans.rs:21:13 | -24 | let _ = !true; +21 | let _ = !true; | ^^^^^ help: try: `false` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: this boolean expression can be simplified - --> $DIR/booleans.rs:25:13 + --> $DIR/booleans.rs:22:13 | -25 | let _ = !false; +22 | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified - --> $DIR/booleans.rs:26:13 + --> $DIR/booleans.rs:23:13 | -26 | let _ = !!a; +23 | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:27:13 + --> $DIR/booleans.rs:24:13 | -27 | let _ = false && a; +24 | let _ = false && a; | ^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:27:22 + --> $DIR/booleans.rs:24:22 | -27 | let _ = false && a; +24 | let _ = false && a; | ^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:28:13 + --> $DIR/booleans.rs:25:13 | -28 | let _ = false || a; +25 | let _ = false || a; | ^^^^^^^^^^ help: try: `a` error: this boolean expression can be simplified - --> $DIR/booleans.rs:33:13 + --> $DIR/booleans.rs:30:13 | -33 | let _ = !(!a && b); +30 | let _ = !(!a && b); | ^^^^^^^^^^ help: try: `!b || a` error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:43:13 + --> $DIR/booleans.rs:40:13 | -43 | let _ = a == b && a != b; +40 | let _ = a == b && a != b; | ^^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:43:13 + --> $DIR/booleans.rs:40:13 | -43 | let _ = a == b && a != b; +40 | let _ = a == b && a != b; | ^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:44:13 + --> $DIR/booleans.rs:41:13 | -44 | let _ = a == b && c == 5 && a == b; +41 | let _ = a == b && c == 5 && a == b; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | -44 | let _ = a == b && c == 5; +41 | let _ = a == b && c == 5; | ^^^^^^^^^^^^^^^^ -44 | let _ = !(c != 5 || a != b); +41 | let _ = !(c != 5 || a != b); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:45:13 + --> $DIR/booleans.rs:42:13 | -45 | let _ = a == b && c == 5 && b == a; +42 | let _ = a == b && c == 5 && b == a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | -45 | let _ = a == b && c == 5; +42 | let _ = a == b && c == 5; | ^^^^^^^^^^^^^^^^ -45 | let _ = !(c != 5 || a != b); +42 | let _ = !(c != 5 || a != b); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:46:13 + --> $DIR/booleans.rs:43:13 | -46 | let _ = a < b && a >= b; +43 | let _ = a < b && a >= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:46:13 + --> $DIR/booleans.rs:43:13 | -46 | let _ = a < b && a >= b; +43 | let _ = a < b && a >= b; | ^^^^^ error: this boolean expression contains a logic bug - --> $DIR/booleans.rs:47:13 + --> $DIR/booleans.rs:44:13 | -47 | let _ = a > b && a <= b; +44 | let _ = a > b && a <= b; | ^^^^^^^^^^^^^^^ help: it would look like the following: `false` | help: this expression can be optimized out by applying boolean operations to the outer expression - --> $DIR/booleans.rs:47:13 + --> $DIR/booleans.rs:44:13 | -47 | let _ = a > b && a <= b; +44 | let _ = a > b && a <= b; | ^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:49:13 + --> $DIR/booleans.rs:46:13 | -49 | let _ = a != b || !(a != b || c == d); +46 | let _ = a != b || !(a != b || c == d); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try | -49 | let _ = c != d || a != b; +46 | let _ = c != d || a != b; | ^^^^^^^^^^^^^^^^ -49 | let _ = !(a == b && c == d); +46 | let _ = !(a == b && c == d); | ^^^^^^^^^^^^^^^^^^^ error: this boolean expression can be simplified - --> $DIR/booleans.rs:57:13 + --> $DIR/booleans.rs:54:13 | -57 | let _ = !a.is_some(); +54 | let _ = !a.is_some(); | ^^^^^^^^^^^^ help: try: `a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:59:13 + --> $DIR/booleans.rs:56:13 | -59 | let _ = !a.is_none(); +56 | let _ = !a.is_none(); | ^^^^^^^^^^^^ help: try: `a.is_some()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:61:13 + --> $DIR/booleans.rs:58:13 | -61 | let _ = !b.is_err(); +58 | let _ = !b.is_err(); | ^^^^^^^^^^^ help: try: `b.is_ok()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:63:13 + --> $DIR/booleans.rs:60:13 | -63 | let _ = !b.is_ok(); +60 | let _ = !b.is_ok(); | ^^^^^^^^^^ help: try: `b.is_err()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:65:13 + --> $DIR/booleans.rs:62:13 | -65 | let _ = !(a.is_some() && !c); +62 | let _ = !(a.is_some() && !c); | ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:66:13 + --> $DIR/booleans.rs:63:13 | -66 | let _ = !(!c ^ c) || !a.is_some(); +63 | let _ = !(!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!(!c ^ c) || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:67:13 + --> $DIR/booleans.rs:64:13 | -67 | let _ = (!c ^ c) || !a.is_some(); +64 | let _ = (!c ^ c) || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!c ^ c) || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:68:13 + --> $DIR/booleans.rs:65:13 | -68 | let _ = !c ^ c || !a.is_some(); +65 | let _ = !c ^ c || !a.is_some(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `!c ^ c || a.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:120:8 + --> $DIR/booleans.rs:137:8 | -120 | if !res.is_ok() { } +137 | if !res.is_ok() {} | ^^^^^^^^^^^^ help: try: `res.is_err()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:121:8 + --> $DIR/booleans.rs:138:8 | -121 | if !res.is_err() { } +138 | if !res.is_err() {} | ^^^^^^^^^^^^^ help: try: `res.is_ok()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:124:8 + --> $DIR/booleans.rs:141:8 | -124 | if !res.is_some() { } +141 | if !res.is_some() {} | ^^^^^^^^^^^^^^ help: try: `res.is_none()` error: this boolean expression can be simplified - --> $DIR/booleans.rs:125:8 + --> $DIR/booleans.rs:142:8 | -125 | if !res.is_none() { } +142 | if !res.is_none() {} | ^^^^^^^^^^^^^^ help: try: `res.is_some()` error: aborting due to 25 previous errors diff --git a/tests/ui/borrow_box.stderr b/tests/ui/borrow_box.stderr index 7cc8eb8da40c..0e42fe177ba9 100644 --- a/tests/ui/borrow_box.stderr +++ b/tests/ui/borrow_box.stderr @@ -1,31 +1,31 @@ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:19:19 + --> $DIR/borrow_box.rs:15:19 | -19 | pub fn test1(foo: &mut Box) { +15 | pub fn test1(foo: &mut Box) { | ^^^^^^^^^^^^^^ help: try: `&mut bool` | note: lint level defined here - --> $DIR/borrow_box.rs:14:9 + --> $DIR/borrow_box.rs:10:9 | -14 | #![deny(clippy::borrowed_box)] +10 | #![deny(clippy::borrowed_box)] | ^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:24:14 + --> $DIR/borrow_box.rs:20:14 | -24 | let foo: &Box; +20 | let foo: &Box; | ^^^^^^^^^^ help: try: `&bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:28:10 + --> $DIR/borrow_box.rs:24:10 | -28 | foo: &'a Box +24 | foo: &'a Box, | ^^^^^^^^^^^^^ help: try: `&'a bool` error: you seem to be trying to use `&Box`. Consider using just `&T` - --> $DIR/borrow_box.rs:32:17 + --> $DIR/borrow_box.rs:28:17 | -32 | fn test4(a: &Box); +28 | fn test4(a: &Box); | ^^^^^^^^^^ help: try: `&bool` error: aborting due to 4 previous errors diff --git a/tests/ui/box_vec.stderr b/tests/ui/box_vec.stderr index 34be890b5345..84c0b6c36e3c 100644 --- a/tests/ui/box_vec.stderr +++ b/tests/ui/box_vec.stderr @@ -1,7 +1,7 @@ error: you seem to be trying to use `Box>`. Consider using just `Vec` - --> $DIR/box_vec.rs:27:18 + --> $DIR/box_vec.rs:23:18 | -27 | pub fn test(foo: Box>) { +23 | pub fn test(foo: Box>) { | ^^^^^^^^^^^^^^ | = note: `-D clippy::box-vec` implied by `-D warnings` diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 11253715716d..540d9f4f4584 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -1,17 +1,17 @@ error: This generic shadows the built-in type `u32` - --> $DIR/builtin-type-shadow.rs:15:8 + --> $DIR/builtin-type-shadow.rs:12:8 | -15 | fn foo(a: u32) -> u32 { +12 | fn foo(a: u32) -> u32 { | ^^^ | = note: `-D clippy::builtin-type-shadow` implied by `-D warnings` error[E0308]: mismatched types - --> $DIR/builtin-type-shadow.rs:16:5 + --> $DIR/builtin-type-shadow.rs:13:5 | -15 | fn foo(a: u32) -> u32 { +12 | fn foo(a: u32) -> u32 { | --- expected `u32` because of return type -16 | 42 +13 | 42 | ^^ expected type parameter, found integral variable | = note: expected type `u32` diff --git a/tests/ui/bytecount.stderr b/tests/ui/bytecount.stderr index c5c0ec7eda4a..605cf287419d 100644 --- a/tests/ui/bytecount.stderr +++ b/tests/ui/bytecount.stderr @@ -1,25 +1,25 @@ error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:18:13 + --> $DIR/bytecount.rs:14:13 | -18 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count +14 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, 0)` | note: lint level defined here - --> $DIR/bytecount.rs:14:8 + --> $DIR/bytecount.rs:10:8 | -14 | #[deny(clippy::naive_bytecount)] +10 | #[deny(clippy::naive_bytecount)] | ^^^^^^^^^^^^^^^^^^^^^^^ error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:20:13 + --> $DIR/bytecount.rs:16:13 | -20 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count +16 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count((&x[..]), 0)` error: You appear to be counting bytes the naive way - --> $DIR/bytecount.rs:32:13 + --> $DIR/bytecount.rs:28:13 | -32 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count +28 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, b + 1)` error: aborting due to 3 previous errors diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 1f9ab5712f52..1b6b1e6319cd 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,181 +1,181 @@ error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:18:5 + --> $DIR/cast.rs:20:5 | -18 | 1i32 as f32; +20 | 1i32 as f32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:19:5 + --> $DIR/cast.rs:21:5 | -19 | 1i64 as f32; +21 | 1i64 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) - --> $DIR/cast.rs:20:5 + --> $DIR/cast.rs:22:5 | -20 | 1i64 as f64; +22 | 1i64 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) - --> $DIR/cast.rs:21:5 + --> $DIR/cast.rs:23:5 | -21 | 1u32 as f32; +23 | 1u32 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) - --> $DIR/cast.rs:22:5 + --> $DIR/cast.rs:24:5 | -22 | 1u64 as f32; +24 | 1u64 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) - --> $DIR/cast.rs:23:5 + --> $DIR/cast.rs:25:5 | -23 | 1u64 as f64; +25 | 1u64 as f64; | ^^^^^^^^^^^ error: casting f32 to i32 may truncate the value - --> $DIR/cast.rs:25:5 + --> $DIR/cast.rs:27:5 | -25 | 1f32 as i32; +27 | 1f32 as i32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` error: casting f32 to u32 may truncate the value - --> $DIR/cast.rs:26:5 + --> $DIR/cast.rs:28:5 | -26 | 1f32 as u32; +28 | 1f32 as u32; | ^^^^^^^^^^^ error: casting f32 to u32 may lose the sign of the value - --> $DIR/cast.rs:26:5 + --> $DIR/cast.rs:28:5 | -26 | 1f32 as u32; +28 | 1f32 as u32; | ^^^^^^^^^^^ | = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting f64 to f32 may truncate the value - --> $DIR/cast.rs:27:5 + --> $DIR/cast.rs:29:5 | -27 | 1f64 as f32; +29 | 1f64 as f32; | ^^^^^^^^^^^ error: casting i32 to i8 may truncate the value - --> $DIR/cast.rs:28:5 + --> $DIR/cast.rs:30:5 | -28 | 1i32 as i8; +30 | 1i32 as i8; | ^^^^^^^^^^ error: casting i32 to u8 may lose the sign of the value - --> $DIR/cast.rs:29:5 + --> $DIR/cast.rs:31:5 | -29 | 1i32 as u8; +31 | 1i32 as u8; | ^^^^^^^^^^ error: casting i32 to u8 may truncate the value - --> $DIR/cast.rs:29:5 + --> $DIR/cast.rs:31:5 | -29 | 1i32 as u8; +31 | 1i32 as u8; | ^^^^^^^^^^ error: casting f64 to isize may truncate the value - --> $DIR/cast.rs:30:5 + --> $DIR/cast.rs:32:5 | -30 | 1f64 as isize; +32 | 1f64 as isize; | ^^^^^^^^^^^^^ error: casting f64 to usize may truncate the value - --> $DIR/cast.rs:31:5 + --> $DIR/cast.rs:33:5 | -31 | 1f64 as usize; +33 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting f64 to usize may lose the sign of the value - --> $DIR/cast.rs:31:5 + --> $DIR/cast.rs:33:5 | -31 | 1f64 as usize; +33 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting u8 to i8 may wrap around the value - --> $DIR/cast.rs:33:5 + --> $DIR/cast.rs:35:5 | -33 | 1u8 as i8; +35 | 1u8 as i8; | ^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` error: casting u16 to i16 may wrap around the value - --> $DIR/cast.rs:34:5 + --> $DIR/cast.rs:36:5 | -34 | 1u16 as i16; +36 | 1u16 as i16; | ^^^^^^^^^^^ error: casting u32 to i32 may wrap around the value - --> $DIR/cast.rs:35:5 + --> $DIR/cast.rs:37:5 | -35 | 1u32 as i32; +37 | 1u32 as i32; | ^^^^^^^^^^^ error: casting u64 to i64 may wrap around the value - --> $DIR/cast.rs:36:5 + --> $DIR/cast.rs:38:5 | -36 | 1u64 as i64; +38 | 1u64 as i64; | ^^^^^^^^^^^ error: casting usize to isize may wrap around the value - --> $DIR/cast.rs:37:5 + --> $DIR/cast.rs:39:5 | -37 | 1usize as isize; +39 | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting f32 to f64 may become silently lossy if types change - --> $DIR/cast.rs:39:5 + --> $DIR/cast.rs:41:5 | -39 | 1.0f32 as f64; +41 | 1.0f32 as f64; | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast.rs:41:5 + --> $DIR/cast.rs:43:5 | -41 | (1u8 + 1u8) as u16; +43 | (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` error: casting i32 to u32 may lose the sign of the value - --> $DIR/cast.rs:43:5 + --> $DIR/cast.rs:45:5 | -43 | 1i32 as u32; +45 | 1i32 as u32; | ^^^^^^^^^^^ error: casting isize to usize may lose the sign of the value - --> $DIR/cast.rs:44:5 + --> $DIR/cast.rs:46:5 | -44 | 1isize as usize; +46 | 1isize as usize; | ^^^^^^^^^^^^^^^ error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/cast.rs:47:5 + --> $DIR/cast.rs:49:5 | -47 | 1i32 as i32; +49 | 1i32 as i32; | ^^^^^^^^^^^ | = note: `-D clippy::unnecessary-cast` implied by `-D warnings` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/cast.rs:48:5 + --> $DIR/cast.rs:50:5 | -48 | 1f32 as f32; +50 | 1f32 as f32; | ^^^^^^^^^^^ error: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/cast.rs:49:5 + --> $DIR/cast.rs:51:5 | -49 | false as bool; +51 | false as bool; | ^^^^^^^^^^^^^ error: aborting due to 28 previous errors diff --git a/tests/ui/cast_alignment.stderr b/tests/ui/cast_alignment.stderr index a4dd6038cab0..1c7d53c3ce70 100644 --- a/tests/ui/cast_alignment.stderr +++ b/tests/ui/cast_alignment.stderr @@ -1,15 +1,15 @@ error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) - --> $DIR/cast_alignment.rs:25:5 + --> $DIR/cast_alignment.rs:22:5 | -25 | (&1u8 as *const u8) as *const u16; +22 | (&1u8 as *const u8) as *const u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::cast-ptr-alignment` implied by `-D warnings` error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) - --> $DIR/cast_alignment.rs:26:5 + --> $DIR/cast_alignment.rs:23:5 | -26 | (&mut 1u8 as *mut u8) as *mut u16; +23 | (&mut 1u8 as *mut u8) as *mut u16; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index 95b9bfb02626..8380c7c84e23 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,63 +1,63 @@ error: casting i8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:17:5 + --> $DIR/cast_lossless_float.rs:14:5 | -17 | 1i8 as f32; +14 | 1i8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:18:5 + --> $DIR/cast_lossless_float.rs:15:5 | -18 | 1i8 as f64; +15 | 1i8 as f64; | ^^^^^^^^^^ help: try: `f64::from(1i8)` error: casting u8 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:19:5 + --> $DIR/cast_lossless_float.rs:16:5 | -19 | 1u8 as f32; +16 | 1u8 as f32; | ^^^^^^^^^^ help: try: `f32::from(1u8)` error: casting u8 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:20:5 + --> $DIR/cast_lossless_float.rs:17:5 | -20 | 1u8 as f64; +17 | 1u8 as f64; | ^^^^^^^^^^ help: try: `f64::from(1u8)` error: casting i16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:21:5 + --> $DIR/cast_lossless_float.rs:18:5 | -21 | 1i16 as f32; +18 | 1i16 as f32; | ^^^^^^^^^^^ help: try: `f32::from(1i16)` error: casting i16 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:22:5 + --> $DIR/cast_lossless_float.rs:19:5 | -22 | 1i16 as f64; +19 | 1i16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i16)` error: casting u16 to f32 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:23:5 + --> $DIR/cast_lossless_float.rs:20:5 | -23 | 1u16 as f32; +20 | 1u16 as f32; | ^^^^^^^^^^^ help: try: `f32::from(1u16)` error: casting u16 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:24:5 + --> $DIR/cast_lossless_float.rs:21:5 | -24 | 1u16 as f64; +21 | 1u16 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u16)` error: casting i32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:25:5 + --> $DIR/cast_lossless_float.rs:22:5 | -25 | 1i32 as f64; +22 | 1i32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1i32)` error: casting u32 to f64 may become silently lossy if types change - --> $DIR/cast_lossless_float.rs:26:5 + --> $DIR/cast_lossless_float.rs:23:5 | -26 | 1u32 as f64; +23 | 1u32 as f64; | ^^^^^^^^^^^ help: try: `f64::from(1u32)` error: aborting due to 10 previous errors diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index 5f9c70879b49..e5558b66681f 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -1,111 +1,111 @@ error: casting i8 to i16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:16:5 + --> $DIR/cast_lossless_integer.rs:14:5 | -16 | 1i8 as i16; +14 | 1i8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting i8 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:17:5 + --> $DIR/cast_lossless_integer.rs:15:5 | -17 | 1i8 as i32; +15 | 1i8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1i8)` error: casting i8 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:18:5 + --> $DIR/cast_lossless_integer.rs:16:5 | -18 | 1i8 as i64; +16 | 1i8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1i8)` error: casting u8 to i16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:19:5 + --> $DIR/cast_lossless_integer.rs:17:5 | -19 | 1u8 as i16; +17 | 1u8 as i16; | ^^^^^^^^^^ help: try: `i16::from(1u8)` error: casting u8 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:20:5 + --> $DIR/cast_lossless_integer.rs:18:5 | -20 | 1u8 as i32; +18 | 1u8 as i32; | ^^^^^^^^^^ help: try: `i32::from(1u8)` error: casting u8 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:21:5 + --> $DIR/cast_lossless_integer.rs:19:5 | -21 | 1u8 as i64; +19 | 1u8 as i64; | ^^^^^^^^^^ help: try: `i64::from(1u8)` error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:22:5 + --> $DIR/cast_lossless_integer.rs:20:5 | -22 | 1u8 as u16; +20 | 1u8 as u16; | ^^^^^^^^^^ help: try: `u16::from(1u8)` error: casting u8 to u32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:23:5 + --> $DIR/cast_lossless_integer.rs:21:5 | -23 | 1u8 as u32; +21 | 1u8 as u32; | ^^^^^^^^^^ help: try: `u32::from(1u8)` error: casting u8 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:24:5 + --> $DIR/cast_lossless_integer.rs:22:5 | -24 | 1u8 as u64; +22 | 1u8 as u64; | ^^^^^^^^^^ help: try: `u64::from(1u8)` error: casting i16 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:25:5 + --> $DIR/cast_lossless_integer.rs:23:5 | -25 | 1i16 as i32; +23 | 1i16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1i16)` error: casting i16 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:26:5 + --> $DIR/cast_lossless_integer.rs:24:5 | -26 | 1i16 as i64; +24 | 1i16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i16)` error: casting u16 to i32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:27:5 + --> $DIR/cast_lossless_integer.rs:25:5 | -27 | 1u16 as i32; +25 | 1u16 as i32; | ^^^^^^^^^^^ help: try: `i32::from(1u16)` error: casting u16 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:28:5 + --> $DIR/cast_lossless_integer.rs:26:5 | -28 | 1u16 as i64; +26 | 1u16 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u16)` error: casting u16 to u32 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:29:5 + --> $DIR/cast_lossless_integer.rs:27:5 | -29 | 1u16 as u32; +27 | 1u16 as u32; | ^^^^^^^^^^^ help: try: `u32::from(1u16)` error: casting u16 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:30:5 + --> $DIR/cast_lossless_integer.rs:28:5 | -30 | 1u16 as u64; +28 | 1u16 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u16)` error: casting i32 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:31:5 + --> $DIR/cast_lossless_integer.rs:29:5 | -31 | 1i32 as i64; +29 | 1i32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1i32)` error: casting u32 to i64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:32:5 + --> $DIR/cast_lossless_integer.rs:30:5 | -32 | 1u32 as i64; +30 | 1u32 as i64; | ^^^^^^^^^^^ help: try: `i64::from(1u32)` error: casting u32 to u64 may become silently lossy if types change - --> $DIR/cast_lossless_integer.rs:33:5 + --> $DIR/cast_lossless_integer.rs:31:5 | -33 | 1u32 as u64; +31 | 1u32 as u64; | ^^^^^^^^^^^ help: try: `u64::from(1u32)` error: aborting due to 18 previous errors diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr index c5f569db167e..9f658d405236 100644 --- a/tests/ui/cast_size.stderr +++ b/tests/ui/cast_size.stderr @@ -1,123 +1,123 @@ error: casting isize to i8 may truncate the value - --> $DIR/cast_size.rs:17:5 + --> $DIR/cast_size.rs:20:5 | -17 | 1isize as i8; +20 | 1isize as i8; | ^^^^^^^^^^^^ | = note: `-D clippy::cast-possible-truncation` implied by `-D warnings` error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:18:5 + --> $DIR/cast_size.rs:21:5 | -18 | 1isize as f64; +21 | 1isize as f64; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-precision-loss` implied by `-D warnings` error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast_size.rs:19:5 + --> $DIR/cast_size.rs:22:5 | -19 | 1usize as f64; +22 | 1usize as f64; | ^^^^^^^^^^^^^ error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:20:5 + --> $DIR/cast_size.rs:23:5 | -20 | 1isize as f32; +23 | 1isize as f32; | ^^^^^^^^^^^^^ error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast_size.rs:21:5 + --> $DIR/cast_size.rs:24:5 | -21 | 1usize as f32; +24 | 1usize as f32; | ^^^^^^^^^^^^^ error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:22:5 + --> $DIR/cast_size.rs:25:5 | -22 | 1isize as i32; +25 | 1isize as i32; | ^^^^^^^^^^^^^ error: casting isize to u32 may lose the sign of the value - --> $DIR/cast_size.rs:23:5 + --> $DIR/cast_size.rs:26:5 | -23 | 1isize as u32; +26 | 1isize as u32; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-sign-loss` implied by `-D warnings` error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:23:5 + --> $DIR/cast_size.rs:26:5 | -23 | 1isize as u32; +26 | 1isize as u32; | ^^^^^^^^^^^^^ error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:24:5 + --> $DIR/cast_size.rs:27:5 | -24 | 1usize as u32; +27 | 1usize as u32; | ^^^^^^^^^^^^^ error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> $DIR/cast_size.rs:28:5 | -25 | 1usize as i32; +28 | 1usize as i32; | ^^^^^^^^^^^^^ error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:25:5 + --> $DIR/cast_size.rs:28:5 | -25 | 1usize as i32; +28 | 1usize as i32; | ^^^^^^^^^^^^^ | = note: `-D clippy::cast-possible-wrap` implied by `-D warnings` error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:27:5 + --> $DIR/cast_size.rs:30:5 | -27 | 1i64 as isize; +30 | 1i64 as isize; | ^^^^^^^^^^^^^ error: casting i64 to usize may lose the sign of the value - --> $DIR/cast_size.rs:28:5 + --> $DIR/cast_size.rs:31:5 | -28 | 1i64 as usize; +31 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:28:5 + --> $DIR/cast_size.rs:31:5 | -28 | 1i64 as usize; +31 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> $DIR/cast_size.rs:32:5 | -29 | 1u64 as isize; +32 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast_size.rs:29:5 + --> $DIR/cast_size.rs:32:5 | -29 | 1u64 as isize; +32 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:30:5 + --> $DIR/cast_size.rs:33:5 | -30 | 1u64 as usize; +33 | 1u64 as usize; | ^^^^^^^^^^^^^ error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast_size.rs:31:5 + --> $DIR/cast_size.rs:34:5 | -31 | 1u32 as isize; +34 | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting i32 to usize may lose the sign of the value - --> $DIR/cast_size.rs:34:5 + --> $DIR/cast_size.rs:37:5 | -34 | 1i32 as usize; +37 | 1i32 as usize; | ^^^^^^^^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index 38a469bfebbd..cee27df2a7df 100644 --- a/tests/ui/char_lit_as_u8.stderr +++ b/tests/ui/char_lit_as_u8.stderr @@ -1,7 +1,7 @@ error: casting character literal to u8. `char`s are 4 bytes wide in rust, so casting to u8 truncates them - --> $DIR/char_lit_as_u8.rs:17:13 + --> $DIR/char_lit_as_u8.rs:13:13 | -17 | let c = 'a' as u8; +13 | let c = 'a' as u8; | ^^^^^^^^^ | = note: `-D clippy::char-lit-as-u8` implied by `-D warnings` diff --git a/tests/ui/checked_unwrap.stderr b/tests/ui/checked_unwrap.stderr index f7f493603486..bce37d502268 100644 --- a/tests/ui/checked_unwrap.stderr +++ b/tests/ui/checked_unwrap.stderr @@ -1,312 +1,312 @@ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:19:9 + --> $DIR/checked_unwrap.rs:16:9 | -18 | if x.is_some() { +15 | if x.is_some() { | ----------- the check is happening here -19 | x.unwrap(); // unnecessary +16 | x.unwrap(); // unnecessary | ^^^^^^^^^^ | note: lint level defined here - --> $DIR/checked_unwrap.rs:13:35 + --> $DIR/checked_unwrap.rs:10:35 | -13 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:21:9 + --> $DIR/checked_unwrap.rs:18:9 | -18 | if x.is_some() { +15 | if x.is_some() { | ----------- because of this check ... -21 | x.unwrap(); // will panic +18 | x.unwrap(); // will panic | ^^^^^^^^^^ | note: lint level defined here - --> $DIR/checked_unwrap.rs:13:9 + --> $DIR/checked_unwrap.rs:10:9 | -13 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] +10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:24:9 + --> $DIR/checked_unwrap.rs:21:9 | -23 | if x.is_none() { +20 | if x.is_none() { | ----------- because of this check -24 | x.unwrap(); // will panic +21 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:26:9 + --> $DIR/checked_unwrap.rs:23:9 | -23 | if x.is_none() { +20 | if x.is_none() { | ----------- the check is happening here ... -26 | x.unwrap(); // unnecessary +23 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:30:9 + --> $DIR/checked_unwrap.rs:27:9 | -29 | if x.is_ok() { +26 | if x.is_ok() { | --------- the check is happening here -30 | x.unwrap(); // unnecessary +27 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:31:9 + --> $DIR/checked_unwrap.rs:28:9 | -29 | if x.is_ok() { +26 | if x.is_ok() { | --------- because of this check -30 | x.unwrap(); // unnecessary -31 | x.unwrap_err(); // will panic +27 | x.unwrap(); // unnecessary +28 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:33:9 + --> $DIR/checked_unwrap.rs:30:9 | -29 | if x.is_ok() { +26 | if x.is_ok() { | --------- because of this check ... -33 | x.unwrap(); // will panic +30 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:34:9 + --> $DIR/checked_unwrap.rs:31:9 | -29 | if x.is_ok() { +26 | if x.is_ok() { | --------- the check is happening here ... -34 | x.unwrap_err(); // unnecessary +31 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:37:9 + --> $DIR/checked_unwrap.rs:34:9 | -36 | if x.is_err() { +33 | if x.is_err() { | ---------- because of this check -37 | x.unwrap(); // will panic +34 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:38:9 + --> $DIR/checked_unwrap.rs:35:9 | -36 | if x.is_err() { +33 | if x.is_err() { | ---------- the check is happening here -37 | x.unwrap(); // will panic -38 | x.unwrap_err(); // unnecessary +34 | x.unwrap(); // will panic +35 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:40:9 + --> $DIR/checked_unwrap.rs:37:9 | -36 | if x.is_err() { +33 | if x.is_err() { | ---------- the check is happening here ... -40 | x.unwrap(); // unnecessary +37 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:41:9 + --> $DIR/checked_unwrap.rs:38:9 | -36 | if x.is_err() { +33 | if x.is_err() { | ---------- because of this check ... -41 | x.unwrap_err(); // will panic +38 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:58:9 + --> $DIR/checked_unwrap.rs:55:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | --------- the check is happening here -58 | x.unwrap(); // unnecessary +55 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:59:9 + --> $DIR/checked_unwrap.rs:56:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | --------- because of this check -58 | x.unwrap(); // unnecessary -59 | x.unwrap_err(); // will panic +55 | x.unwrap(); // unnecessary +56 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:60:9 + --> $DIR/checked_unwrap.rs:57:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | ---------- because of this check ... -60 | y.unwrap(); // will panic +57 | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:61:9 + --> $DIR/checked_unwrap.rs:58:9 | -57 | if x.is_ok() && y.is_err() { +54 | if x.is_ok() && y.is_err() { | ---------- the check is happening here ... -61 | y.unwrap_err(); // unnecessary +58 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:75:9 + --> $DIR/checked_unwrap.rs:72:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- because of this check ... -75 | x.unwrap(); // will panic +72 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:76:9 + --> $DIR/checked_unwrap.rs:73:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- the check is happening here ... -76 | x.unwrap_err(); // unnecessary +73 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:77:9 + --> $DIR/checked_unwrap.rs:74:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- because of this check ... -77 | y.unwrap(); // will panic +74 | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:78:9 + --> $DIR/checked_unwrap.rs:75:9 | -70 | if x.is_ok() || y.is_ok() { +67 | if x.is_ok() || y.is_ok() { | --------- the check is happening here ... -78 | y.unwrap_err(); // unnecessary +75 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:82:9 + --> $DIR/checked_unwrap.rs:79:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here -82 | x.unwrap(); // unnecessary +79 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:83:9 + --> $DIR/checked_unwrap.rs:80:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check -82 | x.unwrap(); // unnecessary -83 | x.unwrap_err(); // will panic +79 | x.unwrap(); // unnecessary +80 | x.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:84:9 + --> $DIR/checked_unwrap.rs:81:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- because of this check ... -84 | y.unwrap(); // will panic +81 | y.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:85:9 + --> $DIR/checked_unwrap.rs:82:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | --------- the check is happening here ... -85 | y.unwrap_err(); // unnecessary +82 | y.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:86:9 + --> $DIR/checked_unwrap.rs:83:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- the check is happening here ... -86 | z.unwrap(); // unnecessary +83 | z.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:87:9 + --> $DIR/checked_unwrap.rs:84:9 | -81 | if x.is_ok() && !(y.is_ok() || z.is_err()) { +78 | if x.is_ok() && !(y.is_ok() || z.is_err()) { | ---------- because of this check ... -87 | z.unwrap_err(); // will panic +84 | z.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:95:9 + --> $DIR/checked_unwrap.rs:92:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check ... -95 | x.unwrap(); // will panic +92 | x.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:96:9 + --> $DIR/checked_unwrap.rs:93:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here ... -96 | x.unwrap_err(); // unnecessary +93 | x.unwrap_err(); // unnecessary | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:97:9 + --> $DIR/checked_unwrap.rs:94:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- the check is happening here ... -97 | y.unwrap(); // unnecessary +94 | y.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap_err()` will always panic. - --> $DIR/checked_unwrap.rs:98:9 + --> $DIR/checked_unwrap.rs:95:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | --------- because of this check ... -98 | y.unwrap_err(); // will panic +95 | y.unwrap_err(); // will panic | ^^^^^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:99:9 + --> $DIR/checked_unwrap.rs:96:9 | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { | ---------- because of this check ... -99 | z.unwrap(); // will panic +96 | z.unwrap(); // will panic | ^^^^^^^^^^ error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:100:9 - | -89 | if x.is_ok() || !(y.is_ok() && z.is_err()) { - | ---------- the check is happening here + --> $DIR/checked_unwrap.rs:97:9 + | +86 | if x.is_ok() || !(y.is_ok() && z.is_err()) { + | ---------- the check is happening here ... -100 | z.unwrap_err(); // unnecessary - | ^^^^^^^^^^^^^^ +97 | z.unwrap_err(); // unnecessary + | ^^^^^^^^^^^^^^ error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`. - --> $DIR/checked_unwrap.rs:108:13 + --> $DIR/checked_unwrap.rs:105:13 | -107 | if x.is_some() { +104 | if x.is_some() { | ----------- the check is happening here -108 | x.unwrap(); // unnecessary +105 | x.unwrap(); // unnecessary | ^^^^^^^^^^ error: This call to `unwrap()` will always panic. - --> $DIR/checked_unwrap.rs:110:13 + --> $DIR/checked_unwrap.rs:107:13 | -107 | if x.is_some() { +104 | if x.is_some() { | ----------- because of this check ... -110 | x.unwrap(); // will panic +107 | x.unwrap(); // will panic | ^^^^^^^^^^ error: aborting due to 34 previous errors diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index b880b821f087..6838e6ad7aef 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -1,75 +1,75 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:18:5 + --> $DIR/cmp_nan.rs:14:5 | -18 | x == std::f32::NAN; +14 | x == std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::cmp-nan` implied by `-D warnings` error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:19:5 + --> $DIR/cmp_nan.rs:15:5 | -19 | x != std::f32::NAN; +15 | x != std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:20:5 + --> $DIR/cmp_nan.rs:16:5 | -20 | x < std::f32::NAN; +16 | x < std::f32::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:21:5 + --> $DIR/cmp_nan.rs:17:5 | -21 | x > std::f32::NAN; +17 | x > std::f32::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:22:5 + --> $DIR/cmp_nan.rs:18:5 | -22 | x <= std::f32::NAN; +18 | x <= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:23:5 + --> $DIR/cmp_nan.rs:19:5 | -23 | x >= std::f32::NAN; +19 | x >= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:26:5 + --> $DIR/cmp_nan.rs:22:5 | -26 | y == std::f64::NAN; +22 | y == std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:27:5 + --> $DIR/cmp_nan.rs:23:5 | -27 | y != std::f64::NAN; +23 | y != std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:28:5 + --> $DIR/cmp_nan.rs:24:5 | -28 | y < std::f64::NAN; +24 | y < std::f64::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:29:5 + --> $DIR/cmp_nan.rs:25:5 | -29 | y > std::f64::NAN; +25 | y > std::f64::NAN; | ^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:30:5 + --> $DIR/cmp_nan.rs:26:5 | -30 | y <= std::f64::NAN; +26 | y <= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead - --> $DIR/cmp_nan.rs:31:5 + --> $DIR/cmp_nan.rs:27:5 | -31 | y >= std::f64::NAN; +27 | y >= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 1f1fdf328529..5038298d9c46 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -1,15 +1,15 @@ error: Comparing with null is better expressed by the .is_null() method - --> $DIR/cmp_null.rs:21:8 + --> $DIR/cmp_null.rs:18:8 | -21 | if p == ptr::null() { +18 | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::cmp-null` implied by `-D warnings` error: Comparing with null is better expressed by the .is_null() method - --> $DIR/cmp_null.rs:26:8 + --> $DIR/cmp_null.rs:23:8 | -26 | if m == ptr::null_mut() { +23 | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index a7371ab4b6c3..2d06f736967f 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -1,57 +1,57 @@ error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:18:14 + --> $DIR/cmp_owned.rs:14:14 | -18 | x != "foo".to_string(); +14 | x != "foo".to_string(); | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` | = note: `-D clippy::cmp-owned` implied by `-D warnings` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:20:9 + --> $DIR/cmp_owned.rs:16:9 | -20 | "foo".to_string() != x; +16 | "foo".to_string() != x; | ^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:27:10 + --> $DIR/cmp_owned.rs:23:10 | -27 | x != "foo".to_owned(); +23 | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:29:10 + --> $DIR/cmp_owned.rs:25:10 | -29 | x != String::from("foo"); +25 | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:33:5 + --> $DIR/cmp_owned.rs:29:5 | -33 | Foo.to_owned() == Foo; +29 | Foo.to_owned() == Foo; | ^^^^^^^^^^^^^^ help: try: `Foo` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:35:30 + --> $DIR/cmp_owned.rs:31:30 | -35 | "abc".chars().filter(|c| c.to_owned() != 'X'); +31 | "abc".chars().filter(|c| c.to_owned() != 'X'); | ^^^^^^^^^^^^ help: try: `*c` error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:42:5 + --> $DIR/cmp_owned.rs:38:5 | -42 | y.to_owned() == *x; +38 | y.to_owned() == *x; | ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:47:5 + --> $DIR/cmp_owned.rs:43:5 | -47 | y.to_owned() == **x; +43 | y.to_owned() == **x; | ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: this creates an owned instance just for comparison - --> $DIR/cmp_owned.rs:54:9 + --> $DIR/cmp_owned.rs:50:9 | -54 | self.to_owned() == *other +50 | self.to_owned() == *other | ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating error: aborting due to 9 previous errors diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 697dec336fab..1884045a2db4 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -1,259 +1,259 @@ error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:16:5 + --> $DIR/collapsible_if.rs:15:5 | -16 | / if x == "hello" { -17 | | if y == "world" { -18 | | println!("Hello world!"); -19 | | } -20 | | } +15 | / if x == "hello" { +16 | | if y == "world" { +17 | | println!("Hello world!"); +18 | | } +19 | | } | |_____^ | = note: `-D clippy::collapsible-if` implied by `-D warnings` help: try | -16 | if x == "hello" && y == "world" { -17 | println!("Hello world!"); -18 | } +15 | if x == "hello" && y == "world" { +16 | println!("Hello world!"); +17 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:22:5 + --> $DIR/collapsible_if.rs:21:5 | -22 | / if x == "hello" || x == "world" { -23 | | if y == "world" || y == "hello" { -24 | | println!("Hello world!"); -25 | | } -26 | | } +21 | / if x == "hello" || x == "world" { +22 | | if y == "world" || y == "hello" { +23 | | println!("Hello world!"); +24 | | } +25 | | } | |_____^ help: try | -22 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") { -23 | println!("Hello world!"); -24 | } +21 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") { +22 | println!("Hello world!"); +23 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:28:5 + --> $DIR/collapsible_if.rs:27:5 | -28 | / if x == "hello" && x == "world" { -29 | | if y == "world" || y == "hello" { -30 | | println!("Hello world!"); -31 | | } -32 | | } +27 | / if x == "hello" && x == "world" { +28 | | if y == "world" || y == "hello" { +29 | | println!("Hello world!"); +30 | | } +31 | | } | |_____^ help: try | -28 | if x == "hello" && x == "world" && (y == "world" || y == "hello") { -29 | println!("Hello world!"); -30 | } +27 | if x == "hello" && x == "world" && (y == "world" || y == "hello") { +28 | println!("Hello world!"); +29 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:34:5 + --> $DIR/collapsible_if.rs:33:5 | -34 | / if x == "hello" || x == "world" { -35 | | if y == "world" && y == "hello" { -36 | | println!("Hello world!"); -37 | | } -38 | | } +33 | / if x == "hello" || x == "world" { +34 | | if y == "world" && y == "hello" { +35 | | println!("Hello world!"); +36 | | } +37 | | } | |_____^ help: try | -34 | if (x == "hello" || x == "world") && y == "world" && y == "hello" { -35 | println!("Hello world!"); -36 | } +33 | if (x == "hello" || x == "world") && y == "world" && y == "hello" { +34 | println!("Hello world!"); +35 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:40:5 + --> $DIR/collapsible_if.rs:39:5 | -40 | / if x == "hello" && x == "world" { -41 | | if y == "world" && y == "hello" { -42 | | println!("Hello world!"); -43 | | } -44 | | } +39 | / if x == "hello" && x == "world" { +40 | | if y == "world" && y == "hello" { +41 | | println!("Hello world!"); +42 | | } +43 | | } | |_____^ help: try | -40 | if x == "hello" && x == "world" && y == "world" && y == "hello" { -41 | println!("Hello world!"); -42 | } +39 | if x == "hello" && x == "world" && y == "world" && y == "hello" { +40 | println!("Hello world!"); +41 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:46:5 + --> $DIR/collapsible_if.rs:45:5 | -46 | / if 42 == 1337 { -47 | | if 'a' != 'A' { -48 | | println!("world!") -49 | | } -50 | | } +45 | / if 42 == 1337 { +46 | | if 'a' != 'A' { +47 | | println!("world!") +48 | | } +49 | | } | |_____^ help: try | -46 | if 42 == 1337 && 'a' != 'A' { -47 | println!("world!") -48 | } +45 | if 42 == 1337 && 'a' != 'A' { +46 | println!("world!") +47 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:55:12 + --> $DIR/collapsible_if.rs:54:12 | -55 | } else { +54 | } else { | ____________^ -56 | | if y == "world" { -57 | | println!("world!") -58 | | } -59 | | } +55 | | if y == "world" { +56 | | println!("world!") +57 | | } +58 | | } | |_____^ help: try | -55 | } else if y == "world" { -56 | println!("world!") -57 | } +54 | } else if y == "world" { +55 | println!("world!") +56 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:63:12 + --> $DIR/collapsible_if.rs:62:12 | -63 | } else { +62 | } else { | ____________^ -64 | | if let Some(42) = Some(42) { -65 | | println!("world!") -66 | | } -67 | | } +63 | | if let Some(42) = Some(42) { +64 | | println!("world!") +65 | | } +66 | | } | |_____^ help: try | -63 | } else if let Some(42) = Some(42) { -64 | println!("world!") -65 | } +62 | } else if let Some(42) = Some(42) { +63 | println!("world!") +64 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:71:12 + --> $DIR/collapsible_if.rs:70:12 | -71 | } else { +70 | } else { | ____________^ -72 | | if y == "world" { -73 | | println!("world") -74 | | } +71 | | if y == "world" { +72 | | println!("world") +73 | | } ... | -77 | | } -78 | | } +76 | | } +77 | | } | |_____^ help: try | -71 | } else if y == "world" { -72 | println!("world") -73 | } -74 | else { -75 | println!("!") -76 | } +70 | } else if y == "world" { +71 | println!("world") +72 | } +73 | else { +74 | println!("!") +75 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:82:12 + --> $DIR/collapsible_if.rs:81:12 | -82 | } else { +81 | } else { | ____________^ -83 | | if let Some(42) = Some(42) { -84 | | println!("world") -85 | | } +82 | | if let Some(42) = Some(42) { +83 | | println!("world") +84 | | } ... | -88 | | } -89 | | } +87 | | } +88 | | } | |_____^ help: try | -82 | } else if let Some(42) = Some(42) { -83 | println!("world") -84 | } -85 | else { -86 | println!("!") -87 | } +81 | } else if let Some(42) = Some(42) { +82 | println!("world") +83 | } +84 | else { +85 | println!("!") +86 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:93:12 - | -93 | } else { - | ____________^ -94 | | if let Some(42) = Some(42) { -95 | | println!("world") -96 | | } -... | -99 | | } -100 | | } - | |_____^ + --> $DIR/collapsible_if.rs:92:12 + | +92 | } else { + | ____________^ +93 | | if let Some(42) = Some(42) { +94 | | println!("world") +95 | | } +... | +98 | | } +99 | | } + | |_____^ help: try - | -93 | } else if let Some(42) = Some(42) { -94 | println!("world") -95 | } -96 | else { -97 | println!("!") -98 | } - | + | +92 | } else if let Some(42) = Some(42) { +93 | println!("world") +94 | } +95 | else { +96 | println!("!") +97 | } + | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:104:12 + --> $DIR/collapsible_if.rs:103:12 | -104 | } else { +103 | } else { | ____________^ -105 | | if x == "hello" { -106 | | println!("world") -107 | | } +104 | | if x == "hello" { +105 | | println!("world") +106 | | } ... | -110 | | } -111 | | } +109 | | } +110 | | } | |_____^ help: try | -104 | } else if x == "hello" { -105 | println!("world") -106 | } -107 | else { -108 | println!("!") -109 | } +103 | } else if x == "hello" { +104 | println!("world") +105 | } +106 | else { +107 | println!("!") +108 | } | error: this `else { if .. }` block can be collapsed - --> $DIR/collapsible_if.rs:115:12 + --> $DIR/collapsible_if.rs:114:12 | -115 | } else { +114 | } else { | ____________^ -116 | | if let Some(42) = Some(42) { -117 | | println!("world") -118 | | } +115 | | if let Some(42) = Some(42) { +116 | | println!("world") +117 | | } ... | -121 | | } -122 | | } +120 | | } +121 | | } | |_____^ help: try | -115 | } else if let Some(42) = Some(42) { -116 | println!("world") -117 | } -118 | else { -119 | println!("!") -120 | } +114 | } else if let Some(42) = Some(42) { +115 | println!("world") +116 | } +117 | else { +118 | println!("!") +119 | } | error: this if statement can be collapsed - --> $DIR/collapsible_if.rs:174:5 + --> $DIR/collapsible_if.rs:173:5 | -174 | / if x == "hello" { -175 | | if y == "world" { // Collapsible -176 | | println!("Hello world!"); -177 | | } -178 | | } +173 | / if x == "hello" { +174 | | if y == "world" { // Collapsible +175 | | println!("Hello world!"); +176 | | } +177 | | } | |_____^ help: try | -174 | if x == "hello" && y == "world" { // Collapsible -175 | println!("Hello world!"); -176 | } +173 | if x == "hello" && y == "world" { // Collapsible +174 | println!("Hello world!"); +175 | } | error: aborting due to 14 previous errors diff --git a/tests/ui/complex_types.stderr b/tests/ui/complex_types.stderr index f373f09951bf..80f133fd1ce8 100644 --- a/tests/ui/complex_types.stderr +++ b/tests/ui/complex_types.stderr @@ -1,93 +1,93 @@ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:19:12 + --> $DIR/complex_types.rs:16:12 | -19 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +16 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::type-complexity` implied by `-D warnings` error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:20:12 + --> $DIR/complex_types.rs:17:12 | -20 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +17 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:23:8 + --> $DIR/complex_types.rs:20:8 | -23 | f: Vec>>, +20 | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:26:11 + --> $DIR/complex_types.rs:23:11 | -26 | struct TS(Vec>>); +23 | struct TS(Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:29:11 + --> $DIR/complex_types.rs:26:11 | -29 | Tuple(Vec>>), +26 | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:30:17 + --> $DIR/complex_types.rs:27:17 | -30 | Struct { f: Vec>> }, +27 | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:34:14 + --> $DIR/complex_types.rs:31:14 | -34 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +31 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:35:30 + --> $DIR/complex_types.rs:32:30 | -35 | fn impl_method(&self, p: Vec>>) { } +32 | fn impl_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:39:14 + --> $DIR/complex_types.rs:36:14 | -39 | const A: Vec>>; +36 | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:40:14 + --> $DIR/complex_types.rs:37:14 | -40 | type B = Vec>>; +37 | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:41:25 + --> $DIR/complex_types.rs:38:25 | -41 | fn method(&self, p: Vec>>); +38 | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:42:29 + --> $DIR/complex_types.rs:39:29 | -42 | fn def_method(&self, p: Vec>>) { } +39 | fn def_method(&self, p: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:45:15 + --> $DIR/complex_types.rs:42:15 | -45 | fn test1() -> Vec>> { vec![] } +42 | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:47:14 + --> $DIR/complex_types.rs:46:14 | -47 | fn test2(_x: Vec>>) { } +46 | fn test2(_x: Vec>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: very complex type used. Consider factoring parts into `type` definitions - --> $DIR/complex_types.rs:50:13 + --> $DIR/complex_types.rs:49:13 | -50 | let _y: Vec>> = vec![]; +49 | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 15 previous errors diff --git a/tests/ui/const_static_lifetime.stderr b/tests/ui/const_static_lifetime.stderr index 908a681584df..ba53d0718fcb 100644 --- a/tests/ui/const_static_lifetime.stderr +++ b/tests/ui/const_static_lifetime.stderr @@ -1,81 +1,81 @@ error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:14:17 + --> $DIR/const_static_lifetime.rs:13:17 | -14 | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. +13 | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^---- help: consider removing `'static`: `&str` | = note: `-D clippy::const-static-lifetime` implied by `-D warnings` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:18:21 + --> $DIR/const_static_lifetime.rs:17:21 | -18 | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static +17 | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:20:32 + --> $DIR/const_static_lifetime.rs:19:32 | -20 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +19 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:20:47 + --> $DIR/const_static_lifetime.rs:19:47 | -20 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static +19 | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:22:18 + --> $DIR/const_static_lifetime.rs:21:18 | -22 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +21 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static | -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:22:30 + --> $DIR/const_static_lifetime.rs:21:30 | -22 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static +21 | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:24:17 + --> $DIR/const_static_lifetime.rs:23:17 | -24 | const VAR_SIX: &'static u8 = &5; +23 | const VAR_SIX: &'static u8 = &5; | -^^^^^^^--- help: consider removing `'static`: `&u8` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:26:29 + --> $DIR/const_static_lifetime.rs:25:29 | -26 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; +25 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:26:39 + --> $DIR/const_static_lifetime.rs:25:39 | -26 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; +25 | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])]; | -^^^^^^^---- help: consider removing `'static`: `&str` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:28:20 + --> $DIR/const_static_lifetime.rs:27:20 | -28 | const VAR_HEIGHT: &'static Foo = &Foo {}; +27 | const VAR_HEIGHT: &'static Foo = &Foo {}; | -^^^^^^^---- help: consider removing `'static`: `&Foo` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:30:19 + --> $DIR/const_static_lifetime.rs:29:19 | -30 | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. +29 | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static. | -^^^^^^^----- help: consider removing `'static`: `&[u8]` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:32:19 + --> $DIR/const_static_lifetime.rs:31:19 | -32 | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. +31 | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static. | -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)` error: Constants have by default a `'static` lifetime - --> $DIR/const_static_lifetime.rs:34:19 + --> $DIR/const_static_lifetime.rs:33:19 | -34 | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. +33 | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static. | -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]` error: aborting due to 13 previous errors diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index e5f808218fe9..e41fac0f6869 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,385 +1,392 @@ error: this `if` has identical blocks - --> $DIR/copies.rs:41:10 + --> $DIR/copies.rs:50:12 | -41 | else { //~ ERROR same body as `if` block - | __________^ -42 | | Foo { bar: 42 }; -43 | | 0..10; -44 | | ..; +50 | } else { + | ____________^ +51 | | //~ ERROR same body as `if` block +52 | | Foo { bar: 42 }; +53 | | 0..10; ... | -48 | | foo(); -49 | | } +58 | | foo(); +59 | | } | |_____^ | = note: `-D clippy::if-same-then-else` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:32:13 + --> $DIR/copies.rs:42:13 | -32 | if true { +42 | if true { | _____________^ -33 | | Foo { bar: 42 }; -34 | | 0..10; -35 | | ..; +43 | | Foo { bar: 42 }; +44 | | 0..10; +45 | | ..; ... | -39 | | foo(); -40 | | } +49 | | foo(); +50 | | } else { | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:90:14 - | -90 | _ => { //~ ERROR match arms have same body - | ______________^ -91 | | foo(); -92 | | let mut a = 42 + [23].len() as i32; -93 | | if true { -... | -97 | | a -98 | | } - | |_________^ - | - = note: `-D clippy::match-same-arms` implied by `-D warnings` + --> $DIR/copies.rs:96:14 + | +96 | _ => { + | ______________^ +97 | | //~ ERROR match arms have same body +98 | | foo(); +99 | | let mut a = 42 + [23].len() as i32; +... | +104 | | a +105 | | }, + | |_________^ + | + = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:81:15 - | -81 | 42 => { - | _______________^ -82 | | foo(); -83 | | let mut a = 42 + [23].len() as i32; -84 | | if true { -... | -88 | | a -89 | | } - | |_________^ + --> $DIR/copies.rs:87:15 + | +87 | 42 => { + | _______________^ +88 | | foo(); +89 | | let mut a = 42 + [23].len() as i32; +90 | | if true { +... | +94 | | a +95 | | }, + | |_________^ note: `42` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:81:15 - | -81 | 42 => { - | _______________^ -82 | | foo(); -83 | | let mut a = 42 + [23].len() as i32; -84 | | if true { -... | -88 | | a -89 | | } - | |_________^ + --> $DIR/copies.rs:87:15 + | +87 | 42 => { + | _______________^ +88 | | foo(); +89 | | let mut a = 42 + [23].len() as i32; +90 | | if true { +... | +94 | | a +95 | | }, + | |_________^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:104:14 + --> $DIR/copies.rs:111:14 | -104 | _ => 0, //~ ERROR match arms have same body +111 | _ => 0, //~ ERROR match arms have same body | ^ | note: same as this - --> $DIR/copies.rs:102:19 + --> $DIR/copies.rs:109:19 | -102 | Abc::A => 0, +109 | Abc::A => 0, | ^ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` - --> $DIR/copies.rs:102:19 + --> $DIR/copies.rs:109:19 | -102 | Abc::A => 0, +109 | Abc::A => 0, | ^ error: this `if` has identical blocks - --> $DIR/copies.rs:114:10 + --> $DIR/copies.rs:120:12 | -114 | else { //~ ERROR same body as `if` block - | __________^ -115 | | 42 -116 | | }; +120 | } else { + | ____________^ +121 | | //~ ERROR same body as `if` block +122 | | 42 +123 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:111:21 + --> $DIR/copies.rs:118:21 | -111 | let _ = if true { +118 | let _ = if true { | _____________________^ -112 | | 42 -113 | | } +119 | | 42 +120 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:128:10 + --> $DIR/copies.rs:134:12 | -128 | else { //~ ERROR same body as `if` block - | __________^ -129 | | for _ in &[42] { -130 | | let foo: &Option<_> = &Some::(42); -131 | | if true { +134 | } else { + | ____________^ +135 | | //~ ERROR same body as `if` block +136 | | for _ in &[42] { +137 | | let foo: &Option<_> = &Some::(42); ... | -136 | | } -137 | | } +143 | | } +144 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:118:13 + --> $DIR/copies.rs:125:13 | -118 | if true { +125 | if true { | _____________^ -119 | | for _ in &[42] { -120 | | let foo: &Option<_> = &Some::(42); -121 | | if true { +126 | | for _ in &[42] { +127 | | let foo: &Option<_> = &Some::(42); +128 | | if true { ... | -126 | | } -127 | | } +133 | | } +134 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:150:10 + --> $DIR/copies.rs:153:12 | -150 | else { //~ ERROR same body as `if` block - | __________^ -151 | | let bar = if true { -152 | | 42 -153 | | } +153 | } else { + | ____________^ +154 | | //~ ERROR same body as `if` block +155 | | let bar = if true { 42 } else { 43 }; +156 | | ... | -159 | | bar + 1; -160 | | } +160 | | bar + 1; +161 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:139:13 + --> $DIR/copies.rs:146:13 | -139 | if true { +146 | if true { | _____________^ -140 | | let bar = if true { -141 | | 42 -142 | | } +147 | | let bar = if true { 42 } else { 43 }; +148 | | +149 | | while foo() { ... | -148 | | bar + 1; -149 | | } +152 | | bar + 1; +153 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:185:10 + --> $DIR/copies.rs:183:12 | -185 | else { //~ ERROR same body as `if` block - | __________^ -186 | | if let Some(a) = Some(42) {} -187 | | } +183 | } else { + | ____________^ +184 | | //~ ERROR same body as `if` block +185 | | if let Some(a) = Some(42) {} +186 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:182:13 + --> $DIR/copies.rs:181:13 | -182 | if true { +181 | if true { | _____________^ -183 | | if let Some(a) = Some(42) {} -184 | | } +182 | | if let Some(a) = Some(42) {} +183 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:192:10 + --> $DIR/copies.rs:190:12 | -192 | else { //~ ERROR same body as `if` block - | __________^ -193 | | if let (1, .., 3) = (1, 2, 3) {} -194 | | } +190 | } else { + | ____________^ +191 | | //~ ERROR same body as `if` block +192 | | if let (1, .., 3) = (1, 2, 3) {} +193 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:189:13 + --> $DIR/copies.rs:188:13 | -189 | if true { +188 | if true { | _____________^ -190 | | if let (1, .., 3) = (1, 2, 3) {} -191 | | } +189 | | if let (1, .., 3) = (1, 2, 3) {} +190 | | } else { | |_____^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:247:15 + --> $DIR/copies.rs:239:15 | -247 | 51 => foo(), //~ ERROR match arms have same body +239 | 51 => foo(), //~ ERROR match arms have same body | ^^^^^ | note: same as this - --> $DIR/copies.rs:246:15 + --> $DIR/copies.rs:238:15 | -246 | 42 => foo(), +238 | 42 => foo(), | ^^^^^ note: consider refactoring into `42 | 51` - --> $DIR/copies.rs:246:15 + --> $DIR/copies.rs:238:15 | -246 | 42 => foo(), +238 | 42 => foo(), | ^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:253:17 + --> $DIR/copies.rs:245:17 | -253 | None => 24, //~ ERROR match arms have same body +245 | None => 24, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:252:20 + --> $DIR/copies.rs:244:20 | -252 | Some(_) => 24, +244 | Some(_) => 24, | ^^ note: consider refactoring into `Some(_) | None` - --> $DIR/copies.rs:252:20 + --> $DIR/copies.rs:244:20 | -252 | Some(_) => 24, +244 | Some(_) => 24, | ^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:275:28 + --> $DIR/copies.rs:267:28 | -275 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body +267 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:274:28 + --> $DIR/copies.rs:266:28 | -274 | (Some(a), None) => bar(a), +266 | (Some(a), None) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), None) | (None, Some(a))` - --> $DIR/copies.rs:274:28 + --> $DIR/copies.rs:266:28 | -274 | (Some(a), None) => bar(a), +266 | (Some(a), None) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:281:26 + --> $DIR/copies.rs:273:26 | -281 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body +273 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body | ^^^^^^ | note: same as this - --> $DIR/copies.rs:280:26 + --> $DIR/copies.rs:272:26 | -280 | (Some(a), ..) => bar(a), +272 | (Some(a), ..) => bar(a), | ^^^^^^ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` - --> $DIR/copies.rs:280:26 + --> $DIR/copies.rs:272:26 | -280 | (Some(a), ..) => bar(a), +272 | (Some(a), ..) => bar(a), | ^^^^^^ error: this `match` has identical arm bodies - --> $DIR/copies.rs:287:20 + --> $DIR/copies.rs:279:20 | -287 | (.., 3) => 42, //~ ERROR match arms have same body +279 | (.., 3) => 42, //~ ERROR match arms have same body | ^^ | note: same as this - --> $DIR/copies.rs:286:23 + --> $DIR/copies.rs:278:23 | -286 | (1, .., 3) => 42, +278 | (1, .., 3) => 42, | ^^ note: consider refactoring into `(1, .., 3) | (.., 3)` - --> $DIR/copies.rs:286:23 + --> $DIR/copies.rs:278:23 | -286 | (1, .., 3) => 42, +278 | (1, .., 3) => 42, | ^^ error: this `if` has identical blocks - --> $DIR/copies.rs:293:12 + --> $DIR/copies.rs:285:12 | -293 | } else { //~ ERROR same body as `if` block +285 | } else { | ____________^ -294 | | 0.0 -295 | | }; +286 | | //~ ERROR same body as `if` block +287 | | 0.0 +288 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:291:21 + --> $DIR/copies.rs:283:21 | -291 | let _ = if true { +283 | let _ = if true { | _____________________^ -292 | | 0.0 -293 | | } else { //~ ERROR same body as `if` block +284 | | 0.0 +285 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:299:12 + --> $DIR/copies.rs:292:12 | -299 | } else { //~ ERROR same body as `if` block +292 | } else { | ____________^ -300 | | -0.0 -301 | | }; +293 | | //~ ERROR same body as `if` block +294 | | -0.0 +295 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:297:21 + --> $DIR/copies.rs:290:21 | -297 | let _ = if true { +290 | let _ = if true { | _____________________^ -298 | | -0.0 -299 | | } else { //~ ERROR same body as `if` block +291 | | -0.0 +292 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:319:12 + --> $DIR/copies.rs:305:12 | -319 | } else { //~ ERROR same body as `if` block +305 | } else { | ____________^ -320 | | std::f32::NAN -321 | | }; +306 | | //~ ERROR same body as `if` block +307 | | std::f32::NAN +308 | | }; | |_____^ | note: same as this - --> $DIR/copies.rs:317:21 + --> $DIR/copies.rs:303:21 | -317 | let _ = if true { +303 | let _ = if true { | _____________________^ -318 | | std::f32::NAN -319 | | } else { //~ ERROR same body as `if` block +304 | | std::f32::NAN +305 | | } else { | |_____^ error: this `if` has identical blocks - --> $DIR/copies.rs:337:10 + --> $DIR/copies.rs:323:12 | -337 | else { //~ ERROR same body as `if` block - | __________^ -338 | | try!(Ok("foo")); -339 | | } +323 | } else { + | ____________^ +324 | | //~ ERROR same body as `if` block +325 | | try!(Ok("foo")); +326 | | } | |_____^ | note: same as this - --> $DIR/copies.rs:334:13 + --> $DIR/copies.rs:321:13 | -334 | if true { +321 | if true { | _____________^ -335 | | try!(Ok("foo")); -336 | | } +322 | | try!(Ok("foo")); +323 | | } else { | |_____^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:363:13 + --> $DIR/copies.rs:347:15 | -363 | else if b { //~ ERROR ifs same condition - | ^ +347 | } else if b { + | ^ | = note: `-D clippy::ifs-same-cond` implied by `-D warnings` note: same as this - --> $DIR/copies.rs:361:8 + --> $DIR/copies.rs:346:8 | -361 | if b { +346 | if b { | ^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:368:13 + --> $DIR/copies.rs:352:15 | -368 | else if a == 1 { //~ ERROR ifs same condition - | ^^^^^^ +352 | } else if a == 1 { + | ^^^^^^ | note: same as this - --> $DIR/copies.rs:366:8 + --> $DIR/copies.rs:351:8 | -366 | if a == 1 { +351 | if a == 1 { | ^^^^^^ error: this `if` has the same condition as a previous if - --> $DIR/copies.rs:375:13 + --> $DIR/copies.rs:358:15 | -375 | else if 2*a == 1 { //~ ERROR ifs same condition - | ^^^^^^^^ +358 | } else if 2 * a == 1 { + | ^^^^^^^^^^ | note: same as this - --> $DIR/copies.rs:371:8 + --> $DIR/copies.rs:356:8 | -371 | if 2*a == 1 { - | ^^^^^^^^ +356 | if 2 * a == 1 { + | ^^^^^^^^^^ error: aborting due to 20 previous errors diff --git a/tests/ui/copy_iterator.stderr b/tests/ui/copy_iterator.stderr index 4620958f47b1..ced9293d1dc9 100644 --- a/tests/ui/copy_iterator.stderr +++ b/tests/ui/copy_iterator.stderr @@ -1,13 +1,13 @@ error: you are implementing `Iterator` on a `Copy` type - --> $DIR/copy_iterator.rs:18:1 + --> $DIR/copy_iterator.rs:15:1 | -18 | / impl Iterator for Countdown { -19 | | type Item = u8; -20 | | -21 | | fn next(&mut self) -> Option { +15 | / impl Iterator for Countdown { +16 | | type Item = u8; +17 | | +18 | | fn next(&mut self) -> Option { ... | -26 | | } -27 | | } +23 | | } +24 | | } | |_^ | = note: `-D clippy::copy-iterator` implied by `-D warnings` diff --git a/tests/ui/cstring.stderr b/tests/ui/cstring.stderr index 74d6e864de4e..490a655ca262 100644 --- a/tests/ui/cstring.stderr +++ b/tests/ui/cstring.stderr @@ -1,15 +1,15 @@ error: you are getting the inner pointer of a temporary `CString` - --> $DIR/cstring.rs:19:5 + --> $DIR/cstring.rs:16:5 | -19 | CString::new("foo").unwrap().as_ptr(); +16 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(clippy::temporary_cstring_as_ptr)] on by default = note: that pointer will be invalid outside this expression help: assign the `CString` to a variable to extend its lifetime - --> $DIR/cstring.rs:19:5 + --> $DIR/cstring.rs:16:5 | -19 | CString::new("foo").unwrap().as_ptr(); +16 | CString::new("foo").unwrap().as_ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/cyclomatic_complexity.stderr b/tests/ui/cyclomatic_complexity.stderr index 390df2f5a5b6..de9e5c77f1b2 100644 --- a/tests/ui/cyclomatic_complexity.stderr +++ b/tests/ui/cyclomatic_complexity.stderr @@ -1,270 +1,269 @@ error: the function has a cyclomatic complexity of 28 - --> $DIR/cyclomatic_complexity.rs:16:1 + --> $DIR/cyclomatic_complexity.rs:15:1 | -16 | / fn main() { -17 | | if true { -18 | | println!("a"); -19 | | } +15 | / fn main() { +16 | | if true { +17 | | println!("a"); +18 | | } ... | -97 | | } -98 | | } +96 | | } +97 | | } | |_^ | = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 7 - --> $DIR/cyclomatic_complexity.rs:101:1 + --> $DIR/cyclomatic_complexity.rs:100:1 | -101 | / fn kaboom() { -102 | | let n = 0; -103 | | 'a: for i in 0..20 { -104 | | 'b: for j in i..20 { +100 | / fn kaboom() { +101 | | let n = 0; +102 | | 'a: for i in 0..20 { +103 | | 'b: for j in i..20 { ... | -119 | | } -120 | | } +118 | | } +119 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:147:1 + --> $DIR/cyclomatic_complexity.rs:146:1 | -147 | / fn lots_of_short_circuits() -> bool { -148 | | true && false && true && false && true && false && true -149 | | } +146 | / fn lots_of_short_circuits() -> bool { +147 | | true && false && true && false && true && false && true +148 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:152:1 + --> $DIR/cyclomatic_complexity.rs:151:1 | -152 | / fn lots_of_short_circuits2() -> bool { -153 | | true || false || true || false || true || false || true -154 | | } +151 | / fn lots_of_short_circuits2() -> bool { +152 | | true || false || true || false || true || false || true +153 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:157:1 + --> $DIR/cyclomatic_complexity.rs:156:1 | -157 | / fn baa() { -158 | | let x = || match 99 { -159 | | 0 => 0, -160 | | 1 => 1, +156 | / fn baa() { +157 | | let x = || match 99 { +158 | | 0 => 0, +159 | | 1 => 1, ... | -171 | | } -172 | | } +170 | | } +171 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:158:13 + --> $DIR/cyclomatic_complexity.rs:157:13 | -158 | let x = || match 99 { +157 | let x = || match 99 { | _____________^ -159 | | 0 => 0, -160 | | 1 => 1, -161 | | 2 => 2, +158 | | 0 => 0, +159 | | 1 => 1, +160 | | 2 => 2, ... | -165 | | _ => 42, -166 | | }; +164 | | _ => 42, +165 | | }; | |_____^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:175:1 - | -175 | / fn bar() { -176 | | match 99 { -177 | | 0 => println!("hi"), -178 | | _ => println!("bye"), -179 | | } -180 | | } + --> $DIR/cyclomatic_complexity.rs:174:1 + | +174 | / fn bar() { +175 | | match 99 { +176 | | 0 => println!("hi"), +177 | | _ => println!("bye"), +178 | | } +179 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:194:1 + --> $DIR/cyclomatic_complexity.rs:193:1 | -194 | / fn barr() { -195 | | match 99 { -196 | | 0 => println!("hi"), -197 | | 1 => println!("bla"), +193 | / fn barr() { +194 | | match 99 { +195 | | 0 => println!("hi"), +196 | | 1 => println!("bla"), ... | -200 | | } -201 | | } +199 | | } +200 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:204:1 + --> $DIR/cyclomatic_complexity.rs:203:1 | -204 | / fn barr2() { -205 | | match 99 { -206 | | 0 => println!("hi"), -207 | | 1 => println!("bla"), +203 | / fn barr2() { +204 | | match 99 { +205 | | 0 => println!("hi"), +206 | | 1 => println!("bla"), ... | -216 | | } -217 | | } +215 | | } +216 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:220:1 + --> $DIR/cyclomatic_complexity.rs:219:1 | -220 | / fn barrr() { -221 | | match 99 { -222 | | 0 => println!("hi"), -223 | | 1 => panic!("bla"), +219 | / fn barrr() { +220 | | match 99 { +221 | | 0 => println!("hi"), +222 | | 1 => panic!("bla"), ... | -226 | | } -227 | | } +225 | | } +226 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:230:1 + --> $DIR/cyclomatic_complexity.rs:229:1 | -230 | / fn barrr2() { -231 | | match 99 { -232 | | 0 => println!("hi"), -233 | | 1 => panic!("bla"), +229 | / fn barrr2() { +230 | | match 99 { +231 | | 0 => println!("hi"), +232 | | 1 => panic!("bla"), ... | -242 | | } -243 | | } +241 | | } +242 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:246:1 + --> $DIR/cyclomatic_complexity.rs:245:1 | -246 | / fn barrrr() { -247 | | match 99 { -248 | | 0 => println!("hi"), -249 | | 1 => println!("bla"), +245 | / fn barrrr() { +246 | | match 99 { +247 | | 0 => println!("hi"), +248 | | 1 => println!("bla"), ... | -252 | | } -253 | | } +251 | | } +252 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity.rs:256:1 + --> $DIR/cyclomatic_complexity.rs:255:1 | -256 | / fn barrrr2() { -257 | | match 99 { -258 | | 0 => println!("hi"), -259 | | 1 => println!("bla"), +255 | / fn barrrr2() { +256 | | match 99 { +257 | | 0 => println!("hi"), +258 | | 1 => println!("bla"), ... | -268 | | } -269 | | } +267 | | } +268 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 2 - --> $DIR/cyclomatic_complexity.rs:272:1 + --> $DIR/cyclomatic_complexity.rs:271:1 | -272 | / fn cake() { -273 | | if 4 == 5 { -274 | | println!("yea"); -275 | | } else { +271 | / fn cake() { +272 | | if 4 == 5 { +273 | | println!("yea"); +274 | | } else { ... | -278 | | println!("whee"); -279 | | } +277 | | println!("whee"); +278 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 4 - --> $DIR/cyclomatic_complexity.rs:283:1 + --> $DIR/cyclomatic_complexity.rs:281:1 | -283 | / pub fn read_file(input_path: &str) -> String { -284 | | use std::fs::File; -285 | | use std::io::{Read, Write}; -286 | | use std::path::Path; +281 | / pub fn read_file(input_path: &str) -> String { +282 | | use std::fs::File; +283 | | use std::io::{Read, Write}; +284 | | use std::path::Path; ... | -308 | | } -309 | | } +306 | | } +307 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:314:1 - | -314 | / fn void(void: Void) { -315 | | if true { -316 | | match void { -317 | | } -318 | | } -319 | | } + --> $DIR/cyclomatic_complexity.rs:312:1 + | +312 | / fn void(void: Void) { +313 | | if true { +314 | | match void {} +315 | | } +316 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:328:1 - | -328 | / fn try() -> Result { -329 | | match 5 { -330 | | 5 => Ok(5), -331 | | _ => return Err("bla"), -332 | | } -333 | | } + --> $DIR/cyclomatic_complexity.rs:325:1 + | +325 | / fn try() -> Result { +326 | | match 5 { +327 | | 5 => Ok(5), +328 | | _ => return Err("bla"), +329 | | } +330 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:336:1 + --> $DIR/cyclomatic_complexity.rs:333:1 | -336 | / fn try_again() -> Result { -337 | | let _ = try!(Ok(42)); -338 | | let _ = try!(Ok(43)); -339 | | let _ = try!(Ok(44)); +333 | / fn try_again() -> Result { +334 | | let _ = try!(Ok(42)); +335 | | let _ = try!(Ok(43)); +336 | | let _ = try!(Ok(44)); ... | -348 | | } -349 | | } +345 | | } +346 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 1 - --> $DIR/cyclomatic_complexity.rs:352:1 + --> $DIR/cyclomatic_complexity.rs:349:1 | -352 | / fn early() -> Result { -353 | | return Ok(5); -354 | | return Ok(5); -355 | | return Ok(5); +349 | / fn early() -> Result { +350 | | return Ok(5); +351 | | return Ok(5); +352 | | return Ok(5); ... | -361 | | return Ok(5); -362 | | } +358 | | return Ok(5); +359 | | } | |_^ | = help: you could split it up into multiple smaller functions error: the function has a cyclomatic complexity of 8 - --> $DIR/cyclomatic_complexity.rs:366:1 + --> $DIR/cyclomatic_complexity.rs:363:1 | -366 | / fn early_ret() -> i32 { -367 | | let a = if true { 42 } else { return 0; }; -368 | | let a = if a < 99 { 42 } else { return 0; }; -369 | | let a = if a < 99 { 42 } else { return 0; }; +363 | / fn early_ret() -> i32 { +364 | | let a = if true { 42 } else { return 0; }; +365 | | let a = if a < 99 { 42 } else { return 0; }; +366 | | let a = if a < 99 { 42 } else { return 0; }; ... | -382 | | } -383 | | } +379 | | } +380 | | } | |_^ | = help: you could split it up into multiple smaller functions diff --git a/tests/ui/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index f066e29ce752..3493c0d9ea54 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.stderr +++ b/tests/ui/cyclomatic_complexity_attr_used.stderr @@ -1,13 +1,13 @@ error: the function has a cyclomatic complexity of 3 - --> $DIR/cyclomatic_complexity_attr_used.rs:21:1 + --> $DIR/cyclomatic_complexity_attr_used.rs:18:1 | -21 | / fn kaboom() { -22 | | if 42 == 43 { -23 | | panic!(); -24 | | } else if "cake" == "lie" { -25 | | println!("what?"); -26 | | } -27 | | } +18 | / fn kaboom() { +19 | | if 42 == 43 { +20 | | panic!(); +21 | | } else if "cake" == "lie" { +22 | | println!("what?"); +23 | | } +24 | | } | |_^ | = note: `-D clippy::cyclomatic-complexity` implied by `-D warnings` diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index d944c49066ab..42f8a6e3bc54 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -1,33 +1,33 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:28:9 + --> $DIR/decimal_literal_representation.rs:26:9 | -28 | 32_773, // 0x8005 +26 | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` | = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:29:9 + --> $DIR/decimal_literal_representation.rs:27:9 | -29 | 65_280, // 0xFF00 +27 | 65_280, // 0xFF00 | ^^^^^^ help: consider: `0xFF00` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:30:9 + --> $DIR/decimal_literal_representation.rs:28:9 | -30 | 2_131_750_927, // 0x7F0F_F00F +28 | 2_131_750_927, // 0x7F0F_F00F | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:31:9 + --> $DIR/decimal_literal_representation.rs:29:9 | -31 | 2_147_483_647, // 0x7FFF_FFFF +29 | 2_147_483_647, // 0x7FFF_FFFF | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:32:9 + --> $DIR/decimal_literal_representation.rs:30:9 | -32 | 4_042_322_160, // 0xF0F0_F0F0 +30 | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` error: aborting due to 5 previous errors diff --git a/tests/ui/default_trait_access.stderr b/tests/ui/default_trait_access.stderr index d6ae00214c04..b838f6a3bf4e 100644 --- a/tests/ui/default_trait_access.stderr +++ b/tests/ui/default_trait_access.stderr @@ -1,51 +1,51 @@ error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:20:22 + --> $DIR/default_trait_access.rs:17:22 | -20 | let s1: String = Default::default(); +17 | let s1: String = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` | = note: `-D clippy::default-trait-access` implied by `-D warnings` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:24:22 + --> $DIR/default_trait_access.rs:21:22 | -24 | let s3: String = D2::default(); +21 | let s3: String = D2::default(); | ^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:26:22 + --> $DIR/default_trait_access.rs:23:22 | -26 | let s4: String = std::default::Default::default(); +23 | let s4: String = std::default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling std::string::String::default() is more clear than this expression - --> $DIR/default_trait_access.rs:30:22 + --> $DIR/default_trait_access.rs:27:22 | -30 | let s6: String = default::Default::default(); +27 | let s6: String = default::Default::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::string::String::default()` error: Calling GenericDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:40:46 + --> $DIR/default_trait_access.rs:37:46 | -40 | let s11: GenericDerivedDefault = Default::default(); +37 | let s11: GenericDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `GenericDerivedDefault::default()` error: Calling TupleDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:46:36 + --> $DIR/default_trait_access.rs:43:36 | -46 | let s14: TupleDerivedDefault = Default::default(); +43 | let s14: TupleDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleDerivedDefault::default()` error: Calling ArrayDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:48:36 + --> $DIR/default_trait_access.rs:45:36 | -48 | let s15: ArrayDerivedDefault = Default::default(); +45 | let s15: ArrayDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `ArrayDerivedDefault::default()` error: Calling TupleStructDerivedDefault::default() is more clear than this expression - --> $DIR/default_trait_access.rs:52:42 + --> $DIR/default_trait_access.rs:49:42 | -52 | let s17: TupleStructDerivedDefault = Default::default(); +49 | let s17: TupleStructDerivedDefault = Default::default(); | ^^^^^^^^^^^^^^^^^^ help: try: `TupleStructDerivedDefault::default()` error: aborting due to 8 previous errors diff --git a/tests/ui/deprecated.stderr b/tests/ui/deprecated.stderr index d44528ab28f5..335f6451e592 100644 --- a/tests/ui/deprecated.stderr +++ b/tests/ui/deprecated.stderr @@ -1,33 +1,33 @@ error: lint `str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon` - --> $DIR/deprecated.rs:14:8 + --> $DIR/deprecated.rs:10:8 | -14 | #[warn(str_to_string)] +10 | #[warn(str_to_string)] | ^^^^^^^^^^^^^ | = note: `-D renamed-and-removed-lints` implied by `-D warnings` error: lint `string_to_string` has been removed: `using `string::to_string` is common even today and specialization will likely happen soon` - --> $DIR/deprecated.rs:16:8 + --> $DIR/deprecated.rs:11:8 | -16 | #[warn(string_to_string)] +11 | #[warn(string_to_string)] | ^^^^^^^^^^^^^^^^ error: lint `unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7` - --> $DIR/deprecated.rs:18:8 + --> $DIR/deprecated.rs:12:8 | -18 | #[warn(unstable_as_slice)] +12 | #[warn(unstable_as_slice)] | ^^^^^^^^^^^^^^^^^ error: lint `unstable_as_mut_slice` has been removed: ``Vec::as_mut_slice` has been stabilized in 1.7` - --> $DIR/deprecated.rs:20:8 + --> $DIR/deprecated.rs:13:8 | -20 | #[warn(unstable_as_mut_slice)] +13 | #[warn(unstable_as_mut_slice)] | ^^^^^^^^^^^^^^^^^^^^^ error: lint `misaligned_transmute` has been removed: `this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr` - --> $DIR/deprecated.rs:22:8 + --> $DIR/deprecated.rs:14:8 | -22 | #[warn(misaligned_transmute)] +14 | #[warn(misaligned_transmute)] | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index 824b5b44cba7..dd36f773337c 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -1,15 +1,17 @@ error: you are deriving `Hash` but have implemented `PartialEq` explicitly - --> $DIR/derive.rs:27:10 + --> $DIR/derive.rs:25:10 | -27 | #[derive(Hash)] +25 | #[derive(Hash)] | ^^^^ | = note: #[deny(clippy::derive_hash_xor_eq)] on by default note: `PartialEq` implemented here - --> $DIR/derive.rs:30:1 + --> $DIR/derive.rs:28:1 | -30 | / impl PartialEq for Bar { -31 | | fn eq(&self, _: &Bar) -> bool { true } +28 | / impl PartialEq for Bar { +29 | | fn eq(&self, _: &Bar) -> bool { +30 | | true +31 | | } 32 | | } | |_^ @@ -23,88 +25,106 @@ note: `PartialEq` implemented here --> $DIR/derive.rs:37:1 | 37 | / impl PartialEq for Baz { -38 | | fn eq(&self, _: &Baz) -> bool { true } -39 | | } +38 | | fn eq(&self, _: &Baz) -> bool { +39 | | true +40 | | } +41 | | } | |_^ error: you are implementing `Hash` explicitly but have derived `PartialEq` - --> $DIR/derive.rs:44:1 + --> $DIR/derive.rs:46:1 | -44 | / impl Hash for Bah { -45 | | fn hash(&self, _: &mut H) {} -46 | | } +46 | / impl Hash for Bah { +47 | | fn hash(&self, _: &mut H) {} +48 | | } | |_^ | note: `PartialEq` implemented here - --> $DIR/derive.rs:41:10 + --> $DIR/derive.rs:43:10 | -41 | #[derive(PartialEq)] +43 | #[derive(PartialEq)] | ^^^^^^^^^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:51:1 + --> $DIR/derive.rs:53:1 | -51 | / impl Clone for Qux { -52 | | fn clone(&self) -> Self { Qux } -53 | | } +53 | / impl Clone for Qux { +54 | | fn clone(&self) -> Self { +55 | | Qux +56 | | } +57 | | } | |_^ | = note: `-D clippy::expl-impl-clone-on-copy` implied by `-D warnings` note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:51:1 + --> $DIR/derive.rs:53:1 | -51 | / impl Clone for Qux { -52 | | fn clone(&self) -> Self { Qux } -53 | | } +53 | / impl Clone for Qux { +54 | | fn clone(&self) -> Self { +55 | | Qux +56 | | } +57 | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:75:1 + --> $DIR/derive.rs:77:1 | -75 | / impl<'a> Clone for Lt<'a> { -76 | | fn clone(&self) -> Self { unimplemented!() } -77 | | } +77 | / impl<'a> Clone for Lt<'a> { +78 | | fn clone(&self) -> Self { +79 | | unimplemented!() +80 | | } +81 | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:75:1 + --> $DIR/derive.rs:77:1 | -75 | / impl<'a> Clone for Lt<'a> { -76 | | fn clone(&self) -> Self { unimplemented!() } -77 | | } +77 | / impl<'a> Clone for Lt<'a> { +78 | | fn clone(&self) -> Self { +79 | | unimplemented!() +80 | | } +81 | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:85:1 + --> $DIR/derive.rs:89:1 | -85 | / impl Clone for BigArray { -86 | | fn clone(&self) -> Self { unimplemented!() } -87 | | } +89 | / impl Clone for BigArray { +90 | | fn clone(&self) -> Self { +91 | | unimplemented!() +92 | | } +93 | | } | |_^ | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:85:1 + --> $DIR/derive.rs:89:1 | -85 | / impl Clone for BigArray { -86 | | fn clone(&self) -> Self { unimplemented!() } -87 | | } +89 | / impl Clone for BigArray { +90 | | fn clone(&self) -> Self { +91 | | unimplemented!() +92 | | } +93 | | } | |_^ error: you are implementing `Clone` explicitly on a `Copy` type - --> $DIR/derive.rs:95:1 - | -95 | / impl Clone for FnPtr { -96 | | fn clone(&self) -> Self { unimplemented!() } -97 | | } - | |_^ - | + --> $DIR/derive.rs:101:1 + | +101 | / impl Clone for FnPtr { +102 | | fn clone(&self) -> Self { +103 | | unimplemented!() +104 | | } +105 | | } + | |_^ + | note: consider deriving `Clone` or removing `Copy` - --> $DIR/derive.rs:95:1 - | -95 | / impl Clone for FnPtr { -96 | | fn clone(&self) -> Self { unimplemented!() } -97 | | } - | |_^ + --> $DIR/derive.rs:101:1 + | +101 | / impl Clone for FnPtr { +102 | | fn clone(&self) -> Self { +103 | | unimplemented!() +104 | | } +105 | | } + | |_^ error: aborting due to 7 previous errors diff --git a/tests/ui/dlist.stderr b/tests/ui/dlist.stderr index b3dc6095cd85..f2ca4dab9974 100644 --- a/tests/ui/dlist.stderr +++ b/tests/ui/dlist.stderr @@ -1,48 +1,48 @@ error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:24:16 + --> $DIR/dlist.rs:19:16 | -24 | type Baz = LinkedList; +19 | type Baz = LinkedList; | ^^^^^^^^^^^^^^ | = note: `-D clippy::linkedlist` implied by `-D warnings` = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:25:12 + --> $DIR/dlist.rs:20:12 | -25 | fn foo(LinkedList); +20 | fn foo(LinkedList); | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:26:24 + --> $DIR/dlist.rs:21:23 | -26 | const BAR : Option>; - | ^^^^^^^^^^^^^^ +21 | const BAR: Option>; + | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:37:15 + --> $DIR/dlist.rs:32:15 | -37 | fn foo(_: LinkedList) {} +32 | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:40:39 + --> $DIR/dlist.rs:35:39 | -40 | pub fn test(my_favourite_linked_list: LinkedList) { +35 | pub fn test(my_favourite_linked_list: LinkedList) { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work error: I see you're using a LinkedList! Perhaps you meant some other data structure? - --> $DIR/dlist.rs:44:29 + --> $DIR/dlist.rs:39:29 | -44 | pub fn test_ret() -> Option> { +39 | pub fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ | = help: a VecDeque might work diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr index 646b6f13faba..a06f278efc00 100644 --- a/tests/ui/double_comparison.stderr +++ b/tests/ui/double_comparison.stderr @@ -1,51 +1,51 @@ error: This binary expression can be simplified - --> $DIR/double_comparison.rs:14:8 + --> $DIR/double_comparison.rs:13:8 | -14 | if x == y || x < y { +13 | if x == y || x < y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` | = note: `-D clippy::double-comparisons` implied by `-D warnings` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:17:8 + --> $DIR/double_comparison.rs:16:8 | -17 | if x < y || x == y { +16 | if x < y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x <= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:20:8 + --> $DIR/double_comparison.rs:19:8 | -20 | if x == y || x > y { +19 | if x == y || x > y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:23:8 + --> $DIR/double_comparison.rs:22:8 | -23 | if x > y || x == y { +22 | if x > y || x == y { | ^^^^^^^^^^^^^^^ help: try: `x >= y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:26:8 + --> $DIR/double_comparison.rs:25:8 | -26 | if x < y || x > y { +25 | if x < y || x > y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:29:8 + --> $DIR/double_comparison.rs:28:8 | -29 | if x > y || x < y { +28 | if x > y || x < y { | ^^^^^^^^^^^^^^ help: try: `x != y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:32:8 + --> $DIR/double_comparison.rs:31:8 | -32 | if x <= y && x >= y { +31 | if x <= y && x >= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: This binary expression can be simplified - --> $DIR/double_comparison.rs:35:8 + --> $DIR/double_comparison.rs:34:8 | -35 | if x >= y && x <= y { +34 | if x >= y && x <= y { | ^^^^^^^^^^^^^^^^ help: try: `x == y` error: aborting due to 8 previous errors diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index cf0292f7af13..11ad56012862 100644 --- a/tests/ui/double_neg.stderr +++ b/tests/ui/double_neg.stderr @@ -1,7 +1,7 @@ error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op - --> $DIR/double_neg.rs:19:5 + --> $DIR/double_neg.rs:15:5 | -19 | --x; +15 | --x; | ^^^ | = note: `-D clippy::double-neg` implied by `-D warnings` diff --git a/tests/ui/drop_forget_copy.stderr b/tests/ui/drop_forget_copy.stderr index ef337ae66911..3b950eaebe38 100644 --- a/tests/ui/drop_forget_copy.stderr +++ b/tests/ui/drop_forget_copy.stderr @@ -1,75 +1,75 @@ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:43:5 + --> $DIR/drop_forget_copy.rs:42:5 | -43 | drop(s1); +42 | drop(s1); | ^^^^^^^^ | = note: `-D clippy::drop-copy` implied by `-D warnings` note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:43:10 + --> $DIR/drop_forget_copy.rs:42:10 | -43 | drop(s1); +42 | drop(s1); | ^^ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:44:5 + --> $DIR/drop_forget_copy.rs:43:5 | -44 | drop(s2); +43 | drop(s2); | ^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:44:10 + --> $DIR/drop_forget_copy.rs:43:10 | -44 | drop(s2); +43 | drop(s2); | ^^ error: calls to `std::mem::drop` with a value that implements Copy. Dropping a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:46:5 + --> $DIR/drop_forget_copy.rs:45:5 | -46 | drop(s4); +45 | drop(s4); | ^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:46:10 + --> $DIR/drop_forget_copy.rs:45:10 | -46 | drop(s4); +45 | drop(s4); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:49:5 + --> $DIR/drop_forget_copy.rs:48:5 | -49 | forget(s1); +48 | forget(s1); | ^^^^^^^^^^ | = note: `-D clippy::forget-copy` implied by `-D warnings` note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:49:12 + --> $DIR/drop_forget_copy.rs:48:12 | -49 | forget(s1); +48 | forget(s1); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:50:5 + --> $DIR/drop_forget_copy.rs:49:5 | -50 | forget(s2); +49 | forget(s2); | ^^^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:50:12 + --> $DIR/drop_forget_copy.rs:49:12 | -50 | forget(s2); +49 | forget(s2); | ^^ error: calls to `std::mem::forget` with a value that implements Copy. Forgetting a copy leaves the original intact. - --> $DIR/drop_forget_copy.rs:52:5 + --> $DIR/drop_forget_copy.rs:51:5 | -52 | forget(s4); +51 | forget(s4); | ^^^^^^^^^^ | note: argument has type SomeStruct - --> $DIR/drop_forget_copy.rs:52:12 + --> $DIR/drop_forget_copy.rs:51:12 | -52 | forget(s4); +51 | forget(s4); | ^^ error: aborting due to 6 previous errors diff --git a/tests/ui/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 15661ef1d2b1..972ab298c4cd 100644 --- a/tests/ui/drop_forget_ref.stderr +++ b/tests/ui/drop_forget_ref.stderr @@ -1,219 +1,219 @@ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:22:5 + --> $DIR/drop_forget_ref.rs:18:5 | -22 | drop(&SomeStruct); +18 | drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::drop-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:22:10 + --> $DIR/drop_forget_ref.rs:18:10 | -22 | drop(&SomeStruct); +18 | drop(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:23:5 + --> $DIR/drop_forget_ref.rs:19:5 | -23 | forget(&SomeStruct); +19 | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::forget-ref` implied by `-D warnings` note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:23:12 + --> $DIR/drop_forget_ref.rs:19:12 | -23 | forget(&SomeStruct); +19 | forget(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:26:5 + --> $DIR/drop_forget_ref.rs:22:5 | -26 | drop(&owned1); +22 | drop(&owned1); | ^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:26:10 + --> $DIR/drop_forget_ref.rs:22:10 | -26 | drop(&owned1); +22 | drop(&owned1); | ^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:27:5 + --> $DIR/drop_forget_ref.rs:23:5 | -27 | drop(&&owned1); +23 | drop(&&owned1); | ^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct - --> $DIR/drop_forget_ref.rs:27:10 + --> $DIR/drop_forget_ref.rs:23:10 | -27 | drop(&&owned1); +23 | drop(&&owned1); | ^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:28:5 + --> $DIR/drop_forget_ref.rs:24:5 | -28 | drop(&mut owned1); +24 | drop(&mut owned1); | ^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:28:10 + --> $DIR/drop_forget_ref.rs:24:10 | -28 | drop(&mut owned1); +24 | drop(&mut owned1); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:31:5 + --> $DIR/drop_forget_ref.rs:27:5 | -31 | forget(&owned2); +27 | forget(&owned2); | ^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:31:12 + --> $DIR/drop_forget_ref.rs:27:12 | -31 | forget(&owned2); +27 | forget(&owned2); | ^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:32:5 + --> $DIR/drop_forget_ref.rs:28:5 | -32 | forget(&&owned2); +28 | forget(&&owned2); | ^^^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct - --> $DIR/drop_forget_ref.rs:32:12 + --> $DIR/drop_forget_ref.rs:28:12 | -32 | forget(&&owned2); +28 | forget(&&owned2); | ^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:33:5 + --> $DIR/drop_forget_ref.rs:29:5 | -33 | forget(&mut owned2); +29 | forget(&mut owned2); | ^^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:33:12 + --> $DIR/drop_forget_ref.rs:29:12 | -33 | forget(&mut owned2); +29 | forget(&mut owned2); | ^^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:37:5 + --> $DIR/drop_forget_ref.rs:33:5 | -37 | drop(reference1); +33 | drop(reference1); | ^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:37:10 + --> $DIR/drop_forget_ref.rs:33:10 | -37 | drop(reference1); +33 | drop(reference1); | ^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:38:5 + --> $DIR/drop_forget_ref.rs:34:5 | -38 | forget(&*reference1); +34 | forget(&*reference1); | ^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:38:12 + --> $DIR/drop_forget_ref.rs:34:12 | -38 | forget(&*reference1); +34 | forget(&*reference1); | ^^^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:41:5 + --> $DIR/drop_forget_ref.rs:37:5 | -41 | drop(reference2); +37 | drop(reference2); | ^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:41:10 + --> $DIR/drop_forget_ref.rs:37:10 | -41 | drop(reference2); +37 | drop(reference2); | ^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:43:5 + --> $DIR/drop_forget_ref.rs:39:5 | -43 | forget(reference3); +39 | forget(reference3); | ^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct - --> $DIR/drop_forget_ref.rs:43:12 + --> $DIR/drop_forget_ref.rs:39:12 | -43 | forget(reference3); +39 | forget(reference3); | ^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:46:5 + --> $DIR/drop_forget_ref.rs:42:5 | -46 | drop(reference4); +42 | drop(reference4); | ^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:46:10 + --> $DIR/drop_forget_ref.rs:42:10 | -46 | drop(reference4); +42 | drop(reference4); | ^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:47:5 + --> $DIR/drop_forget_ref.rs:43:5 | -47 | forget(reference4); +43 | forget(reference4); | ^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:47:12 + --> $DIR/drop_forget_ref.rs:43:12 | -47 | forget(reference4); +43 | forget(reference4); | ^^^^^^^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:52:5 + --> $DIR/drop_forget_ref.rs:48:5 | -52 | drop(&val); +48 | drop(&val); | ^^^^^^^^^^ | note: argument has type &T - --> $DIR/drop_forget_ref.rs:52:10 + --> $DIR/drop_forget_ref.rs:48:10 | -52 | drop(&val); +48 | drop(&val); | ^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:58:5 + --> $DIR/drop_forget_ref.rs:54:5 | -58 | forget(&val); +54 | forget(&val); | ^^^^^^^^^^^^ | note: argument has type &T - --> $DIR/drop_forget_ref.rs:58:12 + --> $DIR/drop_forget_ref.rs:54:12 | -58 | forget(&val); +54 | forget(&val); | ^^^^ error: calls to `std::mem::drop` with a reference instead of an owned value. Dropping a reference does nothing. - --> $DIR/drop_forget_ref.rs:66:5 + --> $DIR/drop_forget_ref.rs:62:5 | -66 | std::mem::drop(&SomeStruct); +62 | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:66:20 + --> $DIR/drop_forget_ref.rs:62:20 | -66 | std::mem::drop(&SomeStruct); +62 | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^ error: calls to `std::mem::forget` with a reference instead of an owned value. Forgetting a reference does nothing. - --> $DIR/drop_forget_ref.rs:69:5 + --> $DIR/drop_forget_ref.rs:65:5 | -69 | std::mem::forget(&SomeStruct); +65 | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct - --> $DIR/drop_forget_ref.rs:69:22 + --> $DIR/drop_forget_ref.rs:65:22 | -69 | std::mem::forget(&SomeStruct); +65 | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^ error: aborting due to 18 previous errors diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index 87b5c5e19d9a..ba1b5b1ded71 100644 --- a/tests/ui/duplicate_underscore_argument.stderr +++ b/tests/ui/duplicate_underscore_argument.stderr @@ -1,7 +1,7 @@ error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult - --> $DIR/duplicate_underscore_argument.rs:17:23 + --> $DIR/duplicate_underscore_argument.rs:13:23 | -17 | fn join_the_dark_side(darth: i32, _darth: i32) {} +13 | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ | = note: `-D clippy::duplicate-underscore-argument` implied by `-D warnings` diff --git a/tests/ui/duration_subsec.stderr b/tests/ui/duration_subsec.stderr index 854af9dcb51b..1310ac123406 100644 --- a/tests/ui/duration_subsec.stderr +++ b/tests/ui/duration_subsec.stderr @@ -1,33 +1,33 @@ error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:20:24 + --> $DIR/duration_subsec.rs:17:24 | -20 | let bad_millis_1 = dur.subsec_micros() / 1_000; +17 | let bad_millis_1 = dur.subsec_micros() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` | = note: `-D clippy::duration-subsec` implied by `-D warnings` error: Calling `subsec_millis()` is more concise than this calculation - --> $DIR/duration_subsec.rs:21:24 + --> $DIR/duration_subsec.rs:18:24 | -21 | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; +18 | let bad_millis_2 = dur.subsec_nanos() / 1_000_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_millis()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:26:22 + --> $DIR/duration_subsec.rs:23:22 | -26 | let bad_micros = dur.subsec_nanos() / 1_000; +23 | let bad_micros = dur.subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:31:13 + --> $DIR/duration_subsec.rs:28:13 | -31 | let _ = (&dur).subsec_nanos() / 1_000; +28 | let _ = (&dur).subsec_nanos() / 1_000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&dur).subsec_micros()` error: Calling `subsec_micros()` is more concise than this calculation - --> $DIR/duration_subsec.rs:35:13 + --> $DIR/duration_subsec.rs:32:13 | -35 | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; +32 | let _ = dur.subsec_nanos() / NANOS_IN_MICRO; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `dur.subsec_micros()` error: aborting due to 5 previous errors diff --git a/tests/ui/else_if_without_else.stderr b/tests/ui/else_if_without_else.stderr index 7c8afcf3ce17..8771df872971 100644 --- a/tests/ui/else_if_without_else.stderr +++ b/tests/ui/else_if_without_else.stderr @@ -1,22 +1,24 @@ error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:51:12 + --> $DIR/else_if_without_else.rs:54:12 | -51 | } else if bla2() { //~ ERROR else if without else +54 | } else if bla2() { | ____________^ -52 | | println!("else if"); -53 | | } +55 | | //~ ERROR else if without else +56 | | println!("else if"); +57 | | } | |_____^ | = note: `-D clippy::else-if-without-else` implied by `-D warnings` = help: add an `else` block here error: if expression with an `else if`, but without a final `else` - --> $DIR/else_if_without_else.rs:59:12 + --> $DIR/else_if_without_else.rs:63:12 | -59 | } else if bla3() { //~ ERROR else if without else +63 | } else if bla3() { | ____________^ -60 | | println!("else if 2"); -61 | | } +64 | | //~ ERROR else if without else +65 | | println!("else if 2"); +66 | | } | |_____^ | = help: add an `else` block here diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index 9d6691c974d4..fd981f2210f0 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -1,14 +1,14 @@ error: enum with no variants - --> $DIR/empty_enum.rs:17:1 + --> $DIR/empty_enum.rs:13:1 | -17 | enum Empty {} +13 | enum Empty {} | ^^^^^^^^^^^^^ | = note: `-D clippy::empty-enum` implied by `-D warnings` help: consider using the uninhabited type `!` or a wrapper around it - --> $DIR/empty_enum.rs:17:1 + --> $DIR/empty_enum.rs:13:1 | -17 | enum Empty {} +13 | enum Empty {} | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/entry.stderr b/tests/ui/entry.stderr index 60e5ae893b66..9a4e0ba31eee 100644 --- a/tests/ui/entry.stderr +++ b/tests/ui/entry.stderr @@ -1,46 +1,74 @@ error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:23:5 + --> $DIR/entry.rs:19:5 | -23 | if !m.contains_key(&k) { m.insert(k, v); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k).or_insert(v)` +19 | / if !m.contains_key(&k) { +20 | | m.insert(k, v); +21 | | } + | |_____^ help: consider using: `m.entry(k).or_insert(v)` | = note: `-D clippy::map-entry` implied by `-D warnings` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:27:5 + --> $DIR/entry.rs:25:5 | -27 | if !m.contains_key(&k) { foo(); m.insert(k, v); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +25 | / if !m.contains_key(&k) { +26 | | foo(); +27 | | m.insert(k, v); +28 | | } + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:31:5 + --> $DIR/entry.rs:32:5 | -31 | if !m.contains_key(&k) { m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +32 | / if !m.contains_key(&k) { +33 | | m.insert(k, v) +34 | | } else { +35 | | None +36 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:35:5 + --> $DIR/entry.rs:40:5 | -35 | if m.contains_key(&k) { None } else { m.insert(k, v) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +40 | / if m.contains_key(&k) { +41 | | None +42 | | } else { +43 | | m.insert(k, v) +44 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:39:5 + --> $DIR/entry.rs:48:5 | -39 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +48 | / if !m.contains_key(&k) { +49 | | foo(); +50 | | m.insert(k, v) +51 | | } else { +52 | | None +53 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `HashMap` - --> $DIR/entry.rs:43:5 + --> $DIR/entry.rs:57:5 | -43 | if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +57 | / if m.contains_key(&k) { +58 | | None +59 | | } else { +60 | | foo(); +61 | | m.insert(k, v) +62 | | }; + | |_____^ help: consider using: `m.entry(k)` error: usage of `contains_key` followed by `insert` on a `BTreeMap` - --> $DIR/entry.rs:47:5 + --> $DIR/entry.rs:66:5 | -47 | if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `m.entry(k)` +66 | / if !m.contains_key(&k) { +67 | | foo(); +68 | | m.insert(k, v) +69 | | } else { +70 | | None +71 | | }; + | |_____^ help: consider using: `m.entry(k)` error: aborting due to 7 previous errors diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index 2dac4a2b1067..58c6f4d3301f 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -1,15 +1,15 @@ error: don't use glob imports for enum variants - --> $DIR/enum_glob_use.rs:16:1 + --> $DIR/enum_glob_use.rs:13:1 | -16 | use std::cmp::Ordering::*; +13 | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::enum-glob-use` implied by `-D warnings` error: don't use glob imports for enum variants - --> $DIR/enum_glob_use.rs:22:1 + --> $DIR/enum_glob_use.rs:19:1 | -22 | use self::Enum::*; +19 | use self::Enum::*; | ^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index 7b63fab3a99f..ff8f9b82ae6d 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,61 +1,61 @@ error: Variant name ends with the enum's name - --> $DIR/enum_variants.rs:26:5 + --> $DIR/enum_variants.rs:24:5 | -26 | cFoo, +24 | cFoo, | ^^^^ | = note: `-D clippy::enum-variant-names` implied by `-D warnings` error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:37:5 + --> $DIR/enum_variants.rs:35:5 | -37 | FoodGood, +35 | FoodGood, | ^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:38:5 + --> $DIR/enum_variants.rs:36:5 | -38 | FoodMiddle, +36 | FoodMiddle, | ^^^^^^^^^^ error: Variant name starts with the enum's name - --> $DIR/enum_variants.rs:39:5 + --> $DIR/enum_variants.rs:37:5 | -39 | FoodBad, +37 | FoodBad, | ^^^^^^^ error: All variants have the same prefix: `Food` - --> $DIR/enum_variants.rs:36:1 + --> $DIR/enum_variants.rs:34:1 | -36 | / enum Food { -37 | | FoodGood, -38 | | FoodMiddle, -39 | | FoodBad, -40 | | } +34 | / enum Food { +35 | | FoodGood, +36 | | FoodMiddle, +37 | | FoodBad, +38 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `CallType` - --> $DIR/enum_variants.rs:46:1 + --> $DIR/enum_variants.rs:44:1 | -46 | / enum BadCallType { -47 | | CallTypeCall, -48 | | CallTypeCreate, -49 | | CallTypeDestroy, -50 | | } +44 | / enum BadCallType { +45 | | CallTypeCall, +46 | | CallTypeCreate, +47 | | CallTypeDestroy, +48 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports error: All variants have the same prefix: `Constant` - --> $DIR/enum_variants.rs:57:1 + --> $DIR/enum_variants.rs:56:1 | -57 | / enum Consts { -58 | | ConstantInt, -59 | | ConstantCake, -60 | | ConstantLie, -61 | | } +56 | / enum Consts { +57 | | ConstantInt, +58 | | ConstantCake, +59 | | ConstantLie, +60 | | } | |_^ | = help: remove the prefixes and use full paths to the variants instead of glob imports diff --git a/tests/ui/enums_clike.stderr b/tests/ui/enums_clike.stderr index 27b184ea3cc7..0756b9a80d40 100644 --- a/tests/ui/enums_clike.stderr +++ b/tests/ui/enums_clike.stderr @@ -1,51 +1,51 @@ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:22:5 + --> $DIR/enums_clike.rs:17:5 | -22 | X = 0x1_0000_0000, +17 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::enum-clike-unportable-variant` implied by `-D warnings` error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:29:5 + --> $DIR/enums_clike.rs:24:5 | -29 | X = 0x1_0000_0000, +24 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:32:5 + --> $DIR/enums_clike.rs:27:5 | -32 | A = 0xFFFF_FFFF, +27 | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:39:5 + --> $DIR/enums_clike.rs:34:5 | -39 | Z = 0xFFFF_FFFF, +34 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:40:5 + --> $DIR/enums_clike.rs:35:5 | -40 | A = 0x1_0000_0000, +35 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:42:5 + --> $DIR/enums_clike.rs:37:5 | -42 | C = (std::i32::MIN as isize) - 1, +37 | C = (std::i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:48:5 + --> $DIR/enums_clike.rs:43:5 | -48 | Z = 0xFFFF_FFFF, +43 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ error: Clike enum variant discriminant is not portable to 32-bit targets - --> $DIR/enums_clike.rs:49:5 + --> $DIR/enums_clike.rs:44:5 | -49 | A = 0x1_0000_0000, +44 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/erasing_op.stderr b/tests/ui/erasing_op.stderr index 2cc3db7c2683..a500a132af7d 100644 --- a/tests/ui/erasing_op.stderr +++ b/tests/ui/erasing_op.stderr @@ -1,21 +1,21 @@ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:19:5 + --> $DIR/erasing_op.rs:15:5 | -19 | x * 0; +15 | x * 0; | ^^^^^ | = note: `-D clippy::erasing-op` implied by `-D warnings` error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:20:5 + --> $DIR/erasing_op.rs:16:5 | -20 | 0 & x; +16 | 0 & x; | ^^^^^ error: this operation will always return zero. This is likely not the intended outcome - --> $DIR/erasing_op.rs:21:5 + --> $DIR/erasing_op.rs:17:5 | -21 | 0 / x; +17 | 0 / x; | ^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/escape_analysis.stderr b/tests/ui/escape_analysis.stderr index 25ba413b75a5..ec9b7317eedf 100644 --- a/tests/ui/escape_analysis.stderr +++ b/tests/ui/escape_analysis.stderr @@ -1,15 +1,15 @@ error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:45:13 + --> $DIR/escape_analysis.rs:43:13 | -45 | fn warn_arg(x: Box) { +43 | fn warn_arg(x: Box) { | ^ | = note: `-D clippy::boxed-local` implied by `-D warnings` error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:137:12 + --> $DIR/escape_analysis.rs:134:12 | -137 | pub fn new(_needs_name: Box>) -> () { +134 | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index dcdf0699ff73..cd14855c49df 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -1,35 +1,35 @@ error: redundant closure found - --> $DIR/eta.rs:17:27 + --> $DIR/eta.rs:22:27 | -17 | let a = Some(1u8).map(|a| foo(a)); +22 | let a = Some(1u8).map(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` | = note: `-D clippy::redundant-closure` implied by `-D warnings` error: redundant closure found - --> $DIR/eta.rs:18:10 + --> $DIR/eta.rs:23:10 | -18 | meta(|a| foo(a)); +23 | meta(|a| foo(a)); | ^^^^^^^^^^ help: remove closure as shown: `foo` error: redundant closure found - --> $DIR/eta.rs:19:27 + --> $DIR/eta.rs:24:27 | -19 | let c = Some(1u8).map(|a| {1+2; foo}(a)); +24 | let c = Some(1u8).map(|a| {1+2; foo}(a)); | ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `{1+2; foo}` error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/eta.rs:21:21 + --> $DIR/eta.rs:26:21 | -21 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted +26 | all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted | ^^^ help: change this to: `&2` | = note: `-D clippy::needless-borrow` implied by `-D warnings` error: redundant closure found - --> $DIR/eta.rs:28:27 + --> $DIR/eta.rs:33:27 | -28 | let e = Some(1u8).map(|a| generic(a)); +33 | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: remove closure as shown: `generic` error: aborting due to 5 previous errors diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index d5be92e993f2..38317376fc4e 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -1,51 +1,51 @@ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:18:28 + --> $DIR/eval_order_dependence.rs:24:9 | -18 | let a = { x = 1; 1 } + x; - | ^ +24 | } + x; + | ^ | = note: `-D clippy::eval-order-dependence` implied by `-D warnings` note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:18:15 + --> $DIR/eval_order_dependence.rs:22:9 | -18 | let a = { x = 1; 1 } + x; - | ^^^^^ +22 | x = 1; + | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:21:5 + --> $DIR/eval_order_dependence.rs:27:5 | -21 | x += { x = 20; 2 }; +27 | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:21:12 + --> $DIR/eval_order_dependence.rs:28:9 | -21 | x += { x = 20; 2 }; - | ^^^^^^ +28 | x = 20; + | ^^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:27:24 + --> $DIR/eval_order_dependence.rs:40:12 | -27 | let foo = Foo { a: x, .. { x = 6; base } }; - | ^ +40 | a: x, + | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:27:32 + --> $DIR/eval_order_dependence.rs:42:13 | -27 | let foo = Foo { a: x, .. { x = 6; base } }; - | ^^^^^ +42 | x = 6; + | ^^^^^ error: unsequenced read of a variable - --> $DIR/eval_order_dependence.rs:31:9 + --> $DIR/eval_order_dependence.rs:49:9 | -31 | x += { x = 20; 2 }; +49 | x += { | ^ | note: whether read occurs before this write depends on evaluation order - --> $DIR/eval_order_dependence.rs:31:16 + --> $DIR/eval_order_dependence.rs:50:13 | -31 | x += { x = 20; 2 }; - | ^^^^^^ +50 | x = 20; + | ^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/excessive_precision.stderr b/tests/ui/excessive_precision.stderr index 783e41f2b502..a69652373d51 100644 --- a/tests/ui/excessive_precision.stderr +++ b/tests/ui/excessive_precision.stderr @@ -1,111 +1,111 @@ error: float has excessive precision - --> $DIR/excessive_precision.rs:25:26 + --> $DIR/excessive_precision.rs:23:26 | -25 | const BAD32_1: f32 = 0.123_456_789_f32; +23 | const BAD32_1: f32 = 0.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` | = note: `-D clippy::excessive-precision` implied by `-D warnings` error: float has excessive precision - --> $DIR/excessive_precision.rs:26:26 + --> $DIR/excessive_precision.rs:24:26 | -26 | const BAD32_2: f32 = 0.123_456_789; +24 | const BAD32_2: f32 = 0.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:27:26 + --> $DIR/excessive_precision.rs:25:26 | -27 | const BAD32_3: f32 = 0.100_000_000_000_1; +25 | const BAD32_3: f32 = 0.100_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:28:29 + --> $DIR/excessive_precision.rs:26:29 | -28 | const BAD32_EDGE: f32 = 1.000_000_9; +26 | const BAD32_EDGE: f32 = 1.000_000_9; | ^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.000_001` error: float has excessive precision - --> $DIR/excessive_precision.rs:30:26 + --> $DIR/excessive_precision.rs:28:26 | -30 | const BAD64_1: f64 = 0.123_456_789_012_345_67f64; +28 | const BAD64_1: f64 = 0.123_456_789_012_345_67f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:31:26 + --> $DIR/excessive_precision.rs:29:26 | -31 | const BAD64_2: f64 = 0.123_456_789_012_345_67; +29 | const BAD64_2: f64 = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:32:26 + --> $DIR/excessive_precision.rs:30:26 | -32 | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; +30 | const BAD64_3: f64 = 0.100_000_000_000_000_000_1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.1` error: float has excessive precision - --> $DIR/excessive_precision.rs:35:22 + --> $DIR/excessive_precision.rs:33:22 | -35 | println!("{:?}", 8.888_888_888_888_888_888_888); +33 | println!("{:?}", 8.888_888_888_888_888_888_888); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `8.888_888_888_888_89` error: float has excessive precision - --> $DIR/excessive_precision.rs:46:22 + --> $DIR/excessive_precision.rs:44:22 | -46 | let bad32: f32 = 1.123_456_789; +44 | let bad32: f32 = 1.123_456_789; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:47:26 + --> $DIR/excessive_precision.rs:45:26 | -47 | let bad32_suf: f32 = 1.123_456_789_f32; +45 | let bad32_suf: f32 = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:48:21 + --> $DIR/excessive_precision.rs:46:21 | -48 | let bad32_inf = 1.123_456_789_f32; +46 | let bad32_inf = 1.123_456_789_f32; | ^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8` error: float has excessive precision - --> $DIR/excessive_precision.rs:50:22 + --> $DIR/excessive_precision.rs:48:22 | -50 | let bad64: f64 = 0.123_456_789_012_345_67; +48 | let bad64: f64 = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:51:26 + --> $DIR/excessive_precision.rs:49:26 | -51 | let bad64_suf: f64 = 0.123_456_789_012_345_67f64; +49 | let bad64_suf: f64 = 0.123_456_789_012_345_67f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:52:21 + --> $DIR/excessive_precision.rs:50:21 | -52 | let bad64_inf = 0.123_456_789_012_345_67; +50 | let bad64_inf = 0.123_456_789_012_345_67; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_012_345_66` error: float has excessive precision - --> $DIR/excessive_precision.rs:58:36 + --> $DIR/excessive_precision.rs:56:36 | -58 | let bad_vec32: Vec = vec![0.123_456_789]; +56 | let bad_vec32: Vec = vec![0.123_456_789]; | ^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_79` error: float has excessive precision - --> $DIR/excessive_precision.rs:59:36 + --> $DIR/excessive_precision.rs:57:36 | -59 | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; +57 | let bad_vec64: Vec = vec![0.123_456_789_123_456_789]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0.123_456_789_123_456_78` error: float has excessive precision - --> $DIR/excessive_precision.rs:63:24 + --> $DIR/excessive_precision.rs:61:24 | -63 | let bad_e32: f32 = 1.123_456_788_888e-10; +61 | let bad_e32: f32 = 1.123_456_788_888e-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8e-10` error: float has excessive precision - --> $DIR/excessive_precision.rs:66:27 + --> $DIR/excessive_precision.rs:64:27 | -66 | let bad_bige32: f32 = 1.123_456_788_888E-10; +64 | let bad_bige32: f32 = 1.123_456_788_888E-10; | ^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `1.123_456_8E-10` error: aborting due to 18 previous errors diff --git a/tests/ui/expect_fun_call.stderr b/tests/ui/expect_fun_call.stderr index 6b1550b21956..ad8fe14e9a03 100644 --- a/tests/ui/expect_fun_call.stderr +++ b/tests/ui/expect_fun_call.stderr @@ -1,39 +1,39 @@ error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:34:26 + --> $DIR/expect_fun_call.rs:36:26 | -34 | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); +36 | with_none_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` | = note: `-D clippy::expect-fun-call` implied by `-D warnings` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:37:26 + --> $DIR/expect_fun_call.rs:39:26 | -37 | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); +39 | with_none_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:47:25 + --> $DIR/expect_fun_call.rs:49:25 | -47 | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); +49 | with_err_and_format.expect(&format!("Error {}: fake error", error_code)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:50:25 + --> $DIR/expect_fun_call.rs:52:25 | -50 | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); +52 | with_err_and_as_str.expect(format!("Error {}: fake error", error_code).as_str()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| panic!("Error {}: fake error", error_code))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:65:17 + --> $DIR/expect_fun_call.rs:67:17 | -65 | Some("foo").expect({ &format!("error") }); +67 | Some("foo").expect({ &format!("error") }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { let msg = { &format!("error") }; panic!(msg) }))` error: use of `expect` followed by a function call - --> $DIR/expect_fun_call.rs:66:17 + --> $DIR/expect_fun_call.rs:68:17 | -66 | Some("foo").expect(format!("error").as_ref()); +68 | Some("foo").expect(format!("error").as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("error"))` error: aborting due to 6 previous errors diff --git a/tests/ui/explicit_counter_loop.stderr b/tests/ui/explicit_counter_loop.stderr index 023f7f299a72..caafd2375f00 100644 --- a/tests/ui/explicit_counter_loop.stderr +++ b/tests/ui/explicit_counter_loop.stderr @@ -13,15 +13,15 @@ error: the variable `_index` is used as a loop counter. Consider using `for (_in | ^^^^ error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:58:19 + --> $DIR/explicit_counter_loop.rs:60:19 | -58 | for ch in text.chars() { +60 | for ch in text.chars() { | ^^^^^^^^^^^^ error: the variable `count` is used as a loop counter. Consider using `for (count, item) in text.chars().enumerate()` or similar iterators - --> $DIR/explicit_counter_loop.rs:69:19 + --> $DIR/explicit_counter_loop.rs:71:19 | -69 | for ch in text.chars() { +71 | for ch in text.chars() { | ^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/explicit_write.stderr b/tests/ui/explicit_write.stderr index fadc12c7594d..171bf312a9bd 100644 --- a/tests/ui/explicit_write.stderr +++ b/tests/ui/explicit_write.stderr @@ -1,39 +1,39 @@ error: use of `write!(stdout(), ...).unwrap()`. Consider using `print!` instead - --> $DIR/explicit_write.rs:28:9 + --> $DIR/explicit_write.rs:24:9 | -28 | write!(std::io::stdout(), "test").unwrap(); +24 | write!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::explicit-write` implied by `-D warnings` error: use of `write!(stderr(), ...).unwrap()`. Consider using `eprint!` instead - --> $DIR/explicit_write.rs:29:9 + --> $DIR/explicit_write.rs:25:9 | -29 | write!(std::io::stderr(), "test").unwrap(); +25 | write!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `writeln!(stdout(), ...).unwrap()`. Consider using `println!` instead - --> $DIR/explicit_write.rs:30:9 + --> $DIR/explicit_write.rs:26:9 | -30 | writeln!(std::io::stdout(), "test").unwrap(); +26 | writeln!(std::io::stdout(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `writeln!(stderr(), ...).unwrap()`. Consider using `eprintln!` instead - --> $DIR/explicit_write.rs:31:9 + --> $DIR/explicit_write.rs:27:9 | -31 | writeln!(std::io::stderr(), "test").unwrap(); +27 | writeln!(std::io::stderr(), "test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `stdout().write_fmt(...).unwrap()`. Consider using `print!` instead - --> $DIR/explicit_write.rs:32:9 + --> $DIR/explicit_write.rs:28:9 | -32 | std::io::stdout().write_fmt(format_args!("test")).unwrap(); +28 | std::io::stdout().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `stderr().write_fmt(...).unwrap()`. Consider using `eprint!` instead - --> $DIR/explicit_write.rs:33:9 + --> $DIR/explicit_write.rs:29:9 | -33 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); +29 | std::io::stderr().write_fmt(format_args!("test")).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/fallible_impl_from.stderr b/tests/ui/fallible_impl_from.stderr index 97ece9314649..8af5933a9f84 100644 --- a/tests/ui/fallible_impl_from.stderr +++ b/tests/ui/fallible_impl_from.stderr @@ -1,91 +1,91 @@ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:17:1 + --> $DIR/fallible_impl_from.rs:14:1 | -17 | / impl From for Foo { -18 | | fn from(s: String) -> Self { -19 | | Foo(s.parse().unwrap()) -20 | | } -21 | | } +14 | / impl From for Foo { +15 | | fn from(s: String) -> Self { +16 | | Foo(s.parse().unwrap()) +17 | | } +18 | | } | |_^ | note: lint level defined here - --> $DIR/fallible_impl_from.rs:13:9 + --> $DIR/fallible_impl_from.rs:10:9 | -13 | #![deny(clippy::fallible_impl_from)] +10 | #![deny(clippy::fallible_impl_from)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:19:13 + --> $DIR/fallible_impl_from.rs:16:13 | -19 | Foo(s.parse().unwrap()) +16 | Foo(s.parse().unwrap()) | ^^^^^^^^^^^^^^^^^^ error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:40:1 + --> $DIR/fallible_impl_from.rs:35:1 | -40 | / impl From for Invalid { -41 | | fn from(i: usize) -> Invalid { -42 | | if i != 42 { -43 | | panic!(); +35 | / impl From for Invalid { +36 | | fn from(i: usize) -> Invalid { +37 | | if i != 42 { +38 | | panic!(); ... | -46 | | } -47 | | } +41 | | } +42 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:43:13 + --> $DIR/fallible_impl_from.rs:38:13 | -43 | panic!(); +38 | panic!(); | ^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:49:1 + --> $DIR/fallible_impl_from.rs:44:1 | -49 | / impl From> for Invalid { -50 | | fn from(s: Option) -> Invalid { -51 | | let s = s.unwrap(); -52 | | if !s.is_empty() { +44 | / impl From> for Invalid { +45 | | fn from(s: Option) -> Invalid { +46 | | let s = s.unwrap(); +47 | | if !s.is_empty() { ... | -58 | | } -59 | | } +53 | | } +54 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:51:17 + --> $DIR/fallible_impl_from.rs:46:17 | -51 | let s = s.unwrap(); +46 | let s = s.unwrap(); | ^^^^^^^^^^ -52 | if !s.is_empty() { -53 | panic!(42); +47 | if !s.is_empty() { +48 | panic!(42); | ^^^^^^^^^^^ -54 | } else if s.parse::().unwrap() != 42 { +49 | } else if s.parse::().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -55 | panic!("{:?}", s); +50 | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: consider implementing `TryFrom` instead - --> $DIR/fallible_impl_from.rs:67:1 + --> $DIR/fallible_impl_from.rs:62:1 | -67 | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { -68 | | fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { -69 | | if s.parse::().ok().unwrap() != 42 { -70 | | panic!("{:?}", s); +62 | / impl<'a> From<&'a mut as ProjStrTrait>::ProjString> for Invalid { +63 | | fn from(s: &'a mut as ProjStrTrait>::ProjString) -> Invalid { +64 | | if s.parse::().ok().unwrap() != 42 { +65 | | panic!("{:?}", s); ... | -73 | | } -74 | | } +68 | | } +69 | | } | |_^ | = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail. note: potential failure(s) - --> $DIR/fallible_impl_from.rs:69:12 + --> $DIR/fallible_impl_from.rs:64:12 | -69 | if s.parse::().ok().unwrap() != 42 { +64 | if s.parse::().ok().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -70 | panic!("{:?}", s); +65 | panic!("{:?}", s); | ^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) diff --git a/tests/ui/filter_methods.stderr b/tests/ui/filter_methods.stderr index 6adbec44cf94..8fde78ca5a72 100644 --- a/tests/ui/filter_methods.stderr +++ b/tests/ui/filter_methods.stderr @@ -1,40 +1,40 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.filter_map(..)` instead. - --> $DIR/filter_methods.rs:18:21 + --> $DIR/filter_methods.rs:14:21 | -18 | let _: Vec<_> = vec![5; 6].into_iter() - | _____________________^ -19 | | .filter(|&x| x == 0) -20 | | .map(|x| x * 2) - | |_____________________________________________^ +14 | let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::filter-map` implied by `-D warnings` error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator. - --> $DIR/filter_methods.rs:23:21 + --> $DIR/filter_methods.rs:16:21 | -23 | let _: Vec<_> = vec![5_i8; 6].into_iter() +16 | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -24 | | .filter(|&x| x == 0) -25 | | .flat_map(|x| x.checked_mul(2)) - | |_______________________________________________________________^ +17 | | .into_iter() +18 | | .filter(|&x| x == 0) +19 | | .flat_map(|x| x.checked_mul(2)) + | |_______________________________________^ error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator. - --> $DIR/filter_methods.rs:28:21 + --> $DIR/filter_methods.rs:22:21 | -28 | let _: Vec<_> = vec![5_i8; 6].into_iter() +22 | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -29 | | .filter_map(|x| x.checked_mul(2)) -30 | | .flat_map(|x| x.checked_mul(2)) - | |_______________________________________________________________^ +23 | | .into_iter() +24 | | .filter_map(|x| x.checked_mul(2)) +25 | | .flat_map(|x| x.checked_mul(2)) + | |_______________________________________^ error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly expressed by only calling `.filter_map(..)` instead. - --> $DIR/filter_methods.rs:33:21 + --> $DIR/filter_methods.rs:28:21 | -33 | let _: Vec<_> = vec![5_i8; 6].into_iter() +28 | let _: Vec<_> = vec![5_i8; 6] | _____________________^ -34 | | .filter_map(|x| x.checked_mul(2)) -35 | | .map(|x| x.checked_mul(2)) - | |__________________________________________________________^ +29 | | .into_iter() +30 | | .filter_map(|x| x.checked_mul(2)) +31 | | .map(|x| x.checked_mul(2)) + | |__________________________________^ error: aborting due to 4 previous errors diff --git a/tests/ui/float_cmp.stderr b/tests/ui/float_cmp.stderr index 52ec0e3ed78e..3acd71eb99bc 100644 --- a/tests/ui/float_cmp.stderr +++ b/tests/ui/float_cmp.stderr @@ -1,38 +1,38 @@ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:59:5 + --> $DIR/float_cmp.rs:69:5 | -59 | ONE as f64 != 2.0; +69 | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(ONE as f64 - 2.0).abs() < error` | = note: `-D clippy::float-cmp` implied by `-D warnings` note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:59:5 + --> $DIR/float_cmp.rs:69:5 | -59 | ONE as f64 != 2.0; +69 | ONE as f64 != 2.0; | ^^^^^^^^^^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:64:5 + --> $DIR/float_cmp.rs:74:5 | -64 | x == 1.0; +74 | x == 1.0; | ^^^^^^^^ help: consider comparing them within some error: `(x - 1.0).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:64:5 + --> $DIR/float_cmp.rs:74:5 | -64 | x == 1.0; +74 | x == 1.0; | ^^^^^^^^ error: strict comparison of f32 or f64 - --> $DIR/float_cmp.rs:67:5 + --> $DIR/float_cmp.rs:77:5 | -67 | twice(x) != twice(ONE as f64); +77 | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider comparing them within some error: `(twice(x) - twice(ONE as f64)).abs() < error` | note: std::f32::EPSILON and std::f64::EPSILON are available. - --> $DIR/float_cmp.rs:67:5 + --> $DIR/float_cmp.rs:77:5 | -67 | twice(x) != twice(ONE as f64); +77 | twice(x) != twice(ONE as f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index f70a6d3b32f2..640cee1bc2f9 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -1,420 +1,420 @@ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:38:14 + --> $DIR/for_loop.rs:50:14 | -38 | for i in 0..vec.len() { +50 | for i in 0..vec.len() { | ^^^^^^^^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | -38 | for in &vec { +50 | for in &vec { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:47:14 + --> $DIR/for_loop.rs:59:14 | -47 | for i in 0..vec.len() { +59 | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -47 | for in &vec { +59 | for in &vec { | ^^^^^^ ^^^^ error: the loop variable `j` is only used to index `STATIC`. - --> $DIR/for_loop.rs:52:14 + --> $DIR/for_loop.rs:64:14 | -52 | for j in 0..4 { +64 | for j in 0..4 { | ^^^^ help: consider using an iterator | -52 | for in &STATIC { +64 | for in &STATIC { | ^^^^^^ ^^^^^^^ error: the loop variable `j` is only used to index `CONST`. - --> $DIR/for_loop.rs:56:14 + --> $DIR/for_loop.rs:68:14 | -56 | for j in 0..4 { +68 | for j in 0..4 { | ^^^^ help: consider using an iterator | -56 | for in &CONST { +68 | for in &CONST { | ^^^^^^ ^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:60:14 + --> $DIR/for_loop.rs:72:14 | -60 | for i in 0..vec.len() { +72 | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -60 | for (i, ) in vec.iter().enumerate() { +72 | for (i, ) in vec.iter().enumerate() { | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec2`. - --> $DIR/for_loop.rs:68:14 + --> $DIR/for_loop.rs:80:14 | -68 | for i in 0..vec.len() { +80 | for i in 0..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -68 | for in vec2.iter().take(vec.len()) { +80 | for in vec2.iter().take(vec.len()) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:72:14 + --> $DIR/for_loop.rs:84:14 | -72 | for i in 5..vec.len() { +84 | for i in 5..vec.len() { | ^^^^^^^^^^^^ help: consider using an iterator | -72 | for in vec.iter().skip(5) { +84 | for in vec.iter().skip(5) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:76:14 + --> $DIR/for_loop.rs:88:14 | -76 | for i in 0..MAX_LEN { +88 | for i in 0..MAX_LEN { | ^^^^^^^^^^ help: consider using an iterator | -76 | for in vec.iter().take(MAX_LEN) { +88 | for in vec.iter().take(MAX_LEN) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:80:14 + --> $DIR/for_loop.rs:92:14 | -80 | for i in 0..=MAX_LEN { +92 | for i in 0..=MAX_LEN { | ^^^^^^^^^^^ help: consider using an iterator | -80 | for in vec.iter().take(MAX_LEN + 1) { +92 | for in vec.iter().take(MAX_LEN + 1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:84:14 + --> $DIR/for_loop.rs:96:14 | -84 | for i in 5..10 { +96 | for i in 5..10 { | ^^^^^ help: consider using an iterator | -84 | for in vec.iter().take(10).skip(5) { +96 | for in vec.iter().take(10).skip(5) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/for_loop.rs:88:14 - | -88 | for i in 5..=10 { - | ^^^^^^ + --> $DIR/for_loop.rs:100:14 + | +100 | for i in 5..=10 { + | ^^^^^^ help: consider using an iterator - | -88 | for in vec.iter().take(10 + 1).skip(5) { - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +100 | for in vec.iter().take(10 + 1).skip(5) { + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:92:14 - | -92 | for i in 5..vec.len() { - | ^^^^^^^^^^^^ + --> $DIR/for_loop.rs:104:14 + | +104 | for i in 5..vec.len() { + | ^^^^^^^^^^^^ help: consider using an iterator - | -92 | for (i, ) in vec.iter().enumerate().skip(5) { - | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +104 | for (i, ) in vec.iter().enumerate().skip(5) { + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is used to index `vec` - --> $DIR/for_loop.rs:96:14 - | -96 | for i in 5..10 { - | ^^^^^ + --> $DIR/for_loop.rs:108:14 + | +108 | for i in 5..10 { + | ^^^^^ help: consider using an iterator - | -96 | for (i, ) in vec.iter().enumerate().take(10).skip(5) { - | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +108 | for (i, ) in vec.iter().enumerate().take(10).skip(5) { + | ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:100:14 + --> $DIR/for_loop.rs:112:14 | -100 | for i in 10..0 { +112 | for i in 10..0 { | ^^^^^ | = note: `-D clippy::reverse-range-loop` implied by `-D warnings` help: consider using the following if you are attempting to iterate over this range in reverse | -100 | for i in (0..10).rev() { +112 | for i in (0..10).rev() { | ^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:104:14 + --> $DIR/for_loop.rs:116:14 | -104 | for i in 10..=0 { +116 | for i in 10..=0 { | ^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -104 | for i in (0...10).rev() { +116 | for i in (0...10).rev() { | ^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:108:14 + --> $DIR/for_loop.rs:120:14 | -108 | for i in MAX_LEN..0 { +120 | for i in MAX_LEN..0 { | ^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -108 | for i in (0..MAX_LEN).rev() { +120 | for i in (0..MAX_LEN).rev() { | ^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:112:14 + --> $DIR/for_loop.rs:124:14 | -112 | for i in 5..5 { +124 | for i in 5..5 { | ^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:137:14 + --> $DIR/for_loop.rs:149:14 | -137 | for i in 10..5 + 4 { +149 | for i in 10..5 + 4 { | ^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -137 | for i in (5 + 4..10).rev() { +149 | for i in (5 + 4..10).rev() { | ^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:141:14 + --> $DIR/for_loop.rs:153:14 | -141 | for i in (5 + 2)..(3 - 1) { +153 | for i in (5 + 2)..(3 - 1) { | ^^^^^^^^^^^^^^^^ help: consider using the following if you are attempting to iterate over this range in reverse | -141 | for i in ((3 - 1)..(5 + 2)).rev() { +153 | for i in ((3 - 1)..(5 + 2)).rev() { | ^^^^^^^^^^^^^^^^^^^^^^^^ error: this range is empty so this for loop will never run - --> $DIR/for_loop.rs:145:14 + --> $DIR/for_loop.rs:157:14 | -145 | for i in (5 + 2)..(8 - 1) { +157 | for i in (5 + 2)..(8 - 1) { | ^^^^^^^^^^^^^^^^ error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:167:15 + --> $DIR/for_loop.rs:179:15 | -167 | for _v in vec.iter() {} +179 | for _v in vec.iter() {} | ^^^^^^^^^^ help: to write this more concisely, try: `&vec` | = note: `-D clippy::explicit-iter-loop` implied by `-D warnings` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:169:15 + --> $DIR/for_loop.rs:181:15 | -169 | for _v in vec.iter_mut() {} +181 | for _v in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` error: it is more concise to loop over containers instead of using explicit iteration methods` - --> $DIR/for_loop.rs:172:15 + --> $DIR/for_loop.rs:184:15 | -172 | for _v in out_vec.into_iter() {} +184 | for _v in out_vec.into_iter() {} | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec` | = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:175:15 + --> $DIR/for_loop.rs:187:15 | -175 | for _v in array.into_iter() {} +187 | for _v in array.into_iter() {} | ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:180:15 + --> $DIR/for_loop.rs:192:15 | -180 | for _v in [1, 2, 3].iter() {} +192 | for _v in [1, 2, 3].iter() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:184:15 + --> $DIR/for_loop.rs:196:15 | -184 | for _v in [0; 32].iter() {} +196 | for _v in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:189:15 + --> $DIR/for_loop.rs:201:15 | -189 | for _v in ll.iter() {} +201 | for _v in ll.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&ll` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:192:15 + --> $DIR/for_loop.rs:204:15 | -192 | for _v in vd.iter() {} +204 | for _v in vd.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&vd` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:195:15 + --> $DIR/for_loop.rs:207:15 | -195 | for _v in bh.iter() {} +207 | for _v in bh.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bh` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:198:15 + --> $DIR/for_loop.rs:210:15 | -198 | for _v in hm.iter() {} +210 | for _v in hm.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hm` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:201:15 + --> $DIR/for_loop.rs:213:15 | -201 | for _v in bt.iter() {} +213 | for _v in bt.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bt` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:204:15 + --> $DIR/for_loop.rs:216:15 | -204 | for _v in hs.iter() {} +216 | for _v in hs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hs` error: it is more concise to loop over references to containers instead of using explicit iteration methods - --> $DIR/for_loop.rs:207:15 + --> $DIR/for_loop.rs:219:15 | -207 | for _v in bs.iter() {} +219 | for _v in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want - --> $DIR/for_loop.rs:209:15 + --> $DIR/for_loop.rs:221:15 | -209 | for _v in vec.iter().next() {} +221 | for _v in vec.iter().next() {} | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iter-next-loop` implied by `-D warnings` error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> $DIR/for_loop.rs:216:5 + --> $DIR/for_loop.rs:228:5 | -216 | vec.iter().cloned().map(|x| out.push(x)).collect::>(); +228 | vec.iter().cloned().map(|x| out.push(x)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-collect` implied by `-D warnings` error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:325:19 + --> $DIR/for_loop.rs:337:19 | -325 | for (_, v) in &m { +337 | for (_, v) in &m { | ^^ | = note: `-D clippy::for-kv-map` implied by `-D warnings` help: use the corresponding method | -325 | for v in m.values() { +337 | for v in m.values() { | ^ ^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:330:19 + --> $DIR/for_loop.rs:342:19 | -330 | for (_, v) in &*m { +342 | for (_, v) in &*m { | ^^^ help: use the corresponding method | -330 | for v in (*m).values() { +342 | for v in (*m).values() { | ^ ^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:338:19 + --> $DIR/for_loop.rs:350:19 | -338 | for (_, v) in &mut m { +350 | for (_, v) in &mut m { | ^^^^^^ help: use the corresponding method | -338 | for v in m.values_mut() { +350 | for v in m.values_mut() { | ^ ^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> $DIR/for_loop.rs:343:19 + --> $DIR/for_loop.rs:355:19 | -343 | for (_, v) in &mut *m { +355 | for (_, v) in &mut *m { | ^^^^^^^ help: use the corresponding method | -343 | for v in (*m).values_mut() { +355 | for v in (*m).values_mut() { | ^ ^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's keys - --> $DIR/for_loop.rs:349:24 + --> $DIR/for_loop.rs:361:24 | -349 | for (k, _value) in rm { +361 | for (k, _value) in rm { | ^^ help: use the corresponding method | -349 | for k in rm.keys() { +361 | for k in rm.keys() { | ^ ^^^^^^^^^ error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:402:14 + --> $DIR/for_loop.rs:414:14 | -402 | for i in 0..src.len() { +414 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` | = note: `-D clippy::manual-memcpy` implied by `-D warnings` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:407:14 + --> $DIR/for_loop.rs:419:14 | -407 | for i in 0..src.len() { +419 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[10..(src.len() + 10)].clone_from_slice(&src[..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:412:14 + --> $DIR/for_loop.rs:424:14 | -412 | for i in 0..src.len() { +424 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[10..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:417:14 + --> $DIR/for_loop.rs:429:14 | -417 | for i in 11..src.len() { +429 | for i in 11..src.len() { | ^^^^^^^^^^^^^ help: try replacing the loop by: `dst[11..src.len()].clone_from_slice(&src[(11 - 10)..(src.len() - 10)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:422:14 + --> $DIR/for_loop.rs:434:14 | -422 | for i in 0..dst.len() { +434 | for i in 0..dst.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..dst.len()])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:435:14 + --> $DIR/for_loop.rs:447:14 | -435 | for i in 10..256 { +447 | for i in 10..256 { | ^^^^^^^ help: try replacing the loop by | -435 | for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)]) -436 | dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) { +447 | for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)]) +448 | dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) { | error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:447:14 + --> $DIR/for_loop.rs:459:14 | -447 | for i in 10..LOOP_OFFSET { +459 | for i in 10..LOOP_OFFSET { | ^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].clone_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:460:14 + --> $DIR/for_loop.rs:472:14 | -460 | for i in 0..src_vec.len() { +472 | for i in 0..src_vec.len() { | ^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst_vec[..src_vec.len()].clone_from_slice(&src_vec[..])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:489:14 + --> $DIR/for_loop.rs:501:14 | -489 | for i in from..from + src.len() { +501 | for i in from..from + src.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + src.len()].clone_from_slice(&src[0..(from + src.len() - from)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:493:14 + --> $DIR/for_loop.rs:505:14 | -493 | for i in from..from + 3 { +505 | for i in from..from + 3 { | ^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[from..from + 3].clone_from_slice(&src[0..(from + 3 - from)])` error: it looks like you're manually copying between slices - --> $DIR/for_loop.rs:500:14 + --> $DIR/for_loop.rs:512:14 | -500 | for i in 0..src.len() { +512 | for i in 0..src.len() { | ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])` error: aborting due to 51 previous errors diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index e1620b221257..84749b6caac3 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,90 +1,19 @@ -error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:25:6 - | -25 | } if foo() { - | ^ - | - = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` - = note: to remove this lint, add the missing `else` or add a new line before the second `if` - -error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:32:10 - | -32 | } if foo() { - | ^ - | - = note: to remove this lint, add the missing `else` or add a new line before the second `if` - -error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:40:10 - | -40 | } if foo() { - | ^ - | - = note: to remove this lint, add the missing `else` or add a new line before the second `if` - -error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:49:6 - | -49 | } else - | ______^ -50 | | if foo() { // the span of the above error should continue here - | |____^ - | - = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` - -error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:54:6 - | -54 | } - | ______^ -55 | | else -56 | | if foo() { // the span of the above error should continue here - | |____^ - | - = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` - -error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:81:6 - | -81 | a =- 35; - | ^^^^ - | - = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` - = note: to remove this lint, use either `-=` or `= -` - -error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - --> $DIR/formatting.rs:82:6 - | -82 | a =* &191; - | ^^^^ - | - = note: to remove this lint, use either `*=` or `= *` - -error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:85:6 - | -85 | b =! false; - | ^^^^ - | - = note: to remove this lint, use either `!=` or `= !` - error: possibly missing a comma here - --> $DIR/formatting.rs:94:19 + --> $DIR/formatting.rs:88:11 | -94 | -1, -2, -3 // <= no comma here - | ^ +88 | -3 // <= no comma here + | ^ | = note: `-D clippy::possible-missing-comma` implied by `-D warnings` = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:98:19 + --> $DIR/formatting.rs:96:11 | -98 | -1, -2, -3 // <= no comma here - | ^ +96 | -3 // <= no comma here + | ^ | = note: to remove this lint, add a comma or write the expr in a single line -error: aborting due to 10 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index 9c45eb033ea2..206d04d6a395 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -1,78 +1,77 @@ error: this function has too many arguments (8/7) - --> $DIR/functions.rs:21:1 + --> $DIR/functions.rs:17:1 | -21 | / fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) { -22 | | } - | |_^ +17 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::too-many-arguments` implied by `-D warnings` error: this function has too many arguments (8/7) - --> $DIR/functions.rs:29:5 + --> $DIR/functions.rs:34:5 | -29 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()); +34 | 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) - --> $DIR/functions.rs:38:5 + --> $DIR/functions.rs:43:5 | -38 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} +43 | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:47:34 + --> $DIR/functions.rs:52:34 | -47 | println!("{}", unsafe { *p }); +52 | println!("{}", unsafe { *p }); | ^ | = note: `-D clippy::not-unsafe-ptr-arg-deref` implied by `-D warnings` error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:48:35 + --> $DIR/functions.rs:53:35 | -48 | println!("{:?}", unsafe { p.as_ref() }); +53 | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:49:33 + --> $DIR/functions.rs:54:33 | -49 | unsafe { std::ptr::read(p) }; +54 | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:60:30 + --> $DIR/functions.rs:65:30 | -60 | println!("{}", unsafe { *p }); +65 | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:61:31 + --> $DIR/functions.rs:66:31 | -61 | println!("{:?}", unsafe { p.as_ref() }); +66 | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:62:29 + --> $DIR/functions.rs:67:29 | -62 | unsafe { std::ptr::read(p) }; +67 | unsafe { std::ptr::read(p) }; | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:71:34 + --> $DIR/functions.rs:76:34 | -71 | println!("{}", unsafe { *p }); +76 | println!("{}", unsafe { *p }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:72:35 + --> $DIR/functions.rs:77:35 | -72 | println!("{:?}", unsafe { p.as_ref() }); +77 | println!("{:?}", unsafe { p.as_ref() }); | ^ error: this public function dereferences a raw pointer but is not marked `unsafe` - --> $DIR/functions.rs:73:33 + --> $DIR/functions.rs:78:33 | -73 | unsafe { std::ptr::read(p) }; +78 | unsafe { std::ptr::read(p) }; | ^ error: aborting due to 12 previous errors diff --git a/tests/ui/fxhash.stderr b/tests/ui/fxhash.stderr index f5f8ae7e8013..a1e50401b46e 100644 --- a/tests/ui/fxhash.stderr +++ b/tests/ui/fxhash.stderr @@ -1,39 +1,39 @@ error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:18:24 + --> $DIR/fxhash.rs:16:24 | -18 | use std::collections::{HashMap, HashSet}; +16 | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashMap` | = note: `-D clippy::default-hash-types` implied by `-D warnings` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:18:33 + --> $DIR/fxhash.rs:16:33 | -18 | use std::collections::{HashMap, HashSet}; +16 | use std::collections::{HashMap, HashSet}; | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:22:15 + --> $DIR/fxhash.rs:19:15 | -22 | let _map: HashMap = HashMap::default(); +19 | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashMap over HashMap, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:22:41 + --> $DIR/fxhash.rs:19:41 | -22 | let _map: HashMap = HashMap::default(); +19 | let _map: HashMap = HashMap::default(); | ^^^^^^^ help: use: `FxHashMap` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:23:15 + --> $DIR/fxhash.rs:20:15 | -23 | let _set: HashSet = HashSet::default(); +20 | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: Prefer FxHashSet over HashSet, it has better performance and we don't need any collision prevention in clippy - --> $DIR/fxhash.rs:23:33 + --> $DIR/fxhash.rs:20:33 | -23 | let _set: HashSet = HashSet::default(); +20 | let _set: HashSet = HashSet::default(); | ^^^^^^^ help: use: `FxHashSet` error: aborting due to 6 previous errors diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index 90b46e960f47..8b07e740a9a4 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -1,75 +1,75 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:37:17 + --> $DIR/get_unwrap.rs:41:17 | -37 | let _ = boxed_slice.get(1).unwrap(); +41 | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]` | = note: `-D clippy::get-unwrap` implied by `-D warnings` error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:38:17 + --> $DIR/get_unwrap.rs:42:17 | -38 | let _ = some_slice.get(0).unwrap(); +42 | let _ = some_slice.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]` error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:39:17 + --> $DIR/get_unwrap.rs:43:17 | -39 | let _ = some_vec.get(0).unwrap(); +43 | let _ = some_vec.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]` error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:40:17 + --> $DIR/get_unwrap.rs:44:17 | -40 | let _ = some_vecdeque.get(0).unwrap(); +44 | let _ = some_vecdeque.get(0).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]` error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:41:17 + --> $DIR/get_unwrap.rs:45:17 | -41 | let _ = some_hashmap.get(&1).unwrap(); +45 | let _ = some_hashmap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]` error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:42:17 + --> $DIR/get_unwrap.rs:46:17 | -42 | let _ = some_btreemap.get(&1).unwrap(); +46 | let _ = some_btreemap.get(&1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:47:10 + --> $DIR/get_unwrap.rs:52:10 | -47 | *boxed_slice.get_mut(0).unwrap() = 1; +52 | *boxed_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut boxed_slice[0]` error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:48:10 + --> $DIR/get_unwrap.rs:53:10 | -48 | *some_slice.get_mut(0).unwrap() = 1; +53 | *some_slice.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_slice[0]` error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:49:10 + --> $DIR/get_unwrap.rs:54:10 | -49 | *some_vec.get_mut(0).unwrap() = 1; +54 | *some_vec.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_vec[0]` error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:50:10 + --> $DIR/get_unwrap.rs:55:10 | -50 | *some_vecdeque.get_mut(0).unwrap() = 1; +55 | *some_vecdeque.get_mut(0).unwrap() = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut some_vecdeque[0]` error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:58:17 + --> $DIR/get_unwrap.rs:64:17 | -58 | let _ = some_vec.get(0..1).unwrap().to_vec(); +64 | let _ = some_vec.get(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - --> $DIR/get_unwrap.rs:59:17 + --> $DIR/get_unwrap.rs:65:17 | -59 | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); +65 | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]` error: aborting due to 12 previous errors diff --git a/tests/ui/identity_conversion.stderr b/tests/ui/identity_conversion.stderr index 15bef8b125eb..aab6bf7f218e 100644 --- a/tests/ui/identity_conversion.stderr +++ b/tests/ui/identity_conversion.stderr @@ -1,67 +1,67 @@ error: identical conversion - --> $DIR/identity_conversion.rs:16:13 + --> $DIR/identity_conversion.rs:13:13 | -16 | let _ = T::from(val); +13 | let _ = T::from(val); | ^^^^^^^^^^^^ help: consider removing `T::from()`: `val` | note: lint level defined here - --> $DIR/identity_conversion.rs:13:9 + --> $DIR/identity_conversion.rs:10:9 | -13 | #![deny(clippy::identity_conversion)] +10 | #![deny(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: identical conversion - --> $DIR/identity_conversion.rs:17:5 + --> $DIR/identity_conversion.rs:14:5 | -17 | val.into() +14 | val.into() | ^^^^^^^^^^ help: consider removing `.into()`: `val` error: identical conversion - --> $DIR/identity_conversion.rs:29:22 + --> $DIR/identity_conversion.rs:26:22 | -29 | let _: i32 = 0i32.into(); +26 | let _: i32 = 0i32.into(); | ^^^^^^^^^^^ help: consider removing `.into()`: `0i32` error: identical conversion - --> $DIR/identity_conversion.rs:50:21 + --> $DIR/identity_conversion.rs:47:21 | -50 | let _: String = "foo".to_string().into(); +47 | let _: String = "foo".to_string().into(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:51:21 + --> $DIR/identity_conversion.rs:48:21 | -51 | let _: String = From::from("foo".to_string()); +48 | let _: String = From::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `From::from()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:52:13 + --> $DIR/identity_conversion.rs:49:13 | -52 | let _ = String::from("foo".to_string()); +49 | let _ = String::from("foo".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `"foo".to_string()` error: identical conversion - --> $DIR/identity_conversion.rs:53:13 + --> $DIR/identity_conversion.rs:50:13 | -53 | let _ = String::from(format!("A: {:04}", 123)); +50 | let _ = String::from(format!("A: {:04}", 123)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `String::from()`: `format!("A: {:04}", 123)` error: identical conversion - --> $DIR/identity_conversion.rs:54:13 + --> $DIR/identity_conversion.rs:51:13 | -54 | let _ = "".lines().into_iter(); +51 | let _ = "".lines().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `"".lines()` error: identical conversion - --> $DIR/identity_conversion.rs:55:13 + --> $DIR/identity_conversion.rs:52:13 | -55 | let _ = vec![1, 2, 3].into_iter().into_iter(); +52 | let _ = vec![1, 2, 3].into_iter().into_iter(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2, 3].into_iter()` error: identical conversion - --> $DIR/identity_conversion.rs:56:21 + --> $DIR/identity_conversion.rs:53:21 | -56 | let _: String = format!("Hello {}", "world").into(); +53 | let _: String = format!("Hello {}", "world").into(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Hello {}", "world")` error: aborting due to 10 previous errors diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 332350fd1d85..e2b6efa7dbe1 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,51 +1,51 @@ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:23:5 + --> $DIR/identity_op.rs:24:5 | -23 | x + 0; +24 | x + 0; | ^^^^^ | = note: `-D clippy::identity-op` implied by `-D warnings` error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:24:5 + --> $DIR/identity_op.rs:25:5 | -24 | x + (1 - 1); +25 | x + (1 - 1); | ^^^^^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:26:5 + --> $DIR/identity_op.rs:27:5 | -26 | 0 + x; +27 | 0 + x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:29:5 + --> $DIR/identity_op.rs:30:5 | -29 | x | (0); +30 | x | (0); | ^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:32:5 + --> $DIR/identity_op.rs:33:5 | -32 | x * 1; +33 | x * 1; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:33:5 + --> $DIR/identity_op.rs:34:5 | -33 | 1 * x; +34 | 1 * x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:39:5 + --> $DIR/identity_op.rs:40:5 | -39 | -1 & x; +40 | -1 & x; | ^^^^^^ error: the operation is ineffective. Consider reducing it to `u` - --> $DIR/identity_op.rs:42:5 + --> $DIR/identity_op.rs:43:5 | -42 | u & 255; +43 | u & 255; | ^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index a054ac6223d9..0393e49a2ee7 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -1,24 +1,24 @@ error: Unnecessary boolean `not` operation - --> $DIR/if_not_else.rs:19:5 + --> $DIR/if_not_else.rs:18:5 | -19 | / if !bla() { -20 | | println!("Bugs"); -21 | | } else { -22 | | println!("Bunny"); -23 | | } +18 | / if !bla() { +19 | | println!("Bugs"); +20 | | } else { +21 | | println!("Bunny"); +22 | | } | |_____^ | = note: `-D clippy::if-not-else` implied by `-D warnings` = help: remove the `!` and swap the blocks of the if/else error: Unnecessary `!=` operation - --> $DIR/if_not_else.rs:24:5 + --> $DIR/if_not_else.rs:23:5 | -24 | / if 4 != 5 { -25 | | println!("Bugs"); -26 | | } else { -27 | | println!("Bunny"); -28 | | } +23 | / if 4 != 5 { +24 | | println!("Bugs"); +25 | | } else { +26 | | println!("Bunny"); +27 | | } | |_____^ | = help: change to `==` and swap the blocks of the if/else diff --git a/tests/ui/impl.stderr b/tests/ui/impl.stderr index c24a96e8aa76..adad754bffee 100644 --- a/tests/ui/impl.stderr +++ b/tests/ui/impl.stderr @@ -1,34 +1,34 @@ error: Multiple implementations of this structure - --> $DIR/impl.rs:22:1 + --> $DIR/impl.rs:19:1 | -22 | / impl MyStruct { -23 | | fn second() {} -24 | | } +19 | / impl MyStruct { +20 | | fn second() {} +21 | | } | |_^ | = note: `-D clippy::multiple-inherent-impl` implied by `-D warnings` note: First implementation here - --> $DIR/impl.rs:18:1 + --> $DIR/impl.rs:15:1 | -18 | / impl MyStruct { -19 | | fn first() {} -20 | | } +15 | / impl MyStruct { +16 | | fn first() {} +17 | | } | |_^ error: Multiple implementations of this structure - --> $DIR/impl.rs:36:5 + --> $DIR/impl.rs:33:5 | -36 | / impl super::MyStruct { -37 | | fn third() {} -38 | | } +33 | / impl super::MyStruct { +34 | | fn third() {} +35 | | } | |_____^ | note: First implementation here - --> $DIR/impl.rs:18:1 + --> $DIR/impl.rs:15:1 | -18 | / impl MyStruct { -19 | | fn first() {} -20 | | } +15 | / impl MyStruct { +16 | | fn first() {} +17 | | } | |_^ error: aborting due to 2 previous errors diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index c561e0a3dfb4..58b823e6ca18 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -1,136 +1,136 @@ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:21:35 + --> $DIR/implicit_hasher.rs:20:35 | -21 | impl Foo for HashMap { +20 | impl Foo for HashMap { | ^^^^^^^^^^^^^ | = note: `-D clippy::implicit-hasher` implied by `-D warnings` help: consider adding a type parameter | -21 | impl Foo for HashMap { +20 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -27 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +26 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:30:36 + --> $DIR/implicit_hasher.rs:29:36 | -30 | impl Foo for (HashMap,) { +29 | impl Foo for (HashMap,) { | ^^^^^^^^^^^^^ help: consider adding a type parameter | -30 | impl Foo for (HashMap,) { +29 | impl Foo for (HashMap,) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -32 | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) +31 | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:35:19 + --> $DIR/implicit_hasher.rs:34:19 | -35 | impl Foo for HashMap { +34 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider adding a type parameter | -35 | impl Foo for HashMap { +34 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -37 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +36 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:53:32 + --> $DIR/implicit_hasher.rs:51:32 | -53 | impl Foo for HashSet { +51 | impl Foo for HashSet { | ^^^^^^^^^^ help: consider adding a type parameter | -53 | impl Foo for HashSet { +51 | impl Foo for HashSet { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ help: ...and use generic constructor | -55 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) +53 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: impl for `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:58:19 + --> $DIR/implicit_hasher.rs:56:19 | -58 | impl Foo for HashSet { +56 | impl Foo for HashSet { | ^^^^^^^^^^^^^^^ help: consider adding a type parameter | -58 | impl Foo for HashSet { +56 | impl Foo for HashSet { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -60 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) +58 | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:75:23 + --> $DIR/implicit_hasher.rs:73:23 | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^ help: consider adding a type parameter | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:75:53 + --> $DIR/implicit_hasher.rs:73:53 | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^ help: consider adding a type parameter | -75 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) { +73 | pub fn foo(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: impl for `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:80:43 + --> $DIR/implicit_hasher.rs:77:43 | -80 | impl Foo for HashMap { +77 | impl Foo for HashMap { | ^^^^^^^^^^^^^ ... -93 | gen!(impl); - | ----------- in this macro invocation +89 | gen!(impl ); + | ------------ in this macro invocation help: consider adding a type parameter | -80 | impl Foo for HashMap { +77 | impl Foo for HashMap { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ help: ...and use generic constructor | -82 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) +79 | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) | ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashMap` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:88:33 + --> $DIR/implicit_hasher.rs:85:33 | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^ ... -94 | gen!(fn bar); +90 | gen!(fn bar); | ------------- in this macro invocation help: consider adding a type parameter | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ error: parameter of type `HashSet` should be generalized over different hashers - --> $DIR/implicit_hasher.rs:88:63 + --> $DIR/implicit_hasher.rs:85:63 | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^ ... -94 | gen!(fn bar); +90 | gen!(fn bar); | ------------- in this macro invocation help: consider adding a type parameter | -88 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) { +85 | pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ error: aborting due to 10 previous errors diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index 6f4fe12757a3..26474aab4b8f 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -1,51 +1,51 @@ error: missing return statement - --> $DIR/implicit_return.rs:21:5 + --> $DIR/implicit_return.rs:17:5 | -21 | true +17 | true | ^^^^ help: add `return` as shown: `return true` | = note: `-D clippy::implicit-return` implied by `-D warnings` error: missing return statement - --> $DIR/implicit_return.rs:27:9 + --> $DIR/implicit_return.rs:23:9 | -27 | true +23 | true | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:29:9 + --> $DIR/implicit_return.rs:25:9 | -29 | false +25 | false | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:36:17 + --> $DIR/implicit_return.rs:32:17 | -36 | true => false, +32 | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:38:13 + --> $DIR/implicit_return.rs:33:18 | -38 | true - | ^^^^ help: add `return` as shown: `return true` +33 | false => true, + | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:46:9 + --> $DIR/implicit_return.rs:40:9 | -46 | break true; +40 | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:52:9 + --> $DIR/implicit_return.rs:45:16 | -52 | true - | ^^^^ help: add `return` as shown: `return true` +45 | let _ = || true; + | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:54:16 + --> $DIR/implicit_return.rs:46:16 | -54 | let _ = || true; +46 | let _ = || true; | ^^^^ help: add `return` as shown: `return true` error: aborting due to 8 previous errors diff --git a/tests/ui/inconsistent_digit_grouping.stderr b/tests/ui/inconsistent_digit_grouping.stderr index a417394629eb..77e2f3bd41b2 100644 --- a/tests/ui/inconsistent_digit_grouping.stderr +++ b/tests/ui/inconsistent_digit_grouping.stderr @@ -1,33 +1,33 @@ error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:16 + --> $DIR/inconsistent_digit_grouping.rs:22:16 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `123_456` | = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:26 + --> $DIR/inconsistent_digit_grouping.rs:22:26 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^ help: consider: `12_345_678` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:38 + --> $DIR/inconsistent_digit_grouping.rs:22:38 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^ help: consider: `1_234_567` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:48 + --> $DIR/inconsistent_digit_grouping.rs:22:48 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1_234.567_8_f32` error: digits grouped inconsistently by underscores - --> $DIR/inconsistent_digit_grouping.rs:17:64 + --> $DIR/inconsistent_digit_grouping.rs:22:64 | -17 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); +22 | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32); | ^^^^^^^^^^^^^^ help: consider: `1.234_567_8_f32` error: aborting due to 5 previous errors diff --git a/tests/ui/indexing_slicing.stderr b/tests/ui/indexing_slicing.stderr index 14e9627e5734..c9a45bc40847 100644 --- a/tests/ui/indexing_slicing.stderr +++ b/tests/ui/indexing_slicing.stderr @@ -1,308 +1,308 @@ error: index out of bounds: the len is 4 but the index is 4 - --> $DIR/indexing_slicing.rs:28:5 + --> $DIR/indexing_slicing.rs:25:5 | -28 | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +25 | x[4]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^ | = note: #[deny(const_err)] on by default error: index out of bounds: the len is 4 but the index is 8 - --> $DIR/indexing_slicing.rs:29:5 + --> $DIR/indexing_slicing.rs:26:5 | -29 | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +26 | x[1 << 3]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^^^^^^ error: index out of bounds: the len is 0 but the index is 0 - --> $DIR/indexing_slicing.rs:59:5 + --> $DIR/indexing_slicing.rs:56:5 | -59 | empty[0]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +56 | empty[0]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^^^^^ error: index out of bounds: the len is 4 but the index is 15 - --> $DIR/indexing_slicing.rs:90:5 + --> $DIR/indexing_slicing.rs:87:5 | -90 | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. +87 | x[N]; // Ok, let rustc's `const_err` lint handle `usize` indexing on arrays. | ^^^^ error: indexing may panic. - --> $DIR/indexing_slicing.rs:23:5 + --> $DIR/indexing_slicing.rs:20:5 | -23 | x[index]; +20 | x[index]; | ^^^^^^^^ | = note: `-D clippy::indexing-slicing` implied by `-D warnings` = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:24:6 + --> $DIR/indexing_slicing.rs:21:6 | -24 | &x[index..]; +21 | &x[index..]; | ^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:25:6 + --> $DIR/indexing_slicing.rs:22:6 | -25 | &x[..index]; +22 | &x[..index]; | ^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:26:6 + --> $DIR/indexing_slicing.rs:23:6 | -26 | &x[index_from..index_to]; +23 | &x[index_from..index_to]; | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:27:6 + --> $DIR/indexing_slicing.rs:24:6 | -27 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +24 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:27:6 + --> $DIR/indexing_slicing.rs:24:6 | -27 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. +24 | &x[index_from..][..index_to]; // Two lint reports, one for [index_from..] and another for [..index_to]. | ^^^^^^^^^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:30:11 + --> $DIR/indexing_slicing.rs:27:11 | -30 | &x[..=4]; +27 | &x[..=4]; | ^ | = note: `-D clippy::out-of-bounds-indexing` implied by `-D warnings` error: range is out of bounds - --> $DIR/indexing_slicing.rs:31:11 + --> $DIR/indexing_slicing.rs:28:11 | -31 | &x[1..5]; +28 | &x[1..5]; | ^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:32:6 + --> $DIR/indexing_slicing.rs:29:6 | -32 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. +29 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:32:8 + --> $DIR/indexing_slicing.rs:29:8 | -32 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. +29 | &x[5..][..10]; // Two lint reports, one for [5..] and another for [..10]. | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:33:8 + --> $DIR/indexing_slicing.rs:30:8 | -33 | &x[5..]; +30 | &x[5..]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:34:10 + --> $DIR/indexing_slicing.rs:31:10 | -34 | &x[..5]; +31 | &x[..5]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:35:8 + --> $DIR/indexing_slicing.rs:32:8 | -35 | &x[5..].iter().map(|x| 2 * x).collect::>(); +32 | &x[5..].iter().map(|x| 2 * x).collect::>(); | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:36:12 + --> $DIR/indexing_slicing.rs:33:12 | -36 | &x[0..=4]; +33 | &x[0..=4]; | ^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:37:6 + --> $DIR/indexing_slicing.rs:34:6 | -37 | &x[0..][..3]; +34 | &x[0..][..3]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:38:6 + --> $DIR/indexing_slicing.rs:35:6 | -38 | &x[1..][..5]; +35 | &x[1..][..5]; | ^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:51:5 + --> $DIR/indexing_slicing.rs:48:5 | -51 | y[0]; +48 | y[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:52:6 + --> $DIR/indexing_slicing.rs:49:6 | -52 | &y[1..2]; +49 | &y[1..2]; | ^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:53:6 + --> $DIR/indexing_slicing.rs:50:6 | -53 | &y[0..=4]; +50 | &y[0..=4]; | ^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:54:6 + --> $DIR/indexing_slicing.rs:51:6 | -54 | &y[..=4]; +51 | &y[..=4]; | ^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:60:12 + --> $DIR/indexing_slicing.rs:57:12 | -60 | &empty[1..5]; +57 | &empty[1..5]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:61:16 + --> $DIR/indexing_slicing.rs:58:16 | -61 | &empty[0..=4]; +58 | &empty[0..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:62:15 + --> $DIR/indexing_slicing.rs:59:15 | -62 | &empty[..=4]; +59 | &empty[..=4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:63:12 + --> $DIR/indexing_slicing.rs:60:12 | -63 | &empty[1..]; +60 | &empty[1..]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:64:14 + --> $DIR/indexing_slicing.rs:61:14 | -64 | &empty[..4]; +61 | &empty[..4]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:65:16 + --> $DIR/indexing_slicing.rs:62:16 | -65 | &empty[0..=0]; +62 | &empty[0..=0]; | ^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:66:15 + --> $DIR/indexing_slicing.rs:63:15 | -66 | &empty[..=0]; +63 | &empty[..=0]; | ^ error: indexing may panic. - --> $DIR/indexing_slicing.rs:74:5 + --> $DIR/indexing_slicing.rs:71:5 | -74 | v[0]; +71 | v[0]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:75:5 + --> $DIR/indexing_slicing.rs:72:5 | -75 | v[10]; +72 | v[10]; | ^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:76:5 + --> $DIR/indexing_slicing.rs:73:5 | -76 | v[1 << 3]; +73 | v[1 << 3]; | ^^^^^^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:77:6 + --> $DIR/indexing_slicing.rs:74:6 | -77 | &v[10..100]; +74 | &v[10..100]; | ^^^^^^^^^^ | = help: Consider using `.get(n..m)` or `.get_mut(n..m)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:78:6 + --> $DIR/indexing_slicing.rs:75:6 | -78 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +75 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^^^^^^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:78:8 + --> $DIR/indexing_slicing.rs:75:8 | -78 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. +75 | &x[10..][..100]; // Two lint reports, one for [10..] and another for [..100]. | ^^ error: slicing may panic. - --> $DIR/indexing_slicing.rs:79:6 + --> $DIR/indexing_slicing.rs:76:6 | -79 | &v[10..]; +76 | &v[10..]; | ^^^^^^^ | = help: Consider using `.get(n..)` or .get_mut(n..)` instead error: slicing may panic. - --> $DIR/indexing_slicing.rs:80:6 + --> $DIR/indexing_slicing.rs:77:6 | -80 | &v[..100]; +77 | &v[..100]; | ^^^^^^^^ | = help: Consider using `.get(..n)`or `.get_mut(..n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:92:5 + --> $DIR/indexing_slicing.rs:89:5 | -92 | v[N]; +89 | v[N]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic. - --> $DIR/indexing_slicing.rs:93:5 + --> $DIR/indexing_slicing.rs:90:5 | -93 | v[M]; +90 | v[M]; | ^^^^ | = help: Consider using `.get(n)` or `.get_mut(n)` instead error: range is out of bounds - --> $DIR/indexing_slicing.rs:97:13 + --> $DIR/indexing_slicing.rs:94:13 | -97 | &x[num..10]; // should trigger out of bounds error +94 | &x[num..10]; // should trigger out of bounds error | ^^ error: range is out of bounds - --> $DIR/indexing_slicing.rs:98:8 + --> $DIR/indexing_slicing.rs:95:8 | -98 | &x[10..num]; // should trigger out of bounds error +95 | &x[10..num]; // should trigger out of bounds error | ^^ error: aborting due to 43 previous errors diff --git a/tests/ui/infallible_destructuring_match.stderr b/tests/ui/infallible_destructuring_match.stderr index bce83b91242e..62588a2ad7ce 100644 --- a/tests/ui/infallible_destructuring_match.stderr +++ b/tests/ui/infallible_destructuring_match.stderr @@ -1,27 +1,27 @@ error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:28:5 + --> $DIR/infallible_destructuring_match.rs:25:5 | -28 | / let data = match wrapper { -29 | | SingleVariantEnum::Variant(i) => i, -30 | | }; +25 | / let data = match wrapper { +26 | | SingleVariantEnum::Variant(i) => i, +27 | | }; | |______^ help: try this: `let SingleVariantEnum::Variant(data) = wrapper;` | = note: `-D clippy::infallible-destructuring-match` implied by `-D warnings` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:49:5 + --> $DIR/infallible_destructuring_match.rs:46:5 | -49 | / let data = match wrapper { -50 | | TupleStruct(i) => i, -51 | | }; +46 | / let data = match wrapper { +47 | | TupleStruct(i) => i, +48 | | }; | |______^ help: try this: `let TupleStruct(data) = wrapper;` error: you seem to be trying to use match to destructure a single infallible pattern. Consider using `let` - --> $DIR/infallible_destructuring_match.rs:70:5 + --> $DIR/infallible_destructuring_match.rs:67:5 | -70 | / let data = match wrapper { -71 | | Ok(i) => i, -72 | | }; +67 | / let data = match wrapper { +68 | | Ok(i) => i, +69 | | }; | |______^ help: try this: `let Ok(data) = wrapper;` error: aborting due to 3 previous errors diff --git a/tests/ui/infinite_iter.stderr b/tests/ui/infinite_iter.stderr index 5b783c2b8b99..2c3b05aaff32 100644 --- a/tests/ui/infinite_iter.stderr +++ b/tests/ui/infinite_iter.stderr @@ -1,99 +1,108 @@ error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> $DIR/infinite_iter.rs:20:5 + --> $DIR/infinite_iter.rs:19:5 | -20 | repeat(0_u8).collect::>(); // infinite iter +19 | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-collect` implied by `-D warnings` error: infinite iteration detected - --> $DIR/infinite_iter.rs:20:5 + --> $DIR/infinite_iter.rs:19:5 | -20 | repeat(0_u8).collect::>(); // infinite iter +19 | repeat(0_u8).collect::>(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/infinite_iter.rs:18:8 + --> $DIR/infinite_iter.rs:17:8 | -18 | #[deny(clippy::infinite_iter)] +17 | #[deny(clippy::infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:21:5 + --> $DIR/infinite_iter.rs:20:5 | -21 | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter +20 | (0..8_u32).take_while(square_is_lower_64).cycle().count(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:22:5 + --> $DIR/infinite_iter.rs:21:5 | -22 | (0..8_u64).chain(0..).max(); // infinite iter +21 | (0..8_u64).chain(0..).max(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:24:5 + --> $DIR/infinite_iter.rs:26:5 | -24 | (0..8_u32).rev().cycle().map(|x| x + 1_u32).for_each(|x| println!("{}", x)); // infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +26 | / (0..8_u32) +27 | | .rev() +28 | | .cycle() +29 | | .map(|x| x + 1_u32) +30 | | .for_each(|x| println!("{}", x)); // infinite iter + | |________________________________________^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:26:5 + --> $DIR/infinite_iter.rs:32:5 | -26 | (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter +32 | (0_usize..).flat_map(|x| 0..x).product::(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: infinite iteration detected - --> $DIR/infinite_iter.rs:27:5 + --> $DIR/infinite_iter.rs:33:5 | -27 | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter +33 | (0_u64..).filter(|x| x % 2 == 0).last(); // infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:34:5 + --> $DIR/infinite_iter.rs:40:5 | -34 | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter +40 | (0..).zip((0..).take_while(square_is_lower_64)).count(); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/infinite_iter.rs:32:8 + --> $DIR/infinite_iter.rs:38:8 | -32 | #[deny(clippy::maybe_infinite_iter)] +38 | #[deny(clippy::maybe_infinite_iter)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:35:5 + --> $DIR/infinite_iter.rs:41:5 | -35 | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter +41 | repeat(42).take_while(|x| *x == 42).chain(0..42).max(); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:36:5 - | -36 | (1..).scan(0, |state, x| { *state += x; Some(*state) }).min(); // maybe infinite iter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/infinite_iter.rs:42:5 + | +42 | / (1..) +43 | | .scan(0, |state, x| { +44 | | *state += x; +45 | | Some(*state) +46 | | }) +47 | | .min(); // maybe infinite iter + | |______________^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:37:5 + --> $DIR/infinite_iter.rs:48:5 | -37 | (0..).find(|x| *x == 24); // maybe infinite iter +48 | (0..).find(|x| *x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:38:5 + --> $DIR/infinite_iter.rs:49:5 | -38 | (0..).position(|x| x == 24); // maybe infinite iter +49 | (0..).position(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:39:5 + --> $DIR/infinite_iter.rs:50:5 | -39 | (0..).any(|x| x == 24); // maybe infinite iter +50 | (0..).any(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ error: possible infinite iteration detected - --> $DIR/infinite_iter.rs:40:5 + --> $DIR/infinite_iter.rs:51:5 | -40 | (0..).all(|x| x == 24); // maybe infinite iter +51 | (0..).all(|x| x == 24); // maybe infinite iter | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/infinite_loop.stderr b/tests/ui/infinite_loop.stderr index fdbdd13fd8f9..de7851519ec7 100644 --- a/tests/ui/infinite_loop.stderr +++ b/tests/ui/infinite_loop.stderr @@ -1,57 +1,57 @@ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:26:11 + --> $DIR/infinite_loop.rs:32:11 | -26 | while y < 10 { +32 | while y < 10 { | ^^^^^^ | = note: #[deny(clippy::while_immutable_condition)] on by default error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:31:11 + --> $DIR/infinite_loop.rs:37:11 | -31 | while y < 10 && x < 3 { +37 | while y < 10 && x < 3 { | ^^^^^^^^^^^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:38:11 + --> $DIR/infinite_loop.rs:44:11 | -38 | while !cond { +44 | while !cond { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:82:11 + --> $DIR/infinite_loop.rs:88:11 | -82 | while i < 3 { +88 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:87:11 + --> $DIR/infinite_loop.rs:93:11 | -87 | while i < 3 && j > 0 { +93 | while i < 3 && j > 0 { | ^^^^^^^^^^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:91:11 + --> $DIR/infinite_loop.rs:97:11 | -91 | while i < 3 { +97 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:106:11 + --> $DIR/infinite_loop.rs:112:11 | -106 | while i < 3 { +112 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:111:11 + --> $DIR/infinite_loop.rs:117:11 | -111 | while i < 3 { +117 | while i < 3 { | ^^^^^ error: Variable in the condition are not mutated in the loop body. This either leads to an infinite or to a never running loop. - --> $DIR/infinite_loop.rs:174:15 + --> $DIR/infinite_loop.rs:183:15 | -174 | while self.count < n { +183 | while self.count < n { | ^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/inline_fn_without_body.stderr b/tests/ui/inline_fn_without_body.stderr index 112fad812e5e..0eaee7c7b257 100644 --- a/tests/ui/inline_fn_without_body.stderr +++ b/tests/ui/inline_fn_without_body.stderr @@ -1,25 +1,27 @@ error: use of `#[inline]` on trait method `default_inline` which has no body - --> $DIR/inline_fn_without_body.rs:18:5 + --> $DIR/inline_fn_without_body.rs:14:5 | -18 | #[inline] +14 | #[inline] | _____-^^^^^^^^ -19 | | fn default_inline(); +15 | | fn default_inline(); | |____- help: remove | = note: `-D clippy::inline-fn-without-body` implied by `-D warnings` error: use of `#[inline]` on trait method `always_inline` which has no body - --> $DIR/inline_fn_without_body.rs:21:5 + --> $DIR/inline_fn_without_body.rs:17:5 | -21 | #[inline(always)]fn always_inline(); - | ^^^^^^^^^^^^^^^^^ help: remove +17 | #[inline(always)] + | _____-^^^^^^^^^^^^^^^^ +18 | | fn always_inline(); + | |____- help: remove error: use of `#[inline]` on trait method `never_inline` which has no body - --> $DIR/inline_fn_without_body.rs:23:5 + --> $DIR/inline_fn_without_body.rs:20:5 | -23 | #[inline(never)] +20 | #[inline(never)] | _____-^^^^^^^^^^^^^^^ -24 | | fn never_inline(); +21 | | fn never_inline(); | |____- help: remove error: aborting due to 3 previous errors diff --git a/tests/ui/int_plus_one.stderr b/tests/ui/int_plus_one.stderr index 5612b2032908..4a81e911157b 100644 --- a/tests/ui/int_plus_one.stderr +++ b/tests/ui/int_plus_one.stderr @@ -1,43 +1,43 @@ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:20:5 + --> $DIR/int_plus_one.rs:16:5 | -20 | x >= y + 1; +16 | x >= y + 1; | ^^^^^^^^^^ | = note: `-D clippy::int-plus-one` implied by `-D warnings` help: change `>= y + 1` to `> y` as shown | -20 | x > y; +16 | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:21:5 + --> $DIR/int_plus_one.rs:17:5 | -21 | y + 1 <= x; +17 | y + 1 <= x; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -21 | y < x; +17 | y < x; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:23:5 + --> $DIR/int_plus_one.rs:19:5 | -23 | x - 1 >= y; +19 | x - 1 >= y; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -23 | x > y; +19 | x > y; | ^^^^^ error: Unnecessary `>= y + 1` or `x - 1 >=` - --> $DIR/int_plus_one.rs:24:5 + --> $DIR/int_plus_one.rs:20:5 | -24 | y <= x - 1; +20 | y <= x - 1; | ^^^^^^^^^^ help: change `>= y + 1` to `> y` as shown | -24 | y < x; +20 | y < x; | ^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/into_iter_on_ref.stderr b/tests/ui/into_iter_on_ref.stderr index 390554230488..f6d6fe35d7f5 100644 --- a/tests/ui/into_iter_on_ref.stderr +++ b/tests/ui/into_iter_on_ref.stderr @@ -1,8 +1,8 @@ error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:11:22 + --> $DIR/into_iter_on_ref.rs:11:24 | -11 | for _ in [1,2,3].into_iter() {} //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +11 | for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` | note: lint level defined here --> $DIR/into_iter_on_ref.rs:2:9 @@ -11,24 +11,24 @@ note: lint level defined here | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:13:21 + --> $DIR/into_iter_on_ref.rs:13:23 | -13 | let _ = [1,2,3].into_iter(); //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +13 | let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the Vec - --> $DIR/into_iter_on_ref.rs:15:28 + --> $DIR/into_iter_on_ref.rs:15:30 | -15 | let _ = (&vec![1,2,3]).into_iter(); //~ WARN equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +15 | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` | = note: `-D clippy::into-iter-on-ref` implied by `-D warnings` error: this .into_iter() call is equivalent to .iter() and will not move the slice - --> $DIR/into_iter_on_ref.rs:16:44 + --> $DIR/into_iter_on_ref.rs:16:46 | -16 | let _ = vec![1,2,3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +16 | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the slice --> $DIR/into_iter_on_ref.rs:17:41 @@ -43,22 +43,22 @@ error: this .into_iter() call is equivalent to .iter() and will not move the sli | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:20:30 + --> $DIR/into_iter_on_ref.rs:20:32 | -20 | let _ = (&&&&&&&[1,2,3]).into_iter(); //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +20 | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter() and will not move the array - --> $DIR/into_iter_on_ref.rs:21:34 + --> $DIR/into_iter_on_ref.rs:21:36 | -21 | let _ = (&&&&mut &&&[1,2,3]).into_iter(); //~ ERROR equivalent to .iter() - | ^^^^^^^^^ help: call directly: `iter` +21 | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter() + | ^^^^^^^^^ help: call directly: `iter` error: this .into_iter() call is equivalent to .iter_mut() and will not move the array - --> $DIR/into_iter_on_ref.rs:22:38 + --> $DIR/into_iter_on_ref.rs:22:40 | -22 | let _ = (&mut &mut &mut [1,2,3]).into_iter(); //~ ERROR equivalent to .iter_mut() - | ^^^^^^^^^ help: call directly: `iter_mut` +22 | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut() + | ^^^^^^^^^ help: call directly: `iter_mut` error: this .into_iter() call is equivalent to .iter() and will not move the Option --> $DIR/into_iter_on_ref.rs:24:24 diff --git a/tests/ui/invalid_ref.stderr b/tests/ui/invalid_ref.stderr index 52868e908cac..a5142596aebf 100644 --- a/tests/ui/invalid_ref.stderr +++ b/tests/ui/invalid_ref.stderr @@ -1,48 +1,48 @@ error: reference to zeroed memory - --> $DIR/invalid_ref.rs:37:24 + --> $DIR/invalid_ref.rs:33:24 | -37 | let ref_zero: &T = std::mem::zeroed(); // warning +33 | let ref_zero: &T = std::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(clippy::invalid_ref)] on by default = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to zeroed memory - --> $DIR/invalid_ref.rs:41:24 + --> $DIR/invalid_ref.rs:37:24 | -41 | let ref_zero: &T = core::mem::zeroed(); // warning +37 | let ref_zero: &T = core::mem::zeroed(); // warning | ^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to zeroed memory - --> $DIR/invalid_ref.rs:45:24 + --> $DIR/invalid_ref.rs:41:24 | -45 | let ref_zero: &T = std::intrinsics::init(); // warning +41 | let ref_zero: &T = std::intrinsics::init(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to uninitialized memory - --> $DIR/invalid_ref.rs:49:26 + --> $DIR/invalid_ref.rs:45:26 | -49 | let ref_uninit: &T = std::mem::uninitialized(); // warning +45 | let ref_uninit: &T = std::mem::uninitialized(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to uninitialized memory - --> $DIR/invalid_ref.rs:53:26 + --> $DIR/invalid_ref.rs:49:26 | -53 | let ref_uninit: &T = core::mem::uninitialized(); // warning +49 | let ref_uninit: &T = core::mem::uninitialized(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html error: reference to uninitialized memory - --> $DIR/invalid_ref.rs:57:26 + --> $DIR/invalid_ref.rs:53:26 | -57 | let ref_uninit: &T = std::intrinsics::uninit(); // warning +53 | let ref_uninit: &T = std::intrinsics::uninit(); // warning | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Creation of a null reference is undefined behavior; see https://doc.rust-lang.org/reference/behavior-considered-undefined.html diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index e41132dfc8bb..2ac4a48b8623 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -1,165 +1,165 @@ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:26:5 + --> $DIR/invalid_upcast_comparisons.rs:30:5 | -26 | (u8 as u32) > 300; +30 | (u8 as u32) > 300; | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::invalid-upcast-comparisons` implied by `-D warnings` error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:27:5 + --> $DIR/invalid_upcast_comparisons.rs:31:5 | -27 | (u8 as i32) > 300; +31 | (u8 as i32) > 300; | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:28:5 + --> $DIR/invalid_upcast_comparisons.rs:32:5 | -28 | (u8 as u32) == 300; +32 | (u8 as u32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:29:5 + --> $DIR/invalid_upcast_comparisons.rs:33:5 | -29 | (u8 as i32) == 300; +33 | (u8 as i32) == 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:30:5 + --> $DIR/invalid_upcast_comparisons.rs:34:5 | -30 | 300 < (u8 as u32); +34 | 300 < (u8 as u32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:31:5 + --> $DIR/invalid_upcast_comparisons.rs:35:5 | -31 | 300 < (u8 as i32); +35 | 300 < (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:32:5 + --> $DIR/invalid_upcast_comparisons.rs:36:5 | -32 | 300 == (u8 as u32); +36 | 300 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:33:5 + --> $DIR/invalid_upcast_comparisons.rs:37:5 | -33 | 300 == (u8 as i32); +37 | 300 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:35:5 + --> $DIR/invalid_upcast_comparisons.rs:39:5 | -35 | (u8 as u32) <= 300; +39 | (u8 as u32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:36:5 + --> $DIR/invalid_upcast_comparisons.rs:40:5 | -36 | (u8 as i32) <= 300; +40 | (u8 as i32) <= 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:37:5 + --> $DIR/invalid_upcast_comparisons.rs:41:5 | -37 | (u8 as u32) != 300; +41 | (u8 as u32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:38:5 + --> $DIR/invalid_upcast_comparisons.rs:42:5 | -38 | (u8 as i32) != 300; +42 | (u8 as i32) != 300; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:39:5 + --> $DIR/invalid_upcast_comparisons.rs:43:5 | -39 | 300 >= (u8 as u32); +43 | 300 >= (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:40:5 + --> $DIR/invalid_upcast_comparisons.rs:44:5 | -40 | 300 >= (u8 as i32); +44 | 300 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:41:5 + --> $DIR/invalid_upcast_comparisons.rs:45:5 | -41 | 300 != (u8 as u32); +45 | 300 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:42:5 + --> $DIR/invalid_upcast_comparisons.rs:46:5 | -42 | 300 != (u8 as i32); +46 | 300 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:45:5 + --> $DIR/invalid_upcast_comparisons.rs:49:5 | -45 | (u8 as i32) < 0; +49 | (u8 as i32) < 0; | ^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:46:5 + --> $DIR/invalid_upcast_comparisons.rs:50:5 | -46 | -5 != (u8 as i32); +50 | -5 != (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:48:5 + --> $DIR/invalid_upcast_comparisons.rs:52:5 | -48 | (u8 as i32) >= 0; +52 | (u8 as i32) >= 0; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:49:5 + --> $DIR/invalid_upcast_comparisons.rs:53:5 | -49 | -5 == (u8 as i32); +53 | -5 == (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:52:5 + --> $DIR/invalid_upcast_comparisons.rs:56:5 | -52 | 1337 == (u8 as i32); +56 | 1337 == (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:53:5 + --> $DIR/invalid_upcast_comparisons.rs:57:5 | -53 | 1337 == (u8 as u32); +57 | 1337 == (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:55:5 + --> $DIR/invalid_upcast_comparisons.rs:59:5 | -55 | 1337 != (u8 as i32); +59 | 1337 != (u8 as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:56:5 + --> $DIR/invalid_upcast_comparisons.rs:60:5 | -56 | 1337 != (u8 as u32); +60 | 1337 != (u8 as u32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always true - --> $DIR/invalid_upcast_comparisons.rs:71:5 + --> $DIR/invalid_upcast_comparisons.rs:74:5 | -71 | (u8 as i32) > -1; +74 | (u8 as i32) > -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:72:5 + --> $DIR/invalid_upcast_comparisons.rs:75:5 | -72 | (u8 as i32) < -1; +75 | (u8 as i32) < -1; | ^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8` prior to casting, this expression is always false - --> $DIR/invalid_upcast_comparisons.rs:88:5 + --> $DIR/invalid_upcast_comparisons.rs:91:5 | -88 | -5 >= (u8 as i32); +91 | -5 >= (u8 as i32); | ^^^^^^^^^^^^^^^^^ error: aborting due to 27 previous errors diff --git a/tests/ui/issue-3145.stderr b/tests/ui/issue-3145.stderr index 2086f11463fa..6f9f88a8d678 100644 --- a/tests/ui/issue-3145.stderr +++ b/tests/ui/issue-3145.stderr @@ -1,7 +1,7 @@ error: expected token: `,` - --> $DIR/issue-3145.rs:12:19 + --> $DIR/issue-3145.rs:11:19 | -12 | println!("{}" a); //~ERROR expected token: `,` +11 | println!("{}" a); //~ERROR expected token: `,` | ^ error: aborting due to previous error diff --git a/tests/ui/issue_2356.stderr b/tests/ui/issue_2356.stderr index 291e64bec6f4..28b67cbc9fa5 100644 --- a/tests/ui/issue_2356.stderr +++ b/tests/ui/issue_2356.stderr @@ -1,13 +1,13 @@ error: this loop could be written as a `for` loop - --> $DIR/issue_2356.rs:27:29 + --> $DIR/issue_2356.rs:24:29 | -27 | while let Some(e) = it.next() { +24 | while let Some(e) = it.next() { | ^^^^^^^^^ help: try: `for e in it { .. }` | note: lint level defined here - --> $DIR/issue_2356.rs:13:9 + --> $DIR/issue_2356.rs:10:9 | -13 | #![deny(clippy::while_let_on_iterator)] +10 | #![deny(clippy::while_let_on_iterator)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index 15c0cc3af4c5..c988fca3827f 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -1,16 +1,20 @@ error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/item_after_statement.rs:22:5 + --> $DIR/item_after_statement.rs:21:5 | -22 | fn foo() { println!("foo"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +21 | / fn foo() { +22 | | println!("foo"); +23 | | } + | |_____^ | = note: `-D clippy::items-after-statements` implied by `-D warnings` error: adding items after statements is confusing, since items exist from the start of the scope - --> $DIR/item_after_statement.rs:27:5 + --> $DIR/item_after_statement.rs:28:5 | -27 | fn foo() { println!("foo"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +28 | / fn foo() { +29 | | println!("foo"); +30 | | } + | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/large_digit_groups.stderr b/tests/ui/large_digit_groups.stderr index c38abb8887c0..47587f5423a7 100644 --- a/tests/ui/large_digit_groups.stderr +++ b/tests/ui/large_digit_groups.stderr @@ -1,40 +1,40 @@ error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:16 + --> $DIR/large_digit_groups.rs:24:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^ help: consider: `0b11_0110_i64` +24 | 0b1_10110_i64, + | ^^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | = note: `-D clippy::large-digit-groups` implied by `-D warnings` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:31 + --> $DIR/large_digit_groups.rs:25:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` +25 | 0x1_23456_78901_usize, + | ^^^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:54 + --> $DIR/large_digit_groups.rs:26:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^ help: consider: `123_456_f32` +26 | 1_23456_f32, + | ^^^^^^^^^^^ help: consider: `123_456_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:67 + --> $DIR/large_digit_groups.rs:27:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` +27 | 1_23456.12_f32, + | ^^^^^^^^^^^^^^ help: consider: `123_456.12_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:83 + --> $DIR/large_digit_groups.rs:28:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f32` +28 | 1_23456.12345_f32, + | ^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_45_f32` error: digit groups should be smaller - --> $DIR/large_digit_groups.rs:17:102 + --> $DIR/large_digit_groups.rs:29:9 | -17 | let bad = (0b1_10110_i64, 0x1_23456_78901_usize, 1_23456_f32, 1_23456.12_f32, 1_23456.12345_f32, 1_23456.12345_6_f32); - | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f32` +29 | 1_23456.12345_6_f32, + | ^^^^^^^^^^^^^^^^^^^ help: consider: `123_456.123_456_f32` error: aborting due to 6 previous errors diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 4bb25dd855ae..c9c46ced5e22 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -1,69 +1,69 @@ error: large size difference between variants - --> $DIR/large_enum_variant.rs:20:5 + --> $DIR/large_enum_variant.rs:16:5 | -20 | B([i32; 8000]), +16 | B([i32; 8000]), | ^^^^^^^^^^^^^^ | = note: `-D clippy::large-enum-variant` implied by `-D warnings` help: consider boxing the large fields to reduce the total size of the enum | -20 | B(Box<[i32; 8000]>), +16 | B(Box<[i32; 8000]>), | ^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:31:5 + --> $DIR/large_enum_variant.rs:27:5 | -31 | C(T, [i32; 8000]), +27 | C(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:31:5 + --> $DIR/large_enum_variant.rs:27:5 | -31 | C(T, [i32; 8000]), +27 | C(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:44:5 + --> $DIR/large_enum_variant.rs:40:5 | -44 | ContainingLargeEnum(LargeEnum), +40 | ContainingLargeEnum(LargeEnum), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum | -44 | ContainingLargeEnum(Box), +40 | ContainingLargeEnum(Box), | ^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:47:5 + --> $DIR/large_enum_variant.rs:43:5 | -47 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), +43 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:47:5 + --> $DIR/large_enum_variant.rs:43:5 | -47 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), +43 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:54:5 + --> $DIR/large_enum_variant.rs:50:5 | -54 | StructLikeLarge { x: [i32; 8000], y: i32 }, +50 | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - --> $DIR/large_enum_variant.rs:54:5 + --> $DIR/large_enum_variant.rs:50:5 | -54 | StructLikeLarge { x: [i32; 8000], y: i32 }, +50 | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large size difference between variants - --> $DIR/large_enum_variant.rs:59:5 + --> $DIR/large_enum_variant.rs:55:5 | -59 | StructLikeLarge2 { x: [i32; 8000] }, +55 | StructLikeLarge2 { x: [i32; 8000] }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum | -59 | StructLikeLarge2 { x: Box<[i32; 8000]> }, +55 | StructLikeLarge2 { x: Box<[i32; 8000]> }, | ^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index 1f937bafdefb..bc5cd0e595b8 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,139 +1,139 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:18:1 + --> $DIR/len_zero.rs:15:1 | -18 | / impl PubOne { -19 | | pub fn len(self: &Self) -> isize { -20 | | 1 -21 | | } -22 | | } +15 | / impl PubOne { +16 | | pub fn len(self: &Self) -> isize { +17 | | 1 +18 | | } +19 | | } | |_^ | = note: `-D clippy::len-without-is-empty` implied by `-D warnings` error: trait `PubTraitsToo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:67:1 + --> $DIR/len_zero.rs:64:1 | -67 | / pub trait PubTraitsToo { -68 | | fn len(self: &Self) -> isize; -69 | | } +64 | / pub trait PubTraitsToo { +65 | | fn len(self: &Self) -> isize; +66 | | } | |_^ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method - --> $DIR/len_zero.rs:101:1 + --> $DIR/len_zero.rs:98:1 | -101 | / impl HasIsEmpty { -102 | | pub fn len(self: &Self) -> isize { -103 | | 1 -104 | | } +98 | / impl HasIsEmpty { +99 | | pub fn len(self: &Self) -> isize { +100 | | 1 +101 | | } ... | -108 | | } -109 | | } +105 | | } +106 | | } | |_^ error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method - --> $DIR/len_zero.rs:130:1 + --> $DIR/len_zero.rs:127:1 | -130 | / impl HasWrongIsEmpty { -131 | | pub fn len(self: &Self) -> isize { -132 | | 1 -133 | | } +127 | / impl HasWrongIsEmpty { +128 | | pub fn len(self: &Self) -> isize { +129 | | 1 +130 | | } ... | -137 | | } -138 | | } +134 | | } +135 | | } | |_^ error: length comparison to zero - --> $DIR/len_zero.rs:151:8 + --> $DIR/len_zero.rs:148:8 | -151 | if x.len() == 0 { +148 | if x.len() == 0 { | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()` | = note: `-D clippy::len-zero` implied by `-D warnings` error: length comparison to zero - --> $DIR/len_zero.rs:155:8 + --> $DIR/len_zero.rs:152:8 | -155 | if "".len() == 0 {} +152 | if "".len() == 0 {} | ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:170:8 + --> $DIR/len_zero.rs:167:8 | -170 | if has_is_empty.len() == 0 { +167 | if has_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:173:8 + --> $DIR/len_zero.rs:170:8 | -173 | if has_is_empty.len() != 0 { +170 | if has_is_empty.len() != 0 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:176:8 + --> $DIR/len_zero.rs:173:8 | -176 | if has_is_empty.len() > 0 { +173 | if has_is_empty.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:179:8 + --> $DIR/len_zero.rs:176:8 | -179 | if has_is_empty.len() < 1 { +176 | if has_is_empty.len() < 1 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:182:8 + --> $DIR/len_zero.rs:179:8 | -182 | if has_is_empty.len() >= 1 { +179 | if has_is_empty.len() >= 1 { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:193:8 + --> $DIR/len_zero.rs:190:8 | -193 | if 0 == has_is_empty.len() { +190 | if 0 == has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:196:8 + --> $DIR/len_zero.rs:193:8 | -196 | if 0 != has_is_empty.len() { +193 | if 0 != has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:199:8 + --> $DIR/len_zero.rs:196:8 | -199 | if 0 < has_is_empty.len() { +196 | if 0 < has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:202:8 + --> $DIR/len_zero.rs:199:8 | -202 | if 1 <= has_is_empty.len() { +199 | if 1 <= has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!has_is_empty.is_empty()` error: length comparison to one - --> $DIR/len_zero.rs:205:8 + --> $DIR/len_zero.rs:202:8 | -205 | if 1 > has_is_empty.len() { +202 | if 1 > has_is_empty.len() { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:219:8 + --> $DIR/len_zero.rs:216:8 | -219 | if with_is_empty.len() == 0 { +216 | if with_is_empty.len() == 0 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()` error: length comparison to zero - --> $DIR/len_zero.rs:232:8 + --> $DIR/len_zero.rs:229:8 | -232 | if b.len() != 0 {} +229 | if b.len() != 0 {} | ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!b.is_empty()` error: trait `DependsOnFoo` has a `len` method but no (possibly inherited) `is_empty` method - --> $DIR/len_zero.rs:238:1 + --> $DIR/len_zero.rs:235:1 | -238 | / pub trait DependsOnFoo: Foo { -239 | | fn len(&mut self) -> usize; -240 | | } +235 | / pub trait DependsOnFoo: Foo { +236 | | fn len(&mut self) -> usize; +237 | | } | |_^ error: aborting due to 19 previous errors diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index 6e2ec6d4aaae..91acf6dcb306 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -1,47 +1,47 @@ error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:67:5 + --> $DIR/let_if_seq.rs:72:5 | -67 | / let mut foo = 0; -68 | | if f() { -69 | | foo = 42; -70 | | } +72 | / let mut foo = 0; +73 | | if f() { +74 | | foo = 42; +75 | | } | |_____^ help: it is more idiomatic to write: `let foo = if f() { 42 } else { 0 };` | = note: `-D clippy::useless-let-if-seq` implied by `-D warnings` = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:72:5 + --> $DIR/let_if_seq.rs:77:5 | -72 | / let mut bar = 0; -73 | | if f() { -74 | | f(); -75 | | bar = 42; -... | -78 | | f(); -79 | | } +77 | / let mut bar = 0; +78 | | if f() { +79 | | f(); +80 | | bar = 42; +81 | | } else { +82 | | f(); +83 | | } | |_____^ help: it is more idiomatic to write: `let bar = if f() { ..; 42 } else { ..; 0 };` | = note: you might not need `mut` at all error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:81:5 + --> $DIR/let_if_seq.rs:85:5 | -81 | / let quz; -82 | | if f() { -83 | | quz = 42; -84 | | } else { -85 | | quz = 0; -86 | | } +85 | / let quz; +86 | | if f() { +87 | | quz = 42; +88 | | } else { +89 | | quz = 0; +90 | | } | |_____^ help: it is more idiomatic to write: `let quz = if f() { 42 } else { 0 };` error: `if _ { .. } else { .. }` is an expression - --> $DIR/let_if_seq.rs:110:5 + --> $DIR/let_if_seq.rs:114:5 | -110 | / let mut baz = 0; -111 | | if f() { -112 | | baz = 42; -113 | | } +114 | / let mut baz = 0; +115 | | if f() { +116 | | baz = 42; +117 | | } | |_____^ help: it is more idiomatic to write: `let baz = if f() { 42 } else { 0 };` | = note: you might not need `mut` at all diff --git a/tests/ui/let_return.stderr b/tests/ui/let_return.stderr index cdd4b6bd5379..894c15c2d6db 100644 --- a/tests/ui/let_return.stderr +++ b/tests/ui/let_return.stderr @@ -1,26 +1,26 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/let_return.rs:20:5 + --> $DIR/let_return.rs:16:5 | -20 | x +16 | x | ^ | = note: `-D clippy::let-and-return` implied by `-D warnings` note: this expression can be directly returned - --> $DIR/let_return.rs:19:13 + --> $DIR/let_return.rs:15:13 | -19 | let x = 5; +15 | let x = 5; | ^ error: returning the result of a let binding from a block. Consider returning the expression directly. - --> $DIR/let_return.rs:26:9 + --> $DIR/let_return.rs:22:9 | -26 | x +22 | x | ^ | note: this expression can be directly returned - --> $DIR/let_return.rs:25:17 + --> $DIR/let_return.rs:21:17 | -25 | let x = 5; +21 | let x = 5; | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index e8c7bb37e738..a8771dd5f470 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,15 +1,15 @@ error: this let-binding has unit value. Consider omitting `let _x =` - --> $DIR/let_unit.rs:24:5 + --> $DIR/let_unit.rs:20:5 | -24 | let _x = println!("x"); +20 | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::let-unit-value` implied by `-D warnings` error: this let-binding has unit value. Consider omitting `let _a =` - --> $DIR/let_unit.rs:28:9 + --> $DIR/let_unit.rs:24:9 | -28 | let _a = (); +24 | let _a = (); | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index 46dbf6cce094..5bddf5aa7467 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -1,96 +1,122 @@ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:17:1 + --> $DIR/lifetimes.rs:13:1 | -17 | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::needless-lifetimes` implied by `-D warnings` error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:19:1 + --> $DIR/lifetimes.rs:15:1 | -19 | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +15 | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:27:1 + --> $DIR/lifetimes.rs:23:1 | -27 | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +23 | / fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { +24 | | x +25 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:39:1 + --> $DIR/lifetimes.rs:47:1 | -39 | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { Ok(x) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +47 | / fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> { +48 | | Ok(x) +49 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:42:1 + --> $DIR/lifetimes.rs:52:1 | -42 | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> where T: Copy { Ok(x) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +52 | / fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> +53 | | where +54 | | T: Copy, +55 | | { +56 | | Ok(x) +57 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:48:1 + --> $DIR/lifetimes.rs:63:1 | -48 | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +63 | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:62:1 + --> $DIR/lifetimes.rs:84:1 | -62 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> -63 | | where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I> -64 | | { unreachable!() } - | |__________________^ +84 | / fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> +85 | | where +86 | | for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I>, +87 | | { +88 | | unreachable!() +89 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:87:5 - | -87 | fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/lifetimes.rs:117:5 + | +117 | / fn self_and_out<'s>(&'s self) -> &'s u8 { +118 | | &self.x +119 | | } + | |_____^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:91:5 - | -91 | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $DIR/lifetimes.rs:125:5 + | +125 | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:107:1 + --> $DIR/lifetimes.rs:141:1 | -107 | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +141 | / fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { +142 | | unimplemented!() +143 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:127:1 + --> $DIR/lifetimes.rs:171:1 | -127 | fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +171 | / fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { +172 | | unimplemented!() +173 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:131:1 + --> $DIR/lifetimes.rs:177:1 | -131 | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +177 | / fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { +178 | | unimplemented!() +179 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:142:1 + --> $DIR/lifetimes.rs:196:1 | -142 | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +196 | / fn named_input_elided_output<'a>(_arg: &'a str) -> &str { +197 | | unimplemented!() +198 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:146:1 + --> $DIR/lifetimes.rs:204:1 | -146 | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +204 | / fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { +205 | | unimplemented!() +206 | | } + | |_^ error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration) - --> $DIR/lifetimes.rs:176:1 + --> $DIR/lifetimes.rs:241:1 | -176 | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +241 | / fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> { +242 | | unimplemented!() +243 | | } + | |_^ error: aborting due to 15 previous errors diff --git a/tests/ui/lint_without_lint_pass.stderr b/tests/ui/lint_without_lint_pass.stderr index 65d1283a6e34..d0d65df21f0c 100644 --- a/tests/ui/lint_without_lint_pass.stderr +++ b/tests/ui/lint_without_lint_pass.stderr @@ -1,11 +1,11 @@ error: the lint `TEST_LINT` is not added to any `LintPass` - --> $DIR/lint_without_lint_pass.rs:12:1 + --> $DIR/lint_without_lint_pass.rs:11:1 | -12 | / declare_clippy_lint! { -13 | | pub TEST_LINT, -14 | | correctness, -15 | | "" -16 | | } +11 | / declare_clippy_lint! { +12 | | pub TEST_LINT, +13 | | correctness, +14 | | "" +15 | | } | |_^ | note: lint level defined here diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index 50856f6a937c..603819de16e5 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -1,21 +1,21 @@ error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:16:22 + --> $DIR/map_clone.rs:14:22 | -16 | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); +14 | let _: Vec = vec![5_i8; 6].iter().map(|x| *x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![5_i8; 6].iter().cloned()` | = note: `-D clippy::map-clone` implied by `-D warnings` error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:17:26 + --> $DIR/map_clone.rs:15:26 | -17 | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); +15 | let _: Vec = vec![String::new()].iter().map(|x| x.clone()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()` error: You are using an explicit closure for cloning elements - --> $DIR/map_clone.rs:18:23 + --> $DIR/map_clone.rs:16:23 | -18 | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); +16 | let _: Vec = vec![42, 43].iter().map(|&x| x).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![42, 43].iter().cloned()` error: aborting due to 3 previous errors diff --git a/tests/ui/map_flatten.stderr b/tests/ui/map_flatten.stderr index d41e6297758e..488797173f60 100644 --- a/tests/ui/map_flatten.stderr +++ b/tests/ui/map_flatten.stderr @@ -1,7 +1,7 @@ error: called `map(..).flatten()` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` - --> $DIR/map_flatten.rs:16:21 + --> $DIR/map_flatten.rs:14:21 | -16 | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); +14 | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using flat_map instead: `vec![5_i8; 6].into_iter().flat_map(|x| 0..x)` | = note: `-D clippy::map-flatten` implied by `-D warnings` diff --git a/tests/ui/match_bool.stderr b/tests/ui/match_bool.stderr index 9bef0d823e2c..a073f9954981 100644 --- a/tests/ui/match_bool.stderr +++ b/tests/ui/match_bool.stderr @@ -1,74 +1,109 @@ error: this boolean expression can be simplified - --> $DIR/match_bool.rs:35:11 + --> $DIR/match_bool.rs:38:11 | -35 | match test && test { +38 | match test && test { | ^^^^^^^^^^^^ help: try: `test` | = note: `-D clippy::nonminimal-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:14:5 + --> $DIR/match_bool.rs:13:5 | -14 | / match test { -15 | | true => 0, -16 | | false => 42, -17 | | }; +13 | / match test { +14 | | true => 0, +15 | | false => 42, +16 | | }; | |_____^ help: consider using an if/else expression: `if test { 0 } else { 42 }` | = note: `-D clippy::match-bool` implied by `-D warnings` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:20:5 + --> $DIR/match_bool.rs:19:5 | -20 | / match option == 1 { -21 | | true => 1, -22 | | false => 0, -23 | | }; +19 | / match option == 1 { +20 | | true => 1, +21 | | false => 0, +22 | | }; | |_____^ help: consider using an if/else expression: `if option == 1 { 1 } else { 0 }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:25:5 + --> $DIR/match_bool.rs:24:5 + | +24 | / match test { +25 | | true => (), +26 | | false => { +27 | | println!("Noooo!"); +28 | | }, +29 | | }; + | |_____^ +help: consider using an if/else expression + | +24 | if !test { +25 | println!("Noooo!"); +26 | }; | -25 | / match test { -26 | | true => (), -27 | | false => { println!("Noooo!"); } -28 | | }; - | |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:30:5 + --> $DIR/match_bool.rs:31:5 + | +31 | / match test { +32 | | false => { +33 | | println!("Noooo!"); +34 | | }, +35 | | _ => (), +36 | | }; + | |_____^ +help: consider using an if/else expression + | +31 | if !test { +32 | println!("Noooo!"); +33 | }; | -30 | / match test { -31 | | false => { println!("Noooo!"); } -32 | | _ => (), -33 | | }; - | |_____^ help: consider using an if/else expression: `if !test { println!("Noooo!"); }` error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:35:5 + --> $DIR/match_bool.rs:38:5 + | +38 | / match test && test { +39 | | false => { +40 | | println!("Noooo!"); +41 | | }, +42 | | _ => (), +43 | | }; + | |_____^ +help: consider using an if/else expression + | +38 | if !(test && test) { +39 | println!("Noooo!"); +40 | }; | -35 | / match test && test { -36 | | false => { println!("Noooo!"); } -37 | | _ => (), -38 | | }; - | |_____^ help: consider using an if/else expression: `if !(test && test) { println!("Noooo!"); }` error: equal expressions as operands to `&&` - --> $DIR/match_bool.rs:35:11 + --> $DIR/match_bool.rs:38:11 | -35 | match test && test { +38 | match test && test { | ^^^^^^^^^^^^ | = note: #[deny(clippy::eq_op)] on by default error: you seem to be trying to match on a boolean expression - --> $DIR/match_bool.rs:40:5 + --> $DIR/match_bool.rs:45:5 + | +45 | / match test { +46 | | false => { +47 | | println!("Noooo!"); +48 | | }, +... | +51 | | }, +52 | | }; + | |_____^ +help: consider using an if/else expression + | +45 | if test { +46 | println!("Yes!"); +47 | } else { +48 | println!("Noooo!"); +49 | }; | -40 | / match test { -41 | | false => { println!("Noooo!"); } -42 | | true => { println!("Yes!"); } -43 | | }; - | |_____^ help: consider using an if/else expression: `if test { println!("Yes!"); } else { println!("Noooo!"); }` error: aborting due to 8 previous errors diff --git a/tests/ui/match_overlapping_arm.stderr b/tests/ui/match_overlapping_arm.stderr index 4f9d8ac76839..ef8fc08f95b2 100644 --- a/tests/ui/match_overlapping_arm.stderr +++ b/tests/ui/match_overlapping_arm.stderr @@ -1,33 +1,33 @@ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:20:9 | -20 | 0 ... 10 => println!("0 ... 10"), - | ^^^^^^^^ +20 | 0...10 => println!("0 ... 10"), + | ^^^^^^ | = note: `-D clippy::match-overlapping-arm` implied by `-D warnings` note: overlaps with this --> $DIR/match_overlapping_arm.rs:21:9 | -21 | 0 ... 11 => println!("0 ... 11"), - | ^^^^^^^^ +21 | 0...11 => println!("0 ... 11"), + | ^^^^^^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:26:9 | -26 | 0 ... 5 => println!("0 ... 5"), - | ^^^^^^^ +26 | 0...5 => println!("0 ... 5"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:28:9 | -28 | FOO ... 11 => println!("0 ... 11"), - | ^^^^^^^^^^ +28 | FOO...11 => println!("0 ... 11"), + | ^^^^^^^^ error: some ranges overlap --> $DIR/match_overlapping_arm.rs:34:9 | -34 | 0 ... 5 => println!("0 ... 5"), - | ^^^^^^^ +34 | 0...5 => println!("0 ... 5"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:33:9 @@ -38,8 +38,8 @@ note: overlaps with this error: some ranges overlap --> $DIR/match_overlapping_arm.rs:40:9 | -40 | 0 ... 2 => println!("0 ... 2"), - | ^^^^^^^ +40 | 0...2 => println!("0 ... 2"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:39:9 @@ -50,14 +50,14 @@ note: overlaps with this error: some ranges overlap --> $DIR/match_overlapping_arm.rs:63:9 | -63 | 0 .. 11 => println!("0 .. 11"), - | ^^^^^^^ +63 | 0..11 => println!("0 .. 11"), + | ^^^^^ | note: overlaps with this --> $DIR/match_overlapping_arm.rs:64:9 | -64 | 0 ... 11 => println!("0 ... 11"), - | ^^^^^^^^ +64 | 0...11 => println!("0 ... 11"), + | ^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index 53e61efa83a5..3ed70168c6eb 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -1,281 +1,281 @@ error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:26:9 + --> $DIR/matches.rs:20:9 | -26 | / match v { -27 | | &Some(v) => println!("{:?}", v), -28 | | &None => println!("none"), -29 | | } +20 | / match v { +21 | | &Some(v) => println!("{:?}", v), +22 | | &None => println!("none"), +23 | | } | |_________^ | = note: `-D clippy::match-ref-pats` implied by `-D warnings` help: instead of prefixing all patterns with `&`, you can dereference the expression | -26 | match *v { -27 | Some(v) => println!("{:?}", v), -28 | None => println!("none"), +20 | match *v { +21 | Some(v) => println!("{:?}", v), +22 | None => println!("none"), | error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:36:5 + --> $DIR/matches.rs:31:5 | -36 | / match tup { -37 | | &(v, 1) => println!("{}", v), -38 | | _ => println!("none"), -39 | | } +31 | / match tup { +32 | | &(v, 1) => println!("{}", v), +33 | | _ => println!("none"), +34 | | } | |_____^ help: instead of prefixing all patterns with `&`, you can dereference the expression | -36 | match *tup { -37 | (v, 1) => println!("{}", v), +31 | match *tup { +32 | (v, 1) => println!("{}", v), | error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:42:5 + --> $DIR/matches.rs:37:5 | -42 | / match &w { -43 | | &Some(v) => println!("{:?}", v), -44 | | &None => println!("none"), -45 | | } +37 | / match &w { +38 | | &Some(v) => println!("{:?}", v), +39 | | &None => println!("none"), +40 | | } | |_____^ help: try | -42 | match w { -43 | Some(v) => println!("{:?}", v), -44 | None => println!("none"), +37 | match w { +38 | Some(v) => println!("{:?}", v), +39 | None => println!("none"), | error: you don't need to add `&` to all patterns - --> $DIR/matches.rs:53:5 + --> $DIR/matches.rs:48:5 | -53 | / if let &None = a { -54 | | println!("none"); -55 | | } +48 | / if let &None = a { +49 | | println!("none"); +50 | | } | |_____^ help: instead of prefixing all patterns with `&`, you can dereference the expression | -53 | if let None = *a { +48 | if let None = *a { | ^^^^ ^^ error: you don't need to add `&` to both the expression and the patterns - --> $DIR/matches.rs:58:5 + --> $DIR/matches.rs:53:5 | -58 | / if let &None = &b { -59 | | println!("none"); -60 | | } +53 | / if let &None = &b { +54 | | println!("none"); +55 | | } | |_____^ help: try | -58 | if let None = b { +53 | if let None = b { | ^^^^ ^ error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:69:9 + --> $DIR/matches.rs:64:9 | -69 | Err(_) => panic!("err") +64 | Err(_) => panic!("err"), | ^^^^^^ | = note: `-D clippy::match-wild-err-arm` implied by `-D warnings` = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies - --> $DIR/matches.rs:68:18 + --> $DIR/matches.rs:63:18 | -68 | Ok(_) => println!("ok"), +63 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | = note: `-D clippy::match-same-arms` implied by `-D warnings` note: same as this - --> $DIR/matches.rs:67:18 + --> $DIR/matches.rs:62:18 | -67 | Ok(3) => println!("ok"), +62 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:67:18 + --> $DIR/matches.rs:62:18 | -67 | Ok(3) => println!("ok"), +62 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:75:9 + --> $DIR/matches.rs:70:9 | -75 | Err(_) => {panic!()} +70 | Err(_) => panic!(), | ^^^^^^ | = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies - --> $DIR/matches.rs:74:18 + --> $DIR/matches.rs:69:18 | -74 | Ok(_) => println!("ok"), +69 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:73:18 + --> $DIR/matches.rs:68:18 | -73 | Ok(3) => println!("ok"), +68 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:73:18 + --> $DIR/matches.rs:68:18 | -73 | Ok(3) => println!("ok"), +68 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: Err(_) will match all errors, maybe not a good idea - --> $DIR/matches.rs:81:9 + --> $DIR/matches.rs:76:9 | -81 | Err(_) => {panic!();} +76 | Err(_) => { | ^^^^^^ | = note: to remove this warning, match each error separately or use unreachable macro error: this `match` has identical arm bodies - --> $DIR/matches.rs:80:18 + --> $DIR/matches.rs:75:18 | -80 | Ok(_) => println!("ok"), +75 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:79:18 + --> $DIR/matches.rs:74:18 | -79 | Ok(3) => println!("ok"), +74 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:79:18 + --> $DIR/matches.rs:74:18 | -79 | Ok(3) => println!("ok"), +74 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:87:18 + --> $DIR/matches.rs:84:18 | -87 | Ok(_) => println!("ok"), +84 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:86:18 + --> $DIR/matches.rs:83:18 | -86 | Ok(3) => println!("ok"), +83 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:86:18 + --> $DIR/matches.rs:83:18 | -86 | Ok(3) => println!("ok"), +83 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:94:18 + --> $DIR/matches.rs:91:18 | -94 | Ok(_) => println!("ok"), +91 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:93:18 + --> $DIR/matches.rs:90:18 | -93 | Ok(3) => println!("ok"), +90 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:93:18 + --> $DIR/matches.rs:90:18 | -93 | Ok(3) => println!("ok"), +90 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:100:18 - | -100 | Ok(_) => println!("ok"), - | ^^^^^^^^^^^^^^ - | + --> $DIR/matches.rs:97:18 + | +97 | Ok(_) => println!("ok"), + | ^^^^^^^^^^^^^^ + | note: same as this - --> $DIR/matches.rs:99:18 - | -99 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ + --> $DIR/matches.rs:96:18 + | +96 | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:99:18 - | -99 | Ok(3) => println!("ok"), - | ^^^^^^^^^^^^^^ - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + --> $DIR/matches.rs:96:18 + | +96 | Ok(3) => println!("ok"), + | ^^^^^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:106:18 + --> $DIR/matches.rs:103:18 | -106 | Ok(_) => println!("ok"), +103 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:105:18 + --> $DIR/matches.rs:102:18 | -105 | Ok(3) => println!("ok"), +102 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:105:18 + --> $DIR/matches.rs:102:18 | -105 | Ok(3) => println!("ok"), +102 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:127:29 + --> $DIR/matches.rs:126:29 | -127 | (Ok(_), Some(x)) => println!("ok {}", x), +126 | (Ok(_), Some(x)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:126:29 + --> $DIR/matches.rs:125:29 | -126 | (Ok(x), Some(_)) => println!("ok {}", x), +125 | (Ok(x), Some(_)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ note: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))` - --> $DIR/matches.rs:126:29 + --> $DIR/matches.rs:125:29 | -126 | (Ok(x), Some(_)) => println!("ok {}", x), +125 | (Ok(x), Some(_)) => println!("ok {}", x), | ^^^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: this `match` has identical arm bodies - --> $DIR/matches.rs:142:18 + --> $DIR/matches.rs:141:18 | -142 | Ok(_) => println!("ok"), +141 | Ok(_) => println!("ok"), | ^^^^^^^^^^^^^^ | note: same as this - --> $DIR/matches.rs:141:18 + --> $DIR/matches.rs:140:18 | -141 | Ok(3) => println!("ok"), +140 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ note: consider refactoring into `Ok(3) | Ok(_)` - --> $DIR/matches.rs:141:18 + --> $DIR/matches.rs:140:18 | -141 | Ok(3) => println!("ok"), +140 | Ok(3) => println!("ok"), | ^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: use as_ref() instead - --> $DIR/matches.rs:149:33 + --> $DIR/matches.rs:150:33 | -149 | let borrowed: Option<&()> = match owned { +150 | let borrowed: Option<&()> = match owned { | _________________________________^ -150 | | None => None, -151 | | Some(ref v) => Some(v), -152 | | }; +151 | | None => None, +152 | | Some(ref v) => Some(v), +153 | | }; | |_____^ help: try this: `owned.as_ref()` | = note: `-D clippy::match-as-ref` implied by `-D warnings` error: use as_mut() instead - --> $DIR/matches.rs:155:39 + --> $DIR/matches.rs:156:39 | -155 | let borrow_mut: Option<&mut ()> = match mut_owned { +156 | let borrow_mut: Option<&mut ()> = match mut_owned { | _______________________________________^ -156 | | None => None, -157 | | Some(ref mut v) => Some(v), -158 | | }; +157 | | None => None, +158 | | Some(ref mut v) => Some(v), +159 | | }; | |_____^ help: try this: `mut_owned.as_mut()` error: aborting due to 19 previous errors diff --git a/tests/ui/mem_discriminant.stderr b/tests/ui/mem_discriminant.stderr index 6414e4c96d63..a00f7ab30e18 100644 --- a/tests/ui/mem_discriminant.stderr +++ b/tests/ui/mem_discriminant.stderr @@ -1,101 +1,101 @@ error: calling `mem::discriminant` on non-enum type `&str` - --> $DIR/mem_discriminant.rs:24:5 + --> $DIR/mem_discriminant.rs:23:5 | -24 | mem::discriminant(&"hello"); +23 | mem::discriminant(&"hello"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here - --> $DIR/mem_discriminant.rs:11:9 + --> $DIR/mem_discriminant.rs:10:9 | -11 | #![deny(clippy::mem_discriminant_non_enum)] +10 | #![deny(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:25:5 + --> $DIR/mem_discriminant.rs:24:5 | -25 | mem::discriminant(&&Some(2)); +24 | mem::discriminant(&&Some(2)); | ^^^^^^^^^^^^^^^^^^---------^ | | | help: try dereferencing: `&Some(2)` error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:26:5 + --> $DIR/mem_discriminant.rs:25:5 | -26 | mem::discriminant(&&None::); +25 | mem::discriminant(&&None::); | ^^^^^^^^^^^^^^^^^^------------^ | | | help: try dereferencing: `&None::` error: calling `mem::discriminant` on non-enum type `&Foo` - --> $DIR/mem_discriminant.rs:27:5 + --> $DIR/mem_discriminant.rs:26:5 | -27 | mem::discriminant(&&Foo::One(5)); +26 | mem::discriminant(&&Foo::One(5)); | ^^^^^^^^^^^^^^^^^^-------------^ | | | help: try dereferencing: `&Foo::One(5)` error: calling `mem::discriminant` on non-enum type `&Foo` - --> $DIR/mem_discriminant.rs:28:5 + --> $DIR/mem_discriminant.rs:27:5 | -28 | mem::discriminant(&&Foo::Two(5)); +27 | mem::discriminant(&&Foo::Two(5)); | ^^^^^^^^^^^^^^^^^^-------------^ | | | help: try dereferencing: `&Foo::Two(5)` error: calling `mem::discriminant` on non-enum type `A` - --> $DIR/mem_discriminant.rs:29:5 + --> $DIR/mem_discriminant.rs:28:5 | -29 | mem::discriminant(&A(Foo::One(0))); +28 | mem::discriminant(&A(Foo::One(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:33:5 + --> $DIR/mem_discriminant.rs:32:5 | -33 | mem::discriminant(&ro); +32 | mem::discriminant(&ro); | ^^^^^^^^^^^^^^^^^^---^ | | | help: try dereferencing: `ro` error: calling `mem::discriminant` on non-enum type `&std::option::Option` - --> $DIR/mem_discriminant.rs:34:5 + --> $DIR/mem_discriminant.rs:33:5 | -34 | mem::discriminant(rro); +33 | mem::discriminant(rro); | ^^^^^^^^^^^^^^^^^^---^ | | | help: try dereferencing: `*rro` error: calling `mem::discriminant` on non-enum type `&&std::option::Option` - --> $DIR/mem_discriminant.rs:35:5 + --> $DIR/mem_discriminant.rs:34:5 | -35 | mem::discriminant(&rro); +34 | mem::discriminant(&rro); | ^^^^^^^^^^^^^^^^^^----^ | | | help: try dereferencing: `*rro` error: calling `mem::discriminant` on non-enum type `&&std::option::Option` - --> $DIR/mem_discriminant.rs:38:27 + --> $DIR/mem_discriminant.rs:38:13 | -38 | ($param:expr) => (mem::discriminant($param)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +38 | mem::discriminant($param) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ ... -41 | mem_discriminant_but_in_a_macro!(&rro); +42 | mem_discriminant_but_in_a_macro!(&rro); | --------------------------------------- | | | | | help: try dereferencing: `*rro` | in this macro invocation error: calling `mem::discriminant` on non-enum type `&&&&&std::option::Option` - --> $DIR/mem_discriminant.rs:44:5 + --> $DIR/mem_discriminant.rs:45:5 | -44 | mem::discriminant(&rrrrro); +45 | mem::discriminant(&rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ | | | help: try dereferencing: `****rrrrro` error: calling `mem::discriminant` on non-enum type `&&&std::option::Option` - --> $DIR/mem_discriminant.rs:45:5 + --> $DIR/mem_discriminant.rs:46:5 | -45 | mem::discriminant(*rrrrro); +46 | mem::discriminant(*rrrrro); | ^^^^^^^^^^^^^^^^^^-------^ | | | help: try dereferencing: `****rrrrro` diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 06ac6a3679df..479cd4934ab8 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -1,21 +1,21 @@ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:28:5 + --> $DIR/mem_forget.rs:23:5 | -28 | memstuff::forget(six); +23 | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::mem-forget` implied by `-D warnings` error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:31:5 + --> $DIR/mem_forget.rs:26:5 | -31 | std::mem::forget(seven); +26 | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of mem::forget on Drop type - --> $DIR/mem_forget.rs:34:5 + --> $DIR/mem_forget.rs:29:5 | -34 | forgetSomething(eight); +29 | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index 64a1690156cf..06d8f5f74c0b 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -1,15 +1,15 @@ error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:18:13 + --> $DIR/mem_replace.rs:16:13 | -18 | let _ = mem::replace(&mut an_option, None); +16 | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` | = note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:20:13 + --> $DIR/mem_replace.rs:18:13 | -20 | let _ = mem::replace(an_option, None); +18 | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` error: aborting due to 2 previous errors diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index 3ed67ad258e0..74a93e350dee 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -1,45 +1,45 @@ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:25:5 + --> $DIR/min_max.rs:21:5 | -25 | min(1, max(3, x)); +21 | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::min-max` implied by `-D warnings` error: this min/max combination leads to constant result - --> $DIR/min_max.rs:26:5 + --> $DIR/min_max.rs:22:5 | -26 | min(max(3, x), 1); +22 | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:27:5 + --> $DIR/min_max.rs:23:5 | -27 | max(min(x, 1), 3); +23 | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:28:5 + --> $DIR/min_max.rs:24:5 | -28 | max(3, min(x, 1)); +24 | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:30:5 + --> $DIR/min_max.rs:26:5 | -30 | my_max(3, my_min(x, 1)); +26 | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:42:5 + --> $DIR/min_max.rs:38:5 | -42 | min("Apple", max("Zoo", s)); +38 | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this min/max combination leads to constant result - --> $DIR/min_max.rs:43:5 + --> $DIR/min_max.rs:39:5 | -43 | max(min(s, "Apple"), "Zoo"); +39 | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/missing-doc.stderr b/tests/ui/missing-doc.stderr index 67f50152c734..b50305ab9eef 100644 --- a/tests/ui/missing-doc.stderr +++ b/tests/ui/missing-doc.stderr @@ -1,267 +1,257 @@ error: missing documentation for a type alias - --> $DIR/missing-doc.rs:38:1 + --> $DIR/missing-doc.rs:32:1 | -38 | type Typedef = String; +32 | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-docs-in-private-items` implied by `-D warnings` error: missing documentation for a type alias - --> $DIR/missing-doc.rs:39:1 + --> $DIR/missing-doc.rs:33:1 | -39 | pub type PubTypedef = String; +33 | pub type PubTypedef = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct - --> $DIR/missing-doc.rs:41:1 + --> $DIR/missing-doc.rs:35:1 | -41 | / struct Foo { -42 | | a: isize, -43 | | b: isize, -44 | | } +35 | / struct Foo { +36 | | a: isize, +37 | | b: isize, +38 | | } | |_^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:42:5 + --> $DIR/missing-doc.rs:36:5 | -42 | a: isize, +36 | a: isize, | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:43:5 + --> $DIR/missing-doc.rs:37:5 | -43 | b: isize, +37 | b: isize, | ^^^^^^^^ error: missing documentation for a struct - --> $DIR/missing-doc.rs:46:1 + --> $DIR/missing-doc.rs:40:1 | -46 | / pub struct PubFoo { -47 | | pub a: isize, -48 | | b: isize, -49 | | } +40 | / pub struct PubFoo { +41 | | pub a: isize, +42 | | b: isize, +43 | | } | |_^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:47:5 + --> $DIR/missing-doc.rs:41:5 | -47 | pub a: isize, +41 | pub a: isize, | ^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:48:5 + --> $DIR/missing-doc.rs:42:5 | -48 | b: isize, +42 | b: isize, | ^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:57:1 + --> $DIR/missing-doc.rs:51:1 | -57 | mod module_no_dox {} +51 | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:58:1 + --> $DIR/missing-doc.rs:52:1 | -58 | pub mod pub_module_no_dox {} +52 | pub mod pub_module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:62:1 + --> $DIR/missing-doc.rs:56:1 | -62 | pub fn foo2() {} +56 | pub fn foo2() {} | ^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:63:1 + --> $DIR/missing-doc.rs:57:1 | -63 | fn foo3() {} +57 | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for a trait - --> $DIR/missing-doc.rs:80:1 + --> $DIR/missing-doc.rs:75:1 | -80 | / pub trait C { -81 | | fn foo(&self); -82 | | fn foo_with_impl(&self) {} -83 | | } +75 | / pub trait C { +76 | | fn foo(&self); +77 | | fn foo_with_impl(&self) {} +78 | | } | |_^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:81:5 + --> $DIR/missing-doc.rs:76:5 | -81 | fn foo(&self); +76 | fn foo(&self); | ^^^^^^^^^^^^^^ error: missing documentation for a trait method - --> $DIR/missing-doc.rs:82:5 + --> $DIR/missing-doc.rs:77:5 | -82 | fn foo_with_impl(&self) {} +77 | fn foo_with_impl(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:92:5 + --> $DIR/missing-doc.rs:87:5 | -92 | type AssociatedType; +87 | type AssociatedType; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type - --> $DIR/missing-doc.rs:93:5 + --> $DIR/missing-doc.rs:88:5 | -93 | type AssociatedTypeDef = Self; +88 | type AssociatedTypeDef = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:104:5 - | -104 | pub fn foo() {} - | ^^^^^^^^^^^^^^^ + --> $DIR/missing-doc.rs:99:5 + | +99 | pub fn foo() {} + | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:105:5 + --> $DIR/missing-doc.rs:100:5 | -105 | fn bar() {} +100 | fn bar() {} | ^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:109:5 + --> $DIR/missing-doc.rs:104:5 | -109 | pub fn foo() {} +104 | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method - --> $DIR/missing-doc.rs:112:5 + --> $DIR/missing-doc.rs:107:5 | -112 | fn foo2() {} +107 | fn foo2() {} | ^^^^^^^^^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:138:1 + --> $DIR/missing-doc.rs:134:1 | -138 | / enum Baz { -139 | | BazA { -140 | | a: isize, -141 | | b: isize -142 | | }, -143 | | BarB -144 | | } +134 | / enum Baz { +135 | | BazA { a: isize, b: isize }, +136 | | BarB, +137 | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:139:5 + --> $DIR/missing-doc.rs:135:5 | -139 | / BazA { -140 | | a: isize, -141 | | b: isize -142 | | }, - | |_____^ +135 | BazA { a: isize, b: isize }, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:140:9 + --> $DIR/missing-doc.rs:135:12 | -140 | a: isize, - | ^^^^^^^^ +135 | BazA { a: isize, b: isize }, + | ^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:141:9 + --> $DIR/missing-doc.rs:135:22 | -141 | b: isize - | ^^^^^^^^ +135 | BazA { a: isize, b: isize }, + | ^^^^^^^^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:143:5 + --> $DIR/missing-doc.rs:136:5 | -143 | BarB +136 | BarB, | ^^^^ error: missing documentation for an enum - --> $DIR/missing-doc.rs:146:1 + --> $DIR/missing-doc.rs:139:1 | -146 | / pub enum PubBaz { -147 | | PubBazA { -148 | | a: isize, -149 | | }, -150 | | } +139 | / pub enum PubBaz { +140 | | PubBazA { a: isize }, +141 | | } | |_^ error: missing documentation for a variant - --> $DIR/missing-doc.rs:147:5 + --> $DIR/missing-doc.rs:140:5 | -147 | / PubBazA { -148 | | a: isize, -149 | | }, - | |_____^ +140 | PubBazA { a: isize }, + | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct field - --> $DIR/missing-doc.rs:148:9 + --> $DIR/missing-doc.rs:140:15 | -148 | a: isize, - | ^^^^^^^^ +140 | PubBazA { a: isize }, + | ^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:172:1 + --> $DIR/missing-doc.rs:160:1 | -172 | const FOO: u32 = 0; +160 | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a constant - --> $DIR/missing-doc.rs:179:1 + --> $DIR/missing-doc.rs:167:1 | -179 | pub const FOO4: u32 = 0; +167 | pub const FOO4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:182:1 + --> $DIR/missing-doc.rs:169:1 | -182 | static BAR: u32 = 0; +169 | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static - --> $DIR/missing-doc.rs:189:1 + --> $DIR/missing-doc.rs:176:1 | -189 | pub static BAR4: u32 = 0; +176 | pub static BAR4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module - --> $DIR/missing-doc.rs:192:1 + --> $DIR/missing-doc.rs:178:1 | -192 | / mod internal_impl { -193 | | /// dox -194 | | pub fn documented() {} -195 | | pub fn undocumented1() {} +178 | / mod internal_impl { +179 | | /// dox +180 | | pub fn documented() {} +181 | | pub fn undocumented1() {} ... | -204 | | } -205 | | } +190 | | } +191 | | } | |_^ error: missing documentation for a function - --> $DIR/missing-doc.rs:195:5 + --> $DIR/missing-doc.rs:181:5 | -195 | pub fn undocumented1() {} +181 | pub fn undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:196:5 + --> $DIR/missing-doc.rs:182:5 | -196 | pub fn undocumented2() {} +182 | pub fn undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:197:5 + --> $DIR/missing-doc.rs:183:5 | -197 | fn undocumented3() {} +183 | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:202:9 + --> $DIR/missing-doc.rs:188:9 | -202 | pub fn also_undocumented1() {} +188 | pub fn also_undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function - --> $DIR/missing-doc.rs:203:9 + --> $DIR/missing-doc.rs:189:9 | -203 | fn also_undocumented2() {} +189 | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 39 previous errors diff --git a/tests/ui/missing_inline.stderr b/tests/ui/missing_inline.stderr index fc617ef54c90..132285a1eaae 100644 --- a/tests/ui/missing_inline.stderr +++ b/tests/ui/missing_inline.stderr @@ -1,39 +1,39 @@ error: missing `#[inline]` for a function - --> $DIR/missing_inline.rs:43:1 + --> $DIR/missing_inline.rs:40:1 | -43 | pub fn pub_foo() {} // missing #[inline] +40 | pub fn pub_foo() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::missing-inline-in-public-items` implied by `-D warnings` error: missing `#[inline]` for a default trait method - --> $DIR/missing_inline.rs:58:5 + --> $DIR/missing_inline.rs:56:5 | -58 | fn PubBar_b() {} // missing #[inline] +56 | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:71:5 + --> $DIR/missing_inline.rs:70:5 | -71 | fn PubBar_a() {} // missing #[inline] +70 | fn PubBar_a() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:72:5 + --> $DIR/missing_inline.rs:71:5 | -72 | fn PubBar_b() {} // missing #[inline] +71 | fn PubBar_b() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:73:5 + --> $DIR/missing_inline.rs:72:5 | -73 | fn PubBar_c() {} // missing #[inline] +72 | fn PubBar_c() {} // missing #[inline] | ^^^^^^^^^^^^^^^^ error: missing `#[inline]` for a method - --> $DIR/missing_inline.rs:83:5 + --> $DIR/missing_inline.rs:82:5 | -83 | pub fn PubFooImpl() {} // missing #[inline] +82 | pub fn PubFooImpl() {} // missing #[inline] | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index c1e6d0a6e629..bf891aa4578d 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -1,19 +1,19 @@ error: module has the same name as its containing module - --> $DIR/module_inception.rs:17:9 + --> $DIR/module_inception.rs:14:9 | -17 | / mod bar { -18 | | mod foo {} -19 | | } +14 | / mod bar { +15 | | mod foo {} +16 | | } | |_________^ | = note: `-D clippy::module-inception` implied by `-D warnings` error: module has the same name as its containing module - --> $DIR/module_inception.rs:22:5 + --> $DIR/module_inception.rs:19:5 | -22 | / mod foo { -23 | | mod bar {} -24 | | } +19 | / mod foo { +20 | | mod bar {} +21 | | } | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index 57e2c59ee147..e4d20c5c63ca 100644 --- a/tests/ui/modulo_one.stderr +++ b/tests/ui/modulo_one.stderr @@ -1,7 +1,7 @@ error: any number modulo 1 will be 0 - --> $DIR/modulo_one.rs:17:5 + --> $DIR/modulo_one.rs:14:5 | -17 | 10 % 1; +14 | 10 % 1; | ^^^^^^ | = note: `-D clippy::modulo-one` implied by `-D warnings` diff --git a/tests/ui/mut_from_ref.stderr b/tests/ui/mut_from_ref.stderr index 48b5abf5a6ed..db0f05a7fa70 100644 --- a/tests/ui/mut_from_ref.stderr +++ b/tests/ui/mut_from_ref.stderr @@ -1,62 +1,62 @@ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:19:39 + --> $DIR/mut_from_ref.rs:16:39 | -19 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { +16 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^^^^ | = note: `-D clippy::mut-from-ref` implied by `-D warnings` note: immutable borrow here - --> $DIR/mut_from_ref.rs:19:29 + --> $DIR/mut_from_ref.rs:16:29 | -19 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { +16 | fn this_wont_hurt_a_bit(&self) -> &mut Foo { | ^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:25:25 + --> $DIR/mut_from_ref.rs:22:25 | -25 | fn ouch(x: &Foo) -> &mut Foo; +22 | fn ouch(x: &Foo) -> &mut Foo; | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:25:16 + --> $DIR/mut_from_ref.rs:22:16 | -25 | fn ouch(x: &Foo) -> &mut Foo; +22 | fn ouch(x: &Foo) -> &mut Foo; | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:34:21 + --> $DIR/mut_from_ref.rs:31:21 | -34 | fn fail(x: &u32) -> &mut u16 { +31 | fn fail(x: &u32) -> &mut u16 { | ^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:34:12 + --> $DIR/mut_from_ref.rs:31:12 | -34 | fn fail(x: &u32) -> &mut u16 { +31 | fn fail(x: &u32) -> &mut u16 { | ^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:38:50 + --> $DIR/mut_from_ref.rs:35:50 | -38 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { +35 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:38:25 + --> $DIR/mut_from_ref.rs:35:25 | -38 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { +35 | fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 { | ^^^^^^^ error: mutable borrow from immutable input(s) - --> $DIR/mut_from_ref.rs:42:67 + --> $DIR/mut_from_ref.rs:39:67 | -42 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { +39 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^^^^^ | note: immutable borrow here - --> $DIR/mut_from_ref.rs:42:27 + --> $DIR/mut_from_ref.rs:39:27 | -42 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { +39 | fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 { | ^^^^^^^ ^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index c05c02157955..626a309a6a92 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -1,61 +1,61 @@ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:20:12 + --> $DIR/mut_mut.rs:13:11 | -20 | fn fun(x : &mut &mut u32) -> bool { - | ^^^^^^^^^^^^^ +13 | fn fun(x: &mut &mut u32) -> bool { + | ^^^^^^^^^^^^^ | = note: `-D clippy::mut-mut` implied by `-D warnings` error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:34:17 + --> $DIR/mut_mut.rs:29:17 | -34 | let mut x = &mut &mut 1u32; +29 | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:29:20 + --> $DIR/mut_mut.rs:23:9 | -29 | ($p:expr) => { &mut $p } - | ^^^^^^^ +23 | &mut $p + | ^^^^^^^ ... -49 | let mut z = mut_ptr!(&mut 3u32); +44 | let mut z = mut_ptr!(&mut 3u32); | ------------------- in this macro invocation error: this expression mutably borrows a mutable reference. Consider reborrowing - --> $DIR/mut_mut.rs:36:21 + --> $DIR/mut_mut.rs:31:21 | -36 | let mut y = &mut x; +31 | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:40:33 + --> $DIR/mut_mut.rs:35:32 | -40 | let y : &mut &mut u32 = &mut &mut 2; - | ^^^^^^^^^^^ +35 | let y: &mut &mut u32 = &mut &mut 2; + | ^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:40:17 + --> $DIR/mut_mut.rs:35:16 | -40 | let y : &mut &mut u32 = &mut &mut 2; - | ^^^^^^^^^^^^^ +35 | let y: &mut &mut u32 = &mut &mut 2; + | ^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:45:38 + --> $DIR/mut_mut.rs:40:37 | -45 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; - | ^^^^^^^^^^^^^^^^ +40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; + | ^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:45:17 + --> $DIR/mut_mut.rs:40:16 | -45 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; - | ^^^^^^^^^^^^^^^^^^ +40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; + | ^^^^^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible - --> $DIR/mut_mut.rs:45:22 + --> $DIR/mut_mut.rs:40:21 | -45 | let y : &mut &mut &mut u32 = &mut &mut &mut 2; - | ^^^^^^^^^^^^^ +40 | let y: &mut &mut &mut u32 = &mut &mut &mut 2; + | ^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/mut_range_bound.stderr b/tests/ui/mut_range_bound.stderr index a476ad5d14e6..87537d77f444 100644 --- a/tests/ui/mut_range_bound.stderr +++ b/tests/ui/mut_range_bound.stderr @@ -1,33 +1,33 @@ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:28:21 + --> $DIR/mut_range_bound.rs:25:9 | -28 | for i in 0..m { m = 5; } // warning - | ^^^^^ +25 | m = 5; + | ^^^^^ | = note: `-D clippy::mut-range-bound` implied by `-D warnings` error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:33:22 + --> $DIR/mut_range_bound.rs:32:9 | -33 | for i in m..10 { m *= 2; } // warning - | ^^^^^^ +32 | m *= 2; + | ^^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:39:21 + --> $DIR/mut_range_bound.rs:40:9 | -39 | for i in m..n { m = 5; n = 7; } // warning (1 for each mutated bound) - | ^^^^^ +40 | m = 5; + | ^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:39:28 + --> $DIR/mut_range_bound.rs:41:9 | -39 | for i in m..n { m = 5; n = 7; } // warning (1 for each mutated bound) - | ^^^^^ +41 | n = 7; + | ^^^^^ error: attempt to mutate range bound within loop; note that the range of the loop is unchanged - --> $DIR/mut_range_bound.rs:50:22 + --> $DIR/mut_range_bound.rs:55:22 | -50 | let n = &mut m; // warning +55 | let n = &mut m; // warning | ^ error: aborting due to 5 previous errors diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 07b07580d4bc..1664c1dffed6 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -1,21 +1,21 @@ error: The function/method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:32:34 + --> $DIR/mut_reference.rs:26:34 | -32 | takes_an_immutable_reference(&mut 42); +26 | takes_an_immutable_reference(&mut 42); | ^^^^^^^ | = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` error: The function/method `as_ptr` doesn't need a mutable reference - --> $DIR/mut_reference.rs:34:12 + --> $DIR/mut_reference.rs:28:12 | -34 | as_ptr(&mut 42); +28 | as_ptr(&mut 42); | ^^^^^^^ error: The function/method `takes_an_immutable_reference` doesn't need a mutable reference - --> $DIR/mut_reference.rs:38:44 + --> $DIR/mut_reference.rs:32:44 | -38 | my_struct.takes_an_immutable_reference(&mut 42); +32 | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index a317e8a6c944..d6f4f03c3230 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -1,47 +1,47 @@ error: Consider using an AtomicBool instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:19:5 + --> $DIR/mutex_atomic.rs:15:5 | -19 | Mutex::new(true); +15 | Mutex::new(true); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-atomic` implied by `-D warnings` error: Consider using an AtomicUsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:20:5 + --> $DIR/mutex_atomic.rs:16:5 | -20 | Mutex::new(5usize); +16 | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicIsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:21:5 + --> $DIR/mutex_atomic.rs:17:5 | -21 | Mutex::new(9isize); +17 | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:23:5 + --> $DIR/mutex_atomic.rs:19:5 | -23 | Mutex::new(&x as *const u32); +19 | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:24:5 + --> $DIR/mutex_atomic.rs:20:5 | -24 | Mutex::new(&mut x as *mut u32); +20 | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Consider using an AtomicUsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:25:5 + --> $DIR/mutex_atomic.rs:21:5 | -25 | Mutex::new(0u32); +21 | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ | = note: `-D clippy::mutex-integer` implied by `-D warnings` error: Consider using an AtomicIsize instead of a Mutex here. If you just want the locking behaviour and not the internal type, consider using Mutex<()>. - --> $DIR/mutex_atomic.rs:26:5 + --> $DIR/mutex_atomic.rs:22:5 | -26 | Mutex::new(0i32); +22 | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index 638a3f56f0f2..df2f80ffd119 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -1,95 +1,139 @@ error: this if-then-else expression will always return true - --> $DIR/needless_bool.rs:41:5 + --> $DIR/needless_bool.rs:40:5 | -41 | if x { true } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +40 | / if x { +41 | | true +42 | | } else { +43 | | true +44 | | }; + | |_____^ | = note: `-D clippy::needless-bool` implied by `-D warnings` error: this if-then-else expression will always return false - --> $DIR/needless_bool.rs:42:5 + --> $DIR/needless_bool.rs:45:5 | -42 | if x { false } else { false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +45 | / if x { +46 | | false +47 | | } else { +48 | | false +49 | | }; + | |_____^ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:43:5 + --> $DIR/needless_bool.rs:50:5 | -43 | if x { true } else { false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `x` +50 | / if x { +51 | | true +52 | | } else { +53 | | false +54 | | }; + | |_____^ help: you can reduce it to: `x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:44:5 + --> $DIR/needless_bool.rs:55:5 | -44 | if x { false } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `!x` +55 | / if x { +56 | | false +57 | | } else { +58 | | true +59 | | }; + | |_____^ help: you can reduce it to: `!x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:45:5 + --> $DIR/needless_bool.rs:60:5 | -45 | if x && y { false } else { true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `!(x && y)` +60 | / if x && y { +61 | | false +62 | | } else { +63 | | true +64 | | }; + | |_____^ help: you can reduce it to: `!(x && y)` error: this if-then-else expression will always return true - --> $DIR/needless_bool.rs:60:5 + --> $DIR/needless_bool.rs:83:5 | -60 | if x { return true } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +83 | / if x { +84 | | return true; +85 | | } else { +86 | | return true; +87 | | }; + | |_____^ error: this if-then-else expression will always return false - --> $DIR/needless_bool.rs:65:5 + --> $DIR/needless_bool.rs:92:5 | -65 | if x { return false } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +92 | / if x { +93 | | return false; +94 | | } else { +95 | | return false; +96 | | }; + | |_____^ error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:70:5 - | -70 | if x { return true } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return x` + --> $DIR/needless_bool.rs:101:5 + | +101 | / if x { +102 | | return true; +103 | | } else { +104 | | return false; +105 | | }; + | |_____^ help: you can reduce it to: `return x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:75:5 - | -75 | if x && y { return true } else { return false }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return x && y` + --> $DIR/needless_bool.rs:110:5 + | +110 | / if x && y { +111 | | return true; +112 | | } else { +113 | | return false; +114 | | }; + | |_____^ help: you can reduce it to: `return x && y` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:80:5 - | -80 | if x { return false } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return !x` + --> $DIR/needless_bool.rs:119:5 + | +119 | / if x { +120 | | return false; +121 | | } else { +122 | | return true; +123 | | }; + | |_____^ help: you can reduce it to: `return !x` error: this if-then-else expression returns a bool literal - --> $DIR/needless_bool.rs:85:5 - | -85 | if x && y { return false } else { return true }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can reduce it to: `return !(x && y)` + --> $DIR/needless_bool.rs:128:5 + | +128 | / if x && y { +129 | | return false; +130 | | } else { +131 | | return true; +132 | | }; + | |_____^ help: you can reduce it to: `return !(x && y)` error: equality checks against true are unnecessary - --> $DIR/needless_bool.rs:89:7 - | -89 | if x == true { }; - | ^^^^^^^^^^ help: try simplifying it as shown: `x` - | - = note: `-D clippy::bool-comparison` implied by `-D warnings` + --> $DIR/needless_bool.rs:136:8 + | +136 | if x == true {}; + | ^^^^^^^^^ help: try simplifying it as shown: `x` + | + = note: `-D clippy::bool-comparison` implied by `-D warnings` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool.rs:93:7 - | -93 | if x == false { }; - | ^^^^^^^^^^^ help: try simplifying it as shown: `!x` + --> $DIR/needless_bool.rs:140:8 + | +140 | if x == false {}; + | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: equality checks against true are unnecessary - --> $DIR/needless_bool.rs:104:8 + --> $DIR/needless_bool.rs:150:8 | -104 | if x == true { }; +150 | if x == true {}; | ^^^^^^^^^ help: try simplifying it as shown: `x` error: equality checks against false can be replaced by a negation - --> $DIR/needless_bool.rs:105:8 + --> $DIR/needless_bool.rs:151:8 | -105 | if x == false { }; +151 | if x == false {}; | ^^^^^^^^^^ help: try simplifying it as shown: `!x` error: aborting due to 15 previous errors diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index 93ba61784d30..42deedfa869a 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,41 +1,41 @@ error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:25:15 + --> $DIR/needless_borrow.rs:22:15 | -25 | let c = x(&&a); +22 | let c = x(&&a); | ^^^ help: change this to: `&a` | = note: `-D clippy::needless-borrow` implied by `-D warnings` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:32:17 + --> $DIR/needless_borrow.rs:29:17 | -32 | if let Some(ref cake) = Some(&5) {} +29 | if let Some(ref cake) = Some(&5) {} | ^^^^^^^^ help: change this to: `cake` error: this expression borrows a reference that is immediately dereferenced by the compiler - --> $DIR/needless_borrow.rs:39:15 + --> $DIR/needless_borrow.rs:36:15 | -39 | 46 => &&a, +36 | 46 => &&a, | ^^^ help: change this to: `&a` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:61:34 + --> $DIR/needless_borrow.rs:58:34 | -61 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +58 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrow.rs:62:30 + --> $DIR/needless_borrow.rs:59:30 | -62 | let _ = v.iter().filter(|&ref a| a.is_empty()); +59 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` error: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:62:31 + --> $DIR/needless_borrow.rs:59:31 | -62 | let _ = v.iter().filter(|&ref a| a.is_empty()); +59 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^ help: change this to: `a` error: aborting due to 6 previous errors diff --git a/tests/ui/needless_borrowed_ref.stderr b/tests/ui/needless_borrowed_ref.stderr index ef80473a9dc2..5ec7b9e4f3e7 100644 --- a/tests/ui/needless_borrowed_ref.stderr +++ b/tests/ui/needless_borrowed_ref.stderr @@ -1,27 +1,27 @@ error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:18:34 + --> $DIR/needless_borrowed_ref.rs:14:34 | -18 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +14 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); | ^^^^^^ help: try removing the `&ref` part and just keep: `a` | = note: `-D clippy::needless-borrowed-reference` implied by `-D warnings` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:23:17 + --> $DIR/needless_borrowed_ref.rs:19:17 | -23 | if let Some(&ref v) = thingy { +19 | if let Some(&ref v) = thingy { | ^^^^^^ help: try removing the `&ref` part and just keep: `v` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:52:27 + --> $DIR/needless_borrowed_ref.rs:48:27 | -52 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' +48 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' | ^^^^^^ help: try removing the `&ref` part and just keep: `k` error: this pattern takes a reference on something that is being de-referenced - --> $DIR/needless_borrowed_ref.rs:52:38 + --> $DIR/needless_borrowed_ref.rs:48:38 | -52 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' +48 | (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref' | ^^^^^^ help: try removing the `&ref` part and just keep: `k` error: aborting due to 4 previous errors diff --git a/tests/ui/needless_collect.stderr b/tests/ui/needless_collect.stderr index ee41a9d8dead..39b3aa5470bc 100644 --- a/tests/ui/needless_collect.stderr +++ b/tests/ui/needless_collect.stderr @@ -1,27 +1,27 @@ error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:19:28 + --> $DIR/needless_collect.rs:16:28 | -19 | let len = sample.iter().collect::>().len(); +16 | let len = sample.iter().collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` | = note: `-D clippy::needless-collect` implied by `-D warnings` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:20:21 + --> $DIR/needless_collect.rs:17:21 | -20 | if sample.iter().collect::>().is_empty() { +17 | if sample.iter().collect::>().is_empty() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.next().is_none()` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:23:27 + --> $DIR/needless_collect.rs:20:27 | -23 | sample.iter().cloned().collect::>().contains(&1); +20 | sample.iter().cloned().collect::>().contains(&1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.any(|&x| x == 1)` error: avoid using `collect()` when not needed - --> $DIR/needless_collect.rs:24:34 + --> $DIR/needless_collect.rs:21:34 | -24 | sample.iter().map(|x| (x, x)).collect::>().len(); +21 | sample.iter().map(|x| (x, x)).collect::>().len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `.count()` error: aborting due to 4 previous errors diff --git a/tests/ui/needless_continue.stderr b/tests/ui/needless_continue.stderr index 10e7062f2a63..06f63ee496ee 100644 --- a/tests/ui/needless_continue.stderr +++ b/tests/ui/needless_continue.stderr @@ -12,9 +12,9 @@ error: This else block is redundant. = help: Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so: if i % 2 == 0 && i % 3 == 0 { println!("{}", i); - println!("{}", i+1); + println!("{}", i + 1); if i % 5 == 0 { - println!("{}", i+2); + println!("{}", i + 2); } let i = 0; println!("bar {} ", i); diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index 3685f0e96142..e11aa73db2ab 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,128 +1,128 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:21:23 + --> $DIR/needless_pass_by_value.rs:24:23 | -21 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { +24 | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` | = note: `-D clippy::needless-pass-by-value` implied by `-D warnings` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:35:11 + --> $DIR/needless_pass_by_value.rs:38:11 | -35 | fn bar(x: String, y: Wrapper) { +38 | 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 - --> $DIR/needless_pass_by_value.rs:35:22 + --> $DIR/needless_pass_by_value.rs:38:22 | -35 | fn bar(x: String, y: Wrapper) { +38 | 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 - --> $DIR/needless_pass_by_value.rs:41:71 + --> $DIR/needless_pass_by_value.rs:44:71 | -41 | fn test_borrow_trait, U: AsRef, V>(t: T, u: U, v: V) { +44 | 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 - --> $DIR/needless_pass_by_value.rs:53:18 + --> $DIR/needless_pass_by_value.rs:56:18 | -53 | fn test_match(x: Option>, y: Option>) { +56 | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead | -53 | fn test_match(x: &Option>, y: Option>) { -54 | match *x { +56 | fn test_match(x: &Option>, y: Option>) { +57 | match *x { | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:66:24 + --> $DIR/needless_pass_by_value.rs:69:24 | -66 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +69 | 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 - --> $DIR/needless_pass_by_value.rs:66:36 + --> $DIR/needless_pass_by_value.rs:69:36 | -66 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { +69 | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ help: consider taking a reference instead | -66 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { -67 | let Wrapper(s) = z; // moved -68 | let Wrapper(ref t) = *y; // not moved -69 | let Wrapper(_) = *y; // still not moved +69 | fn test_destructure(x: Wrapper, y: &Wrapper, z: Wrapper) { +70 | let Wrapper(s) = z; // moved +71 | let Wrapper(ref t) = *y; // not moved +72 | let Wrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:82:49 + --> $DIR/needless_pass_by_value.rs:85:49 | -82 | fn test_blanket_ref(_foo: T, _serializable: S) {} +85 | fn test_blanket_ref(_foo: T, _serializable: S) {} | ^ help: consider taking a reference instead: `&T` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:84:18 + --> $DIR/needless_pass_by_value.rs:87:18 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | 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 - --> $DIR/needless_pass_by_value.rs:84:29 + --> $DIR/needless_pass_by_value.rs:87:29 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ help: consider changing the type to | -84 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: &str, u: Vec, v: Vec) { | ^^^^ help: change `t.clone()` to | -86 | let _ = t.to_string(); +89 | let _ = t.to_string(); | ^^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:84:40 + --> $DIR/needless_pass_by_value.rs:87:40 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | 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 - --> $DIR/needless_pass_by_value.rs:84:53 + --> $DIR/needless_pass_by_value.rs:87:53 | -84 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider changing the type to | -84 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { +87 | fn issue_2114(s: String, t: String, u: Vec, v: &[i32]) { | ^^^^^^ help: change `v.clone()` to | -88 | let _ = v.to_owned(); +91 | let _ = v.to_owned(); | ^^^^^^^^^^^^ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:96:12 - | -96 | s: String, - | ^^^^^^ help: consider changing the type to: `&str` + --> $DIR/needless_pass_by_value.rs:100:12 + | +100 | s: String, + | ^^^^^^ help: consider changing the type to: `&str` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:97:12 - | -97 | t: String, - | ^^^^^^ help: consider taking a reference instead: `&String` + --> $DIR/needless_pass_by_value.rs:101:12 + | +101 | t: String, + | ^^^^^^ help: consider taking a reference instead: `&String` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:109:13 + --> $DIR/needless_pass_by_value.rs:110:23 | -109 | _u: U, - | ^ help: consider taking a reference instead: `&U` +110 | fn baz(&self, _u: U, _s: Self) {} + | ^ help: consider taking a reference instead: `&U` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:110:13 + --> $DIR/needless_pass_by_value.rs:110:30 | -110 | _s: Self, - | ^^^^ help: consider taking a reference instead: `&Self` +110 | fn baz(&self, _u: U, _s: Self) {} + | ^^^^ help: consider taking a reference instead: `&Self` error: this argument is passed by value, but not consumed in the function body --> $DIR/needless_pass_by_value.rs:132:24 diff --git a/tests/ui/needless_range_loop.stderr b/tests/ui/needless_range_loop.stderr index 688e9fc3a2c5..03a469dfa722 100644 --- a/tests/ui/needless_range_loop.stderr +++ b/tests/ui/needless_range_loop.stderr @@ -1,83 +1,83 @@ error: the loop variable `i` is only used to index `ns`. - --> $DIR/needless_range_loop.rs:18:14 + --> $DIR/needless_range_loop.rs:17:14 | -18 | for i in 3..10 { +17 | for i in 3..10 { | ^^^^^ | = note: `-D clippy::needless-range-loop` implied by `-D warnings` help: consider using an iterator | -18 | for in ns.iter().take(10).skip(3) { +17 | for in ns.iter().take(10).skip(3) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `ms`. - --> $DIR/needless_range_loop.rs:39:14 + --> $DIR/needless_range_loop.rs:38:14 | -39 | for i in 0..ms.len() { +38 | for i in 0..ms.len() { | ^^^^^^^^^^^ help: consider using an iterator | -39 | for in &mut ms { +38 | for in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `ms`. - --> $DIR/needless_range_loop.rs:45:14 + --> $DIR/needless_range_loop.rs:44:14 | -45 | for i in 0..ms.len() { +44 | for i in 0..ms.len() { | ^^^^^^^^^^^ help: consider using an iterator | -45 | for in &mut ms { +44 | for in &mut ms { | ^^^^^^ ^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/needless_range_loop.rs:69:14 + --> $DIR/needless_range_loop.rs:68:14 | -69 | for i in x..x + 4 { +68 | for i in x..x + 4 { | ^^^^^^^^ help: consider using an iterator | -69 | for in vec.iter_mut().skip(x).take(4) { +68 | for in vec.iter_mut().skip(x).take(4) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `vec`. - --> $DIR/needless_range_loop.rs:76:14 + --> $DIR/needless_range_loop.rs:75:14 | -76 | for i in x..=x + 4 { +75 | for i in x..=x + 4 { | ^^^^^^^^^ help: consider using an iterator | -76 | for in vec.iter_mut().skip(x).take(4 + 1) { +75 | for in vec.iter_mut().skip(x).take(4 + 1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:82:14 + --> $DIR/needless_range_loop.rs:81:14 | -82 | for i in 0..3 { +81 | for i in 0..3 { | ^^^^ help: consider using an iterator | -82 | for in &arr { +81 | for in &arr { | ^^^^^^ ^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:86:14 + --> $DIR/needless_range_loop.rs:85:14 | -86 | for i in 0..2 { +85 | for i in 0..2 { | ^^^^ help: consider using an iterator | -86 | for in arr.iter().take(2) { +85 | for in arr.iter().take(2) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: the loop variable `i` is only used to index `arr`. - --> $DIR/needless_range_loop.rs:90:14 + --> $DIR/needless_range_loop.rs:89:14 | -90 | for i in 1..3 { +89 | for i in 1..3 { | ^^^^ help: consider using an iterator | -90 | for in arr.iter().skip(1) { +89 | for in arr.iter().skip(1) { | ^^^^^^ ^^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 742ef8d379ef..07d29c19be32 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -1,51 +1,51 @@ error: unneeded return statement - --> $DIR/needless_return.rs:21:5 + --> $DIR/needless_return.rs:17:5 | -21 | return true; +17 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` | = note: `-D clippy::needless-return` implied by `-D warnings` error: unneeded return statement - --> $DIR/needless_return.rs:25:5 + --> $DIR/needless_return.rs:21:5 | -25 | return true - | ^^^^^^^^^^^ help: remove `return` as shown: `true` +21 | return true; + | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:30:9 + --> $DIR/needless_return.rs:26:9 | -30 | return true; +26 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:32:9 + --> $DIR/needless_return.rs:28:9 | -32 | return false; +28 | return false; | ^^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:38:17 + --> $DIR/needless_return.rs:34:17 | -38 | true => return false, +34 | true => return false, | ^^^^^^^^^^^^ help: remove `return` as shown: `false` error: unneeded return statement - --> $DIR/needless_return.rs:40:13 + --> $DIR/needless_return.rs:36:13 | -40 | return true; +36 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:47:9 + --> $DIR/needless_return.rs:43:9 | -47 | return true; +43 | return true; | ^^^^^^^^^^^^ help: remove `return` as shown: `true` error: unneeded return statement - --> $DIR/needless_return.rs:49:16 + --> $DIR/needless_return.rs:45:16 | -49 | let _ = || return true; +45 | let _ = || return true; | ^^^^^^^^^^^ help: remove `return` as shown: `true` error: aborting due to 8 previous errors diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index 512cec847704..d5cd0e7889a2 100644 --- a/tests/ui/needless_update.stderr +++ b/tests/ui/needless_update.stderr @@ -1,7 +1,7 @@ error: struct update has no effect, all the fields in the struct have already been specified - --> $DIR/needless_update.rs:26:23 + --> $DIR/needless_update.rs:22:23 | -26 | S { a: 1, b: 1, ..base }; +22 | S { a: 1, b: 1, ..base }; | ^^^^ | = note: `-D clippy::needless-update` implied by `-D warnings` diff --git a/tests/ui/neg_cmp_op_on_partial_ord.stderr b/tests/ui/neg_cmp_op_on_partial_ord.stderr index 1bd292818b38..ee0f9af6f955 100644 --- a/tests/ui/neg_cmp_op_on_partial_ord.stderr +++ b/tests/ui/neg_cmp_op_on_partial_ord.stderr @@ -1,27 +1,27 @@ 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. - --> $DIR/neg_cmp_op_on_partial_ord.rs:29:21 + --> $DIR/neg_cmp_op_on_partial_ord.rs:24:21 | -29 | let _not_less = !(a_value < another_value); +24 | let _not_less = !(a_value < another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::neg-cmp-op-on-partial-ord` implied by `-D warnings` 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. - --> $DIR/neg_cmp_op_on_partial_ord.rs:32:30 + --> $DIR/neg_cmp_op_on_partial_ord.rs:27:30 | -32 | let _not_less_or_equal = !(a_value <= another_value); +27 | 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. - --> $DIR/neg_cmp_op_on_partial_ord.rs:35:24 + --> $DIR/neg_cmp_op_on_partial_ord.rs:30:24 | -35 | let _not_greater = !(a_value > another_value); +30 | 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. - --> $DIR/neg_cmp_op_on_partial_ord.rs:38:33 + --> $DIR/neg_cmp_op_on_partial_ord.rs:33:33 | -38 | let _not_greater_or_equal = !(a_value >= another_value); +33 | let _not_greater_or_equal = !(a_value >= another_value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/neg_multiply.stderr b/tests/ui/neg_multiply.stderr index ed96dd519ff6..5e5d1afaafe7 100644 --- a/tests/ui/neg_multiply.stderr +++ b/tests/ui/neg_multiply.stderr @@ -1,15 +1,15 @@ error: Negation by multiplying with -1 - --> $DIR/neg_multiply.rs:40:5 + --> $DIR/neg_multiply.rs:36:5 | -40 | x * -1; +36 | x * -1; | ^^^^^^ | = note: `-D clippy::neg-multiply` implied by `-D warnings` error: Negation by multiplying with -1 - --> $DIR/neg_multiply.rs:42:5 + --> $DIR/neg_multiply.rs:38:5 | -42 | -1 * x; +38 | -1 * x; | ^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index e4daa6e43508..6ef26234d9d3 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -1,93 +1,99 @@ error: this loop never actually loops - --> $DIR/never_loop.rs:17:5 + --> $DIR/never_loop.rs:19:5 | -17 | / loop { // clippy::never_loop -18 | | x += 1; -19 | | if x == 1 { -20 | | return -21 | | } -22 | | break; -23 | | } +19 | / loop { +20 | | // clippy::never_loop +21 | | x += 1; +22 | | if x == 1 { +... | +25 | | break; +26 | | } | |_____^ | = note: #[deny(clippy::never_loop)] on by default error: this loop never actually loops - --> $DIR/never_loop.rs:38:5 + --> $DIR/never_loop.rs:41:5 | -38 | / loop { // never loops -39 | | x += 1; -40 | | break -41 | | } +41 | / loop { +42 | | // never loops +43 | | x += 1; +44 | | break; +45 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:57:2 + --> $DIR/never_loop.rs:61:5 | -57 | loop { // never loops - | _____^ -58 | | while i == 0 { // never loops -59 | | break -60 | | } -61 | | return -62 | | } +61 | / loop { +62 | | // never loops +63 | | while i == 0 { +64 | | // never loops +... | +67 | | return; +68 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:58:9 + --> $DIR/never_loop.rs:63:9 | -58 | / while i == 0 { // never loops -59 | | break -60 | | } +63 | / while i == 0 { +64 | | // never loops +65 | | break; +66 | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:69:3 + --> $DIR/never_loop.rs:75:9 | -69 | loop { // never loops - | _________^ -70 | | if x == 5 { break } -71 | | continue 'outer -72 | | } +75 | / loop { +76 | | // never loops +77 | | if x == 5 { +78 | | break; +79 | | } +80 | | continue 'outer; +81 | | } | |_________^ error: this loop never actually loops - --> $DIR/never_loop.rs:102:5 + --> $DIR/never_loop.rs:111:5 | -102 | / while let Some(y) = x { // never loops -103 | | return -104 | | } +111 | / while let Some(y) = x { +112 | | // never loops +113 | | return; +114 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:108:5 + --> $DIR/never_loop.rs:118:5 | -108 | / for x in 0..10 { // never loops -109 | | match x { -110 | | 1 => break, -111 | | _ => return, -112 | | } -113 | | } +118 | / for x in 0..10 { +119 | | // never loops +120 | | match x { +121 | | 1 => break, +122 | | _ => return, +123 | | } +124 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:154:5 + --> $DIR/never_loop.rs:166:5 | -154 | / 'outer: while a { // never loops -155 | | while a { -156 | | if a { -157 | | a = false; +166 | / 'outer: while a { +167 | | // never loops +168 | | while a { +169 | | if a { ... | -161 | | break 'outer; -162 | | } +174 | | break 'outer; +175 | | } | |_____^ error: this loop never actually loops - --> $DIR/never_loop.rs:168:9 + --> $DIR/never_loop.rs:181:9 | -168 | / while false { -169 | | break 'label; -170 | | } +181 | / while false { +182 | | break 'label; +183 | | } | |_________^ error: aborting due to 9 previous errors diff --git a/tests/ui/new_ret_no_self.stderr b/tests/ui/new_ret_no_self.stderr index bab9627ca225..e5911b3d72e9 100644 --- a/tests/ui/new_ret_no_self.stderr +++ b/tests/ui/new_ret_no_self.stderr @@ -25,22 +25,28 @@ error: methods called `new` usually return `Self` | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:120:5 + --> $DIR/new_ret_no_self.rs:126:5 | -120 | pub fn new() -> (u32, u32) { unimplemented!(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +126 | / pub fn new() -> (u32, u32) { +127 | | unimplemented!(); +128 | | } + | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:141:5 + --> $DIR/new_ret_no_self.rs:153:5 | -141 | pub fn new() -> *mut V { unimplemented!(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +153 | / pub fn new() -> *mut V { +154 | | unimplemented!(); +155 | | } + | |_____^ error: methods called `new` usually return `Self` - --> $DIR/new_ret_no_self.rs:155:5 + --> $DIR/new_ret_no_self.rs:171:5 | -155 | pub fn new() -> Option { unimplemented!(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +171 | / pub fn new() -> Option { +172 | | unimplemented!(); +173 | | } + | |_____^ error: aborting due to 6 previous errors diff --git a/tests/ui/new_without_default.stderr b/tests/ui/new_without_default.stderr index 5343428636c4..b37c1e144245 100644 --- a/tests/ui/new_without_default.stderr +++ b/tests/ui/new_without_default.stderr @@ -1,39 +1,45 @@ error: you should consider deriving a `Default` implementation for `Foo` - --> $DIR/new_without_default.rs:22:5 + --> $DIR/new_without_default.rs:17:5 | -22 | pub fn new() -> Foo { Foo } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +17 | / pub fn new() -> Foo { +18 | | Foo +19 | | } + | |_____^ | = note: `-D clippy::new-without-default-derive` implied by `-D warnings` help: try this | -19 | #[derive(Default)] +14 | #[derive(Default)] | error: you should consider deriving a `Default` implementation for `Bar` - --> $DIR/new_without_default.rs:28:5 + --> $DIR/new_without_default.rs:25:5 | -28 | pub fn new() -> Self { Bar } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +25 | / pub fn new() -> Self { +26 | | Bar +27 | | } + | |_____^ help: try this | -25 | #[derive(Default)] +22 | #[derive(Default)] | error: you should consider adding a `Default` implementation for `LtKo<'c>` - --> $DIR/new_without_default.rs:76:5 + --> $DIR/new_without_default.rs:89:5 | -76 | pub fn new() -> LtKo<'c> { unimplemented!() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +89 | / pub fn new() -> LtKo<'c> { +90 | | unimplemented!() +91 | | } + | |_____^ | = note: `-D clippy::new-without-default` implied by `-D warnings` help: try this | -75 | impl Default for LtKo<'c> { -76 | fn default() -> Self { -77 | Self::new() -78 | } -79 | } +88 | impl Default for LtKo<'c> { +89 | fn default() -> Self { +90 | Self::new() +91 | } +92 | } | error: aborting due to 3 previous errors diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index 7f012aa2ed4b..e8a88307c974 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,154 +1,154 @@ error: statement with no effect - --> $DIR/no_effect.rs:71:5 + --> $DIR/no_effect.rs:74:5 | -71 | 0; +74 | 0; | ^^ | = note: `-D clippy::no-effect` implied by `-D warnings` error: statement with no effect - --> $DIR/no_effect.rs:72:5 + --> $DIR/no_effect.rs:75:5 | -72 | s2; +75 | s2; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:73:5 + --> $DIR/no_effect.rs:76:5 | -73 | Unit; +76 | Unit; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:74:5 + --> $DIR/no_effect.rs:77:5 | -74 | Tuple(0); +77 | Tuple(0); | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:75:5 + --> $DIR/no_effect.rs:78:5 | -75 | Struct { field: 0 }; +78 | Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:76:5 + --> $DIR/no_effect.rs:79:5 | -76 | Struct { ..s }; +79 | Struct { ..s }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:77:5 + --> $DIR/no_effect.rs:80:5 | -77 | Union { a: 0 }; +80 | Union { a: 0 }; | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:78:5 + --> $DIR/no_effect.rs:81:5 | -78 | Enum::Tuple(0); +81 | Enum::Tuple(0); | ^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:79:5 + --> $DIR/no_effect.rs:82:5 | -79 | Enum::Struct { field: 0 }; +82 | Enum::Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:80:5 + --> $DIR/no_effect.rs:83:5 | -80 | 5 + 6; +83 | 5 + 6; | ^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:81:5 + --> $DIR/no_effect.rs:84:5 | -81 | *&42; +84 | *&42; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:82:5 + --> $DIR/no_effect.rs:85:5 | -82 | &6; +85 | &6; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:83:5 + --> $DIR/no_effect.rs:86:5 | -83 | (5, 6, 7); +86 | (5, 6, 7); | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:84:5 + --> $DIR/no_effect.rs:87:5 | -84 | box 42; +87 | box 42; | ^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:85:5 + --> $DIR/no_effect.rs:88:5 | -85 | ..; +88 | ..; | ^^^ error: statement with no effect - --> $DIR/no_effect.rs:86:5 + --> $DIR/no_effect.rs:89:5 | -86 | 5..; +89 | 5..; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:87:5 + --> $DIR/no_effect.rs:90:5 | -87 | ..5; +90 | ..5; | ^^^^ error: statement with no effect - --> $DIR/no_effect.rs:88:5 + --> $DIR/no_effect.rs:91:5 | -88 | 5..6; +91 | 5..6; | ^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:90:5 + --> $DIR/no_effect.rs:93:5 | -90 | [42, 55]; +93 | [42, 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:91:5 + --> $DIR/no_effect.rs:94:5 | -91 | [42, 55][1]; +94 | [42, 55][1]; | ^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:92:5 + --> $DIR/no_effect.rs:95:5 | -92 | (42, 55).1; +95 | (42, 55).1; | ^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:93:5 + --> $DIR/no_effect.rs:96:5 | -93 | [42; 55]; +96 | [42; 55]; | ^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:94:5 + --> $DIR/no_effect.rs:97:5 | -94 | [42; 55][13]; +97 | [42; 55][13]; | ^^^^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:96:5 + --> $DIR/no_effect.rs:99:5 | -96 | || x += 5; +99 | || x += 5; | ^^^^^^^^^^ error: statement with no effect - --> $DIR/no_effect.rs:98:5 - | -98 | FooString { s: s }; - | ^^^^^^^^^^^^^^^^^^^ + --> $DIR/no_effect.rs:101:5 + | +101 | FooString { s: s }; + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 25 previous errors diff --git a/tests/ui/non_copy_const.stderr b/tests/ui/non_copy_const.stderr index 744b5474844c..6d65f4dca501 100644 --- a/tests/ui/non_copy_const.stderr +++ b/tests/ui/non_copy_const.stderr @@ -1,7 +1,7 @@ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:22:1 + --> $DIR/non_copy_const.rs:19:1 | -22 | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable +19 | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` @@ -9,264 +9,264 @@ error: a const item should never be interior mutable = note: #[deny(clippy::declare_interior_mutable_const)] on by default error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:23:1 + --> $DIR/non_copy_const.rs:20:1 | -23 | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable +20 | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:24:1 + --> $DIR/non_copy_const.rs:21:1 | -24 | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); +21 | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: make this a static item: `static` error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:28:42 + --> $DIR/non_copy_const.rs:26:9 | -28 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; - | ^^^^^^^^^^^^^^^^^^^^^^ -29 | } -30 | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable +26 | const $name: $ty = $e; + | ^^^^^^^^^^^^^^^^^^^^^^ +... +29 | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable | ------------------------------------------ in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:51:5 + --> $DIR/non_copy_const.rs:50:5 | -51 | const ATOMIC: AtomicUsize; //~ ERROR interior mutable +50 | const ATOMIC: AtomicUsize; //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:55:5 + --> $DIR/non_copy_const.rs:54:5 | -55 | const INPUT: T; +54 | const INPUT: T; | ^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:55:18 + --> $DIR/non_copy_const.rs:54:18 | -55 | const INPUT: T; +54 | const INPUT: T; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:58:5 + --> $DIR/non_copy_const.rs:57:5 | -58 | const ASSOC: Self::NonCopyType; +57 | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:58:18 + --> $DIR/non_copy_const.rs:57:18 | -58 | const ASSOC: Self::NonCopyType; +57 | const ASSOC: Self::NonCopyType; | ^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:62:5 + --> $DIR/non_copy_const.rs:61:5 | -62 | const AN_INPUT: T = Self::INPUT; +61 | const AN_INPUT: T = Self::INPUT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:62:21 + --> $DIR/non_copy_const.rs:61:21 | -62 | const AN_INPUT: T = Self::INPUT; +61 | const AN_INPUT: T = Self::INPUT; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:28:42 + --> $DIR/non_copy_const.rs:26:9 | -28 | ($name:ident: $ty:ty = $e:expr) => { const $name: $ty = $e; }; - | ^^^^^^^^^^^^^^^^^^^^^^ +26 | const $name: $ty = $e; + | ^^^^^^^^^^^^^^^^^^^^^^ ... -65 | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable +64 | declare_const!(ANOTHER_INPUT: T = Self::INPUT); //~ ERROR interior mutable | ----------------------------------------------- in this macro invocation error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:71:5 + --> $DIR/non_copy_const.rs:70:5 | -71 | const SELF_2: Self; +70 | const SELF_2: Self; | ^^^^^^^^^^^^^^^^^^^ | help: consider requiring `Self` to be `Copy` - --> $DIR/non_copy_const.rs:71:19 + --> $DIR/non_copy_const.rs:70:19 | -71 | const SELF_2: Self; +70 | const SELF_2: Self; | ^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:92:5 + --> $DIR/non_copy_const.rs:91:5 | -92 | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable +91 | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:95:5 + --> $DIR/non_copy_const.rs:94:5 | -95 | const U_SELF: U = U::SELF_2; +94 | const U_SELF: U = U::SELF_2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `U` to be `Copy` - --> $DIR/non_copy_const.rs:95:19 + --> $DIR/non_copy_const.rs:94:19 | -95 | const U_SELF: U = U::SELF_2; +94 | const U_SELF: U = U::SELF_2; | ^ error: a const item should never be interior mutable - --> $DIR/non_copy_const.rs:98:5 + --> $DIR/non_copy_const.rs:97:5 | -98 | const T_ASSOC: T::NonCopyType = T::ASSOC; +97 | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:98:20 + --> $DIR/non_copy_const.rs:97:20 | -98 | const T_ASSOC: T::NonCopyType = T::ASSOC; +97 | const T_ASSOC: T::NonCopyType = T::ASSOC; | ^^^^^^^^^^^^^^ error: a const item with interior mutability should not be borrowed - --> $DIR/non_copy_const.rs:105:5 + --> $DIR/non_copy_const.rs:104:5 | -105 | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability +104 | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^ | = note: #[deny(clippy::borrow_interior_mutable_const)] on by default = 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 - --> $DIR/non_copy_const.rs:106:16 + --> $DIR/non_copy_const.rs:105:16 | -106 | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability +105 | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability | ^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:108:5 + --> $DIR/non_copy_const.rs:107:5 | -108 | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability +107 | ATOMIC_USIZE_INIT.store(2, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:109:16 + --> $DIR/non_copy_const.rs:108:16 | -109 | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability +108 | assert_eq!(ATOMIC_USIZE_INIT.load(Ordering::SeqCst), 0); //~ ERROR interior mutability | ^^^^^^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:112:22 + --> $DIR/non_copy_const.rs:111:22 | -112 | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability +111 | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:113:25 + --> $DIR/non_copy_const.rs:112:25 | -113 | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability +112 | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:114:27 + --> $DIR/non_copy_const.rs:113:27 | -114 | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability +113 | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:115:26 + --> $DIR/non_copy_const.rs:114:26 | -115 | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability +114 | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability | ^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:126:14 + --> $DIR/non_copy_const.rs:125:14 | -126 | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability +125 | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:127:14 + --> $DIR/non_copy_const.rs:126:14 | -127 | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability +126 | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:128:19 + --> $DIR/non_copy_const.rs:127:19 | -128 | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability +127 | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:129:14 + --> $DIR/non_copy_const.rs:128:14 | -129 | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +128 | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:130:13 + --> $DIR/non_copy_const.rs:129:13 | -130 | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability +129 | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:136:13 + --> $DIR/non_copy_const.rs:135:13 | -136 | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability +135 | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability | ^^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:141:5 + --> $DIR/non_copy_const.rs:140:5 | -141 | CELL.set(2); //~ ERROR interior mutability +140 | CELL.set(2); //~ ERROR interior mutability | ^^^^ | = 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 - --> $DIR/non_copy_const.rs:142:16 + --> $DIR/non_copy_const.rs:141:16 | -142 | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability +141 | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability | ^^^^ | = 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 - --> $DIR/non_copy_const.rs:155:5 + --> $DIR/non_copy_const.rs:154:5 | -155 | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability +154 | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability | ^^^^^^^^^^^ | = 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 - --> $DIR/non_copy_const.rs:156:16 + --> $DIR/non_copy_const.rs:155:16 | -156 | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability +155 | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability | ^^^^^^^^^^^ | = help: assign this const to a local or static variable, and use the variable here diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 1369cd8a4ad1..568ae721588e 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,170 +1,170 @@ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:28:9 + --> $DIR/non_expressive_names.rs:24:9 | -28 | let bpple: i32; +24 | let bpple: i32; | ^^^^^ | = note: `-D clippy::similar-names` implied by `-D warnings` note: existing binding defined here - --> $DIR/non_expressive_names.rs:26:9 + --> $DIR/non_expressive_names.rs:22:9 | -26 | let apple: i32; +22 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `b_pple` - --> $DIR/non_expressive_names.rs:28:9 + --> $DIR/non_expressive_names.rs:24:9 | -28 | let bpple: i32; +24 | let bpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:30:9 + --> $DIR/non_expressive_names.rs:26:9 | -30 | let cpple: i32; +26 | let cpple: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:26:9 + --> $DIR/non_expressive_names.rs:22:9 | -26 | let apple: i32; +22 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `c_pple` - --> $DIR/non_expressive_names.rs:30:9 + --> $DIR/non_expressive_names.rs:26:9 | -30 | let cpple: i32; +26 | let cpple: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:55:9 + --> $DIR/non_expressive_names.rs:50:9 | -55 | let bluby: i32; +50 | let bluby: i32; | ^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:54:9 + --> $DIR/non_expressive_names.rs:49:9 | -54 | let blubx: i32; +49 | let blubx: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `blub_y` - --> $DIR/non_expressive_names.rs:55:9 + --> $DIR/non_expressive_names.rs:50:9 | -55 | let bluby: i32; +50 | let bluby: i32; | ^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:60:9 + --> $DIR/non_expressive_names.rs:54:9 | -60 | let coke: i32; +54 | let coke: i32; | ^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:58:9 + --> $DIR/non_expressive_names.rs:52:9 | -58 | let cake: i32; +52 | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:78:9 + --> $DIR/non_expressive_names.rs:72:9 | -78 | let xyzeabc: i32; +72 | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:76:9 + --> $DIR/non_expressive_names.rs:70:9 | -76 | let xyz1abc: i32; +70 | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:82:9 + --> $DIR/non_expressive_names.rs:76:9 | -82 | let parsee: i32; +76 | let parsee: i32; | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:80:9 + --> $DIR/non_expressive_names.rs:74:9 | -80 | let parser: i32; +74 | let parser: i32; | ^^^^^^ help: separate the discriminating character by an underscore like: `parse_e` - --> $DIR/non_expressive_names.rs:82:9 + --> $DIR/non_expressive_names.rs:76:9 | -82 | let parsee: i32; +76 | let parsee: i32; | ^^^^^^ error: binding's name is too similar to existing binding - --> $DIR/non_expressive_names.rs:96:16 + --> $DIR/non_expressive_names.rs:90:16 | -96 | bpple: sprang } = unimplemented!(); +90 | bpple: sprang, | ^^^^^^ | note: existing binding defined here - --> $DIR/non_expressive_names.rs:95:22 + --> $DIR/non_expressive_names.rs:89:16 | -95 | let Foo { apple: spring, - | ^^^^^^ +89 | apple: spring, + | ^^^^^^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:130:17 + --> $DIR/non_expressive_names.rs:125:17 | -130 | let e: i32; +125 | let e: i32; | ^ | = note: `-D clippy::many-single-char-names` implied by `-D warnings` error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:133:17 + --> $DIR/non_expressive_names.rs:128:17 | -133 | let e: i32; +128 | let e: i32; | ^ error: 6th binding whose name is just one char - --> $DIR/non_expressive_names.rs:134:17 + --> $DIR/non_expressive_names.rs:129:17 | -134 | let f: i32; +129 | let f: i32; | ^ error: 5th binding whose name is just one char - --> $DIR/non_expressive_names.rs:139:13 + --> $DIR/non_expressive_names.rs:133:13 | -139 | e => panic!(), +133 | e => panic!(), | ^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:149:9 + --> $DIR/non_expressive_names.rs:143:9 | -149 | let _1 = 1; //~ERROR Consider a more descriptive name +143 | let _1 = 1; //~ERROR Consider a more descriptive name | ^^ | = note: `-D clippy::just-underscores-and-digits` implied by `-D warnings` error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:150:9 + --> $DIR/non_expressive_names.rs:144:9 | -150 | let ____1 = 1; //~ERROR Consider a more descriptive name +144 | let ____1 = 1; //~ERROR Consider a more descriptive name | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:151:9 + --> $DIR/non_expressive_names.rs:145:9 | -151 | let __1___2 = 12; //~ERROR Consider a more descriptive name +145 | let __1___2 = 12; //~ERROR Consider a more descriptive name | ^^^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:171:13 + --> $DIR/non_expressive_names.rs:165:13 | -171 | let _1 = 1; +165 | let _1 = 1; | ^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:172:13 + --> $DIR/non_expressive_names.rs:166:13 | -172 | let ____1 = 1; +166 | let ____1 = 1; | ^^^^^ error: consider choosing a more descriptive name - --> $DIR/non_expressive_names.rs:173:13 + --> $DIR/non_expressive_names.rs:167:13 | -173 | let __1___2 = 12; +167 | let __1___2 = 12; | ^^^^^^^ error: aborting due to 17 previous errors diff --git a/tests/ui/ok_expect.stderr b/tests/ui/ok_expect.stderr index f4c8440a7741..be013cba4594 100644 --- a/tests/ui/ok_expect.stderr +++ b/tests/ui/ok_expect.stderr @@ -1,33 +1,33 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:24:5 + --> $DIR/ok_expect.rs:23:5 | -24 | res.ok().expect("disaster!"); +23 | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::ok-expect` implied by `-D warnings` error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:30:5 + --> $DIR/ok_expect.rs:29:5 | -30 | res3.ok().expect("whoof"); +29 | res3.ok().expect("whoof"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:32:5 + --> $DIR/ok_expect.rs:31:5 | -32 | res4.ok().expect("argh"); +31 | res4.ok().expect("argh"); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:34:5 + --> $DIR/ok_expect.rs:33:5 | -34 | res5.ok().expect("oops"); +33 | res5.ok().expect("oops"); | ^^^^^^^^^^^^^^^^^^^^^^^^ error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` - --> $DIR/ok_expect.rs:36:5 + --> $DIR/ok_expect.rs:35:5 | -36 | res6.ok().expect("meh"); +35 | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index 27b3ef28ff36..5dd8ea37f6f7 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -1,11 +1,11 @@ error: Matching on `Some` with `ok()` is redundant - --> $DIR/ok_if_let.rs:17:5 + --> $DIR/ok_if_let.rs:13:5 | -17 | / if let Some(y) = x.parse().ok() { -18 | | y -19 | | } else { -20 | | 0 -21 | | } +13 | / if let Some(y) = x.parse().ok() { +14 | | y +15 | | } else { +16 | | 0 +17 | | } | |_____^ | = note: `-D clippy::if-let-some-result` implied by `-D warnings` diff --git a/tests/ui/op_ref.stderr b/tests/ui/op_ref.stderr index e2b7b7820f31..abe7348622f9 100644 --- a/tests/ui/op_ref.stderr +++ b/tests/ui/op_ref.stderr @@ -1,19 +1,19 @@ error: needlessly taken reference of both operands - --> $DIR/op_ref.rs:23:15 + --> $DIR/op_ref.rs:19:15 | -23 | let foo = &5 - &6; +19 | let foo = &5 - &6; | ^^^^^^^ | = note: `-D clippy::op-ref` implied by `-D warnings` help: use the values directly | -23 | let foo = 5 - 6; +19 | let foo = 5 - 6; | ^ ^ error: taken reference of right operand - --> $DIR/op_ref.rs:31:8 + --> $DIR/op_ref.rs:27:8 | -31 | if b < &a { +27 | if b < &a { | ^^^^-- | | | help: use the right value directly: `a` diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index 2835eebfbb3b..10691d65a292 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -1,45 +1,45 @@ error: file opened with "truncate" and "read" - --> $DIR/open_options.rs:18:5 + --> $DIR/open_options.rs:15:5 | -18 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); +15 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::nonsensical-open-options` implied by `-D warnings` error: file opened with "append" and "truncate" - --> $DIR/open_options.rs:19:5 + --> $DIR/open_options.rs:16:5 | -19 | OpenOptions::new().append(true).truncate(true).open("foo.txt"); +16 | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "read" is called more than once - --> $DIR/open_options.rs:21:5 + --> $DIR/open_options.rs:18:5 | -21 | OpenOptions::new().read(true).read(false).open("foo.txt"); +18 | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "create" is called more than once - --> $DIR/open_options.rs:22:5 + --> $DIR/open_options.rs:19:5 | -22 | OpenOptions::new().create(true).create(false).open("foo.txt"); +19 | OpenOptions::new().create(true).create(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "write" is called more than once - --> $DIR/open_options.rs:23:5 + --> $DIR/open_options.rs:20:5 | -23 | OpenOptions::new().write(true).write(false).open("foo.txt"); +20 | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "append" is called more than once - --> $DIR/open_options.rs:24:5 + --> $DIR/open_options.rs:21:5 | -24 | OpenOptions::new().append(true).append(false).open("foo.txt"); +21 | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "truncate" is called more than once - --> $DIR/open_options.rs:25:5 + --> $DIR/open_options.rs:22:5 | -25 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); +22 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index 7a2dfd338a36..86fb9e75d8f1 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:44:5 + --> $DIR/option_map_unit_fn.rs:41:5 | -44 | x.field.map(do_nothing); +41 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` @@ -9,36 +9,41 @@ error: called `map(f)` on an Option value where `f` is a unit function = note: `-D clippy::option-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:46:5 + --> $DIR/option_map_unit_fn.rs:43:5 | -46 | x.field.map(do_nothing); +43 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:48:5 + --> $DIR/option_map_unit_fn.rs:45:5 | -48 | x.field.map(diverge); +45 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:54:5 + --> $DIR/option_map_unit_fn.rs:53:5 | -54 | x.field.map(|value| x.do_option_nothing(value + captured)); +53 | x.field.map(|value| x.do_option_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:56:5 + --> $DIR/option_map_unit_fn.rs:55:5 | -56 | x.field.map(|value| { x.do_option_plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` +55 | x.field.map(|value| { + | _____^ + | |_____| + | || +56 | || x.do_option_plus_one(value + captured); +57 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:59:5 @@ -51,157 +56,212 @@ error: called `map(f)` on an Option value where `f` is a unit closure error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:61:5 | -61 | x.field.map(|value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +61 | x.field.map(|value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure --> $DIR/option_map_unit_fn.rs:63:5 | -63 | x.field.map(|value| { do_nothing(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` +63 | x.field.map(|value| { + | _____^ + | |_____| + | || +64 | || do_nothing(value + captured); +65 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:65:5 + --> $DIR/option_map_unit_fn.rs:67:5 | -65 | x.field.map(|value| { { do_nothing(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` +67 | x.field.map(|value| { + | _____^ + | |_____| + | || +68 | || do_nothing(value + captured); +69 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:68:5 + --> $DIR/option_map_unit_fn.rs:71:5 | -68 | x.field.map(|value| diverge(value + captured)); +71 | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:70:5 + --> $DIR/option_map_unit_fn.rs:73:5 | -70 | x.field.map(|value| { diverge(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +73 | x.field.map(|value| diverge(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:72:5 + --> $DIR/option_map_unit_fn.rs:75:5 | -72 | x.field.map(|value| { diverge(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` +75 | x.field.map(|value| { + | _____^ + | |_____| + | || +76 | || diverge(value + captured); +77 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { diverge(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:74:5 + --> $DIR/option_map_unit_fn.rs:79:5 | -74 | x.field.map(|value| { { diverge(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` +79 | x.field.map(|value| { + | _____^ + | |_____| + | || +80 | || diverge(value + captured); +81 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { diverge(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:79:5 + --> $DIR/option_map_unit_fn.rs:85:5 | -79 | x.field.map(|value| { let y = plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` +85 | x.field.map(|value| { + | _____^ + | |_____| + | || +86 | || let y = plus_one(value + captured); +87 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:81:5 + --> $DIR/option_map_unit_fn.rs:89:5 | -81 | x.field.map(|value| { plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` +89 | x.field.map(|value| { + | _____^ + | |_____| + | || +90 | || plus_one(value + captured); +91 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:83:5 + --> $DIR/option_map_unit_fn.rs:93:5 | -83 | x.field.map(|value| { { plus_one(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` +93 | x.field.map(|value| { + | _____^ + | |_____| + | || +94 | || plus_one(value + captured); +95 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:86:5 + --> $DIR/option_map_unit_fn.rs:97:5 | -86 | x.field.map(|ref value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +97 | x.field.map(|ref value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:89:5 - | -89 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { ... }` + --> $DIR/option_map_unit_fn.rs:99:5 + | +99 | x.field.map(|value| { + | _____^ + | |_____| + | || +100 | || do_nothing(value); +101 | || do_nothing(value) +102 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:91:5 - | -91 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { ... }` + --> $DIR/option_map_unit_fn.rs:104:5 + | +104 | x.field.map(|value| { + | _____^ + | |_____| + | || +105 | || if value > 0 { +106 | || do_nothing(value); +107 | || do_nothing(value) +108 | || } +109 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:95:5 - | -95 | x.field.map(|value| { - | _____^ - | |_____| - | || -96 | || do_nothing(value); -97 | || do_nothing(value) -98 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { ... }` - | |_______| - | + --> $DIR/option_map_unit_fn.rs:113:5 + | +113 | x.field.map(|value| { + | _____^ + | |_____| + | || +114 | || do_nothing(value); +115 | || do_nothing(value) +116 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:99:5 - | -99 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(value) = x.field { ... }` + --> $DIR/option_map_unit_fn.rs:117:5 + | +117 | x.field.map(|value| { + | _____^ + | |_____| + | || +118 | || do_nothing(value); +119 | || do_nothing(value); +120 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:102:5 + --> $DIR/option_map_unit_fn.rs:124:5 | -102 | Some(42).map(diverge); +124 | Some(42).map(diverge); | ^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = Some(42) { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:103:5 + --> $DIR/option_map_unit_fn.rs:125:5 | -103 | "12".parse::().ok().map(diverge); +125 | "12".parse::().ok().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = "12".parse::().ok() { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:104:5 + --> $DIR/option_map_unit_fn.rs:126:5 | -104 | Some(plus_one(1)).map(do_nothing); +126 | Some(plus_one(1)).map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:108:5 + --> $DIR/option_map_unit_fn.rs:130:5 | -108 | y.map(do_nothing); +130 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_y) = y { do_nothing(...) }` diff --git a/tests/ui/option_option.stderr b/tests/ui/option_option.stderr index 8a867fd4fe26..0689a10231bf 100644 --- a/tests/ui/option_option.stderr +++ b/tests/ui/option_option.stderr @@ -1,58 +1,58 @@ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:11:13 + --> $DIR/option_option.rs:10:13 | -11 | fn input(_: Option>) { +10 | fn input(_: Option>) {} | ^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::option-option` implied by `-D warnings` error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:14:16 + --> $DIR/option_option.rs:12:16 | -14 | fn output() -> Option> { +12 | fn output() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:18:27 + --> $DIR/option_option.rs:16:27 | -18 | fn output_nested() -> Vec>> { +16 | fn output_nested() -> Vec>> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:23:30 + --> $DIR/option_option.rs:21:30 | -23 | fn output_nested_nested() -> Option>> { +21 | fn output_nested_nested() -> Option>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:28:8 + --> $DIR/option_option.rs:26:8 | -28 | x: Option>, +26 | x: Option>, | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:32:23 + --> $DIR/option_option.rs:30:23 | -32 | fn struct_fn() -> Option> { +30 | fn struct_fn() -> Option> { | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:38:22 + --> $DIR/option_option.rs:36:22 | -38 | fn trait_fn() -> Option>; +36 | fn trait_fn() -> Option>; | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:42:11 + --> $DIR/option_option.rs:40:11 | -42 | Tuple(Option>), +40 | Tuple(Option>), | ^^^^^^^^^^^^^^^^^^ error: consider using `Option` instead of `Option>` or a custom enum if you need to distinguish all 3 cases - --> $DIR/option_option.rs:43:15 + --> $DIR/option_option.rs:41:17 | -43 | Struct{x: Option>}, - | ^^^^^^^^^^^^^^^^^^ +41 | Struct { x: Option> }, + | ^^^^^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index 0bd20210f01f..1c15eeaf67be 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -1,51 +1,51 @@ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:21:5 + --> $DIR/overflow_check_conditional.rs:17:8 | -21 | if a + b < a { +17 | if a + b < a {} | ^^^^^^^^^ | = note: `-D clippy::overflow-check-conditional` implied by `-D warnings` error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:24:5 + --> $DIR/overflow_check_conditional.rs:18:8 | -24 | if a > a + b { +18 | if a > a + b {} | ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:27:5 + --> $DIR/overflow_check_conditional.rs:19:8 | -27 | if a + b < b { +19 | if a + b < b {} | ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:30:5 + --> $DIR/overflow_check_conditional.rs:20:8 | -30 | if b > a + b { +20 | if b > a + b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:33:5 + --> $DIR/overflow_check_conditional.rs:21:8 | -33 | if a - b > b { +21 | if a - b > b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:36:5 + --> $DIR/overflow_check_conditional.rs:22:8 | -36 | if b < a - b { +22 | if b < a - b {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:39:5 + --> $DIR/overflow_check_conditional.rs:23:8 | -39 | if a - b > a { +23 | if a - b > a {} | ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. - --> $DIR/overflow_check_conditional.rs:42:5 + --> $DIR/overflow_check_conditional.rs:24:8 | -42 | if a < a - b { +24 | if a < a - b {} | ^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/panic_unimplemented.stderr b/tests/ui/panic_unimplemented.stderr index 75032c1170ec..e357050b739b 100644 --- a/tests/ui/panic_unimplemented.stderr +++ b/tests/ui/panic_unimplemented.stderr @@ -1,33 +1,33 @@ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:18:16 + --> $DIR/panic_unimplemented.rs:14:16 | -18 | panic!("{}"); +14 | panic!("{}"); | ^^^^ | = note: `-D clippy::panic-params` implied by `-D warnings` error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:20:16 + --> $DIR/panic_unimplemented.rs:16:16 | -20 | panic!("{:?}"); +16 | panic!("{:?}"); | ^^^^^^ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:22:23 + --> $DIR/panic_unimplemented.rs:18:23 | -22 | assert!(true, "here be missing values: {}"); +18 | assert!(true, "here be missing values: {}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you probably are missing some parameter in your format string - --> $DIR/panic_unimplemented.rs:25:12 + --> $DIR/panic_unimplemented.rs:21:12 | -25 | panic!("{{{this}}}"); +21 | panic!("{{{this}}}"); | ^^^^^^^^^^^^ error: `unimplemented` should not be present in production code - --> $DIR/panic_unimplemented.rs:68:5 + --> $DIR/panic_unimplemented.rs:64:5 | -68 | unimplemented!(); +64 | unimplemented!(); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unimplemented` implied by `-D warnings` diff --git a/tests/ui/partialeq_ne_impl.stderr b/tests/ui/partialeq_ne_impl.stderr index 0ed2d0789cbf..d429fba5db05 100644 --- a/tests/ui/partialeq_ne_impl.stderr +++ b/tests/ui/partialeq_ne_impl.stderr @@ -1,8 +1,10 @@ error: re-implementing `PartialEq::ne` is unnecessary - --> $DIR/partialeq_ne_impl.rs:20:5 + --> $DIR/partialeq_ne_impl.rs:18:5 | -20 | fn ne(&self, _: &Foo) -> bool { false } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +18 | / fn ne(&self, _: &Foo) -> bool { +19 | | false +20 | | } + | |_____^ | = note: `-D clippy::partialeq-ne-impl` implied by `-D warnings` diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index d236da24022b..b97709d2ae95 100644 --- a/tests/ui/patterns.stderr +++ b/tests/ui/patterns.stderr @@ -1,7 +1,7 @@ error: the `y @ _` pattern can be written as just `y` - --> $DIR/patterns.rs:20:9 + --> $DIR/patterns.rs:17:9 | -20 | y @ _ => (), +17 | y @ _ => (), | ^^^^^ | = note: `-D clippy::redundant-pattern` implied by `-D warnings` diff --git a/tests/ui/precedence.stderr b/tests/ui/precedence.stderr index 3d5553ed0c36..8601f828ef39 100644 --- a/tests/ui/precedence.stderr +++ b/tests/ui/precedence.stderr @@ -1,57 +1,57 @@ error: operator precedence can trip the unwary - --> $DIR/precedence.rs:28:5 + --> $DIR/precedence.rs:24:5 | -28 | 1 << 2 + 3; +24 | 1 << 2 + 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `1 << (2 + 3)` | = note: `-D clippy::precedence` implied by `-D warnings` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:29:5 + --> $DIR/precedence.rs:25:5 | -29 | 1 + 2 << 3; +25 | 1 + 2 << 3; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 2) << 3` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:30:5 + --> $DIR/precedence.rs:26:5 | -30 | 4 >> 1 + 1; +26 | 4 >> 1 + 1; | ^^^^^^^^^^ help: consider parenthesizing your expression: `4 >> (1 + 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:31:5 + --> $DIR/precedence.rs:27:5 | -31 | 1 + 3 >> 2; +27 | 1 + 3 >> 2; | ^^^^^^^^^^ help: consider parenthesizing your expression: `(1 + 3) >> 2` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:32:5 + --> $DIR/precedence.rs:28:5 | -32 | 1 ^ 1 - 1; +28 | 1 ^ 1 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `1 ^ (1 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:33:5 + --> $DIR/precedence.rs:29:5 | -33 | 3 | 2 - 1; +29 | 3 | 2 - 1; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 | (2 - 1)` error: operator precedence can trip the unwary - --> $DIR/precedence.rs:34:5 + --> $DIR/precedence.rs:30:5 | -34 | 3 & 5 - 2; +30 | 3 & 5 - 2; | ^^^^^^^^^ help: consider parenthesizing your expression: `3 & (5 - 2)` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:35:5 + --> $DIR/precedence.rs:31:5 | -35 | -1i32.abs(); +31 | -1i32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1i32.abs())` error: unary minus has lower precedence than method call - --> $DIR/precedence.rs:36:5 + --> $DIR/precedence.rs:32:5 | -36 | -1f32.abs(); +32 | -1f32.abs(); | ^^^^^^^^^^^ help: consider adding parentheses to clarify your intent: `-(1f32.abs())` error: aborting due to 9 previous errors diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index 605e527c208a..199f76568f09 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -1,59 +1,59 @@ error: use of `Debug`-based formatting - --> $DIR/print.rs:23:19 + --> $DIR/print.rs:20:19 | -23 | write!(f, "{:?}", 43.1415) +20 | write!(f, "{:?}", 43.1415) | ^^^^^^ | = note: `-D clippy::use-debug` implied by `-D warnings` error: use of `Debug`-based formatting - --> $DIR/print.rs:30:19 + --> $DIR/print.rs:27:19 | -30 | write!(f, "{:?}", 42.718) +27 | write!(f, "{:?}", 42.718) | ^^^^^^ error: use of `println!` - --> $DIR/print.rs:35:5 + --> $DIR/print.rs:32:5 | -35 | println!("Hello"); +32 | println!("Hello"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-stdout` implied by `-D warnings` error: use of `print!` - --> $DIR/print.rs:36:5 + --> $DIR/print.rs:33:5 | -36 | print!("Hello"); +33 | print!("Hello"); | ^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:38:5 + --> $DIR/print.rs:35:5 | -38 | print!("Hello {}", "World"); +35 | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:40:5 + --> $DIR/print.rs:37:5 | -40 | print!("Hello {:?}", "World"); +37 | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:40:12 + --> $DIR/print.rs:37:12 | -40 | print!("Hello {:?}", "World"); +37 | print!("Hello {:?}", "World"); | ^^^^^^^^^^^^ error: use of `print!` - --> $DIR/print.rs:42:5 + --> $DIR/print.rs:39:5 | -42 | print!("Hello {:#?}", "#orld"); +39 | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `Debug`-based formatting - --> $DIR/print.rs:42:12 + --> $DIR/print.rs:39:12 | -42 | print!("Hello {:#?}", "#orld"); +39 | print!("Hello {:#?}", "#orld"); | ^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/print_literal.stderr b/tests/ui/print_literal.stderr index 9fe7fe34e6eb..cba5cc19eacd 100644 --- a/tests/ui/print_literal.stderr +++ b/tests/ui/print_literal.stderr @@ -1,88 +1,88 @@ error: literal with an empty format string - --> $DIR/print_literal.rs:34:71 + --> $DIR/print_literal.rs:31:71 | -34 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); +31 | println!("{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D clippy::print-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/print_literal.rs:35:24 + --> $DIR/print_literal.rs:32:24 | -35 | print!("Hello {}", "world"); +32 | print!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:36:36 + --> $DIR/print_literal.rs:33:36 | -36 | println!("Hello {} {}", world, "world"); +33 | println!("Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:37:26 + --> $DIR/print_literal.rs:34:26 | -37 | println!("Hello {}", "world"); +34 | println!("Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:38:30 + --> $DIR/print_literal.rs:35:30 | -38 | println!("10 / 4 is {}", 2.5); +35 | println!("10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:39:28 + --> $DIR/print_literal.rs:36:28 | -39 | println!("2 + 1 = {}", 3); +36 | println!("2 + 1 = {}", 3); | ^ error: literal with an empty format string - --> $DIR/print_literal.rs:44:25 + --> $DIR/print_literal.rs:41:25 | -44 | println!("{0} {1}", "hello", "world"); +41 | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:44:34 + --> $DIR/print_literal.rs:41:34 | -44 | println!("{0} {1}", "hello", "world"); +41 | println!("{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:45:25 + --> $DIR/print_literal.rs:42:25 | -45 | println!("{1} {0}", "hello", "world"); +42 | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:45:34 + --> $DIR/print_literal.rs:42:34 | -45 | println!("{1} {0}", "hello", "world"); +42 | println!("{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:48:33 + --> $DIR/print_literal.rs:45:35 | -48 | println!("{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +45 | println!("{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:48:46 + --> $DIR/print_literal.rs:45:50 | -48 | println!("{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +45 | println!("{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:49:33 + --> $DIR/print_literal.rs:46:35 | -49 | println!("{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +46 | println!("{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/print_literal.rs:49:46 + --> $DIR/print_literal.rs:46:50 | -49 | println!("{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +46 | println!("{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 4cd7a6685d4a..639a42711109 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -1,27 +1,27 @@ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:17:5 + --> $DIR/print_with_newline.rs:14:5 | -17 | print!("Hello/n"); +14 | print!("Hello/n"); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::print-with-newline` implied by `-D warnings` error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:18:5 + --> $DIR/print_with_newline.rs:15:5 | -18 | print!("Hello {}/n", "world"); +15 | print!("Hello {}/n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:19:5 + --> $DIR/print_with_newline.rs:16:5 | -19 | print!("Hello {} {}/n", "world", "#2"); +16 | print!("Hello {} {}/n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead - --> $DIR/print_with_newline.rs:20:5 + --> $DIR/print_with_newline.rs:17:5 | -20 | print!("{}/n", 1265); +17 | print!("{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr index e06b403cfec4..9a08150d627d 100644 --- a/tests/ui/println_empty_string.stderr +++ b/tests/ui/println_empty_string.stderr @@ -1,15 +1,15 @@ error: using `println!("")` - --> $DIR/println_empty_string.rs:13:5 + --> $DIR/println_empty_string.rs:12:5 | -13 | println!(""); +12 | println!(""); | ^^^^^^^^^^^^ help: replace it with: `println!()` | = note: `-D clippy::println-empty-string` implied by `-D warnings` error: using `println!("")` - --> $DIR/println_empty_string.rs:16:14 + --> $DIR/println_empty_string.rs:15:14 | -16 | _ => println!(""), +15 | _ => println!(""), | ^^^^^^^^^^^^ help: replace it with: `println!()` error: aborting due to 2 previous errors diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index e7aecf7c20bf..c9e8292795f1 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,85 +1,85 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:18:14 + --> $DIR/ptr_arg.rs:15:14 | -18 | fn do_vec(x: &Vec) { +15 | fn do_vec(x: &Vec) { | ^^^^^^^^^ help: change this to: `&[i64]` | = note: `-D clippy::ptr-arg` implied by `-D warnings` error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:26:14 + --> $DIR/ptr_arg.rs:24:14 | -26 | fn do_str(x: &String) { +24 | fn do_str(x: &String) { | ^^^^^^^ help: change this to: `&str` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:39:18 + --> $DIR/ptr_arg.rs:37:18 | -39 | fn do_vec(x: &Vec); +37 | fn do_vec(x: &Vec); | ^^^^^^^^^ help: change this to: `&[i64]` error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. - --> $DIR/ptr_arg.rs:52:14 + --> $DIR/ptr_arg.rs:50:14 | -52 | fn cloned(x: &Vec) -> Vec { +50 | fn cloned(x: &Vec) -> Vec { | ^^^^^^^^ help: change this to | -52 | fn cloned(x: &[u8]) -> Vec { +50 | fn cloned(x: &[u8]) -> Vec { | ^^^^^ help: change `x.clone()` to | -53 | let e = x.to_owned(); +51 | let e = x.to_owned(); | ^^^^^^^^^^^^ help: change `x.clone()` to | -58 | x.to_owned() +56 | x.to_owned() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:61:18 + --> $DIR/ptr_arg.rs:59:18 | -61 | fn str_cloned(x: &String) -> String { +59 | fn str_cloned(x: &String) -> String { | ^^^^^^^ help: change this to | -61 | fn str_cloned(x: &str) -> String { +59 | fn str_cloned(x: &str) -> String { | ^^^^ help: change `x.clone()` to | -62 | let a = x.to_string(); +60 | let a = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -63 | let b = x.to_string(); +61 | let b = x.to_string(); | ^^^^^^^^^^^^^ help: change `x.clone()` to | -68 | x.to_string() +64 | x.to_string() | error: writing `&String` instead of `&str` involves a new object where a slice will do. - --> $DIR/ptr_arg.rs:71:44 + --> $DIR/ptr_arg.rs:67:44 | -71 | fn false_positive_capacity(x: &Vec, y: &String) { +67 | fn false_positive_capacity(x: &Vec, y: &String) { | ^^^^^^^ help: change this to | -71 | fn false_positive_capacity(x: &Vec, y: &str) { +67 | fn false_positive_capacity(x: &Vec, y: &str) { | ^^^^ help: change `y.clone()` to | -73 | let b = y.to_string(); +69 | let b = y.to_string(); | ^^^^^^^^^^^^^ help: change `y.as_str()` to | -74 | let c = y; +70 | let c = y; | ^ error: using a reference to `Cow` is not recommended. - --> $DIR/ptr_arg.rs:83:25 + --> $DIR/ptr_arg.rs:81:25 | -83 | fn test_cow_with_ref(c: &Cow<[i32]>) { +81 | fn test_cow_with_ref(c: &Cow<[i32]>) {} | ^^^^^^^^^^^ help: change this to: `&[i32]` error: aborting due to 7 previous errors diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr index b3df0abbaa8a..c9bd4d79460f 100644 --- a/tests/ui/ptr_offset_with_cast.stderr +++ b/tests/ui/ptr_offset_with_cast.stderr @@ -1,15 +1,15 @@ error: use of `offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:20:9 + --> $DIR/ptr_offset_with_cast.rs:19:9 | -20 | ptr.offset(offset_usize as isize); +19 | ptr.offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)` | = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings` error: use of `wrapping_offset` with a `usize` casted to an `isize` - --> $DIR/ptr_offset_with_cast.rs:24:9 + --> $DIR/ptr_offset_with_cast.rs:23:9 | -24 | ptr.wrapping_offset(offset_usize as isize); +23 | ptr.wrapping_offset(offset_usize as isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)` error: aborting due to 2 previous errors diff --git a/tests/ui/question_mark.stderr b/tests/ui/question_mark.stderr index 7ca76e381921..d3daaaa92705 100644 --- a/tests/ui/question_mark.stderr +++ b/tests/ui/question_mark.stderr @@ -1,21 +1,19 @@ error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:12:2 + --> $DIR/question_mark.rs:11:5 | -12 | if a.is_none() { - | _____^ -13 | | return None -14 | | } +11 | / if a.is_none() { +12 | | return None; +13 | | } | |_____^ help: replace_it_with: `a?;` | = note: `-D clippy::question-mark` implied by `-D warnings` error: this block may be rewritten with the `?` operator - --> $DIR/question_mark.rs:47:3 + --> $DIR/question_mark.rs:46:9 | -47 | if (self.opt).is_none() { - | _________^ -48 | | return None; -49 | | } +46 | / if (self.opt).is_none() { +47 | | return None; +48 | | } | |_________^ help: replace_it_with: `(self.opt)?;` error: aborting due to 2 previous errors diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index 2dc81b4f042b..7b3c5ebc3e19 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -1,42 +1,42 @@ error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:20:13 + --> $DIR/range.rs:17:13 | -20 | let _ = (0..1).step_by(0); +17 | let _ = (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iterator-step-by-zero` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:24:13 + --> $DIR/range.rs:21:13 | -24 | let _ = (1..).step_by(0); +21 | let _ = (1..).step_by(0); | ^^^^^^^^^^^^^^^^ error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:25:13 + --> $DIR/range.rs:22:13 | -25 | let _ = (1..=2).step_by(0); +22 | let _ = (1..=2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:28:13 + --> $DIR/range.rs:25:13 | -28 | let _ = x.step_by(0); +25 | let _ = x.step_by(0); | ^^^^^^^^^^^^ error: It is more idiomatic to use v1.iter().enumerate() - --> $DIR/range.rs:36:14 + --> $DIR/range.rs:33:14 | -36 | let _x = v1.iter().zip(0..v1.len()); +33 | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::range-zip-with-len` implied by `-D warnings` error: Iterator::step_by(0) will panic at runtime - --> $DIR/range.rs:40:13 + --> $DIR/range.rs:37:13 | -40 | let _ = v1.iter().step_by(2/3); - | ^^^^^^^^^^^^^^^^^^^^^^ +37 | let _ = v1.iter().step_by(2 / 3); + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/range_plus_minus_one.stderr b/tests/ui/range_plus_minus_one.stderr index 0cac21734dc8..dc49420ecb92 100644 --- a/tests/ui/range_plus_minus_one.stderr +++ b/tests/ui/range_plus_minus_one.stderr @@ -1,54 +1,54 @@ error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:22:14 + --> $DIR/range_plus_minus_one.rs:19:14 | -22 | for _ in 0..3+1 { } - | ^^^^^^ help: use: `0..=3` +19 | for _ in 0..3 + 1 {} + | ^^^^^^^^ help: use: `0..=3` | = note: `-D clippy::range-plus-one` implied by `-D warnings` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:25:14 + --> $DIR/range_plus_minus_one.rs:22:14 | -25 | for _ in 0..1+5 { } - | ^^^^^^ help: use: `0..=5` +22 | for _ in 0..1 + 5 {} + | ^^^^^^^^ help: use: `0..=5` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:28:14 + --> $DIR/range_plus_minus_one.rs:25:14 | -28 | for _ in 1..1+1 { } - | ^^^^^^ help: use: `1..=1` +25 | for _ in 1..1 + 1 {} + | ^^^^^^^^ help: use: `1..=1` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:34:14 + --> $DIR/range_plus_minus_one.rs:31:14 | -34 | for _ in 0..(1+f()) { } - | ^^^^^^^^^^ help: use: `0..=f()` +31 | for _ in 0..(1 + f()) {} + | ^^^^^^^^^^^^ help: use: `0..=f()` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:38:13 + --> $DIR/range_plus_minus_one.rs:35:13 | -38 | let _ = ..=11-1; - | ^^^^^^^ help: use: `..11` +35 | let _ = ..=11 - 1; + | ^^^^^^^^^ help: use: `..11` | = note: `-D clippy::range-minus-one` implied by `-D warnings` error: an exclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:39:13 + --> $DIR/range_plus_minus_one.rs:36:13 | -39 | let _ = ..=(11-1); - | ^^^^^^^^^ help: use: `..11` +36 | let _ = ..=(11 - 1); + | ^^^^^^^^^^^ help: use: `..11` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:40:13 + --> $DIR/range_plus_minus_one.rs:37:13 | -40 | let _ = (1..11+1); - | ^^^^^^^^^ help: use: `(1..=11)` +37 | let _ = (1..11 + 1); + | ^^^^^^^^^^^ help: use: `(1..=11)` error: an inclusive range would be more readable - --> $DIR/range_plus_minus_one.rs:41:13 + --> $DIR/range_plus_minus_one.rs:38:13 | -41 | let _ = (f()+1)..(f()+1); - | ^^^^^^^^^^^^^^^^ help: use: `((f()+1)..=f())` +38 | let _ = (f() + 1)..(f() + 1); + | ^^^^^^^^^^^^^^^^^^^^ help: use: `((f() + 1)..=f())` error: aborting due to 8 previous errors diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index db452822f891..2130d2a6fe15 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -96,15 +96,15 @@ note: this value is dropped without further use | ^^^^^^^^^^^^^^^ error: redundant clone - --> $DIR/redundant_clone.rs:43:22 + --> $DIR/redundant_clone.rs:44:22 | -43 | (a.clone(), a.clone()) +44 | (a.clone(), a.clone()) | ^^^^^^^^ help: remove this | note: this value is dropped without further use - --> $DIR/redundant_clone.rs:43:21 + --> $DIR/redundant_clone.rs:44:21 | -43 | (a.clone(), a.clone()) +44 | (a.clone(), a.clone()) | ^ error: aborting due to 9 previous errors diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index 1563de3d74fc..0d49f1a4066e 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -1,34 +1,34 @@ error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:25:2 + --> $DIR/redundant_closure_call.rs:21:5 | -25 | i = closure(); +21 | i = closure(); | ^^^^^^^^^^^^^ | = note: `-D clippy::redundant-closure-call` implied by `-D warnings` error: Closure called just once immediately after it was declared - --> $DIR/redundant_closure_call.rs:28:2 + --> $DIR/redundant_closure_call.rs:24:5 | -28 | i = closure(3); +24 | i = closure(3); | ^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:17:10 + --> $DIR/redundant_closure_call.rs:13:13 | -17 | let a = (|| 42)(); +13 | let a = (|| 42)(); | ^^^^^^^^^ help: Try doing something like: : `42` error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:20:14 + --> $DIR/redundant_closure_call.rs:16:17 | -20 | let mut k = (|m| m+1)(i); - | ^^^^^^^^^^^^ +16 | let mut k = (|m| m + 1)(i); + | ^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. - --> $DIR/redundant_closure_call.rs:22:6 + --> $DIR/redundant_closure_call.rs:18:9 | -22 | k = (|a,b| a*b)(1,5); - | ^^^^^^^^^^^^^^^^ +18 | k = (|a, b| a * b)(1, 5); + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/redundant_field_names.stderr b/tests/ui/redundant_field_names.stderr index d81ddf343f15..7febaa61b715 100644 --- a/tests/ui/redundant_field_names.stderr +++ b/tests/ui/redundant_field_names.stderr @@ -1,45 +1,45 @@ error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:46:9 + --> $DIR/redundant_field_names.rs:43:9 | -46 | gender: gender, +43 | gender: gender, | ^^^^^^^^^^^^^^ help: replace it with: `gender` | = note: `-D clippy::redundant-field-names` implied by `-D warnings` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:47:9 + --> $DIR/redundant_field_names.rs:44:9 | -47 | age: age, +44 | age: age, | ^^^^^^^^ help: replace it with: `age` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:68:25 + --> $DIR/redundant_field_names.rs:65:25 | -68 | let _ = RangeFrom { start: start }; +65 | let _ = RangeFrom { start: start }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:69:23 + --> $DIR/redundant_field_names.rs:66:23 | -69 | let _ = RangeTo { end: end }; +66 | let _ = RangeTo { end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:70:21 + --> $DIR/redundant_field_names.rs:67:21 | -70 | let _ = Range { start: start, end: end }; +67 | let _ = Range { start: start, end: end }; | ^^^^^^^^^^^^ help: replace it with: `start` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:70:35 + --> $DIR/redundant_field_names.rs:67:35 | -70 | let _ = Range { start: start, end: end }; +67 | let _ = Range { start: start, end: end }; | ^^^^^^^^ help: replace it with: `end` error: redundant field names in struct initialization - --> $DIR/redundant_field_names.rs:72:32 + --> $DIR/redundant_field_names.rs:69:32 | -72 | let _ = RangeToInclusive { end: end }; +69 | let _ = RangeToInclusive { end: end }; | ^^^^^^^^ help: replace it with: `end` error: aborting due to 7 previous errors diff --git a/tests/ui/redundant_pattern_matching.stderr b/tests/ui/redundant_pattern_matching.stderr index a42ac7ba04d6..2d2aa88d76d6 100644 --- a/tests/ui/redundant_pattern_matching.stderr +++ b/tests/ui/redundant_pattern_matching.stderr @@ -1,87 +1,81 @@ error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:19:12 + --> $DIR/redundant_pattern_matching.rs:14:12 | -19 | if let Ok(_) = Ok::(42) {} +14 | if let Ok(_) = Ok::(42) {} | -------^^^^^------------------------ help: try this: `if Ok::(42).is_ok()` | = note: `-D clippy::redundant-pattern-matching` implied by `-D warnings` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:21:12 + --> $DIR/redundant_pattern_matching.rs:16:12 | -21 | if let Err(_) = Err::(42) { - | _____- ^^^^^^ -22 | | } - | |_____- help: try this: `if Err::(42).is_err()` +16 | if let Err(_) = Err::(42) {} + | -------^^^^^^------------------------- help: try this: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching.rs:24:12 + --> $DIR/redundant_pattern_matching.rs:18:12 | -24 | if let None = None::<()> { - | _____- ^^^^ -25 | | } - | |_____- help: try this: `if None::<()>.is_none()` +18 | if let None = None::<()> {} + | -------^^^^---------------- help: try this: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching.rs:27:12 + --> $DIR/redundant_pattern_matching.rs:20:12 | -27 | if let Some(_) = Some(42) { - | _____- ^^^^^^^ -28 | | } - | |_____- help: try this: `if Some(42).is_some()` +20 | if let Some(_) = Some(42) {} + | -------^^^^^^^-------------- help: try this: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:46:5 + --> $DIR/redundant_pattern_matching.rs:34:5 | -46 | / match Ok::(42) { -47 | | Ok(_) => true, -48 | | Err(_) => false, -49 | | }; +34 | / match Ok::(42) { +35 | | Ok(_) => true, +36 | | Err(_) => false, +37 | | }; | |_____^ help: try this: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:51:5 + --> $DIR/redundant_pattern_matching.rs:39:5 | -51 | / match Ok::(42) { -52 | | Ok(_) => false, -53 | | Err(_) => true, -54 | | }; +39 | / match Ok::(42) { +40 | | Ok(_) => false, +41 | | Err(_) => true, +42 | | }; | |_____^ help: try this: `Ok::(42).is_err()` error: redundant pattern matching, consider using `is_err()` - --> $DIR/redundant_pattern_matching.rs:56:5 + --> $DIR/redundant_pattern_matching.rs:44:5 | -56 | / match Err::(42) { -57 | | Ok(_) => false, -58 | | Err(_) => true, -59 | | }; +44 | / match Err::(42) { +45 | | Ok(_) => false, +46 | | Err(_) => true, +47 | | }; | |_____^ help: try this: `Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` - --> $DIR/redundant_pattern_matching.rs:61:5 + --> $DIR/redundant_pattern_matching.rs:49:5 | -61 | / match Err::(42) { -62 | | Ok(_) => true, -63 | | Err(_) => false, -64 | | }; +49 | / match Err::(42) { +50 | | Ok(_) => true, +51 | | Err(_) => false, +52 | | }; | |_____^ help: try this: `Err::(42).is_ok()` error: redundant pattern matching, consider using `is_some()` - --> $DIR/redundant_pattern_matching.rs:66:5 + --> $DIR/redundant_pattern_matching.rs:54:5 | -66 | / match Some(42) { -67 | | Some(_) => true, -68 | | None => false, -69 | | }; +54 | / match Some(42) { +55 | | Some(_) => true, +56 | | None => false, +57 | | }; | |_____^ help: try this: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> $DIR/redundant_pattern_matching.rs:71:5 + --> $DIR/redundant_pattern_matching.rs:59:5 | -71 | / match None::<()> { -72 | | Some(_) => false, -73 | | None => true, -74 | | }; +59 | / match None::<()> { +60 | | Some(_) => false, +61 | | None => true, +62 | | }; | |_____^ help: try this: `None::<()>.is_none()` error: aborting due to 10 previous errors diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index 4187d55cb470..c09a31e2d8ab 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -1,69 +1,69 @@ error: immediately dereferencing a reference - --> $DIR/reference.rs:29:13 + --> $DIR/reference.rs:25:13 | -29 | let b = *&a; +25 | let b = *&a; | ^^^ help: try this: `a` | = note: `-D clippy::deref-addrof` implied by `-D warnings` error: immediately dereferencing a reference - --> $DIR/reference.rs:31:13 + --> $DIR/reference.rs:27:13 | -31 | let b = *&get_number(); +27 | let b = *&get_number(); | ^^^^^^^^^^^^^^ help: try this: `get_number()` error: immediately dereferencing a reference - --> $DIR/reference.rs:36:13 + --> $DIR/reference.rs:32:13 | -36 | let b = *&bytes[1..2][0]; +32 | let b = *&bytes[1..2][0]; | ^^^^^^^^^^^^^^^^ help: try this: `bytes[1..2][0]` error: immediately dereferencing a reference - --> $DIR/reference.rs:40:13 + --> $DIR/reference.rs:36:13 | -40 | let b = *&(a); +36 | let b = *&(a); | ^^^^^ help: try this: `(a)` error: immediately dereferencing a reference - --> $DIR/reference.rs:42:13 + --> $DIR/reference.rs:38:13 | -42 | let b = *(&a); +38 | let b = *(&a); | ^^^^^ help: try this: `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:44:13 + --> $DIR/reference.rs:40:13 | -44 | let b = *((&a)); - | ^^^^^^^ help: try this: `a` +40 | let b = *(&a); + | ^^^^^ help: try this: `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:46:13 + --> $DIR/reference.rs:42:13 | -46 | let b = *&&a; +42 | let b = *&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:48:14 + --> $DIR/reference.rs:44:14 | -48 | let b = **&aref; +44 | let b = **&aref; | ^^^^^^ help: try this: `aref` error: immediately dereferencing a reference - --> $DIR/reference.rs:52:14 + --> $DIR/reference.rs:48:14 | -52 | let b = **&&a; +48 | let b = **&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:56:17 + --> $DIR/reference.rs:52:17 | -56 | let y = *&mut x; +52 | let y = *&mut x; | ^^^^^^^ help: try this: `x` error: immediately dereferencing a reference - --> $DIR/reference.rs:63:18 + --> $DIR/reference.rs:59:18 | -63 | let y = **&mut &mut x; +59 | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this: `&mut x` error: aborting due to 11 previous errors diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 1da859dea5c5..680cc5146e5f 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -1,168 +1,168 @@ error: trivial regex - --> $DIR/regex.rs:26:45 + --> $DIR/regex.rs:22:45 | -26 | let pipe_in_wrong_position = Regex::new("|"); +22 | let pipe_in_wrong_position = Regex::new("|"); | ^^^ | = note: `-D clippy::trivial-regex` implied by `-D warnings` = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:27:60 + --> $DIR/regex.rs:23:60 | -27 | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); +23 | let pipe_in_wrong_position_builder = RegexBuilder::new("|"); | ^^^ | = help: the regex is unlikely to be useful as it is error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:28:42 + --> $DIR/regex.rs:24:42 | -28 | let wrong_char_ranice = Regex::new("[z-a]"); +24 | let wrong_char_ranice = Regex::new("[z-a]"); | ^^^ | = note: `-D clippy::invalid-regex` implied by `-D warnings` error: regex syntax error: invalid character class range, the start must be <= the end - --> $DIR/regex.rs:29:37 + --> $DIR/regex.rs:25:37 | -29 | let some_unicode = Regex::new("[é-è]"); +25 | let some_unicode = Regex::new("[é-è]"); | ^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:31:33 + --> $DIR/regex.rs:27:33 | -31 | let some_regex = Regex::new(OPENING_PAREN); +27 | let some_regex = Regex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: trivial regex - --> $DIR/regex.rs:33:53 + --> $DIR/regex.rs:29:53 | -33 | let binary_pipe_in_wrong_position = BRegex::new("|"); +29 | let binary_pipe_in_wrong_position = BRegex::new("|"); | ^^^ | = help: the regex is unlikely to be useful as it is error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:34:41 + --> $DIR/regex.rs:30:41 | -34 | let some_binary_regex = BRegex::new(OPENING_PAREN); +30 | let some_binary_regex = BRegex::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:35:56 + --> $DIR/regex.rs:31:56 | -35 | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); +31 | let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:51:9 + --> $DIR/regex.rs:43:37 | -51 | OPENING_PAREN, - | ^^^^^^^^^^^^^ +43 | let set_error = RegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); + | ^^^^^^^^^^^^^ error: regex syntax error on position 0: unclosed group - --> $DIR/regex.rs:55:9 + --> $DIR/regex.rs:44:39 | -55 | OPENING_PAREN, - | ^^^^^^^^^^^^^ +44 | let bset_error = BRegexSet::new(&[OPENING_PAREN, r"[a-z]+/.(com|org|net)"]); + | ^^^^^^^^^^^^^ error: regex syntax error: unrecognized escape sequence - --> $DIR/regex.rs:59:45 + --> $DIR/regex.rs:46:45 | -59 | let raw_string_error = Regex::new(r"[...//...]"); +46 | let raw_string_error = Regex::new(r"[...//...]"); | ^^ error: regex syntax error: unrecognized escape sequence - --> $DIR/regex.rs:60:46 + --> $DIR/regex.rs:47:46 | -60 | let raw_string_error = Regex::new(r#"[...//...]"#); +47 | let raw_string_error = Regex::new(r#"[...//...]"#); | ^^ error: trivial regex - --> $DIR/regex.rs:64:33 + --> $DIR/regex.rs:51:33 | -64 | let trivial_eq = Regex::new("^foobar$"); +51 | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ | = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:66:48 + --> $DIR/regex.rs:53:48 | -66 | let trivial_eq_builder = RegexBuilder::new("^foobar$"); +53 | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ | = help: consider using `==` on `str`s error: trivial regex - --> $DIR/regex.rs:68:42 + --> $DIR/regex.rs:55:42 | -68 | let trivial_starts_with = Regex::new("^foobar"); +55 | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ | = help: consider using `str::starts_with` error: trivial regex - --> $DIR/regex.rs:70:40 + --> $DIR/regex.rs:57:40 | -70 | let trivial_ends_with = Regex::new("foobar$"); +57 | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ | = help: consider using `str::ends_with` error: trivial regex - --> $DIR/regex.rs:72:39 + --> $DIR/regex.rs:59:39 | -72 | let trivial_contains = Regex::new("foobar"); +59 | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ | = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:74:39 + --> $DIR/regex.rs:61:39 | -74 | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); +61 | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ | = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:76:40 + --> $DIR/regex.rs:63:40 | -76 | let trivial_backslash = Regex::new("a/.b"); +63 | let trivial_backslash = Regex::new("a/.b"); | ^^^^^^^ | = help: consider using `str::contains` error: trivial regex - --> $DIR/regex.rs:79:36 + --> $DIR/regex.rs:66:36 | -79 | let trivial_empty = Regex::new(""); +66 | let trivial_empty = Regex::new(""); | ^^ | = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:81:36 + --> $DIR/regex.rs:68:36 | -81 | let trivial_empty = Regex::new("^"); +68 | let trivial_empty = Regex::new("^"); | ^^^ | = help: the regex is unlikely to be useful as it is error: trivial regex - --> $DIR/regex.rs:83:36 + --> $DIR/regex.rs:70:36 | -83 | let trivial_empty = Regex::new("^$"); +70 | let trivial_empty = Regex::new("^$"); | ^^^^ | = help: consider using `str::is_empty` error: trivial regex - --> $DIR/regex.rs:85:44 + --> $DIR/regex.rs:72:44 | -85 | let binary_trivial_empty = BRegex::new("^$"); +72 | let binary_trivial_empty = BRegex::new("^$"); | ^^^^ | = help: consider using `str::is_empty` diff --git a/tests/ui/replace_consts.stderr b/tests/ui/replace_consts.stderr index 5b8451e046c2..401e3a527a6b 100644 --- a/tests/ui/replace_consts.stderr +++ b/tests/ui/replace_consts.stderr @@ -1,217 +1,217 @@ error: using `ATOMIC_BOOL_INIT` - --> $DIR/replace_consts.rs:23:17 + --> $DIR/replace_consts.rs:22:17 | -23 | { let foo = ATOMIC_BOOL_INIT; }; +22 | { let foo = ATOMIC_BOOL_INIT; }; | ^^^^^^^^^^^^^^^^ help: try this: `AtomicBool::new(false)` | note: lint level defined here - --> $DIR/replace_consts.rs:13:9 + --> $DIR/replace_consts.rs:12:9 | -13 | #![deny(clippy::replace_consts)] +12 | #![deny(clippy::replace_consts)] | ^^^^^^^^^^^^^^^^^^^^^^ error: using `ATOMIC_ISIZE_INIT` - --> $DIR/replace_consts.rs:24:17 + --> $DIR/replace_consts.rs:23:17 | -24 | { let foo = ATOMIC_ISIZE_INIT; }; +23 | { let foo = ATOMIC_ISIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicIsize::new(0)` error: using `ATOMIC_I8_INIT` - --> $DIR/replace_consts.rs:25:17 + --> $DIR/replace_consts.rs:24:17 | -25 | { let foo = ATOMIC_I8_INIT; }; +24 | { let foo = ATOMIC_I8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicI8::new(0)` error: using `ATOMIC_I16_INIT` - --> $DIR/replace_consts.rs:26:17 + --> $DIR/replace_consts.rs:25:17 | -26 | { let foo = ATOMIC_I16_INIT; }; +25 | { let foo = ATOMIC_I16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI16::new(0)` error: using `ATOMIC_I32_INIT` - --> $DIR/replace_consts.rs:27:17 + --> $DIR/replace_consts.rs:26:17 | -27 | { let foo = ATOMIC_I32_INIT; }; +26 | { let foo = ATOMIC_I32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI32::new(0)` error: using `ATOMIC_I64_INIT` - --> $DIR/replace_consts.rs:28:17 + --> $DIR/replace_consts.rs:27:17 | -28 | { let foo = ATOMIC_I64_INIT; }; +27 | { let foo = ATOMIC_I64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicI64::new(0)` error: using `ATOMIC_USIZE_INIT` - --> $DIR/replace_consts.rs:29:17 + --> $DIR/replace_consts.rs:28:17 | -29 | { let foo = ATOMIC_USIZE_INIT; }; +28 | { let foo = ATOMIC_USIZE_INIT; }; | ^^^^^^^^^^^^^^^^^ help: try this: `AtomicUsize::new(0)` error: using `ATOMIC_U8_INIT` - --> $DIR/replace_consts.rs:30:17 + --> $DIR/replace_consts.rs:29:17 | -30 | { let foo = ATOMIC_U8_INIT; }; +29 | { let foo = ATOMIC_U8_INIT; }; | ^^^^^^^^^^^^^^ help: try this: `AtomicU8::new(0)` error: using `ATOMIC_U16_INIT` - --> $DIR/replace_consts.rs:31:17 + --> $DIR/replace_consts.rs:30:17 | -31 | { let foo = ATOMIC_U16_INIT; }; +30 | { let foo = ATOMIC_U16_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU16::new(0)` error: using `ATOMIC_U32_INIT` - --> $DIR/replace_consts.rs:32:17 + --> $DIR/replace_consts.rs:31:17 | -32 | { let foo = ATOMIC_U32_INIT; }; +31 | { let foo = ATOMIC_U32_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU32::new(0)` error: using `ATOMIC_U64_INIT` - --> $DIR/replace_consts.rs:33:17 + --> $DIR/replace_consts.rs:32:17 | -33 | { let foo = ATOMIC_U64_INIT; }; +32 | { let foo = ATOMIC_U64_INIT; }; | ^^^^^^^^^^^^^^^ help: try this: `AtomicU64::new(0)` error: using `MIN` - --> $DIR/replace_consts.rs:35:17 + --> $DIR/replace_consts.rs:34:17 | -35 | { let foo = std::isize::MIN; }; +34 | { let foo = std::isize::MIN; }; | ^^^^^^^^^^^^^^^ help: try this: `isize::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:36:17 + --> $DIR/replace_consts.rs:35:17 | -36 | { let foo = std::i8::MIN; }; +35 | { let foo = std::i8::MIN; }; | ^^^^^^^^^^^^ help: try this: `i8::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:37:17 + --> $DIR/replace_consts.rs:36:17 | -37 | { let foo = std::i16::MIN; }; +36 | { let foo = std::i16::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i16::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:38:17 + --> $DIR/replace_consts.rs:37:17 | -38 | { let foo = std::i32::MIN; }; +37 | { let foo = std::i32::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i32::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:39:17 + --> $DIR/replace_consts.rs:38:17 | -39 | { let foo = std::i64::MIN; }; +38 | { let foo = std::i64::MIN; }; | ^^^^^^^^^^^^^ help: try this: `i64::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:40:17 + --> $DIR/replace_consts.rs:39:17 | -40 | { let foo = std::i128::MIN; }; +39 | { let foo = std::i128::MIN; }; | ^^^^^^^^^^^^^^ help: try this: `i128::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:41:17 + --> $DIR/replace_consts.rs:40:17 | -41 | { let foo = std::usize::MIN; }; +40 | { let foo = std::usize::MIN; }; | ^^^^^^^^^^^^^^^ help: try this: `usize::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:42:17 + --> $DIR/replace_consts.rs:41:17 | -42 | { let foo = std::u8::MIN; }; +41 | { let foo = std::u8::MIN; }; | ^^^^^^^^^^^^ help: try this: `u8::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:43:17 + --> $DIR/replace_consts.rs:42:17 | -43 | { let foo = std::u16::MIN; }; +42 | { let foo = std::u16::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u16::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:44:17 + --> $DIR/replace_consts.rs:43:17 | -44 | { let foo = std::u32::MIN; }; +43 | { let foo = std::u32::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u32::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:45:17 + --> $DIR/replace_consts.rs:44:17 | -45 | { let foo = std::u64::MIN; }; +44 | { let foo = std::u64::MIN; }; | ^^^^^^^^^^^^^ help: try this: `u64::min_value()` error: using `MIN` - --> $DIR/replace_consts.rs:46:17 + --> $DIR/replace_consts.rs:45:17 | -46 | { let foo = std::u128::MIN; }; +45 | { let foo = std::u128::MIN; }; | ^^^^^^^^^^^^^^ help: try this: `u128::min_value()` error: using `MAX` - --> $DIR/replace_consts.rs:48:17 + --> $DIR/replace_consts.rs:47:17 | -48 | { let foo = std::isize::MAX; }; +47 | { let foo = std::isize::MAX; }; | ^^^^^^^^^^^^^^^ help: try this: `isize::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:49:17 + --> $DIR/replace_consts.rs:48:17 | -49 | { let foo = std::i8::MAX; }; +48 | { let foo = std::i8::MAX; }; | ^^^^^^^^^^^^ help: try this: `i8::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:50:17 + --> $DIR/replace_consts.rs:49:17 | -50 | { let foo = std::i16::MAX; }; +49 | { let foo = std::i16::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i16::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:51:17 + --> $DIR/replace_consts.rs:50:17 | -51 | { let foo = std::i32::MAX; }; +50 | { let foo = std::i32::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i32::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:52:17 + --> $DIR/replace_consts.rs:51:17 | -52 | { let foo = std::i64::MAX; }; +51 | { let foo = std::i64::MAX; }; | ^^^^^^^^^^^^^ help: try this: `i64::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:53:17 + --> $DIR/replace_consts.rs:52:17 | -53 | { let foo = std::i128::MAX; }; +52 | { let foo = std::i128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `i128::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:54:17 + --> $DIR/replace_consts.rs:53:17 | -54 | { let foo = std::usize::MAX; }; +53 | { let foo = std::usize::MAX; }; | ^^^^^^^^^^^^^^^ help: try this: `usize::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:55:17 + --> $DIR/replace_consts.rs:54:17 | -55 | { let foo = std::u8::MAX; }; +54 | { let foo = std::u8::MAX; }; | ^^^^^^^^^^^^ help: try this: `u8::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:56:17 + --> $DIR/replace_consts.rs:55:17 | -56 | { let foo = std::u16::MAX; }; +55 | { let foo = std::u16::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u16::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:57:17 + --> $DIR/replace_consts.rs:56:17 | -57 | { let foo = std::u32::MAX; }; +56 | { let foo = std::u32::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u32::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:58:17 + --> $DIR/replace_consts.rs:57:17 | -58 | { let foo = std::u64::MAX; }; +57 | { let foo = std::u64::MAX; }; | ^^^^^^^^^^^^^ help: try this: `u64::max_value()` error: using `MAX` - --> $DIR/replace_consts.rs:59:17 + --> $DIR/replace_consts.rs:58:17 | -59 | { let foo = std::u128::MAX; }; +58 | { let foo = std::u128::MAX; }; | ^^^^^^^^^^^^^^ help: try this: `u128::max_value()` error: aborting due to 35 previous errors diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index 04f105c78e28..1ef107a5000f 100644 --- a/tests/ui/result_map_unit_fn.stderr +++ b/tests/ui/result_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:45:5 + --> $DIR/result_map_unit_fn.rs:42:5 | -45 | x.field.map(do_nothing); +42 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` @@ -9,36 +9,41 @@ error: called `map(f)` on an Result value where `f` is a unit function = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:47:5 + --> $DIR/result_map_unit_fn.rs:44:5 | -47 | x.field.map(do_nothing); +44 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:49:5 + --> $DIR/result_map_unit_fn.rs:46:5 | -49 | x.field.map(diverge); +46 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:55:5 + --> $DIR/result_map_unit_fn.rs:54:5 | -55 | x.field.map(|value| x.do_result_nothing(value + captured)); +54 | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:57:5 + --> $DIR/result_map_unit_fn.rs:56:5 | -57 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` +56 | x.field.map(|value| { + | _____^ + | |_____| + | || +57 | || x.do_result_plus_one(value + captured); +58 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:60:5 @@ -51,141 +56,196 @@ error: called `map(f)` on an Result value where `f` is a unit closure error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:62:5 | -62 | x.field.map(|value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +62 | x.field.map(|value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:64:5 | -64 | x.field.map(|value| { do_nothing(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` +64 | x.field.map(|value| { + | _____^ + | |_____| + | || +65 | || do_nothing(value + captured); +66 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:66:5 + --> $DIR/result_map_unit_fn.rs:68:5 | -66 | x.field.map(|value| { { do_nothing(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` +68 | x.field.map(|value| { + | _____^ + | |_____| + | || +69 | || do_nothing(value + captured); +70 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:69:5 + --> $DIR/result_map_unit_fn.rs:72:5 | -69 | x.field.map(|value| diverge(value + captured)); +72 | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:71:5 + --> $DIR/result_map_unit_fn.rs:74:5 | -71 | x.field.map(|value| { diverge(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +74 | x.field.map(|value| diverge(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:73:5 + --> $DIR/result_map_unit_fn.rs:76:5 | -73 | x.field.map(|value| { diverge(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:75:5 - | -75 | x.field.map(|value| { { diverge(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` +76 | x.field.map(|value| { + | _____^ + | |_____| + | || +77 | || diverge(value + captured); +78 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:80:5 | -80 | x.field.map(|value| { let y = plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:82:5 - | -82 | x.field.map(|value| { plus_one(value + captured); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:84:5 - | -84 | x.field.map(|value| { { plus_one(value + captured); } }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` +80 | x.field.map(|value| { + | _____^ + | |_____| + | || +81 | || diverge(value + captured); +82 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:87:5 + --> $DIR/result_map_unit_fn.rs:86:5 | -87 | x.field.map(|ref value| { do_nothing(value + captured) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` +86 | x.field.map(|value| { + | _____^ + | |_____| + | || +87 | || let y = plus_one(value + captured); +88 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:90:5 | -90 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { ... }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:92:5 - | -92 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { ... }` +90 | x.field.map(|value| { + | _____^ + | |_____| + | || +91 | || plus_one(value + captured); +92 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:96:5 + --> $DIR/result_map_unit_fn.rs:94:5 | -96 | x.field.map(|value| { +94 | x.field.map(|value| { | _____^ | |_____| | || -97 | || do_nothing(value); -98 | || do_nothing(value) -99 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { ... }` +95 | || plus_one(value + captured); +96 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` | |_______| | +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:98:5 + | +98 | x.field.map(|ref value| do_nothing(value + captured)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` + error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:100:5 | -100 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Ok(value) = x.field { ... }` +100 | x.field.map(|value| { + | _____^ + | |_____| + | || +101 | || do_nothing(value); +102 | || do_nothing(value) +103 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:105:5 + | +105 | x.field.map(|value| { + | _____^ + | |_____| + | || +106 | || if value > 0 { +107 | || do_nothing(value); +108 | || do_nothing(value) +109 | || } +110 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:114:5 + | +114 | x.field.map(|value| { + | _____^ + | |_____| + | || +115 | || do_nothing(value); +116 | || do_nothing(value) +117 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:118:5 + | +118 | x.field.map(|value| { + | _____^ + | |_____| + | || +119 | || do_nothing(value); +120 | || do_nothing(value); +121 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:104:5 + --> $DIR/result_map_unit_fn.rs:126:5 | -104 | "12".parse::().map(diverge); +126 | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_) = "12".parse::() { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:110:5 + --> $DIR/result_map_unit_fn.rs:132:5 | -110 | y.map(do_nothing); +132 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_y) = y { do_nothing(...) }` diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index e223430e6808..23f10f69435a 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -1,8 +1,9 @@ error: you should not implement `visit_string` without also implementing `visit_str` - --> $DIR/serde.rs:49:5 + --> $DIR/serde.rs:48:5 | -49 | / fn visit_string(self, _v: String) -> Result -50 | | where E: serde::de::Error, +48 | / fn visit_string(self, _v: String) -> Result +49 | | where +50 | | E: serde::de::Error, 51 | | { 52 | | unimplemented!() 53 | | } diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index adca299d3825..196f17ac6539 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -1,137 +1,137 @@ error: `x` is shadowed by itself in `&mut x` - --> $DIR/shadow.rs:23:5 + --> $DIR/shadow.rs:29:5 | -23 | let x = &mut x; +29 | let x = &mut x; | ^^^^^^^^^^^^^^^ | = note: `-D clippy::shadow-same` implied by `-D warnings` note: previous binding is here - --> $DIR/shadow.rs:22:13 + --> $DIR/shadow.rs:28:13 | -22 | let mut x = 1; +28 | let mut x = 1; | ^ error: `x` is shadowed by itself in `{ x }` - --> $DIR/shadow.rs:24:5 + --> $DIR/shadow.rs:30:5 | -24 | let x = { x }; +30 | let x = { x }; | ^^^^^^^^^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:23:9 + --> $DIR/shadow.rs:29:9 | -23 | let x = &mut x; +29 | let x = &mut x; | ^ error: `x` is shadowed by itself in `(&*x)` - --> $DIR/shadow.rs:25:5 + --> $DIR/shadow.rs:31:5 | -25 | let x = (&*x); +31 | let x = (&*x); | ^^^^^^^^^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:24:9 + --> $DIR/shadow.rs:30:9 | -24 | let x = { x }; +30 | let x = { x }; | ^ error: `x` is shadowed by `{ *x + 1 }` which reuses the original value - --> $DIR/shadow.rs:26:9 + --> $DIR/shadow.rs:32:9 | -26 | let x = { *x + 1 }; +32 | let x = { *x + 1 }; | ^ | = note: `-D clippy::shadow-reuse` implied by `-D warnings` note: initialization happens here - --> $DIR/shadow.rs:26:13 + --> $DIR/shadow.rs:32:13 | -26 | let x = { *x + 1 }; +32 | let x = { *x + 1 }; | ^^^^^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:25:9 + --> $DIR/shadow.rs:31:9 | -25 | let x = (&*x); +31 | let x = (&*x); | ^ error: `x` is shadowed by `id(x)` which reuses the original value - --> $DIR/shadow.rs:27:9 + --> $DIR/shadow.rs:33:9 | -27 | let x = id(x); +33 | let x = id(x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:27:13 + --> $DIR/shadow.rs:33:13 | -27 | let x = id(x); +33 | let x = id(x); | ^^^^^ note: previous binding is here - --> $DIR/shadow.rs:26:9 + --> $DIR/shadow.rs:32:9 | -26 | let x = { *x + 1 }; +32 | let x = { *x + 1 }; | ^ error: `x` is shadowed by `(1, x)` which reuses the original value - --> $DIR/shadow.rs:28:9 + --> $DIR/shadow.rs:34:9 | -28 | let x = (1, x); +34 | let x = (1, x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:28:13 + --> $DIR/shadow.rs:34:13 | -28 | let x = (1, x); +34 | let x = (1, x); | ^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:27:9 + --> $DIR/shadow.rs:33:9 | -27 | let x = id(x); +33 | let x = id(x); | ^ error: `x` is shadowed by `first(x)` which reuses the original value - --> $DIR/shadow.rs:29:9 + --> $DIR/shadow.rs:35:9 | -29 | let x = first(x); +35 | let x = first(x); | ^ | note: initialization happens here - --> $DIR/shadow.rs:29:13 + --> $DIR/shadow.rs:35:13 | -29 | let x = first(x); +35 | let x = first(x); | ^^^^^^^^ note: previous binding is here - --> $DIR/shadow.rs:28:9 + --> $DIR/shadow.rs:34:9 | -28 | let x = (1, x); +34 | let x = (1, x); | ^ error: `x` is shadowed by `y` - --> $DIR/shadow.rs:31:9 + --> $DIR/shadow.rs:37:9 | -31 | let x = y; +37 | let x = y; | ^ | = note: `-D clippy::shadow-unrelated` implied by `-D warnings` note: initialization happens here - --> $DIR/shadow.rs:31:13 + --> $DIR/shadow.rs:37:13 | -31 | let x = y; +37 | let x = y; | ^ note: previous binding is here - --> $DIR/shadow.rs:29:9 + --> $DIR/shadow.rs:35:9 | -29 | let x = first(x); +35 | let x = first(x); | ^ error: `x` shadows a previous declaration - --> $DIR/shadow.rs:33:5 + --> $DIR/shadow.rs:39:5 | -33 | let x; +39 | let x; | ^^^^^^ | note: previous binding is here - --> $DIR/shadow.rs:31:9 + --> $DIR/shadow.rs:37:9 | -31 | let x = y; +37 | let x = y; | ^ error: aborting due to 9 previous errors diff --git a/tests/ui/short_circuit_statement.stderr b/tests/ui/short_circuit_statement.stderr index 331bdac31282..7b5c843d0720 100644 --- a/tests/ui/short_circuit_statement.stderr +++ b/tests/ui/short_circuit_statement.stderr @@ -1,21 +1,21 @@ error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:17:5 + --> $DIR/short_circuit_statement.rs:13:5 | -17 | f() && g(); +13 | f() && g(); | ^^^^^^^^^^^ help: replace it with: `if f() { g(); }` | = note: `-D clippy::short-circuit-statement` implied by `-D warnings` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:18:5 + --> $DIR/short_circuit_statement.rs:14:5 | -18 | f() || g(); +14 | f() || g(); | ^^^^^^^^^^^ help: replace it with: `if !f() { g(); }` error: boolean short circuit operator in statement may be clearer using an explicit test - --> $DIR/short_circuit_statement.rs:19:5 + --> $DIR/short_circuit_statement.rs:15:5 | -19 | 1 == 2 || g(); +15 | 1 == 2 || g(); | ^^^^^^^^^^^^^^ help: replace it with: `if !(1 == 2) { g(); }` error: aborting due to 3 previous errors diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr index ff657df1bf8a..273bf7796401 100644 --- a/tests/ui/single_char_pattern.stderr +++ b/tests/ui/single_char_pattern.stderr @@ -1,123 +1,123 @@ error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:17:13 + --> $DIR/single_char_pattern.rs:14:13 | -17 | x.split("x"); +14 | x.split("x"); | ^^^ help: try using a char instead: `'x'` | = note: `-D clippy::single-char-pattern` implied by `-D warnings` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:34:16 + --> $DIR/single_char_pattern.rs:31:16 | -34 | x.contains("x"); +31 | x.contains("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:35:19 + --> $DIR/single_char_pattern.rs:32:19 | -35 | x.starts_with("x"); +32 | x.starts_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:36:17 + --> $DIR/single_char_pattern.rs:33:17 | -36 | x.ends_with("x"); +33 | x.ends_with("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:37:12 + --> $DIR/single_char_pattern.rs:34:12 | -37 | x.find("x"); +34 | x.find("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:38:13 + --> $DIR/single_char_pattern.rs:35:13 | -38 | x.rfind("x"); +35 | x.rfind("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:39:14 + --> $DIR/single_char_pattern.rs:36:14 | -39 | x.rsplit("x"); +36 | x.rsplit("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:40:24 + --> $DIR/single_char_pattern.rs:37:24 | -40 | x.split_terminator("x"); +37 | x.split_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:41:25 + --> $DIR/single_char_pattern.rs:38:25 | -41 | x.rsplit_terminator("x"); +38 | x.rsplit_terminator("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:42:17 + --> $DIR/single_char_pattern.rs:39:17 | -42 | x.splitn(0, "x"); +39 | x.splitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:43:18 + --> $DIR/single_char_pattern.rs:40:18 | -43 | x.rsplitn(0, "x"); +40 | x.rsplitn(0, "x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:44:15 + --> $DIR/single_char_pattern.rs:41:15 | -44 | x.matches("x"); +41 | x.matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:45:16 + --> $DIR/single_char_pattern.rs:42:16 | -45 | x.rmatches("x"); +42 | x.rmatches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:46:21 + --> $DIR/single_char_pattern.rs:43:21 | -46 | x.match_indices("x"); +43 | x.match_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:47:22 + --> $DIR/single_char_pattern.rs:44:22 | -47 | x.rmatch_indices("x"); +44 | x.rmatch_indices("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:48:25 + --> $DIR/single_char_pattern.rs:45:25 | -48 | x.trim_left_matches("x"); +45 | x.trim_left_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:49:26 + --> $DIR/single_char_pattern.rs:46:26 | -49 | x.trim_right_matches("x"); +46 | x.trim_right_matches("x"); | ^^^ help: try using a char instead: `'x'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:51:13 + --> $DIR/single_char_pattern.rs:48:13 | -51 | x.split("/n"); +48 | x.split("/n"); | ^^^^ help: try using a char instead: `'/n'` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:56:31 + --> $DIR/single_char_pattern.rs:53:31 | -56 | x.replace(";", ",").split(","); // issue #2978 +53 | x.replace(";", ",").split(","); // issue #2978 | ^^^ help: try using a char instead: `','` error: single-character string constant used as pattern - --> $DIR/single_char_pattern.rs:57:19 + --> $DIR/single_char_pattern.rs:54:19 | -57 | x.starts_with("/x03"); // issue #2996 +54 | x.starts_with("/x03"); // issue #2996 | ^^^^^^ help: try using a char instead: `'/x03'` error: aborting due to 20 previous errors diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index df614ad201d1..45fcbce00475 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -1,60 +1,68 @@ error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:21:5 + --> $DIR/single_match.rs:17:5 | -21 | / match x { -22 | | Some(y) => { println!("{:?}", y); } -23 | | _ => () -24 | | }; - | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y); }` +17 | / match x { +18 | | Some(y) => { +19 | | println!("{:?}", y); +20 | | }, +21 | | _ => (), +22 | | }; + | |_____^ | = note: `-D clippy::single-match` implied by `-D warnings` +help: try this + | +17 | if let Some(y) = x { +18 | println!("{:?}", y); +19 | }; + | error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:27:5 - | -27 | / match x { -28 | | // Note the missing block braces. -29 | | // We suggest `if let Some(y) = x { .. }` because the macro -30 | | // is expanded before we can do anything. -31 | | Some(y) => println!("{:?}", y), -32 | | _ => () -33 | | } + --> $DIR/single_match.rs:25:5 + | +25 | / match x { +26 | | // Note the missing block braces. +27 | | // We suggest `if let Some(y) = x { .. }` because the macro +28 | | // is expanded before we can do anything. +29 | | Some(y) => println!("{:?}", y), +30 | | _ => (), +31 | | } | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y) }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:36:5 + --> $DIR/single_match.rs:34:5 | -36 | / match z { -37 | | (2...3, 7...9) => dummy(), -38 | | _ => {} -39 | | }; +34 | / match z { +35 | | (2...3, 7...9) => dummy(), +36 | | _ => {}, +37 | | }; | |_____^ help: try this: `if let (2...3, 7...9) = z { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:62:5 + --> $DIR/single_match.rs:63:5 | -62 | / match x { -63 | | Some(y) => dummy(), -64 | | None => () -65 | | }; +63 | / match x { +64 | | Some(y) => dummy(), +65 | | None => (), +66 | | }; | |_____^ help: try this: `if let Some(y) = x { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:67:5 + --> $DIR/single_match.rs:68:5 | -67 | / match y { -68 | | Ok(y) => dummy(), -69 | | Err(..) => () -70 | | }; +68 | / match y { +69 | | Ok(y) => dummy(), +70 | | Err(..) => (), +71 | | }; | |_____^ help: try this: `if let Ok(y) = y { dummy() }` error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let` - --> $DIR/single_match.rs:74:5 + --> $DIR/single_match.rs:75:5 | -74 | / match c { -75 | | Cow::Borrowed(..) => dummy(), -76 | | Cow::Owned(..) => (), -77 | | }; +75 | / match c { +76 | | Cow::Borrowed(..) => dummy(), +77 | | Cow::Owned(..) => (), +78 | | }; | |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }` error: aborting due to 6 previous errors diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index 0b488b2fcf4f..6ae9dd1a818d 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -3,11 +3,21 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 21 | / match ExprNode::Butterflies { 22 | | ExprNode::ExprAddrOf => Some(&NODE), -23 | | _ => { let x = 5; None }, -24 | | } - | |_____^ help: try this: `if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None }` +23 | | _ => { +24 | | let x = 5; +25 | | None +26 | | }, +27 | | } + | |_____^ | = note: `-D clippy::single-match-else` implied by `-D warnings` +help: try this + | +21 | if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { +22 | let x = 5; +23 | None +24 | } + | error: aborting due to previous error diff --git a/tests/ui/starts_ends_with.stderr b/tests/ui/starts_ends_with.stderr index 9921819e0934..0b1b7c020d9d 100644 --- a/tests/ui/starts_ends_with.stderr +++ b/tests/ui/starts_ends_with.stderr @@ -1,77 +1,77 @@ error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:19:5 + --> $DIR/starts_ends_with.rs:16:5 | -19 | "".chars().next() == Some(' '); +16 | "".chars().next() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".starts_with(' ')` | = note: `-D clippy::chars-next-cmp` implied by `-D warnings` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:20:5 + --> $DIR/starts_ends_with.rs:17:5 | -20 | Some(' ') != "".chars().next(); +17 | Some(' ') != "".chars().next(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".starts_with(' ')` error: you should use the `starts_with` method - --> $DIR/starts_ends_with.rs:25:8 + --> $DIR/starts_ends_with.rs:22:8 | -25 | if s.chars().next().unwrap() == 'f' { // s.starts_with('f') +22 | if s.chars().next().unwrap() == 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:28:8 + --> $DIR/starts_ends_with.rs:26:8 | -28 | if s.chars().next_back().unwrap() == 'o' { // s.ends_with('o') +26 | if s.chars().next_back().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` | = note: `-D clippy::chars-last-cmp` implied by `-D warnings` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:31:8 + --> $DIR/starts_ends_with.rs:30:8 | -31 | if s.chars().last().unwrap() == 'o' { // s.ends_with('o') +30 | if s.chars().last().unwrap() == 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `s.ends_with('o')` error: you should use the `starts_with` method --> $DIR/starts_ends_with.rs:34:8 | -34 | if s.chars().next().unwrap() != 'f' { // !s.starts_with('f') +34 | if s.chars().next().unwrap() != 'f' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.starts_with('f')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:37:8 + --> $DIR/starts_ends_with.rs:38:8 | -37 | if s.chars().next_back().unwrap() != 'o' { // !s.ends_with('o') +38 | if s.chars().next_back().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:40:8 + --> $DIR/starts_ends_with.rs:42:8 | -40 | if s.chars().last().unwrap() != 'o' { // !s.ends_with('o') +42 | if s.chars().last().unwrap() != 'o' { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!s.ends_with('o')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:47:5 + --> $DIR/starts_ends_with.rs:50:5 | -47 | "".chars().last() == Some(' '); +50 | "".chars().last() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:48:5 + --> $DIR/starts_ends_with.rs:51:5 | -48 | Some(' ') != "".chars().last(); +51 | Some(' ') != "".chars().last(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:49:5 + --> $DIR/starts_ends_with.rs:52:5 | -49 | "".chars().next_back() == Some(' '); +52 | "".chars().next_back() == Some(' '); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `"".ends_with(' ')` error: you should use the `ends_with` method - --> $DIR/starts_ends_with.rs:50:5 + --> $DIR/starts_ends_with.rs:53:5 | -50 | Some(' ') != "".chars().next_back(); +53 | Some(' ') != "".chars().next_back(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: like this: `!"".ends_with(' ')` error: aborting due to 12 previous errors diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr index 2a82972a3cd4..36af80b86654 100644 --- a/tests/ui/string_extend.stderr +++ b/tests/ui/string_extend.stderr @@ -1,21 +1,21 @@ error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:26:5 + --> $DIR/string_extend.rs:25:5 | -26 | s.extend(abc.chars()); +25 | s.extend(abc.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(abc)` | = note: `-D clippy::string-extend-chars` implied by `-D warnings` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:29:5 + --> $DIR/string_extend.rs:28:5 | -29 | s.extend("abc".chars()); +28 | s.extend("abc".chars()); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str("abc")` error: calling `.extend(_.chars())` - --> $DIR/string_extend.rs:32:5 + --> $DIR/string_extend.rs:31:5 | -32 | s.extend(def.chars()); +31 | s.extend(def.chars()); | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)` error: aborting due to 3 previous errors diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index 21115d8e97ec..fe491d29b781 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -1,75 +1,75 @@ error: manual implementation of an assign operation - --> $DIR/strings.rs:20:9 + --> $DIR/strings.rs:17:9 | -20 | x = x + "."; +17 | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` | = note: `-D clippy::assign-op-pattern` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:20:13 + --> $DIR/strings.rs:17:13 | -20 | x = x + "."; +17 | x = x + "."; | ^^^^^^^ | = note: `-D clippy::string-add` implied by `-D warnings` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:24:13 + --> $DIR/strings.rs:21:13 | -24 | let z = y + "..."; +21 | let z = y + "..."; | ^^^^^^^^^ error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:34:9 + --> $DIR/strings.rs:31:9 | -34 | x = x + "."; +31 | x = x + "."; | ^^^^^^^^^^^ | = note: `-D clippy::string-add-assign` implied by `-D warnings` error: manual implementation of an assign operation - --> $DIR/strings.rs:34:9 + --> $DIR/strings.rs:31:9 | -34 | x = x + "."; +31 | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:48:9 + --> $DIR/strings.rs:45:9 | -48 | x = x + "."; +45 | x = x + "."; | ^^^^^^^^^^^ error: manual implementation of an assign operation - --> $DIR/strings.rs:48:9 + --> $DIR/strings.rs:45:9 | -48 | x = x + "."; +45 | x = x + "."; | ^^^^^^^^^^^ help: replace it with: `x += "."` error: you added something to a string. Consider using `String::push_str()` instead - --> $DIR/strings.rs:52:13 + --> $DIR/strings.rs:49:13 | -52 | let z = y + "..."; +49 | let z = y + "..."; | ^^^^^^^^^ error: calling `as_bytes()` on a string literal - --> $DIR/strings.rs:60:14 + --> $DIR/strings.rs:57:14 | -60 | let bs = "hello there".as_bytes(); +57 | let bs = "hello there".as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"` | = note: `-D clippy::string-lit-as-bytes` implied by `-D warnings` error: calling `as_bytes()` on a string literal - --> $DIR/strings.rs:62:14 + --> $DIR/strings.rs:59:14 | -62 | let bs = r###"raw string with three ### in it and some " ""###.as_bytes(); +59 | let bs = r###"raw string with three ### in it and some " ""###.as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `br###"raw string with three ### in it and some " ""###` error: calling `as_bytes()` on `include_str!(..)` - --> $DIR/strings.rs:69:22 + --> $DIR/strings.rs:66:22 | -69 | let includestr = include_str!("entry.rs").as_bytes(); +66 | let includestr = include_str!("entry.rs").as_bytes(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `include_bytes!(..)` instead: `include_bytes!("entry.rs")` error: aborting due to 11 previous errors diff --git a/tests/ui/stutter.stderr b/tests/ui/stutter.stderr index 2ff992fccf62..8c2d1d432813 100644 --- a/tests/ui/stutter.stderr +++ b/tests/ui/stutter.stderr @@ -1,33 +1,33 @@ error: item name starts with its containing module's name - --> $DIR/stutter.rs:18:5 + --> $DIR/stutter.rs:15:5 | -18 | pub fn foo_bar() {} +15 | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::stutter` implied by `-D warnings` error: item name ends with its containing module's name - --> $DIR/stutter.rs:19:5 + --> $DIR/stutter.rs:16:5 | -19 | pub fn bar_foo() {} +16 | pub fn bar_foo() {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:20:5 + --> $DIR/stutter.rs:17:5 | -20 | pub struct FooCake {} +17 | pub struct FooCake {} | ^^^^^^^^^^^^^^^^^^^^^ error: item name ends with its containing module's name - --> $DIR/stutter.rs:21:5 + --> $DIR/stutter.rs:18:5 | -21 | pub enum CakeFoo {} +18 | pub enum CakeFoo {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name - --> $DIR/stutter.rs:22:5 + --> $DIR/stutter.rs:19:5 | -22 | pub struct Foo7Bar; +19 | pub struct Foo7Bar; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/suspicious_arithmetic_impl.stderr b/tests/ui/suspicious_arithmetic_impl.stderr index 64070cce3a88..5e27dd1d44f4 100644 --- a/tests/ui/suspicious_arithmetic_impl.stderr +++ b/tests/ui/suspicious_arithmetic_impl.stderr @@ -1,15 +1,15 @@ error: Suspicious use of binary operator in `Add` impl - --> $DIR/suspicious_arithmetic_impl.rs:24:20 + --> $DIR/suspicious_arithmetic_impl.rs:20:20 | -24 | Foo(self.0 - other.0) +20 | Foo(self.0 - other.0) | ^ | = note: `-D clippy::suspicious-arithmetic-impl` implied by `-D warnings` error: Suspicious use of binary operator in `AddAssign` impl - --> $DIR/suspicious_arithmetic_impl.rs:30:23 + --> $DIR/suspicious_arithmetic_impl.rs:26:23 | -30 | *self = *self - other; +26 | *self = *self - other; | ^ | = note: #[deny(clippy::suspicious_op_assign_impl)] on by default diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index 7a4fbdad791b..12d012442ad1 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,66 +1,66 @@ error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:21:5 + --> $DIR/swap.rs:17:5 | -21 | / let temp = foo[0]; -22 | | foo[0] = foo[1]; -23 | | foo[1] = temp; +17 | / let temp = foo[0]; +18 | | foo[0] = foo[1]; +19 | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` | = note: `-D clippy::manual-swap` implied by `-D warnings` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:30:5 + --> $DIR/swap.rs:26:5 | -30 | / let temp = foo[0]; -31 | | foo[0] = foo[1]; -32 | | foo[1] = temp; +26 | / let temp = foo[0]; +27 | | foo[0] = foo[1]; +28 | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:39:5 + --> $DIR/swap.rs:35:5 | -39 | / let temp = foo[0]; -40 | | foo[0] = foo[1]; -41 | | foo[1] = temp; +35 | / let temp = foo[0]; +36 | | foo[0] = foo[1]; +37 | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:57:7 + --> $DIR/swap.rs:53:6 | -57 | ; let t = a; - | _______^ -58 | | a = b; -59 | | b = t; +53 | ; let t = a; + | ______^ +54 | | a = b; +55 | | b = t; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:66:7 + --> $DIR/swap.rs:62:6 | -66 | ; let t = c.0; - | _______^ -67 | | c.0 = a; -68 | | a = t; +62 | ; let t = c.0; + | ______^ +63 | | c.0 = a; +64 | | a = t; | |_________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:54:5 + --> $DIR/swap.rs:50:5 | -54 | / a = b; -55 | | b = a; +50 | / a = b; +51 | | b = a; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: `-D clippy::almost-swapped` implied by `-D warnings` = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:63:5 + --> $DIR/swap.rs:59:5 | -63 | / c.0 = a; -64 | | a = c.0; +59 | / c.0 = a; +60 | | a = c.0; | |___________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`? diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index edde5510e2a2..2807539604d1 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -1,34 +1,34 @@ error: `ref` directly on a function argument is ignored. Consider using a reference type instead. - --> $DIR/toplevel_ref_arg.rs:17:15 + --> $DIR/toplevel_ref_arg.rs:13:15 | -17 | fn the_answer(ref mut x: u8) { +13 | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ | = note: `-D clippy::toplevel-ref-arg` implied by `-D warnings` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:28:7 + --> $DIR/toplevel_ref_arg.rs:24:9 | -28 | let ref x = 1; - | ----^^^^^----- help: try: `let x = &1;` +24 | let ref x = 1; + | ----^^^^^----- help: try: `let x = &1;` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:30:7 + --> $DIR/toplevel_ref_arg.rs:26:9 | -30 | let ref y: (&_, u8) = (&1, 2); - | ----^^^^^--------------------- help: try: `let y: &(&_, u8) = &(&1, 2);` +26 | let ref y: (&_, u8) = (&1, 2); + | ----^^^^^--------------------- help: try: `let y: &(&_, u8) = &(&1, 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:32:7 + --> $DIR/toplevel_ref_arg.rs:28:9 | -32 | let ref z = 1 + 2; - | ----^^^^^--------- help: try: `let z = &(1 + 2);` +28 | let ref z = 1 + 2; + | ----^^^^^--------- help: try: `let z = &(1 + 2);` error: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead - --> $DIR/toplevel_ref_arg.rs:34:7 + --> $DIR/toplevel_ref_arg.rs:30:9 | -34 | let ref mut z = 1 + 2; - | ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);` +30 | let ref mut z = 1 + 2; + | ----^^^^^^^^^--------- help: try: `let z = &mut (1 + 2);` error: aborting due to 5 previous errors diff --git a/tests/ui/trailing_zeros.stderr b/tests/ui/trailing_zeros.stderr index 4dbb82b34607..0bd3580a7dde 100644 --- a/tests/ui/trailing_zeros.stderr +++ b/tests/ui/trailing_zeros.stderr @@ -1,15 +1,15 @@ error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:17:31 + --> $DIR/trailing_zeros.rs:16:5 | -17 | let _ = #[clippy::author] (x & 0b1111 == 0); // suggest trailing_zeros - | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` +16 | (x & 0b1111 == 0); // suggest trailing_zeros + | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 4` | = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` error: bit mask could be simplified with a call to `trailing_zeros` - --> $DIR/trailing_zeros.rs:18:13 + --> $DIR/trailing_zeros.rs:17:13 | -18 | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros +17 | let _ = x & 0b1_1111 == 0; // suggest trailing_zeros | ^^^^^^^^^^^^^^^^^ help: try: `x.trailing_zeros() >= 5` error: aborting due to 2 previous errors diff --git a/tests/ui/transmute.stderr b/tests/ui/transmute.stderr index bde43da499fc..6e4fe32a4a6f 100644 --- a/tests/ui/transmute.stderr +++ b/tests/ui/transmute.stderr @@ -1,245 +1,245 @@ error: transmute from a type (`&'a T`) to itself - --> $DIR/transmute.rs:32:20 + --> $DIR/transmute.rs:28:20 | -32 | let _: &'a T = core::intrinsics::transmute(t); +28 | let _: &'a T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::useless-transmute` implied by `-D warnings` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:36:23 + --> $DIR/transmute.rs:32:23 | -36 | let _: *const T = core::intrinsics::transmute(t); +32 | let _: *const T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:38:21 + --> $DIR/transmute.rs:34:21 | -38 | let _: *mut T = core::intrinsics::transmute(t); +34 | let _: *mut T = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *mut T` error: transmute from a reference to a pointer - --> $DIR/transmute.rs:40:23 + --> $DIR/transmute.rs:36:23 | -40 | let _: *const U = core::intrinsics::transmute(t); +36 | let _: *const U = core::intrinsics::transmute(t); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `t as *const T as *const U` error: transmute from a pointer type (`*const T`) to a reference type (`&T`) - --> $DIR/transmute.rs:45:17 + --> $DIR/transmute.rs:41:17 | -45 | let _: &T = std::mem::transmute(p); +41 | let _: &T = std::mem::transmute(p); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p` | = note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:48:21 + --> $DIR/transmute.rs:44:21 | -48 | let _: &mut T = std::mem::transmute(m); +44 | let _: &mut T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m` error: transmute from a pointer type (`*mut T`) to a reference type (`&T`) - --> $DIR/transmute.rs:51:17 + --> $DIR/transmute.rs:47:17 | -51 | let _: &T = std::mem::transmute(m); +47 | let _: &T = std::mem::transmute(m); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m` error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:54:21 + --> $DIR/transmute.rs:50:21 | -54 | let _: &mut T = std::mem::transmute(p as *mut T); +50 | let _: &mut T = std::mem::transmute(p as *mut T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)` error: transmute from a pointer type (`*const U`) to a reference type (`&T`) - --> $DIR/transmute.rs:57:17 + --> $DIR/transmute.rs:53:17 | -57 | let _: &T = std::mem::transmute(o); +53 | let _: &T = std::mem::transmute(o); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) - --> $DIR/transmute.rs:60:21 + --> $DIR/transmute.rs:56:21 | -60 | let _: &mut T = std::mem::transmute(om); +56 | let _: &mut T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)` error: transmute from a pointer type (`*mut U`) to a reference type (`&T`) - --> $DIR/transmute.rs:63:17 + --> $DIR/transmute.rs:59:17 | -63 | let _: &T = std::mem::transmute(om); +59 | let _: &T = std::mem::transmute(om); | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, u8>`) - --> $DIR/transmute.rs:74:32 + --> $DIR/transmute.rs:70:32 | -74 | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; +70 | let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&issue1231::Foo<'_, &u8>`) - --> $DIR/transmute.rs:76:33 + --> $DIR/transmute.rs:72:33 | -76 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; +72 | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const Foo<&_>)` error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`) - --> $DIR/transmute.rs:80:14 + --> $DIR/transmute.rs:76:14 | -80 | unsafe { std::mem::transmute::<_, Bar>(raw) }; +76 | unsafe { std::mem::transmute::<_, Bar>(raw) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)` error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:86:27 + --> $DIR/transmute.rs:82:27 | -86 | let _: Vec = core::intrinsics::transmute(my_vec()); +82 | let _: Vec = core::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:88:27 + --> $DIR/transmute.rs:84:27 | -88 | let _: Vec = core::mem::transmute(my_vec()); +84 | let _: Vec = core::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:90:27 + --> $DIR/transmute.rs:86:27 | -90 | let _: Vec = std::intrinsics::transmute(my_vec()); +86 | let _: Vec = std::intrinsics::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:92:27 + --> $DIR/transmute.rs:88:27 | -92 | let _: Vec = std::mem::transmute(my_vec()); +88 | let _: Vec = std::mem::transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`std::vec::Vec`) to itself - --> $DIR/transmute.rs:94:27 + --> $DIR/transmute.rs:90:27 | -94 | let _: Vec = my_transmute(my_vec()); +90 | let _: Vec = my_transmute(my_vec()); | ^^^^^^^^^^^^^^^^^^^^^^ error: transmute from an integer to a pointer - --> $DIR/transmute.rs:102:31 - | -102 | let _: *const usize = std::mem::transmute(5_isize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` + --> $DIR/transmute.rs:98:31 + | +98 | let _: *const usize = std::mem::transmute(5_isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `5_isize as *const usize` error: transmute from an integer to a pointer - --> $DIR/transmute.rs:106:31 + --> $DIR/transmute.rs:102:31 | -106 | let _: *const usize = std::mem::transmute(1+1usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(1+1usize) as *const usize` +102 | 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`) - --> $DIR/transmute.rs:121:24 + --> $DIR/transmute.rs:117:24 | -121 | let _: Usize = core::intrinsics::transmute(int_const_ptr); +117 | let _: Usize = core::intrinsics::transmute(int_const_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::crosspointer-transmute` implied by `-D warnings` error: transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) - --> $DIR/transmute.rs:123:24 + --> $DIR/transmute.rs:119:24 | -123 | let _: Usize = core::intrinsics::transmute(int_mut_ptr); +119 | let _: Usize = core::intrinsics::transmute(int_mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) - --> $DIR/transmute.rs:125:31 + --> $DIR/transmute.rs:121:31 | -125 | let _: *const Usize = core::intrinsics::transmute(my_int()); +121 | let _: *const Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) - --> $DIR/transmute.rs:127:29 + --> $DIR/transmute.rs:123:29 | -127 | let _: *mut Usize = core::intrinsics::transmute(my_int()); +123 | let _: *mut Usize = core::intrinsics::transmute(my_int()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: transmute from a `u32` to a `char` - --> $DIR/transmute.rs:133:28 + --> $DIR/transmute.rs:129:28 | -133 | let _: char = unsafe { std::mem::transmute(0_u32) }; +129 | let _: char = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_u32).unwrap()` | = note: `-D clippy::transmute-int-to-char` implied by `-D warnings` error: transmute from a `i32` to a `char` - --> $DIR/transmute.rs:134:28 + --> $DIR/transmute.rs:130:28 | -134 | let _: char = unsafe { std::mem::transmute(0_i32) }; +130 | let _: char = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::char::from_u32(0_i32 as u32).unwrap()` error: transmute from a `u8` to a `bool` - --> $DIR/transmute.rs:139:28 + --> $DIR/transmute.rs:135:28 | -139 | let _: bool = unsafe { std::mem::transmute(0_u8) }; +135 | let _: bool = unsafe { std::mem::transmute(0_u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `0_u8 != 0` | = note: `-D clippy::transmute-int-to-bool` implied by `-D warnings` error: transmute from a `u32` to a `f32` - --> $DIR/transmute.rs:144:27 + --> $DIR/transmute.rs:140:27 | -144 | let _: f32 = unsafe { std::mem::transmute(0_u32) }; +140 | let _: f32 = unsafe { std::mem::transmute(0_u32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_u32)` | = note: `-D clippy::transmute-int-to-float` implied by `-D warnings` error: transmute from a `i32` to a `f32` - --> $DIR/transmute.rs:145:27 + --> $DIR/transmute.rs:141:27 | -145 | let _: f32 = unsafe { std::mem::transmute(0_i32) }; +141 | let _: f32 = unsafe { std::mem::transmute(0_i32) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `f32::from_bits(0_i32 as u32)` error: transmute from a `&[u8]` to a `&str` - --> $DIR/transmute.rs:149:28 + --> $DIR/transmute.rs:145:28 | -149 | let _: &str = unsafe { std::mem::transmute(b) }; +145 | let _: &str = unsafe { std::mem::transmute(b) }; | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8(b).unwrap()` | = note: `-D clippy::transmute-bytes-to-str` implied by `-D warnings` error: transmute from a `&mut [u8]` to a `&mut str` - --> $DIR/transmute.rs:150:32 + --> $DIR/transmute.rs:146:32 | -150 | let _: &mut str = unsafe { std::mem::transmute(mb) }; +146 | let _: &mut str = unsafe { std::mem::transmute(mb) }; | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::str::from_utf8_mut(mb).unwrap()` error: transmute from a pointer to a pointer - --> $DIR/transmute.rs:182:29 + --> $DIR/transmute.rs:178:29 | -182 | let _: *const f32 = std::mem::transmute(ptr); +178 | let _: *const f32 = std::mem::transmute(ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr as *const f32` | = note: `-D clippy::transmute-ptr-to-ptr` implied by `-D warnings` error: transmute from a pointer to a pointer - --> $DIR/transmute.rs:183:27 + --> $DIR/transmute.rs:179:27 | -183 | let _: *mut f32 = std::mem::transmute(mut_ptr); +179 | let _: *mut f32 = std::mem::transmute(mut_ptr); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `mut_ptr as *mut f32` error: transmute from a reference to a reference - --> $DIR/transmute.rs:185:23 + --> $DIR/transmute.rs:181:23 | -185 | let _: &f32 = std::mem::transmute(&1u32); +181 | let _: &f32 = std::mem::transmute(&1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1u32 as *const u32 as *const f32)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:186:23 + --> $DIR/transmute.rs:182:23 | -186 | let _: &f64 = std::mem::transmute(&1f32); +182 | let _: &f64 = std::mem::transmute(&1f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&1f32 as *const f32 as *const f64)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:189:27 + --> $DIR/transmute.rs:185:27 | -189 | let _: &mut f32 = std::mem::transmute(&mut 1u32); +185 | let _: &mut f32 = std::mem::transmute(&mut 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(&mut 1u32 as *mut u32 as *mut f32)` error: transmute from a reference to a reference - --> $DIR/transmute.rs:190:37 + --> $DIR/transmute.rs:186:37 | -190 | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); +186 | let _: &GenericParam = std::mem::transmute(&GenericParam { t: 1u32 }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam as *const GenericParam)` error: aborting due to 38 previous errors diff --git a/tests/ui/transmute_64bit.stderr b/tests/ui/transmute_64bit.stderr index dcc6d264caf8..320bbeb7d298 100644 --- a/tests/ui/transmute_64bit.stderr +++ b/tests/ui/transmute_64bit.stderr @@ -1,15 +1,15 @@ error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:21:31 + --> $DIR/transmute_64bit.rs:16:31 | -21 | let _: *const usize = std::mem::transmute(6.0f64); +16 | let _: *const usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::wrong-transmute` implied by `-D warnings` error: transmute from a `f64` to a pointer - --> $DIR/transmute_64bit.rs:23:29 + --> $DIR/transmute_64bit.rs:18:29 | -23 | let _: *mut usize = std::mem::transmute(6.0f64); +18 | let _: *mut usize = std::mem::transmute(6.0f64); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/trivially_copy_pass_by_ref.stderr b/tests/ui/trivially_copy_pass_by_ref.stderr index 3fb577d3edbb..41aa52ecd14e 100644 --- a/tests/ui/trivially_copy_pass_by_ref.stderr +++ b/tests/ui/trivially_copy_pass_by_ref.stderr @@ -1,93 +1,93 @@ error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:57:11 + --> $DIR/trivially_copy_pass_by_ref.rs:56:11 | -57 | fn bad(x: &u32, y: &Foo, z: &Baz) { +56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` | = note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:57:20 + --> $DIR/trivially_copy_pass_by_ref.rs:56:20 | -57 | fn bad(x: &u32, y: &Foo, z: &Baz) { +56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:57:29 + --> $DIR/trivially_copy_pass_by_ref.rs:56:29 | -57 | fn bad(x: &u32, y: &Foo, z: &Baz) { +56 | fn bad(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:12 + --> $DIR/trivially_copy_pass_by_ref.rs:63:12 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^^ help: consider passing by value instead: `self` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:22 + --> $DIR/trivially_copy_pass_by_ref.rs:63:22 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:31 + --> $DIR/trivially_copy_pass_by_ref.rs:63:31 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:67:40 + --> $DIR/trivially_copy_pass_by_ref.rs:63:40 | -67 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) { +63 | fn bad(&self, x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:70:16 + --> $DIR/trivially_copy_pass_by_ref.rs:65:16 | -70 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:70:25 + --> $DIR/trivially_copy_pass_by_ref.rs:65:25 | -70 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:70:34 + --> $DIR/trivially_copy_pass_by_ref.rs:65:34 | -70 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +65 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:84:16 + --> $DIR/trivially_copy_pass_by_ref.rs:77:16 | -84 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `u32` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:84:25 + --> $DIR/trivially_copy_pass_by_ref.rs:77:25 | -84 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:84:34 + --> $DIR/trivially_copy_pass_by_ref.rs:77:34 | -84 | fn bad2(x: &u32, y: &Foo, z: &Baz) { +77 | fn bad2(x: &u32, y: &Foo, z: &Baz) {} | ^^^^ help: consider passing by value instead: `Baz` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:89:34 + --> $DIR/trivially_copy_pass_by_ref.rs:81:34 | -89 | fn trait_method(&self, _foo: &Foo); +81 | fn trait_method(&self, _foo: &Foo); | ^^^^ help: consider passing by value instead: `Foo` error: this argument is passed by reference, but would be more efficient if passed by value - --> $DIR/trivially_copy_pass_by_ref.rs:93:37 + --> $DIR/trivially_copy_pass_by_ref.rs:85:37 | -93 | fn trait_method2(&self, _color: &Color); +85 | fn trait_method2(&self, _color: &Color); | ^^^^^^ help: consider passing by value instead: `Color` error: aborting due to 15 previous errors diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index 0940cd53b5c3..e8770490abb1 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -1,8 +1,8 @@ error: casting i32 to i64 may become silently lossy if types change - --> $DIR/types.rs:19:23 + --> $DIR/types.rs:18:22 | -19 | let c_i64 : i64 = c as i64; - | ^^^^^^^^ help: try: `i64::from(c)` +18 | let c_i64: i64 = c as i64; + | ^^^^^^^^ help: try: `i64::from(c)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index 8de848caec35..e27b58663724 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -1,7 +1,7 @@ error: zero-width space detected - --> $DIR/unicode.rs:16:12 + --> $DIR/unicode.rs:12:12 | -16 | print!("Here >​< is a ZWS, and ​another"); +12 | print!("Here >​< is a ZWS, and ​another"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::zero-width-space` implied by `-D warnings` @@ -9,9 +9,9 @@ error: zero-width space detected ""Here >/u{200B}< is a ZWS, and /u{200B}another"" error: non-nfc unicode sequence detected - --> $DIR/unicode.rs:22:12 + --> $DIR/unicode.rs:18:12 | -22 | print!("̀àh?"); +18 | print!("̀àh?"); | ^^^^^ | = note: `-D clippy::unicode-not-nfc` implied by `-D warnings` @@ -19,9 +19,9 @@ error: non-nfc unicode sequence detected ""̀àh?"" error: literal non-ASCII character detected - --> $DIR/unicode.rs:28:12 + --> $DIR/unicode.rs:24:12 | -28 | print!("Üben!"); +24 | print!("Üben!"); | ^^^^^^^ | = note: `-D clippy::non-ascii-literal` implied by `-D warnings` diff --git a/tests/ui/unit_arg.stderr b/tests/ui/unit_arg.stderr index 6e5cf8354bc4..ed8d4cdfd3d6 100644 --- a/tests/ui/unit_arg.stderr +++ b/tests/ui/unit_arg.stderr @@ -1,67 +1,73 @@ error: passing a unit value to a function - --> $DIR/unit_arg.rs:35:9 + --> $DIR/unit_arg.rs:32:9 | -35 | foo({}); +32 | foo({}); | ^^ | = note: `-D clippy::unit-arg` implied by `-D warnings` help: if you intended to pass a unit value, use a unit literal instead | -35 | foo(()); +32 | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:36:9 + --> $DIR/unit_arg.rs:33:9 | -36 | foo({ 1; }); - | ^^^^^^ +33 | foo({ + | _________^ +34 | | 1; +35 | | }); + | |_____^ help: if you intended to pass a unit value, use a unit literal instead | -36 | foo(()); +33 | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:37:9 + --> $DIR/unit_arg.rs:36:9 | -37 | foo(foo(1)); +36 | foo(foo(1)); | ^^^^^^ help: if you intended to pass a unit value, use a unit literal instead | -37 | foo(()); +36 | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:38:9 + --> $DIR/unit_arg.rs:37:9 | -38 | foo({ +37 | foo({ | _________^ -39 | | foo(1); -40 | | foo(2); -41 | | }); +38 | | foo(1); +39 | | foo(2); +40 | | }); | |_____^ help: if you intended to pass a unit value, use a unit literal instead | -38 | foo(()); +37 | foo(()); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:42:10 + --> $DIR/unit_arg.rs:41:10 | -42 | foo3({}, 2, 2); +41 | foo3({}, 2, 2); | ^^ help: if you intended to pass a unit value, use a unit literal instead | -42 | foo3((), 2, 2); +41 | foo3((), 2, 2); | ^^ error: passing a unit value to a function - --> $DIR/unit_arg.rs:44:11 + --> $DIR/unit_arg.rs:43:11 | -44 | b.bar({ 1; }); - | ^^^^^^ +43 | b.bar({ + | ___________^ +44 | | 1; +45 | | }); + | |_____^ help: if you intended to pass a unit value, use a unit literal instead | -44 | b.bar(()); +43 | b.bar(()); | ^^ error: aborting due to 6 previous errors diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index bd9ac25a64fe..7c76945fe3e7 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -1,16 +1,26 @@ error: ==-comparison of unit values detected. This will always be true - --> $DIR/unit_cmp.rs:26:8 + --> $DIR/unit_cmp.rs:21:8 | -26 | if { true; } == { false; } { - | ^^^^^^^^^^^^^^^^^^^^^^^ +21 | if { + | ________^ +22 | | true; +23 | | } == { +24 | | false; +25 | | } {} + | |_____^ | = note: `-D clippy::unit-cmp` implied by `-D warnings` error: >-comparison of unit values detected. This will always be false - --> $DIR/unit_cmp.rs:29:8 + --> $DIR/unit_cmp.rs:27:8 | -29 | if { true; } > { false; } { - | ^^^^^^^^^^^^^^^^^^^^^^ +27 | if { + | ________^ +28 | | true; +29 | | } > { +30 | | false; +31 | | } {} + | |_____^ error: aborting due to 2 previous errors diff --git a/tests/ui/unnecessary_clone.stderr b/tests/ui/unnecessary_clone.stderr index 5dcd5cae4633..8a0bf9d55b53 100644 --- a/tests/ui/unnecessary_clone.stderr +++ b/tests/ui/unnecessary_clone.stderr @@ -1,95 +1,95 @@ error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:29:5 + --> $DIR/unnecessary_clone.rs:26:5 | -29 | 42.clone(); +26 | 42.clone(); | ^^^^^^^^^^ help: try removing the `clone` call: `42` | = note: `-D clippy::clone-on-copy` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:33:5 + --> $DIR/unnecessary_clone.rs:30:5 | -33 | (&42).clone(); +30 | (&42).clone(); | ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:36:5 + --> $DIR/unnecessary_clone.rs:33:5 | -36 | rc.borrow().clone(); +33 | rc.borrow().clone(); | ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:46:5 + --> $DIR/unnecessary_clone.rs:43:5 | -46 | rc.clone(); +43 | rc.clone(); | ^^^^^^^^^^ help: try this: `Rc::::clone(&rc)` | = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:49:5 + --> $DIR/unnecessary_clone.rs:46:5 | -49 | arc.clone(); +46 | arc.clone(); | ^^^^^^^^^^^ help: try this: `Arc::::clone(&arc)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:52:5 + --> $DIR/unnecessary_clone.rs:49:5 | -52 | rcweak.clone(); +49 | rcweak.clone(); | ^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&rcweak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:55:5 + --> $DIR/unnecessary_clone.rs:52:5 | -55 | arc_weak.clone(); +52 | arc_weak.clone(); | ^^^^^^^^^^^^^^^^ help: try this: `Weak::::clone(&arc_weak)` error: using '.clone()' on a ref-counted pointer - --> $DIR/unnecessary_clone.rs:59:29 + --> $DIR/unnecessary_clone.rs:56:29 | -59 | let _: Arc = x.clone(); +56 | let _: Arc = x.clone(); | ^^^^^^^^^ help: try this: `Arc::::clone(&x)` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:63:5 + --> $DIR/unnecessary_clone.rs:60:5 | -63 | t.clone(); +60 | t.clone(); | ^^^^^^^^^ help: try removing the `clone` call: `t` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:65:5 + --> $DIR/unnecessary_clone.rs:62:5 | -65 | Some(t).clone(); +62 | Some(t).clone(); | ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)` error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type - --> $DIR/unnecessary_clone.rs:71:22 + --> $DIR/unnecessary_clone.rs:68:22 | -71 | let z: &Vec<_> = y.clone(); +68 | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ | = note: #[deny(clippy::clone_double_ref)] on by default help: try dereferencing it | -71 | let z: &Vec<_> = &(*y).clone(); +68 | let z: &Vec<_> = &(*y).clone(); | ^^^^^^^^^^^^^ help: or try being explicit about what type to clone | -71 | let z: &Vec<_> = &std::vec::Vec::clone(y); +68 | let z: &Vec<_> = &std::vec::Vec::clone(y); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: called `cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable - --> $DIR/unnecessary_clone.rs:78:27 + --> $DIR/unnecessary_clone.rs:75:26 | -78 | let v2 : Vec = v.iter().cloned().collect(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +75 | let v2: Vec = v.iter().cloned().collect(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::iter-cloned-collect` implied by `-D warnings` error: using `clone` on a `Copy` type - --> $DIR/unnecessary_clone.rs:110:20 + --> $DIR/unnecessary_clone.rs:111:20 | -110 | let _: E = a.clone(); +111 | let _: E = a.clone(); | ^^^^^^^^^ help: try dereferencing it: `*****a` error: aborting due to 13 previous errors diff --git a/tests/ui/unnecessary_filter_map.stderr b/tests/ui/unnecessary_filter_map.stderr index 8fef60681677..53311b3d2758 100644 --- a/tests/ui/unnecessary_filter_map.stderr +++ b/tests/ui/unnecessary_filter_map.stderr @@ -1,31 +1,37 @@ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:12:13 + --> $DIR/unnecessary_filter_map.rs:11:13 | -12 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); +11 | let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unnecessary-filter-map` implied by `-D warnings` error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:13:13 + --> $DIR/unnecessary_filter_map.rs:12:13 | -13 | let _ = (0..4).filter_map(|x| { if x > 1 { return Some(x); }; None }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +12 | let _ = (0..4).filter_map(|x| { + | _____________^ +13 | | if x > 1 { +14 | | return Some(x); +15 | | }; +16 | | None +17 | | }); + | |______^ error: this `.filter_map` can be written more simply using `.filter` - --> $DIR/unnecessary_filter_map.rs:14:13 + --> $DIR/unnecessary_filter_map.rs:18:13 | -14 | let _ = (0..4).filter_map(|x| match x { +18 | let _ = (0..4).filter_map(|x| match x { | _____________^ -15 | | 0 | 1 => None, -16 | | _ => Some(x), -17 | | }); +19 | | 0 | 1 => None, +20 | | _ => Some(x), +21 | | }); | |______^ error: this `.filter_map` can be written more simply using `.map` - --> $DIR/unnecessary_filter_map.rs:19:13 + --> $DIR/unnecessary_filter_map.rs:23:13 | -19 | let _ = (0..4).filter_map(|x| Some(x + 1)); +23 | let _ = (0..4).filter_map(|x| Some(x + 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/unnecessary_fold.stderr b/tests/ui/unnecessary_fold.stderr index b2865479c433..e0bd744265cc 100644 --- a/tests/ui/unnecessary_fold.stderr +++ b/tests/ui/unnecessary_fold.stderr @@ -1,33 +1,33 @@ error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:14:19 + --> $DIR/unnecessary_fold.rs:13:19 | -14 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); +13 | let _ = (0..3).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` | = note: `-D clippy::unnecessary-fold` implied by `-D warnings` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:16:19 + --> $DIR/unnecessary_fold.rs:15:19 | -16 | let _ = (0..3).fold(true, |acc, x| acc && x > 2); +15 | let _ = (0..3).fold(true, |acc, x| acc && x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.all(|x| x > 2)` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:18:19 + --> $DIR/unnecessary_fold.rs:17:19 | -18 | let _ = (0..3).fold(0, |acc, x| acc + x); +17 | let _ = (0..3).fold(0, |acc, x| acc + x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.sum()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:20:19 + --> $DIR/unnecessary_fold.rs:19:19 | -20 | let _ = (0..3).fold(1, |acc, x| acc * x); +19 | let _ = (0..3).fold(1, |acc, x| acc * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.product()` error: this `.fold` can be written more succinctly using another method - --> $DIR/unnecessary_fold.rs:25:34 + --> $DIR/unnecessary_fold.rs:24:34 | -25 | let _ = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); +24 | let _ = (0..3).map(|x| 2 * x).fold(false, |acc, x| acc || x > 2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.any(|x| x > 2)` error: aborting due to 5 previous errors diff --git a/tests/ui/unnecessary_operation.stderr b/tests/ui/unnecessary_operation.stderr index 8e5417eb13e3..8b576bef6486 100644 --- a/tests/ui/unnecessary_operation.stderr +++ b/tests/ui/unnecessary_operation.stderr @@ -1,124 +1,128 @@ error: statement can be reduced - --> $DIR/unnecessary_operation.rs:48:5 + --> $DIR/unnecessary_operation.rs:54:5 | -48 | Tuple(get_number()); +54 | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | = note: `-D clippy::unnecessary-operation` implied by `-D warnings` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:49:5 + --> $DIR/unnecessary_operation.rs:55:5 | -49 | Struct { field: get_number() }; +55 | Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:50:5 + --> $DIR/unnecessary_operation.rs:56:5 | -50 | Struct { ..get_struct() }; +56 | Struct { ..get_struct() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:51:5 + --> $DIR/unnecessary_operation.rs:57:5 | -51 | Enum::Tuple(get_number()); +57 | Enum::Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:52:5 + --> $DIR/unnecessary_operation.rs:58:5 | -52 | Enum::Struct { field: get_number() }; +58 | Enum::Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:53:5 + --> $DIR/unnecessary_operation.rs:59:5 | -53 | 5 + get_number(); +59 | 5 + get_number(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:54:5 + --> $DIR/unnecessary_operation.rs:60:5 | -54 | *&get_number(); +60 | *&get_number(); | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:55:5 + --> $DIR/unnecessary_operation.rs:61:5 | -55 | &get_number(); +61 | &get_number(); | ^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:56:5 + --> $DIR/unnecessary_operation.rs:62:5 | -56 | (5, 6, get_number()); +62 | (5, 6, get_number()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:57:5 + --> $DIR/unnecessary_operation.rs:63:5 | -57 | box get_number(); +63 | box get_number(); | ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:58:5 + --> $DIR/unnecessary_operation.rs:64:5 | -58 | get_number()..; +64 | get_number()..; | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:59:5 + --> $DIR/unnecessary_operation.rs:65:5 | -59 | ..get_number(); +65 | ..get_number(); | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:60:5 + --> $DIR/unnecessary_operation.rs:66:5 | -60 | 5..get_number(); +66 | 5..get_number(); | ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:61:5 + --> $DIR/unnecessary_operation.rs:67:5 | -61 | [42, get_number()]; +67 | [42, get_number()]; | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:62:5 + --> $DIR/unnecessary_operation.rs:68:5 | -62 | [42, 55][get_number() as usize]; +68 | [42, 55][get_number() as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42, 55];get_number() as usize;` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:63:5 + --> $DIR/unnecessary_operation.rs:69:5 | -63 | (42, get_number()).1; +69 | (42, get_number()).1; | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:64:5 + --> $DIR/unnecessary_operation.rs:70:5 | -64 | [get_number(); 55]; +70 | [get_number(); 55]; | ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:65:5 + --> $DIR/unnecessary_operation.rs:71:5 | -65 | [42; 55][get_number() as usize]; +71 | [42; 55][get_number() as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42; 55];get_number() as usize;` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:66:5 + --> $DIR/unnecessary_operation.rs:72:5 | -66 | {get_number()}; - | ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` +72 | / { +73 | | get_number() +74 | | }; + | |______^ help: replace it with: `get_number();` error: statement can be reduced - --> $DIR/unnecessary_operation.rs:67:5 + --> $DIR/unnecessary_operation.rs:75:5 | -67 | FooString { s: String::from("blah"), }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `String::from("blah");` +75 | / FooString { +76 | | s: String::from("blah"), +77 | | }; + | |______^ help: replace it with: `String::from("blah");` error: aborting due to 20 previous errors diff --git a/tests/ui/unnecessary_ref.stderr b/tests/ui/unnecessary_ref.stderr index a3d8f5e337c6..f048df6e39bf 100644 --- a/tests/ui/unnecessary_ref.stderr +++ b/tests/ui/unnecessary_ref.stderr @@ -1,13 +1,13 @@ error: Creating a reference that is immediately dereferenced. - --> $DIR/unnecessary_ref.rs:23:17 + --> $DIR/unnecessary_ref.rs:20:17 | -23 | let inner = (&outer).inner; +20 | let inner = (&outer).inner; | ^^^^^^^^ help: try this: `outer.inner` | note: lint level defined here - --> $DIR/unnecessary_ref.rs:20:8 + --> $DIR/unnecessary_ref.rs:17:8 | -20 | #[deny(clippy::ref_in_deref)] +17 | #[deny(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index 85982d75494c..a1e43e493b7c 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -1,16 +1,16 @@ error: You matched a field with a wildcard pattern. Consider using `..` instead - --> $DIR/unneeded_field_pattern.rs:27:15 + --> $DIR/unneeded_field_pattern.rs:23:15 | -27 | Foo { a: _, b: 0, .. } => {} +23 | Foo { a: _, b: 0, .. } => {}, | ^^^^ | = note: `-D clippy::unneeded-field-pattern` implied by `-D warnings` = help: Try with `Foo { b: 0, .. }` error: All the struct fields are matched to a wildcard pattern, consider using `..`. - --> $DIR/unneeded_field_pattern.rs:29:9 + --> $DIR/unneeded_field_pattern.rs:25:9 | -29 | Foo { a: _, b: _, c: _ } => {} +25 | Foo { a: _, b: _, c: _ } => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Try with `Foo { .. }` instead diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr index b5ab6937d957..83372a2a5a7c 100644 --- a/tests/ui/unreadable_literal.stderr +++ b/tests/ui/unreadable_literal.stderr @@ -1,33 +1,33 @@ error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:16 + --> $DIR/unreadable_literal.rs:24:16 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` | = note: `-D clippy::unreadable-literal` implied by `-D warnings` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:30 + --> $DIR/unreadable_literal.rs:24:30 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:51 + --> $DIR/unreadable_literal.rs:24:51 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^ help: consider: `123_456_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:17:63 + --> $DIR/unreadable_literal.rs:24:63 | -17 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); +24 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `1.234_567_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:19:19 + --> $DIR/unreadable_literal.rs:26:19 | -19 | let bad_sci = 1.123456e1; +26 | let bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` error: aborting due to 5 previous errors diff --git a/tests/ui/unsafe_removed_from_name.stderr b/tests/ui/unsafe_removed_from_name.stderr index f4bb93735d75..3b2852089788 100644 --- a/tests/ui/unsafe_removed_from_name.stderr +++ b/tests/ui/unsafe_removed_from_name.stderr @@ -1,21 +1,21 @@ error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCell` - --> $DIR/unsafe_removed_from_name.rs:17:1 + --> $DIR/unsafe_removed_from_name.rs:14:1 | -17 | use std::cell::{UnsafeCell as TotallySafeCell}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +14 | use std::cell::UnsafeCell as TotallySafeCell; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unsafe-removed-from-name` implied by `-D warnings` error: removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCellAgain` - --> $DIR/unsafe_removed_from_name.rs:19:1 + --> $DIR/unsafe_removed_from_name.rs:16:1 | -19 | use std::cell::UnsafeCell as TotallySafeCellAgain; +16 | use std::cell::UnsafeCell as TotallySafeCellAgain; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: removed "unsafe" from the name of `Unsafe` in use as `LieAboutModSafety` - --> $DIR/unsafe_removed_from_name.rs:33:1 + --> $DIR/unsafe_removed_from_name.rs:30:1 | -33 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; +30 | use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/unused_io_amount.stderr b/tests/ui/unused_io_amount.stderr index 329dfacd43be..f7b9b3615020 100644 --- a/tests/ui/unused_io_amount.stderr +++ b/tests/ui/unused_io_amount.stderr @@ -1,42 +1,42 @@ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:21:5 + --> $DIR/unused_io_amount.rs:17:5 | -21 | try!(s.write(b"test")); +17 | try!(s.write(b"test")); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::unused-io-amount` implied by `-D warnings` = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:23:5 + --> $DIR/unused_io_amount.rs:19:5 | -23 | try!(s.read(&mut buf)); +19 | try!(s.read(&mut buf)); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:28:5 + --> $DIR/unused_io_amount.rs:24:5 | -28 | s.write(b"test")?; +24 | s.write(b"test")?; | ^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:30:5 + --> $DIR/unused_io_amount.rs:26:5 | -30 | s.read(&mut buf)?; +26 | s.read(&mut buf)?; | ^^^^^^^^^^^^^^^^^ error: handle written amount returned or use `Write::write_all` instead - --> $DIR/unused_io_amount.rs:35:5 + --> $DIR/unused_io_amount.rs:31:5 | -35 | s.write(b"test").unwrap(); +31 | s.write(b"test").unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: handle read amount returned or use `Read::read_exact` instead - --> $DIR/unused_io_amount.rs:37:5 + --> $DIR/unused_io_amount.rs:33:5 | -37 | s.read(&mut buf).unwrap(); +33 | s.read(&mut buf).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/unused_labels.stderr b/tests/ui/unused_labels.stderr index 5a31ada902e3..cbade54c1573 100644 --- a/tests/ui/unused_labels.stderr +++ b/tests/ui/unused_labels.stderr @@ -1,25 +1,29 @@ error: unused label `'label` - --> $DIR/unused_labels.rs:18:5 + --> $DIR/unused_labels.rs:14:5 | -18 | / 'label: for i in 1..2 { -19 | | if i > 4 { continue } -20 | | } +14 | / 'label: for i in 1..2 { +15 | | if i > 4 { +16 | | continue; +17 | | } +18 | | } | |_____^ | = note: `-D clippy::unused-label` implied by `-D warnings` error: unused label `'a` - --> $DIR/unused_labels.rs:31:5 + --> $DIR/unused_labels.rs:28:5 | -31 | 'a: loop { break } - | ^^^^^^^^^^^^^^^^^^ +28 | / 'a: loop { +29 | | break; +30 | | } + | |_____^ error: unused label `'same_label_in_two_fns` - --> $DIR/unused_labels.rs:42:5 + --> $DIR/unused_labels.rs:41:5 | -42 | / 'same_label_in_two_fns: loop { -43 | | let _ = 1; -44 | | } +41 | / 'same_label_in_two_fns: loop { +42 | | let _ = 1; +43 | | } | |_____^ error: aborting due to 3 previous errors diff --git a/tests/ui/unused_lt.stderr b/tests/ui/unused_lt.stderr index f5b788c16a72..e590cfc91aa9 100644 --- a/tests/ui/unused_lt.stderr +++ b/tests/ui/unused_lt.stderr @@ -1,21 +1,21 @@ error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:26:14 + --> $DIR/unused_lt.rs:23:14 | -26 | fn unused_lt<'a>(x: u8) { +23 | fn unused_lt<'a>(x: u8) {} | ^^ | = note: `-D clippy::extra-unused-lifetimes` implied by `-D warnings` error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:30:25 + --> $DIR/unused_lt.rs:25:25 | -30 | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { +25 | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { | ^^ error: this lifetime isn't used in the function definition - --> $DIR/unused_lt.rs:60:10 + --> $DIR/unused_lt.rs:50:10 | -60 | fn x<'a>(&self) {} +50 | fn x<'a>(&self) {} | ^^ error: aborting due to 3 previous errors diff --git a/tests/ui/unwrap_or.stderr b/tests/ui/unwrap_or.stderr index ffdeeb5307f5..2432b7970f63 100644 --- a/tests/ui/unwrap_or.stderr +++ b/tests/ui/unwrap_or.stderr @@ -1,16 +1,16 @@ error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:15:47 + --> $DIR/unwrap_or.rs:13:47 | -15 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); +13 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` | = note: `-D clippy::or-fun-call` implied by `-D warnings` error: use of `unwrap_or` followed by a function call - --> $DIR/unwrap_or.rs:20:10 + --> $DIR/unwrap_or.rs:17:47 | -20 | .unwrap_or("Fail".to_string()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` +17 | let s = Some(String::from("test string")).unwrap_or("Fail".to_string()).len(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "Fail".to_string())` error: aborting due to 2 previous errors diff --git a/tests/ui/use_self.stderr b/tests/ui/use_self.stderr index b71c7a9a4c51..0904db2e9421 100644 --- a/tests/ui/use_self.stderr +++ b/tests/ui/use_self.stderr @@ -1,39 +1,39 @@ error: unnecessary structure name repetition - --> $DIR/use_self.rs:23:21 + --> $DIR/use_self.rs:20:21 | -23 | fn new() -> Foo { +20 | fn new() -> Foo { | ^^^ help: use the applicable keyword: `Self` | = note: `-D clippy::use-self` implied by `-D warnings` error: unnecessary structure name repetition - --> $DIR/use_self.rs:24:13 + --> $DIR/use_self.rs:21:13 | -24 | Foo {} +21 | Foo {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:26:22 + --> $DIR/use_self.rs:23:22 | -26 | fn test() -> Foo { +23 | fn test() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:27:13 + --> $DIR/use_self.rs:24:13 | -27 | Foo::new() +24 | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:32:25 + --> $DIR/use_self.rs:29:25 | -32 | fn default() -> Foo { +29 | fn default() -> Foo { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:33:13 + --> $DIR/use_self.rs:30:13 | -33 | Foo::new() +30 | Foo::new() | ^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition @@ -75,56 +75,56 @@ error: unnecessary structure name repetition error: unnecessary structure name repetition --> $DIR/use_self.rs:108:28 | -108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { +108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition --> $DIR/use_self.rs:108:46 | -108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) { +108 | fn nested(_p1: Box, _p2: (&u8, &Bad)) {} | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:111:20 + --> $DIR/use_self.rs:110:20 | -111 | fn vals(_: Bad) -> Bad { +110 | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:111:28 + --> $DIR/use_self.rs:110:28 | -111 | fn vals(_: Bad) -> Bad { +110 | fn vals(_: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:112:13 + --> $DIR/use_self.rs:111:13 | -112 | Bad::default() +111 | Bad::default() | ^^^^^^^^^^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:117:23 + --> $DIR/use_self.rs:116:23 | -117 | type Output = Bad; +116 | type Output = Bad; | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:119:27 + --> $DIR/use_self.rs:118:27 | -119 | fn mul(self, rhs: Bad) -> Bad { +118 | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:119:35 + --> $DIR/use_self.rs:118:35 | -119 | fn mul(self, rhs: Bad) -> Bad { +118 | fn mul(self, rhs: Bad) -> Bad { | ^^^ help: use the applicable keyword: `Self` error: unnecessary structure name repetition - --> $DIR/use_self.rs:213:54 + --> $DIR/use_self.rs:210:56 | -213 | fn bad(foos: &[Self]) -> impl Iterator { - | ^^^ help: use the applicable keyword: `Self` +210 | fn bad(foos: &[Self]) -> impl Iterator { + | ^^^ help: use the applicable keyword: `Self` error: aborting due to 21 previous errors diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 8092119470e6..c844a8cd75b3 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,33 +1,33 @@ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:27:5 + --> $DIR/used_underscore_binding.rs:23:5 | -27 | _foo + 1 +23 | _foo + 1 | ^^^^ | = note: `-D clippy::used-underscore-binding` implied by `-D warnings` error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:32:20 + --> $DIR/used_underscore_binding.rs:28:20 | -32 | println!("{}", _foo); +28 | println!("{}", _foo); | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:33:16 + --> $DIR/used_underscore_binding.rs:29:16 | -33 | assert_eq!(_foo, _foo); +29 | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:33:22 + --> $DIR/used_underscore_binding.rs:29:22 | -33 | assert_eq!(_foo, _foo); +29 | assert_eq!(_foo, _foo); | ^^^^ error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used. - --> $DIR/used_underscore_binding.rs:46:5 + --> $DIR/used_underscore_binding.rs:42:5 | -46 | s._underscore_field += 1; +42 | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/useless_asref.stderr b/tests/ui/useless_asref.stderr index 8e45facf5875..397ec7108d4d 100644 --- a/tests/ui/useless_asref.stderr +++ b/tests/ui/useless_asref.stderr @@ -1,73 +1,73 @@ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:43:18 + --> $DIR/useless_asref.rs:50:18 | -43 | foo_rstr(rstr.as_ref()); +50 | foo_rstr(rstr.as_ref()); | ^^^^^^^^^^^^^ help: try this: `rstr` | note: lint level defined here - --> $DIR/useless_asref.rs:13:9 + --> $DIR/useless_asref.rs:10:9 | -13 | #![deny(clippy::useless_asref)] +10 | #![deny(clippy::useless_asref)] | ^^^^^^^^^^^^^^^^^^^^^ error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:45:20 + --> $DIR/useless_asref.rs:52:20 | -45 | foo_rslice(rslice.as_ref()); +52 | foo_rslice(rslice.as_ref()); | ^^^^^^^^^^^^^^^ help: try this: `rslice` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:49:21 + --> $DIR/useless_asref.rs:56:21 | -49 | foo_mrslice(mrslice.as_mut()); +56 | foo_mrslice(mrslice.as_mut()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:51:20 + --> $DIR/useless_asref.rs:58:20 | -51 | foo_rslice(mrslice.as_ref()); +58 | foo_rslice(mrslice.as_ref()); | ^^^^^^^^^^^^^^^^ help: try this: `mrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:58:20 + --> $DIR/useless_asref.rs:65:20 | -58 | foo_rslice(rrrrrslice.as_ref()); +65 | foo_rslice(rrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^ help: try this: `rrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:60:18 + --> $DIR/useless_asref.rs:67:18 | -60 | foo_rstr(rrrrrstr.as_ref()); +67 | foo_rstr(rrrrrstr.as_ref()); | ^^^^^^^^^^^^^^^^^ help: try this: `rrrrrstr` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:65:21 + --> $DIR/useless_asref.rs:72:21 | -65 | foo_mrslice(mrrrrrslice.as_mut()); +72 | foo_mrslice(mrrrrrslice.as_mut()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:67:20 + --> $DIR/useless_asref.rs:74:20 | -67 | foo_rslice(mrrrrrslice.as_ref()); +74 | foo_rslice(mrrrrrslice.as_ref()); | ^^^^^^^^^^^^^^^^^^^^ help: try this: `mrrrrrslice` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:70:16 + --> $DIR/useless_asref.rs:77:16 | -70 | foo_rrrrmr((&&&&MoreRef).as_ref()); +77 | foo_rrrrmr((&&&&MoreRef).as_ref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(&&&&MoreRef)` error: this call to `as_mut` does nothing - --> $DIR/useless_asref.rs:116:13 + --> $DIR/useless_asref.rs:127:13 | -116 | foo_mrt(mrt.as_mut()); +127 | foo_mrt(mrt.as_mut()); | ^^^^^^^^^^^^ help: try this: `mrt` error: this call to `as_ref` does nothing - --> $DIR/useless_asref.rs:118:12 + --> $DIR/useless_asref.rs:129:12 | -118 | foo_rt(mrt.as_ref()); +129 | foo_rt(mrt.as_ref()); | ^^^^^^^^^^^^ help: try this: `mrt` error: aborting due to 11 previous errors diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 6b82b105b05d..54d18fbf2e13 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -1,16 +1,22 @@ error: useless lint attribute - --> $DIR/useless_attribute.rs:15:1 + --> $DIR/useless_attribute.rs:12:1 | -15 | #[allow(dead_code)] +12 | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]` | = note: `-D clippy::useless-attribute` implied by `-D warnings` error: useless lint attribute - --> $DIR/useless_attribute.rs:16:1 + --> $DIR/useless_attribute.rs:13:1 | -16 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] +13 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` -error: aborting due to 2 previous errors +error: useless lint attribute + --> $DIR/useless_attribute.rs:14:1 + | +14 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` + +error: aborting due to 3 previous errors diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index e4649eab5ecd..94e9bcdd2a72 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -1,39 +1,39 @@ error: useless use of `vec!` - --> $DIR/vec.rs:34:14 + --> $DIR/vec.rs:30:14 | -34 | on_slice(&vec![]); +30 | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` | = note: `-D clippy::useless-vec` implied by `-D warnings` error: useless use of `vec!` - --> $DIR/vec.rs:37:14 + --> $DIR/vec.rs:33:14 | -37 | on_slice(&vec![1, 2]); +33 | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:40:14 + --> $DIR/vec.rs:36:14 | -40 | on_slice(&vec ![1, 2]); - | ^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` +36 | on_slice(&vec![1, 2]); + | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:43:14 + --> $DIR/vec.rs:39:14 | -43 | on_slice(&vec!(1, 2)); +39 | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` - --> $DIR/vec.rs:46:14 + --> $DIR/vec.rs:42:14 | -46 | on_slice(&vec![1; 2]); +42 | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` error: useless use of `vec!` - --> $DIR/vec.rs:59:14 + --> $DIR/vec.rs:55:14 | -59 | for a in vec![1, 2, 3] { +55 | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` error: aborting due to 6 previous errors diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index b166e8bacb53..57cfa14a3927 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -1,114 +1,114 @@ error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:19:5 + --> $DIR/while_loop.rs:15:5 | -19 | / loop { -20 | | if let Some(_x) = y { -21 | | let _v = 1; -22 | | } else { -23 | | break -24 | | } -25 | | } +15 | / loop { +16 | | if let Some(_x) = y { +17 | | let _v = 1; +18 | | } else { +19 | | break; +20 | | } +21 | | } | |_____^ help: try: `while let Some(_x) = y { .. }` | = note: `-D clippy::while-let-loop` implied by `-D warnings` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:32:5 + --> $DIR/while_loop.rs:29:5 | -32 | / loop { -33 | | match y { -34 | | Some(_x) => true, -35 | | None => break -36 | | }; -37 | | } +29 | / loop { +30 | | match y { +31 | | Some(_x) => true, +32 | | None => break, +33 | | }; +34 | | } | |_____^ help: try: `while let Some(_x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:38:5 + --> $DIR/while_loop.rs:35:5 | -38 | / loop { -39 | | let x = match y { -40 | | Some(x) => x, -41 | | None => break +35 | / loop { +36 | | let x = match y { +37 | | Some(x) => x, +38 | | None => break, ... | -44 | | let _str = "foo"; -45 | | } +41 | | let _str = "foo"; +42 | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:46:5 + --> $DIR/while_loop.rs:43:5 | -46 | / loop { -47 | | let x = match y { -48 | | Some(x) => x, -49 | | None => break, +43 | / loop { +44 | | let x = match y { +45 | | Some(x) => x, +46 | | None => break, ... | -52 | | { let _b = "foobar"; } -53 | | } +53 | | } +54 | | } | |_____^ help: try: `while let Some(x) = y { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:68:5 + --> $DIR/while_loop.rs:71:5 | -68 | / loop { -69 | | let (e, l) = match "".split_whitespace().next() { -70 | | Some(word) => (word.is_empty(), word.len()), -71 | | None => break +71 | / loop { +72 | | let (e, l) = match "".split_whitespace().next() { +73 | | Some(word) => (word.is_empty(), word.len()), +74 | | None => break, ... | -74 | | let _ = (e, l); -75 | | } +77 | | let _ = (e, l); +78 | | } | |_____^ help: try: `while let Some(word) = "".split_whitespace().next() { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:78:33 + --> $DIR/while_loop.rs:81:33 | -78 | while let Option::Some(x) = iter.next() { +81 | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` | = note: `-D clippy::while-let-on-iterator` implied by `-D warnings` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:83:25 + --> $DIR/while_loop.rs:86:25 | -83 | while let Some(x) = iter.next() { +86 | while let Some(x) = iter.next() { | ^^^^^^^^^^^ help: try: `for x in iter { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:88:25 + --> $DIR/while_loop.rs:91:25 | -88 | while let Some(_) = iter.next() {} +91 | while let Some(_) = iter.next() {} | ^^^^^^^^^^^ help: try: `for _ in iter { .. }` error: this loop could be written as a `while let` loop - --> $DIR/while_loop.rs:128:5 + --> $DIR/while_loop.rs:134:5 | -128 | / loop { -129 | | let _ = match iter.next() { -130 | | Some(ele) => ele, -131 | | None => break -132 | | }; -133 | | loop {} -134 | | } +134 | / loop { +135 | | let _ = match iter.next() { +136 | | Some(ele) => ele, +137 | | None => break, +138 | | }; +139 | | loop {} +140 | | } | |_____^ help: try: `while let Some(ele) = iter.next() { .. }` error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body. - --> $DIR/while_loop.rs:133:9 + --> $DIR/while_loop.rs:139:9 | -133 | loop {} +139 | loop {} | ^^^^^^^ | = note: `-D clippy::empty-loop` implied by `-D warnings` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:193:29 + --> $DIR/while_loop.rs:197:29 | -193 | while let Some(v) = y.next() { // use a for loop here +197 | while let Some(v) = y.next() { | ^^^^^^^^ help: try: `for v in y { .. }` error: this loop could be written as a `for` loop - --> $DIR/while_loop.rs:220:26 + --> $DIR/while_loop.rs:225:26 | -220 | while let Some(..) = values.iter().next() { +225 | while let Some(..) = values.iter().next() { | ^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in values.iter() { .. }` error: aborting due to 12 previous errors diff --git a/tests/ui/write_literal.stderr b/tests/ui/write_literal.stderr index 2aa66c320496..40c21902bf2e 100644 --- a/tests/ui/write_literal.stderr +++ b/tests/ui/write_literal.stderr @@ -1,88 +1,88 @@ error: literal with an empty format string - --> $DIR/write_literal.rs:39:79 + --> $DIR/write_literal.rs:36:79 | -39 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); +36 | writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2); | ^ | = note: `-D clippy::write-literal` implied by `-D warnings` error: literal with an empty format string - --> $DIR/write_literal.rs:40:32 + --> $DIR/write_literal.rs:37:32 | -40 | write!(&mut v, "Hello {}", "world"); +37 | write!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:41:44 + --> $DIR/write_literal.rs:38:44 | -41 | writeln!(&mut v, "Hello {} {}", world, "world"); +38 | writeln!(&mut v, "Hello {} {}", world, "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:42:34 + --> $DIR/write_literal.rs:39:34 | -42 | writeln!(&mut v, "Hello {}", "world"); +39 | writeln!(&mut v, "Hello {}", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:43:38 + --> $DIR/write_literal.rs:40:38 | -43 | writeln!(&mut v, "10 / 4 is {}", 2.5); +40 | writeln!(&mut v, "10 / 4 is {}", 2.5); | ^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:44:36 + --> $DIR/write_literal.rs:41:36 | -44 | writeln!(&mut v, "2 + 1 = {}", 3); +41 | writeln!(&mut v, "2 + 1 = {}", 3); | ^ error: literal with an empty format string - --> $DIR/write_literal.rs:49:33 + --> $DIR/write_literal.rs:46:33 | -49 | writeln!(&mut v, "{0} {1}", "hello", "world"); +46 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:49:42 + --> $DIR/write_literal.rs:46:42 | -49 | writeln!(&mut v, "{0} {1}", "hello", "world"); +46 | writeln!(&mut v, "{0} {1}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:50:33 + --> $DIR/write_literal.rs:47:33 | -50 | writeln!(&mut v, "{1} {0}", "hello", "world"); +47 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:50:42 + --> $DIR/write_literal.rs:47:42 | -50 | writeln!(&mut v, "{1} {0}", "hello", "world"); +47 | writeln!(&mut v, "{1} {0}", "hello", "world"); | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:53:41 + --> $DIR/write_literal.rs:50:43 | -53 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +50 | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:53:54 + --> $DIR/write_literal.rs:50:58 | -53 | writeln!(&mut v, "{foo} {bar}", foo="hello", bar="world"); - | ^^^^^^^ +50 | writeln!(&mut v, "{foo} {bar}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:54:41 + --> $DIR/write_literal.rs:51:43 | -54 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +51 | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: literal with an empty format string - --> $DIR/write_literal.rs:54:54 + --> $DIR/write_literal.rs:51:58 | -54 | writeln!(&mut v, "{bar} {foo}", foo="hello", bar="world"); - | ^^^^^^^ +51 | writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world"); + | ^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr index dd7f223c5178..8d2ad1b4d97a 100644 --- a/tests/ui/write_with_newline.stderr +++ b/tests/ui/write_with_newline.stderr @@ -1,27 +1,27 @@ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:22:5 + --> $DIR/write_with_newline.rs:19:5 | -22 | write!(&mut v, "Hello/n"); +19 | write!(&mut v, "Hello/n"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::write-with-newline` implied by `-D warnings` error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:23:5 + --> $DIR/write_with_newline.rs:20:5 | -23 | write!(&mut v, "Hello {}/n", "world"); +20 | write!(&mut v, "Hello {}/n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:24:5 + --> $DIR/write_with_newline.rs:21:5 | -24 | write!(&mut v, "Hello {} {}/n", "world", "#2"); +21 | write!(&mut v, "Hello {} {}/n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead - --> $DIR/write_with_newline.rs:25:5 + --> $DIR/write_with_newline.rs:22:5 | -25 | write!(&mut v, "{}/n", 1265); +22 | write!(&mut v, "{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr index 3e6ec33623ae..5943dfa09b1f 100644 --- a/tests/ui/writeln_empty_string.stderr +++ b/tests/ui/writeln_empty_string.stderr @@ -1,15 +1,15 @@ error: using `writeln!(&mut v, "")` - --> $DIR/writeln_empty_string.rs:21:5 + --> $DIR/writeln_empty_string.rs:18:5 | -21 | writeln!(&mut v, ""); +18 | writeln!(&mut v, ""); | ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)` | = note: `-D clippy::writeln-empty-string` implied by `-D warnings` error: using `writeln!(&mut suggestion, "")` - --> $DIR/writeln_empty_string.rs:24:5 + --> $DIR/writeln_empty_string.rs:21:5 | -24 | writeln!(&mut suggestion, ""); +21 | writeln!(&mut suggestion, ""); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)` error: aborting due to 2 previous errors diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index ee0f4f8a143c..fa97713ed784 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -1,75 +1,75 @@ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:31:17 + --> $DIR/wrong_self_convention.rs:26:17 | -31 | fn from_i32(self) {} +26 | fn from_i32(self) {} | ^^^^ | = note: `-D clippy::wrong-self-convention` implied by `-D warnings` error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:37:21 + --> $DIR/wrong_self_convention.rs:32:21 | -37 | pub fn from_i64(self) {} +32 | pub fn from_i64(self) {} | ^^^^ error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:50:15 + --> $DIR/wrong_self_convention.rs:44:15 | -50 | fn as_i32(self) {} +44 | fn as_i32(self) {} | ^^^^ error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:52:17 + --> $DIR/wrong_self_convention.rs:46:17 | -52 | fn into_i32(&self) {} +46 | fn into_i32(&self) {} | ^^^^^ error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:54:15 + --> $DIR/wrong_self_convention.rs:48:15 | -54 | fn is_i32(self) {} +48 | fn is_i32(self) {} | ^^^^ error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:56:15 + --> $DIR/wrong_self_convention.rs:50:15 | -56 | fn to_i32(self) {} +50 | fn to_i32(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:58:17 + --> $DIR/wrong_self_convention.rs:52:17 | -58 | fn from_i32(self) {} +52 | fn from_i32(self) {} | ^^^^ error: methods called `as_*` usually take self by reference or self by mutable reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:60:19 + --> $DIR/wrong_self_convention.rs:54:19 | -60 | pub fn as_i64(self) {} +54 | pub fn as_i64(self) {} | ^^^^ error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:61:21 + --> $DIR/wrong_self_convention.rs:55:21 | -61 | pub fn into_i64(&self) {} +55 | pub fn into_i64(&self) {} | ^^^^^ error: methods called `is_*` usually take self by reference or no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:62:19 + --> $DIR/wrong_self_convention.rs:56:19 | -62 | pub fn is_i64(self) {} +56 | pub fn is_i64(self) {} | ^^^^ error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:63:19 + --> $DIR/wrong_self_convention.rs:57:19 | -63 | pub fn to_i64(self) {} +57 | pub fn to_i64(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name - --> $DIR/wrong_self_convention.rs:64:21 + --> $DIR/wrong_self_convention.rs:58:21 | -64 | pub fn from_i64(self) {} +58 | pub fn from_i64(self) {} | ^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index 0c24a08a634a..312392050c55 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -1,59 +1,59 @@ error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:17:15 + --> $DIR/zero_div_zero.rs:13:15 | -17 | let nan = 0.0 / 0.0; +13 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = note: #[deny(clippy::eq_op)] on by default error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:17:15 + --> $DIR/zero_div_zero.rs:13:15 | -17 | let nan = 0.0 / 0.0; +13 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = note: `-D clippy::zero-divided-by-zero` implied by `-D warnings` = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:18:19 + --> $DIR/zero_div_zero.rs:14:19 | -18 | let f64_nan = 0.0 / 0.0f64; +14 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:18:19 + --> $DIR/zero_div_zero.rs:14:19 | -18 | let f64_nan = 0.0 / 0.0f64; +14 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:19:25 + --> $DIR/zero_div_zero.rs:15:25 | -19 | let other_f64_nan = 0.0f64 / 0.0; +15 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:19:25 + --> $DIR/zero_div_zero.rs:15:25 | -19 | let other_f64_nan = 0.0f64 / 0.0; +15 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN error: equal expressions as operands to `/` - --> $DIR/zero_div_zero.rs:20:28 + --> $DIR/zero_div_zero.rs:16:28 | -20 | let one_more_f64_nan = 0.0f64/0.0f64; - | ^^^^^^^^^^^^^ +16 | let one_more_f64_nan = 0.0f64 / 0.0f64; + | ^^^^^^^^^^^^^^^ error: constant division of 0.0 with 0.0 will always result in NaN - --> $DIR/zero_div_zero.rs:20:28 + --> $DIR/zero_div_zero.rs:16:28 | -20 | let one_more_f64_nan = 0.0f64/0.0f64; - | ^^^^^^^^^^^^^ +16 | let one_more_f64_nan = 0.0f64 / 0.0f64; + | ^^^^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN diff --git a/tests/ui/zero_ptr.stderr b/tests/ui/zero_ptr.stderr index 7a0c8e70b220..15b27c7c0ad8 100644 --- a/tests/ui/zero_ptr.stderr +++ b/tests/ui/zero_ptr.stderr @@ -1,15 +1,15 @@ error: `0 as *const _` detected. Consider using `ptr::null()` - --> $DIR/zero_ptr.rs:16:13 + --> $DIR/zero_ptr.rs:12:13 | -16 | let x = 0 as *const usize; +12 | let x = 0 as *const usize; | ^^^^^^^^^^^^^^^^^ | = note: `-D clippy::zero-ptr` implied by `-D warnings` error: `0 as *mut _` detected. Consider using `ptr::null_mut()` - --> $DIR/zero_ptr.rs:17:13 + --> $DIR/zero_ptr.rs:13:13 | -17 | let y = 0 as *mut f64; +13 | let y = 0 as *mut f64; | ^^^^^^^^^^^^^ error: aborting due to 2 previous errors From 0a6e568f07ef11ab24fd47cdaaa1719f910952e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 10 Dec 2018 15:46:01 +0100 Subject: [PATCH 4/7] test formatting: don't format tests/ui/formatting.rs --- ci/base-tests.sh | 2 +- tests/ui/formatting.rs | 97 ++++++++++++++++++++++---------------- tests/ui/formatting.stderr | 85 ++++++++++++++++++++++++++++++--- 3 files changed, 135 insertions(+), 49 deletions(-) diff --git a/ci/base-tests.sh b/ci/base-tests.sh index dfc5ad99e0c1..a60e36f29816 100755 --- a/ci/base-tests.sh +++ b/ci/base-tests.sh @@ -35,7 +35,7 @@ set +ex # some lints are sensitive to formatting, exclude some files needs_formatting=false -for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do +for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true done diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 875a74d25081..88f6e497d12e 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -7,74 +7,82 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + + + + #![warn(clippy::all)] #![allow(unused_variables)] #![allow(unused_assignments)] #![allow(clippy::if_same_then_else)] #![allow(clippy::deref_addrof)] -fn foo() -> bool { - true -} +fn foo() -> bool { true } fn main() { // weird `else if` formatting: - if foo() {} - if foo() {} + if foo() { + } if foo() { + } - let _ = { - // if as the last expression + let _ = { // if as the last expression let _ = 0; - if foo() {} if foo() { - } else { + } if foo() { + } + else { } }; - let _ = { - // if in the middle of a block - if foo() {} + let _ = { // if in the middle of a block if foo() { - } else { + } if foo() { + } + else { } let _ = 0; }; if foo() { - } else if foo() { - // the span of the above error should continue here + } else + if foo() { // the span of the above error should continue here } if foo() { - } else if foo() { - // the span of the above error should continue here + } + else + if foo() { // the span of the above error should continue here } // those are ok: - if foo() {} - if foo() {} + if foo() { + } + if foo() { + } if foo() { } else if foo() { } if foo() { - } else if foo() { + } + else if foo() { } if foo() { - } else if foo() { } + else if + foo() {} // weird op_eq formatting: let mut a = 42; - a = -35; - a = *&191; + a =- 35; + a =* &191; let mut b = true; - b = !false; + b =! false; // those are ok: a = -35; @@ -83,30 +91,37 @@ fn main() { // possible missing comma in an array let _ = &[ - -1, - -2, - -3 // <= no comma here - -4, - -5, - -6, + -1, -2, -3 // <= no comma here + -4, -5, -6 ]; let _ = &[ - -1, - -2, - -3 // <= no comma here - *4, - -5, - -6, + -1, -2, -3 // <= no comma here + *4, -5, -6 ]; // those are ok: - let _ = &[-1, -2, -3, -4, -5, -6]; - let _ = &[-1, -2, -3, -4, -5, -6]; - let _ = &[1 + 2, 3 + 4, 5 + 6]; + let _ = &[ + -1, -2, -3, + -4, -5, -6 + ]; + let _ = &[ + -1, -2, -3, + -4, -5, -6, + ]; + let _ = &[ + 1 + 2, 3 + + 4, 5 + 6, + ]; // don't lint for bin op without unary equiv // issue 3244 - vec![1 / 2]; + vec![ + 1 + / 2, + ]; // issue 3396 - vec![true | false]; + vec![ + true + | false, + ]; } diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index 84749b6caac3..e1620b221257 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,19 +1,90 @@ +error: this looks like an `else if` but the `else` is missing + --> $DIR/formatting.rs:25:6 + | +25 | } if foo() { + | ^ + | + = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` + = note: to remove this lint, add the missing `else` or add a new line before the second `if` + +error: this looks like an `else if` but the `else` is missing + --> $DIR/formatting.rs:32:10 + | +32 | } if foo() { + | ^ + | + = note: to remove this lint, add the missing `else` or add a new line before the second `if` + +error: this looks like an `else if` but the `else` is missing + --> $DIR/formatting.rs:40:10 + | +40 | } if foo() { + | ^ + | + = note: to remove this lint, add the missing `else` or add a new line before the second `if` + +error: this is an `else if` but the formatting might hide it + --> $DIR/formatting.rs:49:6 + | +49 | } else + | ______^ +50 | | if foo() { // the span of the above error should continue here + | |____^ + | + = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` + +error: this is an `else if` but the formatting might hide it + --> $DIR/formatting.rs:54:6 + | +54 | } + | ______^ +55 | | else +56 | | if foo() { // the span of the above error should continue here + | |____^ + | + = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` + +error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` + --> $DIR/formatting.rs:81:6 + | +81 | a =- 35; + | ^^^^ + | + = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` + = note: to remove this lint, use either `-=` or `= -` + +error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` + --> $DIR/formatting.rs:82:6 + | +82 | a =* &191; + | ^^^^ + | + = note: to remove this lint, use either `*=` or `= *` + +error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` + --> $DIR/formatting.rs:85:6 + | +85 | b =! false; + | ^^^^ + | + = note: to remove this lint, use either `!=` or `= !` + error: possibly missing a comma here - --> $DIR/formatting.rs:88:11 + --> $DIR/formatting.rs:94:19 | -88 | -3 // <= no comma here - | ^ +94 | -1, -2, -3 // <= no comma here + | ^ | = note: `-D clippy::possible-missing-comma` implied by `-D warnings` = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:96:11 + --> $DIR/formatting.rs:98:19 | -96 | -3 // <= no comma here - | ^ +98 | -1, -2, -3 // <= no comma here + | ^ | = note: to remove this lint, add a comma or write the expr in a single line -error: aborting due to 2 previous errors +error: aborting due to 10 previous errors From f1d5194e3d9c07279811fc4f6a704b5185c8c9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 11 Dec 2018 00:59:59 +0100 Subject: [PATCH 5/7] tests: revert some changs and add further rustfmt::skip attributes. --- tests/ui/cast.rs | 3 ++- tests/ui/identity_op.rs | 3 ++- tests/ui/identity_op.stderr | 32 +++++++++++++++---------------- tests/ui/implicit_return.rs | 6 ++++-- tests/ui/implicit_return.stderr | 24 +++++++++++------------ tests/ui/reference.rs | 3 ++- tests/ui/reference.stderr | 26 ++++++++++++------------- tests/ui/useless_attribute.rs | 4 +++- tests/ui/useless_attribute.stderr | 8 +------- tests/ui/vec.rs | 4 ++-- tests/ui/vec.stderr | 2 +- 11 files changed, 58 insertions(+), 57 deletions(-) diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index 45e878e9d800..51e41b701724 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -51,7 +51,8 @@ fn main() { false as bool; &1i32 as &i32; // Should not trigger - let v = vec![1]; + #[rustfmt::skip] + let v = vec!(1); &v as &[i32]; 1.0 as f64; 1 as u64; diff --git a/tests/ui/identity_op.rs b/tests/ui/identity_op.rs index c8874250a043..299cd2a67863 100644 --- a/tests/ui/identity_op.rs +++ b/tests/ui/identity_op.rs @@ -18,6 +18,7 @@ const ZERO: i64 = 0; clippy::double_parens )] #[warn(clippy::identity_op)] +#[rustfmt::skip] fn main() { let x = 0; @@ -28,7 +29,7 @@ fn main() { 1 + x; x - ZERO; //no error, as we skip lookups (for now) x | (0); - (ZERO) | x; //no error, as we skip lookups (for now) + ((ZERO)) | x; //no error, as we skip lookups (for now) x * 1; 1 * x; diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index e2b6efa7dbe1..19846b5ecdfd 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,51 +1,51 @@ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:24:5 + --> $DIR/identity_op.rs:25:5 | -24 | x + 0; +25 | x + 0; | ^^^^^ | = note: `-D clippy::identity-op` implied by `-D warnings` error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:25:5 + --> $DIR/identity_op.rs:26:5 | -25 | x + (1 - 1); +26 | x + (1 - 1); | ^^^^^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:27:5 + --> $DIR/identity_op.rs:28:5 | -27 | 0 + x; +28 | 0 + x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:30:5 + --> $DIR/identity_op.rs:31:5 | -30 | x | (0); +31 | x | (0); | ^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:33:5 + --> $DIR/identity_op.rs:34:5 | -33 | x * 1; +34 | x * 1; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:34:5 + --> $DIR/identity_op.rs:35:5 | -34 | 1 * x; +35 | 1 * x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` - --> $DIR/identity_op.rs:40:5 + --> $DIR/identity_op.rs:41:5 | -40 | -1 & x; +41 | -1 & x; | ^^^^^^ error: the operation is ineffective. Consider reducing it to `u` - --> $DIR/identity_op.rs:43:5 + --> $DIR/identity_op.rs:44:5 | -43 | u & 255; +44 | u & 255; | ^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/implicit_return.rs b/tests/ui/implicit_return.rs index 3bff92cf492b..6188835e555a 100644 --- a/tests/ui/implicit_return.rs +++ b/tests/ui/implicit_return.rs @@ -27,10 +27,11 @@ fn test_if_block() -> bool { } #[allow(clippy::match_bool)] +#[rustfmt::skip] fn test_match(x: bool) -> bool { match x { true => false, - false => true, + false => { true }, } } @@ -42,7 +43,8 @@ fn test_loop() -> bool { } fn test_closure() { - let _ = || true; + #[rustfmt::skip] + let _ = || { true }; let _ = || true; } diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr index 26474aab4b8f..b2feec3f57af 100644 --- a/tests/ui/implicit_return.stderr +++ b/tests/ui/implicit_return.stderr @@ -19,33 +19,33 @@ error: missing return statement | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:32:17 + --> $DIR/implicit_return.rs:33:17 | -32 | true => false, +33 | true => false, | ^^^^^ help: add `return` as shown: `return false` error: missing return statement - --> $DIR/implicit_return.rs:33:18 + --> $DIR/implicit_return.rs:34:20 | -33 | false => true, - | ^^^^ help: add `return` as shown: `return true` +34 | false => { true }, + | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:40:9 + --> $DIR/implicit_return.rs:41:9 | -40 | break true; +41 | break true; | ^^^^^^^^^^ help: change `break` to `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:45:16 + --> $DIR/implicit_return.rs:47:18 | -45 | let _ = || true; - | ^^^^ help: add `return` as shown: `return true` +47 | let _ = || { true }; + | ^^^^ help: add `return` as shown: `return true` error: missing return statement - --> $DIR/implicit_return.rs:46:16 + --> $DIR/implicit_return.rs:48:16 | -46 | let _ = || true; +48 | let _ = || true; | ^^^^ help: add `return` as shown: `return true` error: aborting due to 8 previous errors diff --git a/tests/ui/reference.rs b/tests/ui/reference.rs index 583829aae418..bab0c21ffd90 100644 --- a/tests/ui/reference.rs +++ b/tests/ui/reference.rs @@ -37,7 +37,8 @@ fn main() { let b = *(&a); - let b = *(&a); + #[rustfmt::skip] + let b = *((&a)); let b = *&&a; diff --git a/tests/ui/reference.stderr b/tests/ui/reference.stderr index c09a31e2d8ab..7665e0d1932b 100644 --- a/tests/ui/reference.stderr +++ b/tests/ui/reference.stderr @@ -31,39 +31,39 @@ error: immediately dereferencing a reference | ^^^^^ help: try this: `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:40:13 + --> $DIR/reference.rs:41:13 | -40 | let b = *(&a); - | ^^^^^ help: try this: `a` +41 | let b = *((&a)); + | ^^^^^^^ help: try this: `a` error: immediately dereferencing a reference - --> $DIR/reference.rs:42:13 + --> $DIR/reference.rs:43:13 | -42 | let b = *&&a; +43 | let b = *&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:44:14 + --> $DIR/reference.rs:45:14 | -44 | let b = **&aref; +45 | let b = **&aref; | ^^^^^^ help: try this: `aref` error: immediately dereferencing a reference - --> $DIR/reference.rs:48:14 + --> $DIR/reference.rs:49:14 | -48 | let b = **&&a; +49 | let b = **&&a; | ^^^^ help: try this: `&a` error: immediately dereferencing a reference - --> $DIR/reference.rs:52:17 + --> $DIR/reference.rs:53:17 | -52 | let y = *&mut x; +53 | let y = *&mut x; | ^^^^^^^ help: try this: `x` error: immediately dereferencing a reference - --> $DIR/reference.rs:59:18 + --> $DIR/reference.rs:60:18 | -59 | let y = **&mut &mut x; +60 | let y = **&mut &mut x; | ^^^^^^^^^^^^ help: try this: `&mut x` error: aborting due to 11 previous errors diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index 4ee6520443d2..2d7a9ae04d1e 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -11,7 +11,9 @@ #[allow(dead_code)] #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] -#[cfg_attr(feature = "cargo-clippy", allow(dead_code))] +#[rustfmt::skip] +#[cfg_attr(feature = "cargo-clippy", + allow(dead_code))] #[allow(unused_imports)] #[allow(unused_extern_crates)] #[macro_use] diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index 54d18fbf2e13..2dde3fd7eac3 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -12,11 +12,5 @@ error: useless lint attribute 13 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` -error: useless lint attribute - --> $DIR/useless_attribute.rs:14:1 - | -14 | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index a7ccda375bfd..f795c11ec5b1 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -35,8 +35,8 @@ fn main() { on_slice(&vec![1, 2]); on_slice(&[1, 2]); - - on_slice(&vec![1, 2]); + #[rustfmt::skip] + on_slice(&vec!(1, 2)); on_slice(&[1, 2]); on_slice(&vec![1; 2]); diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index 94e9bcdd2a72..ccd6a7d25c72 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -21,7 +21,7 @@ error: useless use of `vec!` error: useless use of `vec!` --> $DIR/vec.rs:39:14 | -39 | on_slice(&vec![1, 2]); +39 | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` From 625ca772b59da2355589d634f402725c495ab5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 11 Dec 2018 01:31:04 +0100 Subject: [PATCH 6/7] tests: fix more cases where rustfmt would have hurt the tests --- tests/ui/formatting.rs | 4 - tests/ui/formatting.stderr | 46 +++--- tests/ui/option_map_unit_fn.rs | 75 +++------ tests/ui/option_map_unit_fn.stderr | 254 +++++++++++------------------ tests/ui/result_map_unit_fn.rs | 70 +++----- tests/ui/result_map_unit_fn.stderr | 248 +++++++++++----------------- 6 files changed, 262 insertions(+), 435 deletions(-) diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 88f6e497d12e..3bea98acf2fb 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -7,10 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - - #![warn(clippy::all)] #![allow(unused_variables)] #![allow(unused_assignments)] diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index e1620b221257..7399a0d45491 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -1,87 +1,87 @@ error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:25:6 + --> $DIR/formatting.rs:21:6 | -25 | } if foo() { +21 | } if foo() { | ^ | = note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:32:10 + --> $DIR/formatting.rs:28:10 | -32 | } if foo() { +28 | } if foo() { | ^ | = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this looks like an `else if` but the `else` is missing - --> $DIR/formatting.rs:40:10 + --> $DIR/formatting.rs:36:10 | -40 | } if foo() { +36 | } if foo() { | ^ | = note: to remove this lint, add the missing `else` or add a new line before the second `if` error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:49:6 + --> $DIR/formatting.rs:45:6 | -49 | } else +45 | } else | ______^ -50 | | if foo() { // the span of the above error should continue here +46 | | if foo() { // the span of the above error should continue here | |____^ | = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this is an `else if` but the formatting might hide it - --> $DIR/formatting.rs:54:6 + --> $DIR/formatting.rs:50:6 | -54 | } +50 | } | ______^ -55 | | else -56 | | if foo() { // the span of the above error should continue here +51 | | else +52 | | if foo() { // the span of the above error should continue here | |____^ | = note: to remove this lint, remove the `else` or remove the new line between `else` and `if` error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - --> $DIR/formatting.rs:81:6 + --> $DIR/formatting.rs:77:6 | -81 | a =- 35; +77 | a =- 35; | ^^^^ | = note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings` = note: to remove this lint, use either `-=` or `= -` error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - --> $DIR/formatting.rs:82:6 + --> $DIR/formatting.rs:78:6 | -82 | a =* &191; +78 | a =* &191; | ^^^^ | = note: to remove this lint, use either `*=` or `= *` error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - --> $DIR/formatting.rs:85:6 + --> $DIR/formatting.rs:81:6 | -85 | b =! false; +81 | b =! false; | ^^^^ | = note: to remove this lint, use either `!=` or `= !` error: possibly missing a comma here - --> $DIR/formatting.rs:94:19 + --> $DIR/formatting.rs:90:19 | -94 | -1, -2, -3 // <= no comma here +90 | -1, -2, -3 // <= no comma here | ^ | = note: `-D clippy::possible-missing-comma` implied by `-D warnings` = note: to remove this lint, add a comma or write the expr in a single line error: possibly missing a comma here - --> $DIR/formatting.rs:98:19 + --> $DIR/formatting.rs:94:19 | -98 | -1, -2, -3 // <= no comma here +94 | -1, -2, -3 // <= no comma here | ^ | = note: to remove this lint, add a comma or write the expr in a single line diff --git a/tests/ui/option_map_unit_fn.rs b/tests/ui/option_map_unit_fn.rs index 5200ff694a07..db473f9b41e3 100644 --- a/tests/ui/option_map_unit_fn.rs +++ b/tests/ui/option_map_unit_fn.rs @@ -31,12 +31,12 @@ impl HasOption { value + 1 } } - +#[rustfmt::skip] fn option_map_unit_fn() { let x = HasOption { field: Some(10) }; x.field.map(plus_one); - let _: Option<()> = x.field.map(do_nothing); + let _ : Option<()> = x.field.map(do_nothing); x.field.map(do_nothing); @@ -45,68 +45,47 @@ fn option_map_unit_fn() { x.field.map(diverge); let captured = 10; - if let Some(value) = x.field { - do_nothing(value + captured) - }; - let _: Option<()> = x.field.map(|value| do_nothing(value + captured)); + if let Some(value) = x.field { do_nothing(value + captured) }; + let _ : Option<()> = x.field.map(|value| do_nothing(value + captured)); x.field.map(|value| x.do_option_nothing(value + captured)); - x.field.map(|value| { - x.do_option_plus_one(value + captured); - }); + x.field.map(|value| { x.do_option_plus_one(value + captured); }); - x.field.map(|value| do_nothing(value + captured)); x.field.map(|value| do_nothing(value + captured)); - x.field.map(|value| { - do_nothing(value + captured); - }); + x.field.map(|value| { do_nothing(value + captured) }); - x.field.map(|value| { - do_nothing(value + captured); - }); + x.field.map(|value| { do_nothing(value + captured); }); + + x.field.map(|value| { { do_nothing(value + captured); } }); - x.field.map(|value| diverge(value + captured)); x.field.map(|value| diverge(value + captured)); - x.field.map(|value| { - diverge(value + captured); - }); + x.field.map(|value| { diverge(value + captured) }); + + x.field.map(|value| { diverge(value + captured); }); + + x.field.map(|value| { { diverge(value + captured); } }); - x.field.map(|value| { - diverge(value + captured); - }); x.field.map(|value| plus_one(value + captured)); - x.field.map(|value| plus_one(value + captured)); - x.field.map(|value| { - let y = plus_one(value + captured); - }); + x.field.map(|value| { plus_one(value + captured) }); + x.field.map(|value| { let y = plus_one(value + captured); }); - x.field.map(|value| { - plus_one(value + captured); - }); + x.field.map(|value| { plus_one(value + captured); }); - x.field.map(|value| { - plus_one(value + captured); - }); + x.field.map(|value| { { plus_one(value + captured); } }); - x.field.map(|ref value| do_nothing(value + captured)); - x.field.map(|value| { - do_nothing(value); - do_nothing(value) - }); + x.field.map(|ref value| { do_nothing(value + captured) }); - x.field.map(|value| { - if value > 0 { - do_nothing(value); - do_nothing(value) - } - }); + + x.field.map(|value| { do_nothing(value); do_nothing(value) }); + + x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); // Suggestion for the let block should be `{ ... }` as it's too difficult to build a // proper suggestion for these cases @@ -114,13 +93,9 @@ fn option_map_unit_fn() { do_nothing(value); do_nothing(value) }); - x.field.map(|value| { - do_nothing(value); - do_nothing(value); - }); + x.field.map(|value| { do_nothing(value); do_nothing(value); }); - // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let - // variable name for them + // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them Some(42).map(diverge); "12".parse::().ok().map(diverge); Some(plus_one(1)).map(do_nothing); diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr index 86fb9e75d8f1..5df5ae7d9181 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -25,243 +25,183 @@ error: called `map(f)` on an Option value where `f` is a unit function | help: try this: `if let Some(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:53:5 + --> $DIR/option_map_unit_fn.rs:51:5 | -53 | x.field.map(|value| x.do_option_nothing(value + captured)); +51 | x.field.map(|value| x.do_option_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:55:5 + --> $DIR/option_map_unit_fn.rs:53:5 | -55 | x.field.map(|value| { - | _____^ - | |_____| - | || -56 | || x.do_option_plus_one(value + captured); -57 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` - | |_______| - | +53 | x.field.map(|value| { x.do_option_plus_one(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:59:5 + --> $DIR/option_map_unit_fn.rs:56:5 | -59 | x.field.map(|value| do_nothing(value + captured)); +56 | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:61:5 + --> $DIR/option_map_unit_fn.rs:58:5 | -61 | x.field.map(|value| do_nothing(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +58 | x.field.map(|value| { do_nothing(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:63:5 + --> $DIR/option_map_unit_fn.rs:60:5 | -63 | x.field.map(|value| { - | _____^ - | |_____| - | || -64 | || do_nothing(value + captured); -65 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` - | |_______| - | +60 | x.field.map(|value| { do_nothing(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:67:5 + --> $DIR/option_map_unit_fn.rs:62:5 | -67 | x.field.map(|value| { - | _____^ - | |_____| - | || -68 | || do_nothing(value + captured); -69 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` - | |_______| - | +62 | x.field.map(|value| { { do_nothing(value + captured); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:71:5 + --> $DIR/option_map_unit_fn.rs:65:5 | -71 | x.field.map(|value| diverge(value + captured)); +65 | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:73:5 + --> $DIR/option_map_unit_fn.rs:67:5 | -73 | x.field.map(|value| diverge(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +67 | x.field.map(|value| { diverge(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:75:5 + --> $DIR/option_map_unit_fn.rs:69:5 | -75 | x.field.map(|value| { - | _____^ - | |_____| - | || -76 | || diverge(value + captured); -77 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { diverge(value + captured); }` - | |_______| - | +69 | x.field.map(|value| { diverge(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:79:5 + --> $DIR/option_map_unit_fn.rs:71:5 | -79 | x.field.map(|value| { - | _____^ - | |_____| - | || -80 | || diverge(value + captured); -81 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { diverge(value + captured); }` - | |_______| - | +71 | x.field.map(|value| { { diverge(value + captured); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:85:5 + --> $DIR/option_map_unit_fn.rs:76:5 | -85 | x.field.map(|value| { - | _____^ - | |_____| - | || -86 | || let y = plus_one(value + captured); -87 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` - | |_______| - | +76 | x.field.map(|value| { let y = plus_one(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:89:5 + --> $DIR/option_map_unit_fn.rs:78:5 | -89 | x.field.map(|value| { - | _____^ - | |_____| - | || -90 | || plus_one(value + captured); -91 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` - | |_______| - | +78 | x.field.map(|value| { plus_one(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:93:5 + --> $DIR/option_map_unit_fn.rs:80:5 | -93 | x.field.map(|value| { - | _____^ - | |_____| - | || -94 | || plus_one(value + captured); -95 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` - | |_______| - | +80 | x.field.map(|value| { { plus_one(value + captured); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:97:5 + --> $DIR/option_map_unit_fn.rs:83:5 | -97 | x.field.map(|ref value| do_nothing(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +83 | x.field.map(|ref value| { do_nothing(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:99:5 - | -99 | x.field.map(|value| { - | _____^ - | |_____| - | || -100 | || do_nothing(value); -101 | || do_nothing(value) -102 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { ... }` - | |_______| - | + --> $DIR/option_map_unit_fn.rs:86:5 + | +86 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:104:5 - | -104 | x.field.map(|value| { - | _____^ - | |_____| - | || -105 | || if value > 0 { -106 | || do_nothing(value); -107 | || do_nothing(value) -108 | || } -109 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { ... }` - | |_______| - | + --> $DIR/option_map_unit_fn.rs:88:5 + | +88 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:113:5 - | -113 | x.field.map(|value| { - | _____^ - | |_____| - | || -114 | || do_nothing(value); -115 | || do_nothing(value) -116 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { ... }` - | |_______| - | + --> $DIR/option_map_unit_fn.rs:92:5 + | +92 | x.field.map(|value| { + | _____^ + | |_____| + | || +93 | || do_nothing(value); +94 | || do_nothing(value) +95 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | error: called `map(f)` on an Option value where `f` is a unit closure - --> $DIR/option_map_unit_fn.rs:117:5 - | -117 | x.field.map(|value| { - | _____^ - | |_____| - | || -118 | || do_nothing(value); -119 | || do_nothing(value); -120 | || }); - | ||______^- help: try this: `if let Some(value) = x.field { ... }` - | |_______| - | + --> $DIR/option_map_unit_fn.rs:96:5 + | +96 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(value) = x.field { ... }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:124:5 - | -124 | Some(42).map(diverge); - | ^^^^^^^^^^^^^^^^^^^^^- - | | - | help: try this: `if let Some(_) = Some(42) { diverge(...) }` + --> $DIR/option_map_unit_fn.rs:99:5 + | +99 | Some(42).map(diverge); + | ^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(_) = Some(42) { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:125:5 + --> $DIR/option_map_unit_fn.rs:100:5 | -125 | "12".parse::().ok().map(diverge); +100 | "12".parse::().ok().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = "12".parse::().ok() { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:126:5 + --> $DIR/option_map_unit_fn.rs:101:5 | -126 | Some(plus_one(1)).map(do_nothing); +101 | Some(plus_one(1)).map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:130:5 + --> $DIR/option_map_unit_fn.rs:105:5 | -130 | y.map(do_nothing); +105 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_y) = y { do_nothing(...) }` diff --git a/tests/ui/result_map_unit_fn.rs b/tests/ui/result_map_unit_fn.rs index 043b3efd45e7..3d731c9b3502 100644 --- a/tests/ui/result_map_unit_fn.rs +++ b/tests/ui/result_map_unit_fn.rs @@ -33,6 +33,7 @@ impl HasResult { } } +#[rustfmt::skip] fn result_map_unit_fn() { let x = HasResult { field: Ok(10) }; @@ -46,68 +47,47 @@ fn result_map_unit_fn() { x.field.map(diverge); let captured = 10; - if let Ok(value) = x.field { - do_nothing(value + captured) - }; + if let Ok(value) = x.field { do_nothing(value + captured) }; let _: Result<(), usize> = x.field.map(|value| do_nothing(value + captured)); x.field.map(|value| x.do_result_nothing(value + captured)); - x.field.map(|value| { - x.do_result_plus_one(value + captured); - }); + x.field.map(|value| { x.do_result_plus_one(value + captured); }); - x.field.map(|value| do_nothing(value + captured)); x.field.map(|value| do_nothing(value + captured)); - x.field.map(|value| { - do_nothing(value + captured); - }); + x.field.map(|value| { do_nothing(value + captured) }); - x.field.map(|value| { - do_nothing(value + captured); - }); + x.field.map(|value| { do_nothing(value + captured); }); + + x.field.map(|value| { { do_nothing(value + captured); } }); - x.field.map(|value| diverge(value + captured)); x.field.map(|value| diverge(value + captured)); - x.field.map(|value| { - diverge(value + captured); - }); + x.field.map(|value| { diverge(value + captured) }); + + x.field.map(|value| { diverge(value + captured); }); + + x.field.map(|value| { { diverge(value + captured); } }); - x.field.map(|value| { - diverge(value + captured); - }); x.field.map(|value| plus_one(value + captured)); - x.field.map(|value| plus_one(value + captured)); - x.field.map(|value| { - let y = plus_one(value + captured); - }); + x.field.map(|value| { plus_one(value + captured) }); + x.field.map(|value| { let y = plus_one(value + captured); }); - x.field.map(|value| { - plus_one(value + captured); - }); + x.field.map(|value| { plus_one(value + captured); }); - x.field.map(|value| { - plus_one(value + captured); - }); + x.field.map(|value| { { plus_one(value + captured); } }); - x.field.map(|ref value| do_nothing(value + captured)); - x.field.map(|value| { - do_nothing(value); - do_nothing(value) - }); + x.field.map(|ref value| { do_nothing(value + captured) }); - x.field.map(|value| { - if value > 0 { - do_nothing(value); - do_nothing(value) - } - }); + + x.field.map(|value| { do_nothing(value); do_nothing(value) }); + + x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); // Suggestion for the let block should be `{ ... }` as it's too difficult to build a // proper suggestion for these cases @@ -115,13 +95,9 @@ fn result_map_unit_fn() { do_nothing(value); do_nothing(value) }); - x.field.map(|value| { - do_nothing(value); - do_nothing(value); - }); + x.field.map(|value| { do_nothing(value); do_nothing(value); }); - // The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let - // variable name for them + // The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let variable name for them let res: Result = Ok(42).map(diverge); "12".parse::().map(diverge); diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index 1ef107a5000f..3f5231dcc061 100644 --- a/tests/ui/result_map_unit_fn.stderr +++ b/tests/ui/result_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:42:5 + --> $DIR/result_map_unit_fn.rs:43:5 | -42 | x.field.map(do_nothing); +43 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` @@ -9,151 +9,148 @@ error: called `map(f)` on an Result value where `f` is a unit function = note: `-D clippy::result-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:44:5 + --> $DIR/result_map_unit_fn.rs:45:5 | -44 | x.field.map(do_nothing); +45 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:46:5 + --> $DIR/result_map_unit_fn.rs:47:5 | -46 | x.field.map(diverge); +47 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:54:5 + --> $DIR/result_map_unit_fn.rs:53:5 | -54 | x.field.map(|value| x.do_result_nothing(value + captured)); +53 | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:56:5 + --> $DIR/result_map_unit_fn.rs:55:5 | -56 | x.field.map(|value| { - | _____^ - | |_____| - | || -57 | || x.do_result_plus_one(value + captured); -58 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` - | |_______| - | +55 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:60:5 + --> $DIR/result_map_unit_fn.rs:58:5 | -60 | x.field.map(|value| do_nothing(value + captured)); +58 | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:62:5 + --> $DIR/result_map_unit_fn.rs:60:5 | -62 | x.field.map(|value| do_nothing(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +60 | x.field.map(|value| { do_nothing(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:64:5 + --> $DIR/result_map_unit_fn.rs:62:5 | -64 | x.field.map(|value| { - | _____^ - | |_____| - | || -65 | || do_nothing(value + captured); -66 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` - | |_______| - | +62 | x.field.map(|value| { do_nothing(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:68:5 + --> $DIR/result_map_unit_fn.rs:64:5 | -68 | x.field.map(|value| { - | _____^ - | |_____| - | || -69 | || do_nothing(value + captured); -70 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` - | |_______| - | +64 | x.field.map(|value| { { do_nothing(value + captured); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:72:5 + --> $DIR/result_map_unit_fn.rs:67:5 | -72 | x.field.map(|value| diverge(value + captured)); +67 | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:74:5 + --> $DIR/result_map_unit_fn.rs:69:5 | -74 | x.field.map(|value| diverge(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +69 | x.field.map(|value| { diverge(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:76:5 + --> $DIR/result_map_unit_fn.rs:71:5 | -76 | x.field.map(|value| { - | _____^ - | |_____| - | || -77 | || diverge(value + captured); -78 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` - | |_______| - | +71 | x.field.map(|value| { diverge(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:73:5 + | +73 | x.field.map(|value| { { diverge(value + captured); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:78:5 + | +78 | x.field.map(|value| { let y = plus_one(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:80:5 | -80 | x.field.map(|value| { - | _____^ - | |_____| - | || -81 | || diverge(value + captured); -82 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` - | |_______| - | +80 | x.field.map(|value| { plus_one(value + captured); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:86:5 + --> $DIR/result_map_unit_fn.rs:82:5 | -86 | x.field.map(|value| { - | _____^ - | |_____| - | || -87 | || let y = plus_one(value + captured); -88 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` - | |_______| - | +82 | x.field.map(|value| { { plus_one(value + captured); } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:85:5 + | +85 | x.field.map(|ref value| { do_nothing(value + captured) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` + +error: called `map(f)` on an Result value where `f` is a unit closure + --> $DIR/result_map_unit_fn.rs:88:5 + | +88 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:90:5 | -90 | x.field.map(|value| { - | _____^ - | |_____| - | || -91 | || plus_one(value + captured); -92 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` - | |_______| - | +90 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:94:5 @@ -162,90 +159,33 @@ error: called `map(f)` on an Result value where `f` is a unit closure | _____^ | |_____| | || -95 | || plus_one(value + captured); -96 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` +95 | || do_nothing(value); +96 | || do_nothing(value) +97 | || }); + | ||______^- help: try this: `if let Ok(value) = x.field { ... }` | |_______| | error: called `map(f)` on an Result value where `f` is a unit closure --> $DIR/result_map_unit_fn.rs:98:5 | -98 | x.field.map(|ref value| do_nothing(value + captured)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- +98 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | - | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:100:5 - | -100 | x.field.map(|value| { - | _____^ - | |_____| - | || -101 | || do_nothing(value); -102 | || do_nothing(value) -103 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { ... }` - | |_______| - | - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:105:5 - | -105 | x.field.map(|value| { - | _____^ - | |_____| - | || -106 | || if value > 0 { -107 | || do_nothing(value); -108 | || do_nothing(value) -109 | || } -110 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { ... }` - | |_______| - | - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:114:5 - | -114 | x.field.map(|value| { - | _____^ - | |_____| - | || -115 | || do_nothing(value); -116 | || do_nothing(value) -117 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { ... }` - | |_______| - | - -error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:118:5 - | -118 | x.field.map(|value| { - | _____^ - | |_____| - | || -119 | || do_nothing(value); -120 | || do_nothing(value); -121 | || }); - | ||______^- help: try this: `if let Ok(value) = x.field { ... }` - | |_______| - | + | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:126:5 + --> $DIR/result_map_unit_fn.rs:102:5 | -126 | "12".parse::().map(diverge); +102 | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_) = "12".parse::() { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:132:5 + --> $DIR/result_map_unit_fn.rs:108:5 | -132 | y.map(do_nothing); +108 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_y) = y { do_nothing(...) }` From 36266b3e6cd3d58716cd1fcd21f05148d322d204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 11 Dec 2018 20:50:55 +0100 Subject: [PATCH 7/7] test reformatting: revert more questionable changes done by rustfmt and add #[rustfmt::skip] --- tests/ui/decimal_literal_representation.rs | 7 ++-- .../ui/decimal_literal_representation.stderr | 20 ++++++------ tests/ui/implicit_hasher.rs | 4 +-- tests/ui/implicit_hasher.stderr | 4 +-- tests/ui/swap.rs | 5 +-- tests/ui/swap.stderr | 32 +++++++++---------- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/ui/decimal_literal_representation.rs b/tests/ui/decimal_literal_representation.rs index c196b27a3a6c..d7823b0b819b 100644 --- a/tests/ui/decimal_literal_representation.rs +++ b/tests/ui/decimal_literal_representation.rs @@ -9,9 +9,9 @@ #[warn(clippy::decimal_literal_representation)] #[allow(unused_variables)] +#[rustfmt::skip] fn main() { - let good = ( - // Hex: + let good = ( // Hex: 127, // 0x7F 256, // 0x100 511, // 0x1FF @@ -21,8 +21,7 @@ fn main() { 61_683, // 0xF0F3 2_131_750_925, // 0x7F0F_F00D ); - let bad = ( - // Hex: + let bad = ( // Hex: 32_773, // 0x8005 65_280, // 0xFF00 2_131_750_927, // 0x7F0F_F00F diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr index 42f8a6e3bc54..c68a25f3dc39 100644 --- a/tests/ui/decimal_literal_representation.stderr +++ b/tests/ui/decimal_literal_representation.stderr @@ -1,33 +1,33 @@ error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:26:9 + --> $DIR/decimal_literal_representation.rs:25:9 | -26 | 32_773, // 0x8005 +25 | 32_773, // 0x8005 | ^^^^^^ help: consider: `0x8005` | = note: `-D clippy::decimal-literal-representation` implied by `-D warnings` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:27:9 + --> $DIR/decimal_literal_representation.rs:26:9 | -27 | 65_280, // 0xFF00 +26 | 65_280, // 0xFF00 | ^^^^^^ help: consider: `0xFF00` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:28:9 + --> $DIR/decimal_literal_representation.rs:27:9 | -28 | 2_131_750_927, // 0x7F0F_F00F +27 | 2_131_750_927, // 0x7F0F_F00F | ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:29:9 + --> $DIR/decimal_literal_representation.rs:28:9 | -29 | 2_147_483_647, // 0x7FFF_FFFF +28 | 2_147_483_647, // 0x7FFF_FFFF | ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF` error: integer literal has a better hexadecimal representation - --> $DIR/decimal_literal_representation.rs:30:9 + --> $DIR/decimal_literal_representation.rs:29:9 | -30 | 4_042_322_160, // 0xF0F0_F0F0 +29 | 4_042_322_160, // 0xF0F0_F0F0 | ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0` error: aborting due to 5 previous errors diff --git a/tests/ui/implicit_hasher.rs b/tests/ui/implicit_hasher.rs index ddcd8bcd755a..acd5a52ff386 100644 --- a/tests/ui/implicit_hasher.rs +++ b/tests/ui/implicit_hasher.rs @@ -85,8 +85,8 @@ macro_rules! gen { pub fn $name(_map: &mut HashMap, _set: &mut HashSet) {} }; } - -gen!(impl ); +#[rustfmt::skip] +gen!(impl); gen!(fn bar); // When the macro is in a different file, the suggestion spans can't be combined properly diff --git a/tests/ui/implicit_hasher.stderr b/tests/ui/implicit_hasher.stderr index 58b823e6ca18..35306e77aecf 100644 --- a/tests/ui/implicit_hasher.stderr +++ b/tests/ui/implicit_hasher.stderr @@ -96,8 +96,8 @@ error: impl for `HashMap` should be generalized over different hashers 77 | impl Foo for HashMap { | ^^^^^^^^^^^^^ ... -89 | gen!(impl ); - | ------------ in this macro invocation +89 | gen!(impl); + | ----------- in this macro invocation help: consider adding a type parameter | 77 | impl Foo for HashMap { diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index e9f227d47a07..20fa9c875744 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -39,6 +39,7 @@ fn vec() { foo.swap(0, 1); } +#[rustfmt::skip] fn main() { array(); slice(); @@ -50,7 +51,7 @@ fn main() { a = b; b = a; -; let t = a; + ; let t = a; a = b; b = t; @@ -59,7 +60,7 @@ fn main() { c.0 = a; a = c.0; -; let t = c.0; + ; let t = c.0; c.0 = a; a = t; } diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index 12d012442ad1..c8e803c4afd7 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -25,42 +25,42 @@ error: this looks like you are swapping elements of `foo` manually | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:53:6 + --> $DIR/swap.rs:54:7 | -53 | ; let t = a; - | ______^ -54 | | a = b; -55 | | b = t; +54 | ; let t = a; + | _______^ +55 | | a = b; +56 | | b = t; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:62:6 + --> $DIR/swap.rs:63:7 | -62 | ; let t = c.0; - | ______^ -63 | | c.0 = a; -64 | | a = t; +63 | ; let t = c.0; + | _______^ +64 | | c.0 = a; +65 | | a = t; | |_________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:50:5 + --> $DIR/swap.rs:51:5 | -50 | / a = b; -51 | | b = a; +51 | / a = b; +52 | | b = a; | |_________^ help: try: `std::mem::swap(&mut a, &mut b)` | = note: `-D clippy::almost-swapped` implied by `-D warnings` = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:59:5 + --> $DIR/swap.rs:60:5 | -59 | / c.0 = a; -60 | | a = c.0; +60 | / c.0 = a; +61 | | a = c.0; | |___________^ help: try: `std::mem::swap(&mut c.0, &mut a)` | = note: or maybe you should use `std::mem::replace`?