From 1f2c97a291133596c7f150d299896fedc7b918b7 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 8 Feb 2017 14:58:07 +0100 Subject: [PATCH] remove all //~ from tests --- tests/compile-fail/methods.rs | 384 +++++++++-------- tests/compile-fail/non_expressive_names.rs | 74 ++-- tests/compile-fail/strings.rs | 22 +- tests/compile-fail/swap.rs | 64 +-- tests/run-pass/deprecated.rs | 8 +- tests/ui/absurd-extreme-comparisons.rs | 70 ++-- tests/ui/absurd-extreme-comparisons.stderr | 2 +- tests/ui/approx_const.rs | 38 +- tests/ui/approx_const.stderr | 38 +- tests/ui/arithmetic.rs | 22 +- tests/ui/arithmetic.stderr | 22 +- tests/ui/array_indexing.rs | 38 +- tests/ui/array_indexing.stderr | 38 +- tests/ui/assign_ops.rs | 126 +++--- tests/ui/assign_ops.stderr | 76 ++-- tests/ui/assign_ops2.rs | 48 +-- tests/ui/assign_ops2.stderr | 32 +- tests/ui/attrs.rs | 6 +- tests/ui/attrs.stderr | 6 +- tests/ui/bit_masks.rs | 30 +- tests/ui/bit_masks.stderr | 30 +- tests/ui/blacklisted_name.rs | 14 +- tests/ui/blacklisted_name.stderr | 8 +- tests/ui/block_in_if_condition.rs | 10 +- tests/ui/block_in_if_condition.stderr | 12 +- tests/ui/bool_comparison.rs | 24 +- tests/ui/booleans.rs | 100 ++--- tests/ui/booleans.stderr | 32 +- tests/ui/box_vec.rs | 2 +- tests/ui/box_vec.stderr | 2 +- tests/ui/builtin-type-shadow.rs | 4 +- tests/ui/builtin-type-shadow.stderr | 4 +- tests/ui/cast.rs | 84 ++-- tests/ui/cast.stderr | 84 ++-- tests/ui/char_lit_as_u8.rs | 2 +- tests/ui/char_lit_as_u8.stderr | 2 +- tests/ui/cmp_nan.rs | 24 +- tests/ui/cmp_nan.stderr | 24 +- tests/ui/cmp_null.rs | 4 +- tests/ui/cmp_null.stderr | 4 +- tests/ui/cmp_owned.rs | 8 +- tests/ui/cmp_owned.stderr | 4 +- tests/ui/collapsible_if.rs | 78 ++-- tests/ui/collapsible_if.stderr | 48 +-- tests/ui/complex_types.rs | 30 +- tests/ui/complex_types.stderr | 30 +- tests/ui/conf_french_blacklisted_name.rs | 14 +- tests/ui/conf_french_blacklisted_name.stderr | 8 +- tests/ui/conf_path_non_string.rs | 2 +- tests/ui/copies.rs | 102 ++--- tests/ui/copies.stderr | 68 +-- tests/ui/cyclomatic_complexity.rs | 40 +- tests/ui/cyclomatic_complexity.stderr | 40 +- tests/ui/cyclomatic_complexity_attr_used.rs | 2 +- .../ui/cyclomatic_complexity_attr_used.stderr | 2 +- tests/ui/derive.rs | 10 +- tests/ui/derive.stderr | 10 +- tests/ui/diverging_sub_expression.rs | 12 +- tests/ui/diverging_sub_expression.stderr | 12 +- tests/ui/dlist.rs | 12 +- tests/ui/dlist.stderr | 12 +- tests/ui/doc.rs | 58 +-- tests/ui/double_neg.rs | 2 +- tests/ui/double_neg.stderr | 2 +- tests/ui/double_parens.rs | 10 +- tests/ui/double_parens.stderr | 10 +- tests/ui/drop_forget_ref.rs | 36 +- tests/ui/drop_forget_ref.stderr | 72 ++-- tests/ui/duplicate_underscore_argument.rs | 4 +- tests/ui/duplicate_underscore_argument.stderr | 2 +- tests/ui/empty_enum.rs | 4 +- tests/ui/empty_enum.stderr | 4 +- tests/ui/entry.rs | 42 +- tests/ui/enum_glob_use.rs | 4 +- tests/ui/enum_glob_use.stderr | 4 +- tests/ui/enum_variants.rs | 20 +- tests/ui/enum_variants.stderr | 26 +- tests/ui/enums_clike.rs | 16 +- tests/ui/enums_clike.stderr | 16 +- tests/ui/eq_op.rs | 64 +-- tests/ui/eq_op.stderr | 70 ++-- tests/ui/escape_analysis.rs | 16 +- tests/ui/escape_analysis.stderr | 16 +- tests/ui/eta.rs | 26 +- tests/ui/eval_order_dependence.rs | 8 +- tests/ui/eval_order_dependence.stderr | 8 +- tests/ui/filter_methods.rs | 8 +- tests/ui/filter_methods.stderr | 8 +- tests/ui/float_cmp.rs | 48 +-- tests/ui/for_loop.rs | 282 ++++++------- tests/ui/for_loop.stderr | 182 ++++----- tests/ui/format.rs | 6 +- tests/ui/format.stderr | 6 +- tests/ui/formatting.rs | 40 +- tests/ui/formatting.stderr | 8 +- tests/ui/functions.rs | 24 +- tests/ui/functions.stderr | 2 +- tests/ui/identity_op.rs | 14 +- tests/ui/identity_op.stderr | 14 +- tests/ui/if_let_redundant_pattern_matching.rs | 24 +- tests/ui/if_not_else.rs | 4 +- tests/ui/if_not_else.stderr | 4 +- tests/ui/invalid_upcast_comparisons.rs | 18 +- tests/ui/invalid_upcast_comparisons.stderr | 18 +- tests/ui/item_after_statement.rs | 4 +- tests/ui/item_after_statement.stderr | 4 +- tests/ui/large_enum_variant.rs | 36 +- tests/ui/large_enum_variant.stderr | 32 +- tests/ui/len_zero.rs | 44 +- tests/ui/len_zero.stderr | 8 +- tests/ui/let_if_seq.rs | 24 +- tests/ui/let_if_seq.stderr | 12 +- tests/ui/let_return.rs | 8 +- tests/ui/let_return.stderr | 8 +- tests/ui/let_unit.rs | 4 +- tests/ui/let_unit.stderr | 4 +- tests/ui/lifetimes.rs | 28 +- tests/ui/lifetimes.stderr | 12 +- tests/ui/lint_pass.rs | 2 +- tests/ui/literals.rs | 26 +- tests/ui/literals.stderr | 16 +- tests/ui/map_clone.rs | 44 +- tests/ui/map_clone.stderr | 22 +- tests/ui/matches.rs | 124 +++--- tests/ui/matches.stderr | 124 +++--- tests/ui/mem_forget.rs | 6 +- tests/ui/methods.rs | 386 +++++++++--------- tests/ui/methods.stderr | 66 +-- tests/ui/min_max.rs | 14 +- tests/ui/min_max.stderr | 14 +- tests/ui/missing-doc.rs | 80 ++-- tests/ui/missing-doc.stderr | 110 ++--- tests/ui/module_inception.rs | 4 +- tests/ui/module_inception.stderr | 4 +- tests/ui/modulo_one.rs | 2 +- tests/ui/modulo_one.stderr | 2 +- tests/ui/mut_mut.rs | 28 +- tests/ui/mut_mut.stderr | 6 +- tests/ui/mut_reference.rs | 6 +- tests/ui/mut_reference.stderr | 6 +- tests/ui/mutex_atomic.rs | 14 +- tests/ui/mutex_atomic.stderr | 14 +- tests/ui/needless_bool.rs | 50 +-- tests/ui/needless_bool.stderr | 4 +- tests/ui/needless_borrow.rs | 6 +- tests/ui/needless_borrow.stderr | 4 +- tests/ui/needless_return.rs | 48 +-- tests/ui/needless_update.rs | 2 +- tests/ui/needless_update.stderr | 2 +- tests/ui/neg_multiply.rs | 4 +- tests/ui/new_without_default.rs | 30 +- tests/ui/no_effect.rs | 164 ++++---- tests/ui/no_effect.stderr | 126 +++--- tests/ui/non_expressive_names.rs | 74 ++-- tests/ui/non_expressive_names.stderr | 44 +- tests/ui/ok_if_let.rs | 2 +- tests/ui/ok_if_let.stderr | 2 +- tests/ui/open_options.rs | 14 +- tests/ui/open_options.stderr | 14 +- tests/ui/overflow_check_conditional.rs | 16 +- tests/ui/overflow_check_conditional.stderr | 16 +- tests/ui/panic.rs | 6 +- tests/ui/panic.stderr | 6 +- tests/ui/partialeq_ne_impl.rs | 2 +- tests/ui/patterns.rs | 2 +- tests/ui/patterns.stderr | 2 +- tests/ui/precedence.rs | 36 +- tests/ui/print.rs | 16 +- tests/ui/print.stderr | 6 +- tests/ui/print_with_newline.rs | 8 +- tests/ui/print_with_newline.stderr | 8 +- tests/ui/ptr_arg.rs | 6 +- tests/ui/ptr_arg.stderr | 6 +- tests/ui/range.rs | 10 +- tests/ui/range.stderr | 10 +- tests/ui/redundant_closure_call.rs | 14 +- tests/ui/redundant_closure_call.stderr | 8 +- tests/ui/reference.rs | 66 +-- tests/ui/regex.rs | 64 +-- tests/ui/serde.rs | 2 +- tests/ui/serde.stderr | 2 +- tests/ui/shadow.rs | 18 +- tests/ui/shadow.stderr | 44 +- tests/ui/short_circuit_statement.rs | 18 +- tests/ui/strings.rs | 22 +- tests/ui/strings.stderr | 10 +- tests/ui/stutter.rs | 8 +- tests/ui/stutter.stderr | 8 +- tests/ui/swap.rs | 64 +-- tests/ui/swap.stderr | 14 +- tests/ui/temporary_assignment.rs | 4 +- tests/ui/temporary_assignment.stderr | 4 +- tests/ui/toplevel_ref_arg.rs | 26 +- tests/ui/toplevel_ref_arg.stderr | 2 +- tests/ui/transmute.rs | 110 ++--- tests/ui/transmute_32bit.rs | 8 +- tests/ui/transmute_64bit.rs | 4 +- tests/ui/unicode.rs | 6 +- tests/ui/unicode.stderr | 4 +- tests/ui/unit_cmp.rs | 4 +- tests/ui/unit_cmp.stderr | 4 +- tests/ui/unneeded_field_pattern.rs | 8 +- tests/ui/unneeded_field_pattern.stderr | 4 +- tests/ui/unsafe_removed_from_name.rs | 6 +- tests/ui/unused_io_amount.rs | 8 +- tests/ui/unused_labels.rs | 6 +- tests/ui/unused_labels.stderr | 6 +- tests/ui/unused_lt.rs | 6 +- tests/ui/unused_lt.stderr | 6 +- tests/ui/used_underscore_binding.rs | 10 +- tests/ui/used_underscore_binding.stderr | 4 +- tests/ui/useless_attribute.rs | 6 +- tests/ui/useless_attribute.stderr | 4 +- tests/ui/vec.rs | 36 +- tests/ui/while_loop.rs | 56 +-- tests/ui/while_loop.stderr | 20 +- tests/ui/wrong_macro_span.rs_ | 6 +- tests/ui/wrong_self_convention.rs | 24 +- tests/ui/wrong_self_convention.stderr | 24 +- tests/ui/zero_div_zero.rs | 16 +- tests/ui/zero_div_zero.stderr | 16 +- 221 files changed, 3155 insertions(+), 3157 deletions(-) diff --git a/tests/compile-fail/methods.rs b/tests/compile-fail/methods.rs index 43a438688..34a0773df 100644 --- a/tests/compile-fail/methods.rs +++ b/tests/compile-fail/methods.rs @@ -15,21 +15,19 @@ use std::iter::FromIterator; struct T; impl T { - fn add(self, other: T) -> T { self } //~ERROR defining a method called `add` - fn drop(&mut self) { } //~ERROR defining a method called `drop` + fn add(self, other: T) -> T { self } + fn drop(&mut self) { } fn sub(&self, other: T) -> &T { self } // no error, self is a ref fn div(self) -> T { self } // no error, different #arguments fn rem(self, other: T) { } // no error, wrong return type fn into_u32(self) -> u32 { 0 } // fine - fn into_u16(&self) -> u16 { 0 } //~ERROR methods called `into_*` usually take self by value + fn into_u16(&self) -> u16 { 0 } - fn to_something(self) -> u32 { 0 } //~ERROR methods called `to_*` usually take self by reference + fn to_something(self) -> u32 { 0 } fn new(self) {} - //~^ ERROR methods called `new` usually take no self - //~| ERROR methods called `new` usually return `Self` } struct Lt<'a> { @@ -96,15 +94,15 @@ fn option_methods() { // Check OPTION_MAP_UNWRAP_OR // single line case - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)` - //~| NOTE replace `map(|x| x + 1).unwrap_or(0)` + let _ = opt.map(|x| x + 1) + .unwrap_or(0); // should lint even though this call is on a separate line // multi line cases - let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or(a)` + let _ = opt.map(|x| { x + 1 } ).unwrap_or(0); - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)` + let _ = opt.map(|x| x + 1) .unwrap_or({ 0 }); @@ -113,15 +111,15 @@ fn option_methods() { // Check OPTION_MAP_UNWRAP_OR_ELSE // single line case - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)` - //~| NOTE replace `map(|x| x + 1).unwrap_or_else(|| 0)` + let _ = opt.map(|x| x + 1) + .unwrap_or_else(|| 0); // should lint even though this call is on a separate line // multi line cases - let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or_else(g)` + let _ = opt.map(|x| { x + 1 } ).unwrap_or_else(|| 0); - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)` + let _ = opt.map(|x| x + 1) .unwrap_or_else(|| 0 ); @@ -194,11 +192,11 @@ fn filter_next() { // check single-line case let _ = v.iter().filter(|&x| *x < 0).next(); - //~^ ERROR called `filter(p).next()` on an `Iterator`. - //~| NOTE replace `filter(|&x| *x < 0).next()` + + // check multi-line case - let _ = v.iter().filter(|&x| { //~ERROR called `filter(p).next()` on an `Iterator`. + let _ = v.iter().filter(|&x| { *x < 0 } ).next(); @@ -214,33 +212,33 @@ fn search_is_some() { // check `find().is_some()`, single-line let _ = v.iter().find(|&x| *x < 0).is_some(); - //~^ ERROR called `is_some()` after searching - //~| NOTE replace `find(|&x| *x < 0).is_some()` + + // check `find().is_some()`, multi-line - let _ = v.iter().find(|&x| { //~ERROR called `is_some()` after searching + let _ = v.iter().find(|&x| { *x < 0 } ).is_some(); // check `position().is_some()`, single-line let _ = v.iter().position(|&x| x < 0).is_some(); - //~^ ERROR called `is_some()` after searching - //~| NOTE replace `position(|&x| x < 0).is_some()` + + // check `position().is_some()`, multi-line - let _ = v.iter().position(|&x| { //~ERROR called `is_some()` after searching + let _ = v.iter().position(|&x| { x < 0 } ).is_some(); // check `rposition().is_some()`, single-line let _ = v.iter().rposition(|&x| x < 0).is_some(); - //~^ ERROR called `is_some()` after searching - //~| NOTE replace `rposition(|&x| x < 0).is_some()` + + // check `rposition().is_some()`, multi-line - let _ = v.iter().rposition(|&x| { //~ERROR called `is_some()` after searching + let _ = v.iter().rposition(|&x| { x < 0 } ).is_some(); @@ -276,75 +274,75 @@ fn or_fun_call() { let with_constructor = Some(vec![1]); with_constructor.unwrap_or(make()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_constructor.unwrap_or_else(make) + + + let with_new = Some(vec![1]); with_new.unwrap_or(Vec::new()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_new.unwrap_or_default(); + + + let with_const_args = Some(vec![1]); with_const_args.unwrap_or(Vec::with_capacity(12)); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_const_args.unwrap_or_else(|| Vec::with_capacity(12)); + + + let with_err : Result<_, ()> = Ok(vec![1]); with_err.unwrap_or(make()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_err.unwrap_or_else(|_| make()); + + + let with_err_args : Result<_, ()> = Ok(vec![1]); with_err_args.unwrap_or(Vec::with_capacity(12)); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_err_args.unwrap_or_else(|_| Vec::with_capacity(12)); + + + let with_default_trait = Some(1); with_default_trait.unwrap_or(Default::default()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_default_trait.unwrap_or_default(); + + + let with_default_type = Some(1); with_default_type.unwrap_or(u64::default()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_default_type.unwrap_or_default(); + + + let with_vec = Some(vec![1]); with_vec.unwrap_or(vec![]); - //~^ERROR use of `unwrap_or` - //~|HELP try this + + // FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]); let without_default = Some(Foo); without_default.unwrap_or(Foo::new()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION without_default.unwrap_or_else(Foo::new); + + + let mut map = HashMap::::new(); map.entry(42).or_insert(String::new()); - //~^ERROR use of `or_insert` followed by a function call - //~|HELP try this - //~|SUGGESTION map.entry(42).or_insert_with(String::new); + + + let mut btree = BTreeMap::::new(); btree.entry(42).or_insert(String::new()); - //~^ERROR use of `or_insert` followed by a function call - //~|HELP try this - //~|SUGGESTION btree.entry(42).or_insert_with(String::new); + + + let stringy = Some(String::from("")); let _ = stringy.unwrap_or("".to_owned()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION stringy.unwrap_or_else(|| "".to_owned()); + + + } /// Checks implementation of `ITER_NTH` lint @@ -356,27 +354,27 @@ fn iter_nth() { { // Make sure we lint `.iter()` for relevant types let bad_vec = some_vec.iter().nth(3); - //~^ERROR called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable + let bad_slice = &some_vec[..].iter().nth(3); - //~^ERROR called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable + let bad_boxed_slice = boxed_slice.iter().nth(3); - //~^ERROR called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable + let bad_vec_deque = some_vec_deque.iter().nth(3); - //~^ERROR called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable + } { // Make sure we lint `.iter_mut()` for relevant types let bad_vec = some_vec.iter_mut().nth(3); - //~^ERROR called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable + } { let bad_slice = &some_vec[..].iter_mut().nth(3); - //~^ERROR called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable + } { let bad_vec_deque = some_vec_deque.iter_mut().nth(3); - //~^ERROR called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable + } // Make sure we don't lint for non-relevant types @@ -390,16 +388,16 @@ fn iter_skip_next() { let mut some_vec = vec![0, 1, 2, 3]; let _ = some_vec.iter().skip(42).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let _ = some_vec.iter().cycle().skip(42).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let _ = (1..10).skip(10).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let _ = &some_vec[..].iter().skip(3).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let foo = IteratorFalsePositives { foo : 0 }; let _ = foo.skip(42).next(); @@ -427,50 +425,50 @@ fn get_unwrap() { { // Test `get().unwrap()` let _ = boxed_slice.get(1).unwrap(); - //~^ERROR called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION boxed_slice[1] + + + let _ = some_slice.get(0).unwrap(); - //~^ERROR called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_slice[0] + + + let _ = some_vec.get(0).unwrap(); - //~^ERROR called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_vec[0] + + + let _ = some_vecdeque.get(0).unwrap(); - //~^ERROR called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_vecdeque[0] + + + let _ = some_hashmap.get(&1).unwrap(); - //~^ERROR called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_hashmap[&1] + + + let _ = some_btreemap.get(&1).unwrap(); - //~^ERROR called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_btreemap[&1] + + + let _ = false_positive.get(0).unwrap(); } { // Test `get_mut().unwrap()` *boxed_slice.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut boxed_slice[0] + + + *some_slice.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut some_slice[0] + + + *some_vec.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut some_vec[0] + + + *some_vecdeque.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut some_vecdeque[0] + + + // Check false positives *some_hashmap.get_mut(&1).unwrap() = 'b'; @@ -485,24 +483,24 @@ fn main() { use std::io; let opt = Some(0); - let _ = opt.unwrap(); //~ERROR used unwrap() on an Option + let _ = opt.unwrap(); let res: Result = Ok(0); - let _ = res.unwrap(); //~ERROR used unwrap() on a Result + let _ = res.unwrap(); - res.ok().expect("disaster!"); //~ERROR called `ok().expect()` + res.ok().expect("disaster!"); // the following should not warn, since `expect` isn't implemented unless // the error type implements `Debug` let res2: Result = Ok(0); res2.ok().expect("oh noes!"); let res3: Result>= Ok(0); - res3.ok().expect("whoof"); //~ERROR called `ok().expect()` + res3.ok().expect("whoof"); let res4: Result = Ok(0); - res4.ok().expect("argh"); //~ERROR called `ok().expect()` + res4.ok().expect("argh"); let res5: io::Result = Ok(0); - res5.ok().expect("oops"); //~ERROR called `ok().expect()` + res5.ok().expect("oops"); let res6: Result = Ok(0); - res6.ok().expect("meh"); //~ERROR called `ok().expect()` + res6.ok().expect("meh"); } struct MyError(()); // doesn't implement Debug @@ -515,14 +513,14 @@ struct MyErrorWithParam { #[allow(unnecessary_operation)] fn starts_with() { "".chars().next() == Some(' '); - //~^ ERROR starts_with - //~| HELP like this - //~| SUGGESTION "".starts_with(' ') + + + Some(' ') != "".chars().next(); - //~^ ERROR starts_with - //~| HELP like this - //~| SUGGESTION !"".starts_with(' ') + + + } fn str_extend_chars() { @@ -532,21 +530,21 @@ fn str_extend_chars() { s.push_str(abc); s.extend(abc.chars()); - //~^ERROR calling `.extend(_.chars())` - //~|HELP try this - //~|SUGGESTION s.push_str(abc) + + + s.push_str("abc"); s.extend("abc".chars()); - //~^ERROR calling `.extend(_.chars())` - //~|HELP try this - //~|SUGGESTION s.push_str("abc") + + + s.push_str(&def); s.extend(def.chars()); - //~^ERROR calling `.extend(_.chars())` - //~|HELP try this - //~|SUGGESTION s.push_str(&def) + + + s.extend(abc.chars().skip(1)); s.extend("abc".chars().skip(1)); @@ -557,40 +555,40 @@ fn str_extend_chars() { } fn clone_on_copy() { - 42.clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try removing the `clone` call - //~| SUGGESTION 42 + 42.clone(); + + vec![1].clone(); // ok, not a Copy type Some(vec![1]).clone(); // ok, not a Copy type - (&42).clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try dereferencing it - //~| SUGGESTION *(&42) + (&42).clone(); + + } fn clone_on_copy_generic(t: T) { - t.clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try removing the `clone` call - //~| SUGGESTION t - Some(t).clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try removing the `clone` call - //~| SUGGESTION Some(t) + t.clone(); + + + Some(t).clone(); + + } fn clone_on_double_ref() { let x = vec![1]; let y = &&x; - let z: &Vec<_> = y.clone(); //~ERROR using `clone` on a double - //~| HELP try dereferencing it - //~| SUGGESTION let z: &Vec<_> = (*y).clone(); + let z: &Vec<_> = y.clone(); + + println!("{:p} {:p}",*y, z); } fn single_char_pattern() { let x = "foo"; x.split("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.split('x'); + + + x.split("xx"); @@ -612,69 +610,69 @@ fn single_char_pattern() { x.split("❤️"); x.contains("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.contains('x'); + + + x.starts_with("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.starts_with('x'); + + + x.ends_with("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.ends_with('x'); + + + x.find("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.find('x'); + + + x.rfind("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rfind('x'); + + + x.rsplit("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rsplit('x'); + + + x.split_terminator("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.split_terminator('x'); + + + x.rsplit_terminator("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rsplit_terminator('x'); + + + x.splitn(0, "x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.splitn(0, 'x'); + + + x.rsplitn(0, "x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rsplitn(0, 'x'); + + + x.matches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.matches('x'); + + + x.rmatches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rmatches('x'); + + + x.match_indices("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.match_indices('x'); + + + x.rmatch_indices("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rmatch_indices('x'); + + + x.trim_left_matches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.trim_left_matches('x'); + + + x.trim_right_matches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.trim_right_matches('x'); + + + let h = HashSet::::new(); h.contains("X"); // should not warn @@ -685,7 +683,7 @@ fn temporary_cstring() { use std::ffi::CString; CString::new("foo").unwrap().as_ptr(); - //~^ ERROR you are getting the inner pointer of a temporary `CString` - //~| NOTE that pointer will be invalid outside this expression - //~| HELP assign the `CString` to a variable to extend its lifetime + + + } diff --git a/tests/compile-fail/non_expressive_names.rs b/tests/compile-fail/non_expressive_names.rs index 778041f49..649a5ecb8 100644 --- a/tests/compile-fail/non_expressive_names.rs +++ b/tests/compile-fail/non_expressive_names.rs @@ -1,17 +1,17 @@ #![feature(plugin)] #![plugin(clippy)] #![deny(clippy,similar_names)] -//~^ NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here + + + + + + + + + + + #![allow(unused)] @@ -24,12 +24,12 @@ fn main() { let specter: i32; let spectre: i32; - let apple: i32; //~ NOTE: existing binding defined here - //~^ NOTE: existing binding defined here - let bpple: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `b_pple` - let cpple: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `c_pple` + let apple: i32; + + let bpple: i32; + + let cpple: i32; + let a_bar: i32; let b_bar: i32; @@ -52,13 +52,13 @@ fn main() { let blubrhs: i32; let blublhs: i32; - let blubx: i32; //~ NOTE: existing binding defined here - let bluby: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `blub_y` + let blubx: i32; + let bluby: i32; - let cake: i32; //~ NOTE: existing binding defined here + + let cake: i32; let cakes: i32; - let coke: i32; //~ ERROR: name is too similar + let coke: i32; match 5 { cheese @ 1 => {}, @@ -74,14 +74,14 @@ fn main() { let ipv6: i32; let abcd1: i32; let abdc2: i32; - let xyz1abc: i32; //~ NOTE: existing binding defined here + let xyz1abc: i32; let xyz2abc: i32; - let xyzeabc: i32; //~ ERROR: name is too similar + let xyzeabc: i32; - let parser: i32; //~ NOTE: existing binding defined here + let parser: i32; let parsed: i32; - let parsee: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `parse_e` + let parsee: i32; + let setter: i32; let getter: i32; @@ -93,8 +93,8 @@ fn main() { fn foo() { let Foo { apple, bpple } = unimplemented!(); - let Foo { apple: spring, //~NOTE existing binding defined here - bpple: sprang } = unimplemented!(); //~ ERROR: name is too similar + let Foo { apple: spring, + bpple: sprang } = unimplemented!(); } #[derive(Clone, Debug)] @@ -128,19 +128,19 @@ fn bla() { let blar: i32; } { - let e: i32; //~ ERROR: 5th binding whose name is just one char - //~^ NOTE implied by + let e: i32; + } { - let e: i32; //~ ERROR: 5th binding whose name is just one char - //~^ NOTE implied by - let f: i32; //~ ERROR: 6th binding whose name is just one char - //~^ NOTE implied by + let e: i32; + + let f: i32; + } match 5 { 1 => println!(""), - e => panic!(), //~ ERROR: 5th binding whose name is just one char - //~^ NOTE implied by + e => panic!(), + } match 5 { 1 => println!(""), diff --git a/tests/compile-fail/strings.rs b/tests/compile-fail/strings.rs index 7cfc8a41e..f893d9949 100644 --- a/tests/compile-fail/strings.rs +++ b/tests/compile-fail/strings.rs @@ -7,11 +7,11 @@ fn add_only() { // ignores assignment distinction let mut x = "".to_owned(); for _ in 1..3 { - x = x + "."; //~ERROR you added something to a string. + x = x + "."; } let y = "".to_owned(); - let z = y + "..."; //~ERROR you added something to a string. + let z = y + "..."; assert_eq!(&x, &z); } @@ -21,7 +21,7 @@ fn add_assign_only() { let mut x = "".to_owned(); for _ in 1..3 { - x = x + "."; //~ERROR you assigned the result of adding something to this string. + x = x + "."; } let y = "".to_owned(); @@ -35,11 +35,11 @@ fn both() { let mut x = "".to_owned(); for _ in 1..3 { - x = x + "."; //~ERROR you assigned the result of adding something to this string. + x = x + "."; } let y = "".to_owned(); - let z = y + "..."; //~ERROR you added something to a string. + let z = y + "..."; assert_eq!(&x, &z); } @@ -48,9 +48,9 @@ fn both() { #[deny(string_lit_as_bytes)] fn str_lit_as_bytes() { let bs = "hello there".as_bytes(); - //~^ERROR calling `as_bytes()` - //~|HELP byte string literal - //~|SUGGESTION b"hello there" + + + // no warning, because this cannot be written as a byte string literal: let ubs = "☃".as_bytes(); @@ -66,8 +66,8 @@ fn main() { // the add is only caught for `String` let mut x = 1; ; x = x + 1; - //~^ WARN manual implementation of an assign operation - //~| HELP replace - //~| SUGGESTION ; x += 1; + + + assert_eq!(2, x); } diff --git a/tests/compile-fail/swap.rs b/tests/compile-fail/swap.rs index 0e56d5ca8..95478dda0 100644 --- a/tests/compile-fail/swap.rs +++ b/tests/compile-fail/swap.rs @@ -8,36 +8,36 @@ struct Foo(u32); fn array() { let mut foo = [1, 2]; - let temp = foo[0]; //~ NOTE implied by + let temp = foo[0]; foo[0] = foo[1]; foo[1] = temp; - //~^^^ ERROR this looks like you are swapping elements of `foo` manually - //~| HELP try - //~| SUGGESTION foo.swap(0, 1); + + + foo.swap(0, 1); } fn slice() { let foo = &mut [1, 2]; - let temp = foo[0]; //~ NOTE implied by + let temp = foo[0]; foo[0] = foo[1]; foo[1] = temp; - //~^^^ ERROR this looks like you are swapping elements of `foo` manually - //~| HELP try - //~| SUGGESTION foo.swap(0, 1); + + + foo.swap(0, 1); } fn vec() { let mut foo = vec![1, 2]; - let temp = foo[0]; //~ NOTE implied by + let temp = foo[0]; foo[0] = foo[1]; foo[1] = temp; - //~^^^ ERROR this looks like you are swapping elements of `foo` manually - //~| HELP try - //~| SUGGESTION foo.swap(0, 1); + + + foo.swap(0, 1); } @@ -50,35 +50,35 @@ fn main() { let mut a = 42; let mut b = 1337; - a = b; //~ NOTE implied by + a = b; b = a; - //~^^ ERROR this looks like you are trying to swap `a` and `b` - //~| HELP try - //~| SUGGESTION std::mem::swap(&mut a, &mut b); - //~| NOTE or maybe you should use `std::mem::replace`? - ; let t = a; //~ NOTE implied by + + + + + ; let t = a; a = b; b = t; - //~^^^ ERROR this looks like you are swapping `a` and `b` manually - //~| HELP try - //~| SUGGESTION ; std::mem::swap(&mut a, &mut b); - //~| NOTE or maybe you should use `std::mem::replace`? + + + + let mut c = Foo(42); - c.0 = a; //~ NOTE implied by + c.0 = a; a = c.0; - //~^^ ERROR this looks like you are trying to swap `c.0` and `a` - //~| HELP try - //~| SUGGESTION std::mem::swap(&mut c.0, &mut a); - //~| NOTE or maybe you should use `std::mem::replace`? - ; let t = c.0; //~ NOTE implied by + + + + + ; let t = c.0; c.0 = a; a = t; - //~^^^ ERROR this looks like you are swapping `c.0` and `a` manually - //~| HELP try - //~| SUGGESTION ; std::mem::swap(&mut c.0, &mut a); - //~| NOTE or maybe you should use `std::mem::replace`? + + + + } diff --git a/tests/run-pass/deprecated.rs b/tests/run-pass/deprecated.rs index 670b096ea..e0c856e3d 100644 --- a/tests/run-pass/deprecated.rs +++ b/tests/run-pass/deprecated.rs @@ -2,11 +2,11 @@ #![plugin(clippy)] #[warn(str_to_string)] -//~^WARNING: lint str_to_string has been removed: using `str::to_string` + #[warn(string_to_string)] -//~^WARNING: lint string_to_string has been removed: using `string::to_string` + #[warn(unstable_as_slice)] -//~^WARNING: lint unstable_as_slice has been removed: `Vec::as_slice` has been stabilized + #[warn(unstable_as_mut_slice)] -//~^WARNING: lint unstable_as_mut_slice has been removed: `Vec::as_mut_slice` has been stabilized + fn main() {} diff --git a/tests/ui/absurd-extreme-comparisons.rs b/tests/ui/absurd-extreme-comparisons.rs index cf69473bb..495dd27bb 100644 --- a/tests/ui/absurd-extreme-comparisons.rs +++ b/tests/ui/absurd-extreme-comparisons.rs @@ -10,66 +10,66 @@ fn main() { let u: u32 = 42; u <= 0; - //~^ ERROR this comparison involving the minimum or maximum element for this type contains a - //~| HELP using u == 0 instead + + u <= Z; - //~^ ERROR this comparison involving - //~| HELP using u == Z instead + + u < Z; - //~^ ERROR this comparison involving - //~| HELP comparison is always false + + Z >= u; - //~^ ERROR this comparison involving - //~| HELP using Z == u instead + + Z > u; - //~^ ERROR this comparison involving - //~| HELP comparison is always false + + u > std::u32::MAX; - //~^ ERROR this comparison involving - //~| HELP comparison is always false + + u >= std::u32::MAX; - //~^ ERROR this comparison involving - //~| HELP using u == std::u32::MAX instead + + std::u32::MAX < u; - //~^ ERROR this comparison involving - //~| HELP comparison is always false + + std::u32::MAX <= u; - //~^ ERROR this comparison involving - //~| HELP using std::u32::MAX == u instead + + 1-1 > u; - //~^ ERROR this comparison involving - //~| HELP because 1-1 is the minimum value for this type, this comparison is always false + + u >= !0; - //~^ ERROR this comparison involving - //~| HELP consider using u == !0 instead + + u <= 12 - 2*6; - //~^ ERROR this comparison involving - //~| HELP consider using u == 12 - 2*6 instead + + let i: i8 = 0; i < -127 - 1; - //~^ ERROR this comparison involving - //~| HELP comparison is always false + + std::i8::MAX >= i; - //~^ ERROR this comparison involving - //~| HELP comparison is always true + + 3-7 < std::i32::MIN; - //~^ ERROR this comparison involving - //~| HELP comparison is always false + + let b = false; b >= true; - //~^ ERROR this comparison involving - //~| HELP using b == true instead + + false > b; - //~^ ERROR this comparison involving - //~| HELP comparison is always false + + u > 0; // ok // this is handled by unit_cmp - () < {}; //~WARNING <-comparison of unit values detected. + () < {}; } use std::cmp::{Ordering, PartialEq, PartialOrd}; diff --git a/tests/ui/absurd-extreme-comparisons.stderr b/tests/ui/absurd-extreme-comparisons.stderr index ba3b6a248..834bcf03f 100644 --- a/tests/ui/absurd-extreme-comparisons.stderr +++ b/tests/ui/absurd-extreme-comparisons.stderr @@ -142,7 +142,7 @@ error: this comparison involving the minimum or maximum element for this type co warning: <-comparison of unit values detected. This will always be false --> $DIR/absurd-extreme-comparisons.rs:72:5 | -72 | () < {}; //~WARNING <-comparison of unit values detected. +72 | () < {}; | ^^^^^^^ | = note: #[warn(unit_cmp)] on by default diff --git a/tests/ui/approx_const.rs b/tests/ui/approx_const.rs index 2240c3799..2da762725 100644 --- a/tests/ui/approx_const.rs +++ b/tests/ui/approx_const.rs @@ -4,54 +4,54 @@ #[deny(approx_constant)] #[allow(unused, shadow_unrelated, similar_names)] fn main() { - let my_e = 2.7182; //~ERROR approximate value of `f{32, 64}::consts::E` found - let almost_e = 2.718; //~ERROR approximate value of `f{32, 64}::consts::E` found + let my_e = 2.7182; + let almost_e = 2.718; let no_e = 2.71; - let my_1_frac_pi = 0.3183; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_PI` found + let my_1_frac_pi = 0.3183; let no_1_frac_pi = 0.31; - let my_frac_1_sqrt_2 = 0.70710678; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found - let almost_frac_1_sqrt_2 = 0.70711; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found + let my_frac_1_sqrt_2 = 0.70710678; + let almost_frac_1_sqrt_2 = 0.70711; let my_frac_1_sqrt_2 = 0.707; - let my_frac_2_pi = 0.63661977; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_PI` found + let my_frac_2_pi = 0.63661977; let no_frac_2_pi = 0.636; - let my_frac_2_sq_pi = 1.128379; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found + let my_frac_2_sq_pi = 1.128379; let no_frac_2_sq_pi = 1.128; - let my_frac_pi_2 = 1.57079632679; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_2` found + let my_frac_pi_2 = 1.57079632679; let no_frac_pi_2 = 1.5705; - let my_frac_pi_3 = 1.04719755119; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_3` found + let my_frac_pi_3 = 1.04719755119; let no_frac_pi_3 = 1.047; - let my_frac_pi_4 = 0.785398163397; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_4` found + let my_frac_pi_4 = 0.785398163397; let no_frac_pi_4 = 0.785; - let my_frac_pi_6 = 0.523598775598; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_6` found + let my_frac_pi_6 = 0.523598775598; let no_frac_pi_6 = 0.523; - let my_frac_pi_8 = 0.3926990816987; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_8` found + let my_frac_pi_8 = 0.3926990816987; let no_frac_pi_8 = 0.392; - let my_ln_10 = 2.302585092994046; //~ERROR approximate value of `f{32, 64}::consts::LN_10` found + let my_ln_10 = 2.302585092994046; let no_ln_10 = 2.303; - let my_ln_2 = 0.6931471805599453; //~ERROR approximate value of `f{32, 64}::consts::LN_2` found + let my_ln_2 = 0.6931471805599453; let no_ln_2 = 0.693; - let my_log10_e = 0.43429448190325182; //~ERROR approximate value of `f{32, 64}::consts::LOG10_E` found + let my_log10_e = 0.43429448190325182; let no_log10_e = 0.434; - let my_log2_e = 1.4426950408889634; //~ERROR approximate value of `f{32, 64}::consts::LOG2_E` found + let my_log2_e = 1.4426950408889634; let no_log2_e = 1.442; - let my_pi = 3.1415; //~ERROR approximate value of `f{32, 64}::consts::PI` found - let almost_pi = 3.14; //~ERROR approximate value of `f{32, 64}::consts::PI` found + let my_pi = 3.1415; + let almost_pi = 3.14; let no_pi = 3.15; - let my_sq2 = 1.4142; //~ERROR approximate value of `f{32, 64}::consts::SQRT_2` found + let my_sq2 = 1.4142; let no_sq2 = 1.414; } diff --git a/tests/ui/approx_const.stderr b/tests/ui/approx_const.stderr index 9f5a91074..cc0408fb2 100644 --- a/tests/ui/approx_const.stderr +++ b/tests/ui/approx_const.stderr @@ -1,7 +1,7 @@ error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly --> $DIR/approx_const.rs:7:16 | -7 | let my_e = 2.7182; //~ERROR approximate value of `f{32, 64}::consts::E` found +7 | let my_e = 2.7182; | ^^^^^^ | note: lint level defined here @@ -13,109 +13,109 @@ note: lint level defined here error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly --> $DIR/approx_const.rs:8:20 | -8 | let almost_e = 2.718; //~ERROR approximate value of `f{32, 64}::consts::E` found +8 | 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:11:24 | -11 | let my_1_frac_pi = 0.3183; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_PI` found +11 | 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:14:28 | -14 | let my_frac_1_sqrt_2 = 0.70710678; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found +14 | 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:15:32 | -15 | let almost_frac_1_sqrt_2 = 0.70711; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found +15 | 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:18:24 | -18 | let my_frac_2_pi = 0.63661977; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_PI` found +18 | 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:21:27 | -21 | let my_frac_2_sq_pi = 1.128379; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found +21 | 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:24:24 | -24 | let my_frac_pi_2 = 1.57079632679; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_2` found +24 | 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:27:24 | -27 | let my_frac_pi_3 = 1.04719755119; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_3` found +27 | 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:30:24 | -30 | let my_frac_pi_4 = 0.785398163397; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_4` found +30 | 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:33:24 | -33 | let my_frac_pi_6 = 0.523598775598; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_6` found +33 | 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:36:24 | -36 | let my_frac_pi_8 = 0.3926990816987; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_8` found +36 | 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:39:20 | -39 | let my_ln_10 = 2.302585092994046; //~ERROR approximate value of `f{32, 64}::consts::LN_10` found +39 | 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:42:19 | -42 | let my_ln_2 = 0.6931471805599453; //~ERROR approximate value of `f{32, 64}::consts::LN_2` found +42 | 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:45:22 | -45 | let my_log10_e = 0.43429448190325182; //~ERROR approximate value of `f{32, 64}::consts::LOG10_E` found +45 | let my_log10_e = 0.43429448190325182; | ^^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::LOG2_E` found. Consider using it directly --> $DIR/approx_const.rs:48:21 | -48 | let my_log2_e = 1.4426950408889634; //~ERROR approximate value of `f{32, 64}::consts::LOG2_E` found +48 | let my_log2_e = 1.4426950408889634; | ^^^^^^^^^^^^^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly --> $DIR/approx_const.rs:51:17 | -51 | let my_pi = 3.1415; //~ERROR approximate value of `f{32, 64}::consts::PI` found +51 | let my_pi = 3.1415; | ^^^^^^ error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly --> $DIR/approx_const.rs:52:21 | -52 | let almost_pi = 3.14; //~ERROR approximate value of `f{32, 64}::consts::PI` found +52 | let almost_pi = 3.14; | ^^^^ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it directly --> $DIR/approx_const.rs:55:18 | -55 | let my_sq2 = 1.4142; //~ERROR approximate value of `f{32, 64}::consts::SQRT_2` found +55 | let my_sq2 = 1.4142; | ^^^^^^ error: aborting due to 19 previous errors diff --git a/tests/ui/arithmetic.rs b/tests/ui/arithmetic.rs index 5479c55e1..b4014cc48 100644 --- a/tests/ui/arithmetic.rs +++ b/tests/ui/arithmetic.rs @@ -5,12 +5,12 @@ #![allow(unused, shadow_reuse, shadow_unrelated, no_effect, unnecessary_operation)] fn main() { let i = 1i32; - 1 + i; //~ERROR integer arithmetic detected - i * 2; //~ERROR integer arithmetic detected - 1 % //~ERROR integer arithmetic detected + 1 + i; + i * 2; + 1 % i / 2; // no error, this is part of the expression in the preceding line - i - 2 + 2 - i; //~ERROR integer arithmetic detected - -i; //~ERROR integer arithmetic detected + i - 2 + 2 - i; + -i; i & 1; // no wrapping i | 1; @@ -20,11 +20,11 @@ fn main() { let f = 1.0f32; - f * 2.0; //~ERROR floating-point arithmetic detected + f * 2.0; - 1.0 + f; //~ERROR floating-point arithmetic detected - f * 2.0; //~ERROR floating-point arithmetic detected - f / 2.0; //~ERROR floating-point arithmetic detected - f - 2.0 * 4.2; //~ERROR floating-point arithmetic detected - -f; //~ERROR floating-point arithmetic detected + 1.0 + f; + f * 2.0; + f / 2.0; + f - 2.0 * 4.2; + -f; } diff --git a/tests/ui/arithmetic.stderr b/tests/ui/arithmetic.stderr index 1c333bfdc..4f68b50cc 100644 --- a/tests/ui/arithmetic.stderr +++ b/tests/ui/arithmetic.stderr @@ -1,7 +1,7 @@ error: integer arithmetic detected --> $DIR/arithmetic.rs:8:5 | -8 | 1 + i; //~ERROR integer arithmetic detected +8 | 1 + i; | ^^^^^ | note: lint level defined here @@ -13,13 +13,13 @@ note: lint level defined here error: integer arithmetic detected --> $DIR/arithmetic.rs:9:5 | -9 | i * 2; //~ERROR integer arithmetic detected +9 | i * 2; | ^^^^^ error: integer arithmetic detected --> $DIR/arithmetic.rs:10:5 | -10 | 1 % //~ERROR integer arithmetic detected +10 | 1 % | _____^ starting here... 11 | | i / 2; // no error, this is part of the expression in the preceding line | |_________^ ...ending here @@ -27,19 +27,19 @@ error: integer arithmetic detected error: integer arithmetic detected --> $DIR/arithmetic.rs:12:5 | -12 | i - 2 + 2 - i; //~ERROR integer arithmetic detected +12 | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: integer arithmetic detected --> $DIR/arithmetic.rs:13:5 | -13 | -i; //~ERROR integer arithmetic detected +13 | -i; | ^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:23:5 | -23 | f * 2.0; //~ERROR floating-point arithmetic detected +23 | f * 2.0; | ^^^^^^^ | note: lint level defined here @@ -51,31 +51,31 @@ note: lint level defined here error: floating-point arithmetic detected --> $DIR/arithmetic.rs:25:5 | -25 | 1.0 + f; //~ERROR floating-point arithmetic detected +25 | 1.0 + f; | ^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:26:5 | -26 | f * 2.0; //~ERROR floating-point arithmetic detected +26 | f * 2.0; | ^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:27:5 | -27 | f / 2.0; //~ERROR floating-point arithmetic detected +27 | f / 2.0; | ^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:28:5 | -28 | f - 2.0 * 4.2; //~ERROR floating-point arithmetic detected +28 | f - 2.0 * 4.2; | ^^^^^^^^^^^^^ error: floating-point arithmetic detected --> $DIR/arithmetic.rs:29:5 | -29 | -f; //~ERROR floating-point arithmetic detected +29 | -f; | ^^ error: aborting due to 11 previous errors diff --git a/tests/ui/array_indexing.rs b/tests/ui/array_indexing.rs index c69144fe2..28b4c78b4 100644 --- a/tests/ui/array_indexing.rs +++ b/tests/ui/array_indexing.rs @@ -9,37 +9,37 @@ fn main() { let x = [1,2,3,4]; x[0]; x[3]; - x[4]; //~ERROR: const index is out of bounds - x[1 << 3]; //~ERROR: const index is out of bounds - &x[1..5]; //~ERROR: range is out of bounds + x[4]; + x[1 << 3]; + &x[1..5]; &x[0..3]; - &x[0...4]; //~ERROR: range is out of bounds - &x[...4]; //~ERROR: range is out of bounds + &x[0...4]; + &x[...4]; &x[..]; &x[1..]; &x[4..]; - &x[5..]; //~ERROR: range is out of bounds + &x[5..]; &x[..4]; - &x[..5]; //~ERROR: range is out of bounds + &x[..5]; let y = &x; - y[0]; //~ERROR: indexing may panic - &y[1..2]; //~ERROR: slicing may panic + y[0]; + &y[1..2]; &y[..]; - &y[0...4]; //~ERROR: slicing may panic - &y[...4]; //~ERROR: slicing may panic + &y[0...4]; + &y[...4]; let empty: [i8; 0] = []; - empty[0]; //~ERROR: const index is out of bounds - &empty[1..5]; //~ERROR: range is out of bounds - &empty[0...4]; //~ERROR: range is out of bounds - &empty[...4]; //~ERROR: range is out of bounds + empty[0]; + &empty[1..5]; + &empty[0...4]; + &empty[...4]; &empty[..]; &empty[0..]; &empty[0..0]; - &empty[0...0]; //~ERROR: range is out of bounds - &empty[...0]; //~ERROR: range is out of bounds + &empty[0...0]; + &empty[...0]; &empty[..0]; - &empty[1..]; //~ERROR: range is out of bounds - &empty[..4]; //~ERROR: range is out of bounds + &empty[1..]; + &empty[..4]; } diff --git a/tests/ui/array_indexing.stderr b/tests/ui/array_indexing.stderr index 3eba56d35..0650866cc 100644 --- a/tests/ui/array_indexing.stderr +++ b/tests/ui/array_indexing.stderr @@ -1,7 +1,7 @@ error: const index is out of bounds --> $DIR/array_indexing.rs:12:5 | -12 | x[4]; //~ERROR: const index is out of bounds +12 | x[4]; | ^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -9,7 +9,7 @@ error: const index is out of bounds error: const index is out of bounds --> $DIR/array_indexing.rs:13:5 | -13 | x[1 << 3]; //~ERROR: const index is out of bounds +13 | x[1 << 3]; | ^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -17,7 +17,7 @@ error: const index is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:14:6 | -14 | &x[1..5]; //~ERROR: range is out of bounds +14 | &x[1..5]; | ^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -25,7 +25,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:16:6 | -16 | &x[0...4]; //~ERROR: range is out of bounds +16 | &x[0...4]; | ^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -33,7 +33,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:17:6 | -17 | &x[...4]; //~ERROR: range is out of bounds +17 | &x[...4]; | ^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -41,7 +41,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:21:6 | -21 | &x[5..]; //~ERROR: range is out of bounds +21 | &x[5..]; | ^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -49,7 +49,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:23:6 | -23 | &x[..5]; //~ERROR: range is out of bounds +23 | &x[..5]; | ^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -57,7 +57,7 @@ error: range is out of bounds error: indexing may panic --> $DIR/array_indexing.rs:26:5 | -26 | y[0]; //~ERROR: indexing may panic +26 | y[0]; | ^^^^ | note: lint level defined here @@ -69,25 +69,25 @@ note: lint level defined here error: slicing may panic --> $DIR/array_indexing.rs:27:6 | -27 | &y[1..2]; //~ERROR: slicing may panic +27 | &y[1..2]; | ^^^^^^^ error: slicing may panic --> $DIR/array_indexing.rs:29:6 | -29 | &y[0...4]; //~ERROR: slicing may panic +29 | &y[0...4]; | ^^^^^^^^ error: slicing may panic --> $DIR/array_indexing.rs:30:6 | -30 | &y[...4]; //~ERROR: slicing may panic +30 | &y[...4]; | ^^^^^^^ error: const index is out of bounds --> $DIR/array_indexing.rs:33:5 | -33 | empty[0]; //~ERROR: const index is out of bounds +33 | empty[0]; | ^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -95,7 +95,7 @@ error: const index is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:34:6 | -34 | &empty[1..5]; //~ERROR: range is out of bounds +34 | &empty[1..5]; | ^^^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -103,7 +103,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:35:6 | -35 | &empty[0...4]; //~ERROR: range is out of bounds +35 | &empty[0...4]; | ^^^^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -111,7 +111,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:36:6 | -36 | &empty[...4]; //~ERROR: range is out of bounds +36 | &empty[...4]; | ^^^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -119,7 +119,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:40:6 | -40 | &empty[0...0]; //~ERROR: range is out of bounds +40 | &empty[0...0]; | ^^^^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -127,7 +127,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:41:6 | -41 | &empty[...0]; //~ERROR: range is out of bounds +41 | &empty[...0]; | ^^^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -135,7 +135,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:43:6 | -43 | &empty[1..]; //~ERROR: range is out of bounds +43 | &empty[1..]; | ^^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default @@ -143,7 +143,7 @@ error: range is out of bounds error: range is out of bounds --> $DIR/array_indexing.rs:44:6 | -44 | &empty[..4]; //~ERROR: range is out of bounds +44 | &empty[..4]; | ^^^^^^^^^^ | = note: #[deny(out_of_bounds_indexing)] on by default diff --git a/tests/ui/assign_ops.rs b/tests/ui/assign_ops.rs index 2b69e110f..78f9dc0d0 100644 --- a/tests/ui/assign_ops.rs +++ b/tests/ui/assign_ops.rs @@ -5,77 +5,77 @@ #[allow(unused_assignments)] fn main() { let mut i = 1i32; - i += 2; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i + 2 - i += 2 + 17; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i + 2 + 17 - i -= 6; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i - 6 + i += 2; + + + i += 2 + 17; + + + i -= 6; + + i -= 2 - 1; - //~^ ERROR assign operation detected - //~| HELP replace it with - //~| SUGGESTION i = i - (2 - 1) - i *= 5; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i * 5 - i *= 1+5; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i * (1+5) - i /= 32; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i / 32 - i /= 32 | 5; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i / (32 | 5) - i /= 32 / 5; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i / (32 / 5) - i %= 42; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i % 42 - i >>= i; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i >> i - i <<= 9 + 6 - 7; //~ ERROR assign operation detected - //~^ HELP replace it with - //~| SUGGESTION i = i << (9 + 6 - 7) + + + + i *= 5; + + + i *= 1+5; + + + i /= 32; + + + i /= 32 | 5; + + + i /= 32 / 5; + + + i %= 42; + + + i >>= i; + + + i <<= 9 + 6 - 7; + + i += 1 << 5; - //~^ ERROR assign operation detected - //~| HELP replace it with - //~| SUGGESTION i = i + (1 << 5) + + + } #[allow(dead_code, unused_assignments)] #[deny(assign_op_pattern)] fn bla() { let mut a = 5; - a = a + 1; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a += 1 - a = 1 + a; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a += 1 - a = a - 1; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a -= 1 - a = a * 99; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a *= 99 - a = 42 * a; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a *= 42 - a = a / 2; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a /= 2 - a = a % 5; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a %= 5 - a = a & 1; //~ ERROR manual implementation of an assign operation - //~^ HELP replace it with - //~| SUGGESTION a &= 1 + a = a + 1; + + + a = 1 + a; + + + a = a - 1; + + + a = a * 99; + + + a = 42 * a; + + + a = a / 2; + + + a = a % 5; + + + a = a & 1; + + a = 1 - a; a = 5 / a; a = 42 % a; diff --git a/tests/ui/assign_ops.stderr b/tests/ui/assign_ops.stderr index 61efd362a..8ce2ae375 100644 --- a/tests/ui/assign_ops.stderr +++ b/tests/ui/assign_ops.stderr @@ -1,7 +1,7 @@ error: assign operation detected --> $DIR/assign_ops.rs:8:5 | -8 | i += 2; //~ ERROR assign operation detected +8 | i += 2; | ^^^^^^ | note: lint level defined here @@ -10,25 +10,25 @@ note: lint level defined here 4 | #[deny(assign_ops)] | ^^^^^^^^^^ help: replace it with - | i = i + 2; //~ ERROR assign operation detected + | i = i + 2; error: assign operation detected --> $DIR/assign_ops.rs:11:5 | -11 | i += 2 + 17; //~ ERROR assign operation detected +11 | i += 2 + 17; | ^^^^^^^^^^^ | help: replace it with - | i = i + 2 + 17; //~ ERROR assign operation detected + | i = i + 2 + 17; error: assign operation detected --> $DIR/assign_ops.rs:14:5 | -14 | i -= 6; //~ ERROR assign operation detected +14 | i -= 6; | ^^^^^^ | help: replace it with - | i = i - 6; //~ ERROR assign operation detected + | i = i - 6; error: assign operation detected --> $DIR/assign_ops.rs:17:5 @@ -42,74 +42,74 @@ help: replace it with error: assign operation detected --> $DIR/assign_ops.rs:21:5 | -21 | i *= 5; //~ ERROR assign operation detected +21 | i *= 5; | ^^^^^^ | help: replace it with - | i = i * 5; //~ ERROR assign operation detected + | i = i * 5; error: assign operation detected --> $DIR/assign_ops.rs:24:5 | -24 | i *= 1+5; //~ ERROR assign operation detected +24 | i *= 1+5; | ^^^^^^^^ | help: replace it with - | i = i * (1+5); //~ ERROR assign operation detected + | i = i * (1+5); error: assign operation detected --> $DIR/assign_ops.rs:27:5 | -27 | i /= 32; //~ ERROR assign operation detected +27 | i /= 32; | ^^^^^^^ | help: replace it with - | i = i / 32; //~ ERROR assign operation detected + | i = i / 32; error: assign operation detected --> $DIR/assign_ops.rs:30:5 | -30 | i /= 32 | 5; //~ ERROR assign operation detected +30 | i /= 32 | 5; | ^^^^^^^^^^^ | help: replace it with - | i = i / (32 | 5); //~ ERROR assign operation detected + | i = i / (32 | 5); error: assign operation detected --> $DIR/assign_ops.rs:33:5 | -33 | i /= 32 / 5; //~ ERROR assign operation detected +33 | i /= 32 / 5; | ^^^^^^^^^^^ | help: replace it with - | i = i / (32 / 5); //~ ERROR assign operation detected + | i = i / (32 / 5); error: assign operation detected --> $DIR/assign_ops.rs:36:5 | -36 | i %= 42; //~ ERROR assign operation detected +36 | i %= 42; | ^^^^^^^ | help: replace it with - | i = i % 42; //~ ERROR assign operation detected + | i = i % 42; error: assign operation detected --> $DIR/assign_ops.rs:39:5 | -39 | i >>= i; //~ ERROR assign operation detected +39 | i >>= i; | ^^^^^^^ | help: replace it with - | i = i >> i; //~ ERROR assign operation detected + | i = i >> i; error: assign operation detected --> $DIR/assign_ops.rs:42:5 | -42 | i <<= 9 + 6 - 7; //~ ERROR assign operation detected +42 | i <<= 9 + 6 - 7; | ^^^^^^^^^^^^^^^ | help: replace it with - | i = i << (9 + 6 - 7); //~ ERROR assign operation detected + | i = i << (9 + 6 - 7); error: assign operation detected --> $DIR/assign_ops.rs:45:5 @@ -123,7 +123,7 @@ help: replace it with error: manual implementation of an assign operation --> $DIR/assign_ops.rs:55:5 | -55 | a = a + 1; //~ ERROR manual implementation of an assign operation +55 | a = a + 1; | ^^^^^^^^^ | note: lint level defined here @@ -132,70 +132,70 @@ note: lint level defined here 52 | #[deny(assign_op_pattern)] | ^^^^^^^^^^^^^^^^^ help: replace it with - | a += 1; //~ ERROR manual implementation of an assign operation + | a += 1; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:58:5 | -58 | a = 1 + a; //~ ERROR manual implementation of an assign operation +58 | a = 1 + a; | ^^^^^^^^^ | help: replace it with - | a += 1; //~ ERROR manual implementation of an assign operation + | a += 1; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:61:5 | -61 | a = a - 1; //~ ERROR manual implementation of an assign operation +61 | a = a - 1; | ^^^^^^^^^ | help: replace it with - | a -= 1; //~ ERROR manual implementation of an assign operation + | a -= 1; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:64:5 | -64 | a = a * 99; //~ ERROR manual implementation of an assign operation +64 | a = a * 99; | ^^^^^^^^^^ | help: replace it with - | a *= 99; //~ ERROR manual implementation of an assign operation + | a *= 99; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:67:5 | -67 | a = 42 * a; //~ ERROR manual implementation of an assign operation +67 | a = 42 * a; | ^^^^^^^^^^ | help: replace it with - | a *= 42; //~ ERROR manual implementation of an assign operation + | a *= 42; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:70:5 | -70 | a = a / 2; //~ ERROR manual implementation of an assign operation +70 | a = a / 2; | ^^^^^^^^^ | help: replace it with - | a /= 2; //~ ERROR manual implementation of an assign operation + | a /= 2; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:73:5 | -73 | a = a % 5; //~ ERROR manual implementation of an assign operation +73 | a = a % 5; | ^^^^^^^^^ | help: replace it with - | a %= 5; //~ ERROR manual implementation of an assign operation + | a %= 5; error: manual implementation of an assign operation --> $DIR/assign_ops.rs:76:5 | -76 | a = a & 1; //~ ERROR manual implementation of an assign operation +76 | a = a & 1; | ^^^^^^^^^ | help: replace it with - | a &= 1; //~ ERROR manual implementation of an assign operation + | a &= 1; error: aborting due to 21 previous errors diff --git a/tests/ui/assign_ops2.rs b/tests/ui/assign_ops2.rs index e8549c01b..3071cce16 100644 --- a/tests/ui/assign_ops2.rs +++ b/tests/ui/assign_ops2.rs @@ -5,30 +5,30 @@ #[deny(misrefactored_assign_op)] fn main() { let mut a = 5; - a += a + 1; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a += 1 - a += 1 + a; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a += 1 - a -= a - 1; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a -= 1 - a *= a * 99; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a *= 99 - a *= 42 * a; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a *= 42 - a /= a / 2; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a /= 2 - a %= a % 5; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a %= 5 - a &= a & 1; //~ ERROR variable appears on both sides of an assignment operation - //~^ HELP replace it with - //~| SUGGESTION a &= 1 + a += a + 1; + + + a += 1 + a; + + + a -= a - 1; + + + a *= a * 99; + + + a *= 42 * a; + + + a /= a / 2; + + + a %= a % 5; + + + a &= a & 1; + + a -= 1 - a; a /= 5 / a; a %= 42 % a; diff --git a/tests/ui/assign_ops2.stderr b/tests/ui/assign_ops2.stderr index 98968fe8d..ded39d1ef 100644 --- a/tests/ui/assign_ops2.stderr +++ b/tests/ui/assign_ops2.stderr @@ -1,7 +1,7 @@ error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:8:5 | -8 | a += a + 1; //~ ERROR variable appears on both sides of an assignment operation +8 | a += a + 1; | ^^^^^^^^^^ | note: lint level defined here @@ -10,70 +10,70 @@ note: lint level defined here 5 | #[deny(misrefactored_assign_op)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with - | a += 1; //~ ERROR variable appears on both sides of an assignment operation + | a += 1; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:11:5 | -11 | a += 1 + a; //~ ERROR variable appears on both sides of an assignment operation +11 | a += 1 + a; | ^^^^^^^^^^ | help: replace it with - | a += 1; //~ ERROR variable appears on both sides of an assignment operation + | a += 1; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:14:5 | -14 | a -= a - 1; //~ ERROR variable appears on both sides of an assignment operation +14 | a -= a - 1; | ^^^^^^^^^^ | help: replace it with - | a -= 1; //~ ERROR variable appears on both sides of an assignment operation + | a -= 1; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:17:5 | -17 | a *= a * 99; //~ ERROR variable appears on both sides of an assignment operation +17 | a *= a * 99; | ^^^^^^^^^^^ | help: replace it with - | a *= 99; //~ ERROR variable appears on both sides of an assignment operation + | a *= 99; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:20:5 | -20 | a *= 42 * a; //~ ERROR variable appears on both sides of an assignment operation +20 | a *= 42 * a; | ^^^^^^^^^^^ | help: replace it with - | a *= 42; //~ ERROR variable appears on both sides of an assignment operation + | a *= 42; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:23:5 | -23 | a /= a / 2; //~ ERROR variable appears on both sides of an assignment operation +23 | a /= a / 2; | ^^^^^^^^^^ | help: replace it with - | a /= 2; //~ ERROR variable appears on both sides of an assignment operation + | a /= 2; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:26:5 | -26 | a %= a % 5; //~ ERROR variable appears on both sides of an assignment operation +26 | a %= a % 5; | ^^^^^^^^^^ | help: replace it with - | a %= 5; //~ ERROR variable appears on both sides of an assignment operation + | a %= 5; error: variable appears on both sides of an assignment operation --> $DIR/assign_ops2.rs:29:5 | -29 | a &= a & 1; //~ ERROR variable appears on both sides of an assignment operation +29 | a &= a & 1; | ^^^^^^^^^^ | help: replace it with - | a &= 1; //~ ERROR variable appears on both sides of an assignment operation + | a &= 1; error: aborting due to 8 previous errors diff --git a/tests/ui/attrs.rs b/tests/ui/attrs.rs index 314602b2b..50dddb838 100644 --- a/tests/ui/attrs.rs +++ b/tests/ui/attrs.rs @@ -3,7 +3,7 @@ #![deny(inline_always, deprecated_semver)] -#[inline(always)] //~ERROR you have declared `#[inline(always)]` on `test_attr_lint`. +#[inline(always)] fn test_attr_lint() { assert!(true) } @@ -24,10 +24,10 @@ fn empty_and_false_positive_stmt() { unreachable!(); } -#[deprecated(since = "forever")] //~ERROR the since field must contain a semver-compliant version +#[deprecated(since = "forever")] pub const SOME_CONST : u8 = 42; -#[deprecated(since = "1")] //~ERROR the since field must contain a semver-compliant version +#[deprecated(since = "1")] pub const ANOTHER_CONST : u8 = 23; #[deprecated(since = "0.1.1")] diff --git a/tests/ui/attrs.stderr b/tests/ui/attrs.stderr index 411da0e22..4ea0c5eec 100644 --- a/tests/ui/attrs.stderr +++ b/tests/ui/attrs.stderr @@ -1,7 +1,7 @@ error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea --> $DIR/attrs.rs:6:1 | -6 | #[inline(always)] //~ERROR you have declared `#[inline(always)]` on `test_attr_lint`. +6 | #[inline(always)] | ^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:27:14 | -27 | #[deprecated(since = "forever")] //~ERROR the since field must contain a semver-compliant version +27 | #[deprecated(since = "forever")] | ^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -25,7 +25,7 @@ note: lint level defined here error: the since field must contain a semver-compliant version --> $DIR/attrs.rs:30:14 | -30 | #[deprecated(since = "1")] //~ERROR the since field must contain a semver-compliant version +30 | #[deprecated(since = "1")] | ^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/bit_masks.rs b/tests/ui/bit_masks.rs index 79772840c..e8f2e47b2 100644 --- a/tests/ui/bit_masks.rs +++ b/tests/ui/bit_masks.rs @@ -9,36 +9,36 @@ const EVEN_MORE_REDIRECTION : i64 = THREE_BITS; fn main() { let x = 5; - x & 0 == 0; //~ERROR &-masking with zero + x & 0 == 0; x & 1 == 1; //ok, distinguishes bit 0 x & 1 == 0; //ok, compared with zero - x & 2 == 1; //~ERROR incompatible bit mask + x & 2 == 1; x | 0 == 0; //ok, equals x == 0 (maybe warn?) x | 1 == 3; //ok, equals x == 2 || x == 3 x | 3 == 3; //ok, equals x <= 3 - x | 3 == 2; //~ERROR incompatible bit mask + x | 3 == 2; - x & 1 > 1; //~ERROR incompatible bit mask + x & 1 > 1; x & 2 > 1; // ok, distinguishes x & 2 == 2 from x & 2 == 0 x & 2 < 1; // ok, distinguishes x & 2 == 2 from x & 2 == 0 x | 1 > 1; // ok (if a bit silly), equals x > 1 - x | 2 > 1; //~ERROR incompatible bit mask + x | 2 > 1; x | 2 <= 2; // ok (if a bit silly), equals x <= 2 x & 192 == 128; // ok, tests for bit 7 and not bit 6 x & 0xffc0 == 0xfe80; // ok // this also now works with constants - x & THREE_BITS == 8; //~ERROR incompatible bit mask - x | EVEN_MORE_REDIRECTION < 7; //~ERROR incompatible bit mask + x & THREE_BITS == 8; + x | EVEN_MORE_REDIRECTION < 7; - 0 & x == 0; //~ERROR &-masking with zero + 0 & x == 0; 1 | x > 1; // and should now also match uncommon usage - 1 < 2 | x; //~ERROR incompatible bit mask - 2 == 3 | x; //~ERROR incompatible bit mask - 1 == x & 2; //~ERROR incompatible bit mask + 1 < 2 | x; + 2 == 3 | x; + 1 == x & 2; x | 1 > 2; // no error, because we allowed ineffective bit masks ineffective(); @@ -49,10 +49,10 @@ fn main() { fn ineffective() { let x = 5; - x | 1 > 3; //~ERROR ineffective bit mask - x | 1 < 4; //~ERROR ineffective bit mask - x | 1 <= 3; //~ERROR ineffective bit mask - x | 1 >= 8; //~ERROR ineffective bit mask + x | 1 > 3; + x | 1 < 4; + x | 1 <= 3; + x | 1 >= 8; x | 1 > 2; // not an error (yet), better written as x >= 2 x | 1 >= 7; // not an error (yet), better written as x >= 6 diff --git a/tests/ui/bit_masks.stderr b/tests/ui/bit_masks.stderr index b8e63cef2..cba88f282 100644 --- a/tests/ui/bit_masks.stderr +++ b/tests/ui/bit_masks.stderr @@ -1,7 +1,7 @@ error: &-masking with zero --> $DIR/bit_masks.rs:12:5 | -12 | x & 0 == 0; //~ERROR &-masking with zero +12 | x & 0 == 0; | ^^^^^^^^^^ | note: lint level defined here @@ -13,67 +13,67 @@ note: lint level defined here error: incompatible bit mask: `_ & 2` can never be equal to `1` --> $DIR/bit_masks.rs:15:5 | -15 | x & 2 == 1; //~ERROR incompatible bit mask +15 | x & 2 == 1; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` --> $DIR/bit_masks.rs:19:5 | -19 | x | 3 == 2; //~ERROR incompatible bit mask +19 | x | 3 == 2; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 1` will never be higher than `1` --> $DIR/bit_masks.rs:21:5 | -21 | x & 1 > 1; //~ERROR incompatible bit mask +21 | x & 1 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` --> $DIR/bit_masks.rs:25:5 | -25 | x | 2 > 1; //~ERROR incompatible bit mask +25 | x | 2 > 1; | ^^^^^^^^^ error: incompatible bit mask: `_ & 7` can never be equal to `8` --> $DIR/bit_masks.rs:32:5 | -32 | x & THREE_BITS == 8; //~ERROR incompatible bit mask +32 | x & THREE_BITS == 8; | ^^^^^^^^^^^^^^^^^^^ error: incompatible bit mask: `_ | 7` will never be lower than `7` --> $DIR/bit_masks.rs:33:5 | -33 | x | EVEN_MORE_REDIRECTION < 7; //~ERROR incompatible bit mask +33 | x | EVEN_MORE_REDIRECTION < 7; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: &-masking with zero --> $DIR/bit_masks.rs:35:5 | -35 | 0 & x == 0; //~ERROR &-masking with zero +35 | 0 & x == 0; | ^^^^^^^^^^ error: incompatible bit mask: `_ | 2` will always be higher than `1` --> $DIR/bit_masks.rs:39:5 | -39 | 1 < 2 | x; //~ERROR incompatible bit mask +39 | 1 < 2 | x; | ^^^^^^^^^ error: incompatible bit mask: `_ | 3` can never be equal to `2` --> $DIR/bit_masks.rs:40:5 | -40 | 2 == 3 | x; //~ERROR incompatible bit mask +40 | 2 == 3 | x; | ^^^^^^^^^^ error: incompatible bit mask: `_ & 2` can never be equal to `1` --> $DIR/bit_masks.rs:41:5 | -41 | 1 == x & 2; //~ERROR incompatible bit mask +41 | 1 == x & 2; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly --> $DIR/bit_masks.rs:52:5 | -52 | x | 1 > 3; //~ERROR ineffective bit mask +52 | x | 1 > 3; | ^^^^^^^^^ | note: lint level defined here @@ -85,19 +85,19 @@ note: lint level defined here error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly --> $DIR/bit_masks.rs:53:5 | -53 | x | 1 < 4; //~ERROR ineffective bit mask +53 | x | 1 < 4; | ^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly --> $DIR/bit_masks.rs:54:5 | -54 | x | 1 <= 3; //~ERROR ineffective bit mask +54 | x | 1 <= 3; | ^^^^^^^^^^ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly --> $DIR/bit_masks.rs:55:5 | -55 | x | 1 >= 8; //~ERROR ineffective bit mask +55 | x | 1 >= 8; | ^^^^^^^^^^ error: aborting due to 15 previous errors diff --git a/tests/ui/blacklisted_name.rs b/tests/ui/blacklisted_name.rs index 1afcd94a0..16b4240fa 100644 --- a/tests/ui/blacklisted_name.rs +++ b/tests/ui/blacklisted_name.rs @@ -6,21 +6,21 @@ #![allow(unused_variables, similar_names)] #![deny(blacklisted_name)] -fn test(foo: ()) {} //~ERROR use of a blacklisted/placeholder name `foo` +fn test(foo: ()) {} fn main() { - let foo = 42; //~ERROR use of a blacklisted/placeholder name `foo` - let bar = 42; //~ERROR use of a blacklisted/placeholder name `bar` - let baz = 42; //~ERROR use of a blacklisted/placeholder name `baz` + let foo = 42; + let bar = 42; + let baz = 42; let barb = 42; let barbaric = 42; match (42, Some(1337), Some(0)) { (foo, Some(bar), baz @ Some(_)) => (), - //~^ ERROR use of a blacklisted/placeholder name `foo` - //~| ERROR use of a blacklisted/placeholder name `bar` - //~| ERROR use of a blacklisted/placeholder name `baz` + + + _ => (), } } diff --git a/tests/ui/blacklisted_name.stderr b/tests/ui/blacklisted_name.stderr index 055fb8836..29e9da227 100644 --- a/tests/ui/blacklisted_name.stderr +++ b/tests/ui/blacklisted_name.stderr @@ -1,7 +1,7 @@ error: use of a blacklisted/placeholder name `foo` --> $DIR/blacklisted_name.rs:9:9 | -9 | fn test(foo: ()) {} //~ERROR use of a blacklisted/placeholder name `foo` +9 | fn test(foo: ()) {} | ^^^ | note: lint level defined here @@ -13,19 +13,19 @@ note: lint level defined here error: use of a blacklisted/placeholder name `foo` --> $DIR/blacklisted_name.rs:12:9 | -12 | let foo = 42; //~ERROR use of a blacklisted/placeholder name `foo` +12 | let foo = 42; | ^^^ error: use of a blacklisted/placeholder name `bar` --> $DIR/blacklisted_name.rs:13:9 | -13 | let bar = 42; //~ERROR use of a blacklisted/placeholder name `bar` +13 | let bar = 42; | ^^^ error: use of a blacklisted/placeholder name `baz` --> $DIR/blacklisted_name.rs:14:9 | -14 | let baz = 42; //~ERROR use of a blacklisted/placeholder name `baz` +14 | let baz = 42; | ^^^ error: use of a blacklisted/placeholder name `foo` diff --git a/tests/ui/block_in_if_condition.rs b/tests/ui/block_in_if_condition.rs index 090c39abc..feb28e377 100644 --- a/tests/ui/block_in_if_condition.rs +++ b/tests/ui/block_in_if_condition.rs @@ -27,7 +27,7 @@ fn macro_if() { } fn condition_has_block() -> i32 { - if { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks; + if { let x = 3; x == 3 } { @@ -38,7 +38,7 @@ fn condition_has_block() -> i32 { } fn condition_has_block_with_single_expression() -> i32 { - if { true } { //~ERROR omit braces around single expression condition + if { true } { 6 } else { 10 @@ -56,18 +56,18 @@ fn pred_test() { // 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) { - //~^ERROR in an 'if' condition, avoid complex blocks or closures with blocks; + } if predicate(|x| { let target = 3; x == target }, v) { - //~^ERROR in an 'if' condition, avoid complex blocks or closures with blocks; + } } fn condition_is_normal() -> i32 { let x = 3; - if true && x == 3 { //~ WARN this boolean expression can be simplified + if true && x == 3 { 6 } else { 10 diff --git a/tests/ui/block_in_if_condition.stderr b/tests/ui/block_in_if_condition.stderr index be63b4a74..d3e869024 100644 --- a/tests/ui/block_in_if_condition.stderr +++ b/tests/ui/block_in_if_condition.stderr @@ -1,7 +1,7 @@ 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:30:8 | -30 | if { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks; +30 | if { | ________^ starting here... 31 | | let x = 3; 32 | | x == 3 @@ -14,7 +14,7 @@ note: lint level defined here 5 | #![deny(block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: try - let res = { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks; + let res = { let x = 3; x == 3 }; @@ -25,7 +25,7 @@ note: lint level defined here error: omit braces around single expression condition --> $DIR/block_in_if_condition.rs:41:8 | -41 | if { true } { //~ERROR omit braces around single expression condition +41 | if { true } { | ^^^^^^^^ | note: lint level defined here @@ -34,7 +34,7 @@ note: lint level defined here 4 | #![deny(block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: try - if true { //~ERROR omit braces around single expression condition + if true { 6 } ... @@ -53,7 +53,7 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste warning: this boolean expression can be simplified --> $DIR/block_in_if_condition.rs:70:8 | -70 | if true && x == 3 { //~ WARN this boolean expression can be simplified +70 | if true && x == 3 { | ^^^^^^^^^^^^^^ | note: lint level defined here @@ -62,7 +62,7 @@ note: lint level defined here 7 | #![warn(nonminimal_bool)] | ^^^^^^^^^^^^^^^ help: try - | if x == 3 { //~ WARN this boolean expression can be simplified + | if x == 3 { error: aborting due to 4 previous errors diff --git a/tests/ui/bool_comparison.rs b/tests/ui/bool_comparison.rs index 836759455..3991d04bd 100644 --- a/tests/ui/bool_comparison.rs +++ b/tests/ui/bool_comparison.rs @@ -5,19 +5,19 @@ fn main() { let x = true; if x == true { "yes" } else { "no" }; - //~^ ERROR equality checks against true are unnecessary - //~| HELP try simplifying it as shown: - //~| SUGGESTION if x { "yes" } else { "no" }; + + + if x == false { "yes" } else { "no" }; - //~^ ERROR equality checks against false can be replaced by a negation - //~| HELP try simplifying it as shown: - //~| SUGGESTION if !x { "yes" } else { "no" }; + + + if true == x { "yes" } else { "no" }; - //~^ ERROR equality checks against true are unnecessary - //~| HELP try simplifying it as shown: - //~| SUGGESTION if x { "yes" } else { "no" }; + + + if false == x { "yes" } else { "no" }; - //~^ ERROR equality checks against false can be replaced by a negation - //~| HELP try simplifying it as shown: - //~| SUGGESTION if !x { "yes" } else { "no" }; + + + } diff --git a/tests/ui/booleans.rs b/tests/ui/booleans.rs index 193edebf3..fc1791f7f 100644 --- a/tests/ui/booleans.rs +++ b/tests/ui/booleans.rs @@ -9,29 +9,29 @@ fn main() { let c: bool = unimplemented!(); let d: bool = unimplemented!(); let e: bool = unimplemented!(); - let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug - //~| HELP this expression can be optimized out - //~| HELP it would look like the following - //~| SUGGESTION let _ = a; + let _ = a && b || a; + + + let _ = !(a && b); - let _ = !true; //~ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = false; - let _ = !false; //~ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = true; - let _ = !!a; //~ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = a; + let _ = !true; + + + let _ = !false; + + + let _ = !!a; + + + + let _ = false && a; + + + + + let _ = false || a; - let _ = false && a; //~ ERROR this boolean expression contains a logic bug - //~| HELP this expression can be optimized out - //~| HELP it would look like the following - //~| SUGGESTION let _ = false; - let _ = false || a; //~ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = a; // don't lint on cfgs let _ = cfg!(you_shall_not_not_pass) && a; @@ -40,9 +40,9 @@ fn main() { let _ = !(a && b || c); - let _ = !(!a && b); //~ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = !b || a; + let _ = !(!a && b); + + } #[allow(unused, many_single_char_names)] @@ -53,38 +53,38 @@ fn equality_stuff() { let d: i32 = unimplemented!(); let e: i32 = unimplemented!(); let _ = a == b && a != b; - //~^ ERROR this boolean expression contains a logic bug - //~| HELP this expression can be optimized out - //~| HELP it would look like the following - //~| SUGGESTION let _ = false; + + + + let _ = a == b && c == 5 && a == b; - //~^ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = a == b && c == 5; - //~| HELP try - //~| SUGGESTION let _ = !(c != 5 || a != b); + + + + + let _ = a == b && c == 5 && b == a; - //~^ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = a == b && c == 5; - //~| HELP try - //~| SUGGESTION let _ = !(c != 5 || a != b); + + + + + let _ = a < b && a >= b; - //~^ ERROR this boolean expression contains a logic bug - //~| HELP this expression can be optimized out - //~| HELP it would look like the following - //~| SUGGESTION let _ = false; + + + + let _ = a > b && a <= b; - //~^ ERROR this boolean expression contains a logic bug - //~| HELP this expression can be optimized out - //~| HELP it would look like the following - //~| SUGGESTION let _ = false; + + + + let _ = a > b && a == b; let _ = a != b || !(a != b || c == d); - //~^ ERROR this boolean expression can be simplified - //~| HELP try - //~| SUGGESTION let _ = c != d || a != b; - //~| HELP try - //~| SUGGESTION let _ = !(a == b && c == d); + + + + + } diff --git a/tests/ui/booleans.stderr b/tests/ui/booleans.stderr index 9be511928..54f6638b9 100644 --- a/tests/ui/booleans.stderr +++ b/tests/ui/booleans.stderr @@ -1,7 +1,7 @@ error: this boolean expression contains a logic bug --> $DIR/booleans.rs:12:13 | -12 | let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug +12 | let _ = a && b || a; | ^^^^^^^^^^^ | note: lint level defined here @@ -12,15 +12,15 @@ note: lint level defined here help: this expression can be optimized out by applying boolean operations to the outer expression --> $DIR/booleans.rs:12:18 | -12 | let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug +12 | let _ = a && b || a; | ^ help: it would look like the following - | let _ = a; //~ ERROR this boolean expression contains a logic bug + | let _ = a; error: this boolean expression can be simplified --> $DIR/booleans.rs:17:13 | -17 | let _ = !true; //~ ERROR this boolean expression can be simplified +17 | let _ = !true; | ^^^^^ | note: lint level defined here @@ -29,57 +29,57 @@ note: lint level defined here 3 | #![deny(nonminimal_bool, logic_bug)] | ^^^^^^^^^^^^^^^ help: try - | let _ = false; //~ ERROR this boolean expression can be simplified + | let _ = false; error: this boolean expression can be simplified --> $DIR/booleans.rs:20:13 | -20 | let _ = !false; //~ ERROR this boolean expression can be simplified +20 | let _ = !false; | ^^^^^^ | help: try - | let _ = true; //~ ERROR this boolean expression can be simplified + | let _ = true; error: this boolean expression can be simplified --> $DIR/booleans.rs:23:13 | -23 | let _ = !!a; //~ ERROR this boolean expression can be simplified +23 | let _ = !!a; | ^^^ | help: try - | let _ = a; //~ ERROR this boolean expression can be simplified + | let _ = a; error: this boolean expression contains a logic bug --> $DIR/booleans.rs:27:13 | -27 | let _ = false && a; //~ ERROR this boolean expression contains a logic bug +27 | let _ = false && a; | ^^^^^^^^^^ | help: this expression can be optimized out by applying boolean operations to the outer expression --> $DIR/booleans.rs:27:22 | -27 | let _ = false && a; //~ ERROR this boolean expression contains a logic bug +27 | let _ = false && a; | ^ help: it would look like the following - | let _ = false; //~ ERROR this boolean expression contains a logic bug + | let _ = false; error: this boolean expression can be simplified --> $DIR/booleans.rs:32:13 | -32 | let _ = false || a; //~ ERROR this boolean expression can be simplified +32 | let _ = false || a; | ^^^^^^^^^^ | help: try - | let _ = a; //~ ERROR this boolean expression can be simplified + | let _ = a; error: this boolean expression can be simplified --> $DIR/booleans.rs:43:13 | -43 | let _ = !(!a && b); //~ ERROR this boolean expression can be simplified +43 | let _ = !(!a && b); | ^^^^^^^^^^ | help: try - | let _ = !b || a; //~ ERROR this boolean expression can be simplified + | let _ = !b || a; error: this boolean expression contains a logic bug --> $DIR/booleans.rs:55:13 diff --git a/tests/ui/box_vec.rs b/tests/ui/box_vec.rs index 071945a81..01f1b1d09 100644 --- a/tests/ui/box_vec.rs +++ b/tests/ui/box_vec.rs @@ -14,7 +14,7 @@ macro_rules! boxit { fn test_macro() { boxit!(Vec::new(), Vec); } -pub fn test(foo: Box>) { //~ ERROR you seem to be trying to use `Box>` +pub fn test(foo: Box>) { println!("{:?}", foo.get(0)) } diff --git a/tests/ui/box_vec.stderr b/tests/ui/box_vec.stderr index b5cc66b60..a7ccf1dcd 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:17:18 | -17 | pub fn test(foo: Box>) { //~ ERROR you seem to be trying to use `Box>` +17 | pub fn test(foo: Box>) { | ^^^^^^^^^^^^^^ | = note: #[deny(box_vec)] implied by #[deny(clippy)] diff --git a/tests/ui/builtin-type-shadow.rs b/tests/ui/builtin-type-shadow.rs index 172875a6b..bcf8a8dec 100644 --- a/tests/ui/builtin-type-shadow.rs +++ b/tests/ui/builtin-type-shadow.rs @@ -2,8 +2,8 @@ #![plugin(clippy)] #![deny(builtin_type_shadow)] -fn foo(a: u32) -> u32 { //~ERROR shadows the built-in type `u32` - 42 //~ERROR E0308 +fn foo(a: u32) -> u32 { + 42 // ^ rustc's type error } diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index e3b6c68e8..98cbd4366 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -1,7 +1,7 @@ error: This generic shadows the built-in type `u32` --> $DIR/builtin-type-shadow.rs:5:8 | -5 | fn foo(a: u32) -> u32 { //~ERROR shadows the built-in type `u32` +5 | fn foo(a: u32) -> u32 { | ^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error[E0308]: mismatched types --> $DIR/builtin-type-shadow.rs:6:5 | -6 | 42 //~ERROR E0308 +6 | 42 | ^^ expected type parameter, found integral variable | = note: expected type `u32` diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index d0ea5f407..ca5106102 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -5,60 +5,60 @@ #[allow(no_effect, unnecessary_operation)] fn main() { // Test cast_precision_loss - 1i32 as f32; //~ERROR casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide) - 1i64 as f32; //~ERROR casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide) - 1i64 as f64; //~ERROR casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide) - 1u32 as f32; //~ERROR casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide) - 1u64 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) - 1u64 as f64; //~ERROR casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide) + 1i32 as f32; + 1i64 as f32; + 1i64 as f64; + 1u32 as f32; + 1u64 as f32; + 1u64 as f64; 1i32 as f64; // Should not trigger the lint 1u32 as f64; // Should not trigger the lint // Test cast_possible_truncation - 1f32 as i32; //~ERROR casting f32 to i32 may truncate the value - 1f32 as u32; //~ERROR casting f32 to u32 may truncate the value - //~^ERROR casting f32 to u32 may lose the sign of the value - 1f64 as f32; //~ERROR casting f64 to f32 may truncate the value - 1i32 as i8; //~ERROR casting i32 to i8 may truncate the value - 1i32 as u8; //~ERROR casting i32 to u8 may truncate the value - //~^ERROR casting i32 to u8 may lose the sign of the value - 1f64 as isize; //~ERROR casting f64 to isize may truncate the value - 1f64 as usize; //~ERROR casting f64 to usize may truncate the value - //~^ERROR casting f64 to usize may lose the sign of the value + 1f32 as i32; + 1f32 as u32; + + 1f64 as f32; + 1i32 as i8; + 1i32 as u8; + + 1f64 as isize; + 1f64 as usize; + // Test cast_possible_wrap - 1u8 as i8; //~ERROR casting u8 to i8 may wrap around the value - 1u16 as i16; //~ERROR casting u16 to i16 may wrap around the value - 1u32 as i32; //~ERROR casting u32 to i32 may wrap around the value - 1u64 as i64; //~ERROR casting u64 to i64 may wrap around the value - 1usize as isize; //~ERROR casting usize to isize may wrap around the value + 1u8 as i8; + 1u16 as i16; + 1u32 as i32; + 1u64 as i64; + 1usize as isize; // Test cast_sign_loss - 1i32 as u32; //~ERROR casting i32 to u32 may lose the sign of the value - 1isize as usize; //~ERROR casting isize to usize may lose the sign of the value + 1i32 as u32; + 1isize as usize; // Extra checks for *size // Casting from *size - 1isize as i8; //~ERROR casting isize to i8 may truncate the value - 1isize as f64; //~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) - 1usize as f64; //~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) - 1isize as f32; //~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) - 1usize 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) - 1isize as i32; //~ERROR casting isize to i32 may truncate the value on targets with 64-bit wide pointers - 1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value - //~^ERROR casting isize to u32 may truncate the value on targets with 64-bit wide pointers - 1usize as u32; //~ERROR casting usize to u32 may truncate the value on targets with 64-bit wide pointers - 1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers - //~^ERROR casting usize to i32 may wrap around the value on targets with 32-bit wide pointers + 1isize as i8; + 1isize as f64; + 1usize as f64; + 1isize as f32; + 1usize as f32; + 1isize as i32; + 1isize as u32; + + 1usize as u32; + 1usize as i32; + // Casting to *size - 1i64 as isize; //~ERROR casting i64 to isize may truncate the value on targets with 32-bit wide pointers - 1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers - //~^ERROR casting i64 to usize may lose the sign of the value - 1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers - //~^ERROR casting u64 to isize may wrap around the value on targets with 64-bit wide pointers - 1u64 as usize; //~ERROR casting u64 to usize may truncate the value on targets with 32-bit wide pointers - 1u32 as isize; //~ERROR casting u32 to isize may wrap around the value on targets with 32-bit wide pointers + 1i64 as isize; + 1i64 as usize; + + 1u64 as isize; + + 1u64 as usize; + 1u32 as isize; 1u32 as usize; // Should not trigger any lint 1i32 as isize; // Neither should this - 1i32 as usize; //~ERROR casting i32 to usize may lose the sign of the value + 1i32 as usize; } diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index e5fbc8fe4..f4d8ec21d 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -1,7 +1,7 @@ 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:8:5 | -8 | 1i32 as f32; //~ERROR casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide) +8 | 1i32 as f32; | ^^^^^^^^^^^ | note: lint level defined here @@ -13,37 +13,37 @@ note: lint level defined here 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:9:5 | -9 | 1i64 as f32; //~ERROR casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide) +9 | 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:10:5 | -10 | 1i64 as f64; //~ERROR casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide) +10 | 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:11:5 | -11 | 1u32 as f32; //~ERROR casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide) +11 | 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:12:5 | -12 | 1u64 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) +12 | 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:13:5 | -13 | 1u64 as f64; //~ERROR casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide) +13 | 1u64 as f64; | ^^^^^^^^^^^ error: casting f32 to i32 may truncate the value --> $DIR/cast.rs:18:5 | -18 | 1f32 as i32; //~ERROR casting f32 to i32 may truncate the value +18 | 1f32 as i32; | ^^^^^^^^^^^ | note: lint level defined here @@ -55,13 +55,13 @@ note: lint level defined here error: casting f32 to u32 may truncate the value --> $DIR/cast.rs:19:5 | -19 | 1f32 as u32; //~ERROR casting f32 to u32 may truncate the value +19 | 1f32 as u32; | ^^^^^^^^^^^ error: casting f32 to u32 may lose the sign of the value --> $DIR/cast.rs:19:5 | -19 | 1f32 as u32; //~ERROR casting f32 to u32 may truncate the value +19 | 1f32 as u32; | ^^^^^^^^^^^ | note: lint level defined here @@ -73,49 +73,49 @@ note: lint level defined here error: casting f64 to f32 may truncate the value --> $DIR/cast.rs:21:5 | -21 | 1f64 as f32; //~ERROR casting f64 to f32 may truncate the value +21 | 1f64 as f32; | ^^^^^^^^^^^ error: casting i32 to i8 may truncate the value --> $DIR/cast.rs:22:5 | -22 | 1i32 as i8; //~ERROR casting i32 to i8 may truncate the value +22 | 1i32 as i8; | ^^^^^^^^^^ error: casting i32 to u8 may lose the sign of the value --> $DIR/cast.rs:23:5 | -23 | 1i32 as u8; //~ERROR casting i32 to u8 may truncate the value +23 | 1i32 as u8; | ^^^^^^^^^^ error: casting i32 to u8 may truncate the value --> $DIR/cast.rs:23:5 | -23 | 1i32 as u8; //~ERROR casting i32 to u8 may truncate the value +23 | 1i32 as u8; | ^^^^^^^^^^ error: casting f64 to isize may truncate the value --> $DIR/cast.rs:25:5 | -25 | 1f64 as isize; //~ERROR casting f64 to isize may truncate the value +25 | 1f64 as isize; | ^^^^^^^^^^^^^ error: casting f64 to usize may truncate the value --> $DIR/cast.rs:26:5 | -26 | 1f64 as usize; //~ERROR casting f64 to usize may truncate the value +26 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting f64 to usize may lose the sign of the value --> $DIR/cast.rs:26:5 | -26 | 1f64 as usize; //~ERROR casting f64 to usize may truncate the value +26 | 1f64 as usize; | ^^^^^^^^^^^^^ error: casting u8 to i8 may wrap around the value --> $DIR/cast.rs:30:5 | -30 | 1u8 as i8; //~ERROR casting u8 to i8 may wrap around the value +30 | 1u8 as i8; | ^^^^^^^^^ | note: lint level defined here @@ -127,151 +127,151 @@ note: lint level defined here error: casting u16 to i16 may wrap around the value --> $DIR/cast.rs:31:5 | -31 | 1u16 as i16; //~ERROR casting u16 to i16 may wrap around the value +31 | 1u16 as i16; | ^^^^^^^^^^^ error: casting u32 to i32 may wrap around the value --> $DIR/cast.rs:32:5 | -32 | 1u32 as i32; //~ERROR casting u32 to i32 may wrap around the value +32 | 1u32 as i32; | ^^^^^^^^^^^ error: casting u64 to i64 may wrap around the value --> $DIR/cast.rs:33:5 | -33 | 1u64 as i64; //~ERROR casting u64 to i64 may wrap around the value +33 | 1u64 as i64; | ^^^^^^^^^^^ error: casting usize to isize may wrap around the value --> $DIR/cast.rs:34:5 | -34 | 1usize as isize; //~ERROR casting usize to isize may wrap around the value +34 | 1usize as isize; | ^^^^^^^^^^^^^^^ error: casting i32 to u32 may lose the sign of the value --> $DIR/cast.rs:37:5 | -37 | 1i32 as u32; //~ERROR casting i32 to u32 may lose the sign of the value +37 | 1i32 as u32; | ^^^^^^^^^^^ error: casting isize to usize may lose the sign of the value --> $DIR/cast.rs:38:5 | -38 | 1isize as usize; //~ERROR casting isize to usize may lose the sign of the value +38 | 1isize as usize; | ^^^^^^^^^^^^^^^ error: casting isize to i8 may truncate the value --> $DIR/cast.rs:42:5 | -42 | 1isize as i8; //~ERROR casting isize to i8 may truncate the value +42 | 1isize as i8; | ^^^^^^^^^^^^ 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.rs:43:5 | -43 | 1isize as f64; //~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) +43 | 1isize as f64; | ^^^^^^^^^^^^^ 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.rs:44:5 | -44 | 1usize as f64; //~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) +44 | 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.rs:45:5 | -45 | 1isize as f32; //~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) +45 | 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.rs:46:5 | -46 | 1usize 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) +46 | 1usize as f32; | ^^^^^^^^^^^^^ error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers --> $DIR/cast.rs:47:5 | -47 | 1isize as i32; //~ERROR casting isize to i32 may truncate the value on targets with 64-bit wide pointers +47 | 1isize as i32; | ^^^^^^^^^^^^^ error: casting isize to u32 may lose the sign of the value --> $DIR/cast.rs:48:5 | -48 | 1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value +48 | 1isize as u32; | ^^^^^^^^^^^^^ error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers --> $DIR/cast.rs:48:5 | -48 | 1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value +48 | 1isize as u32; | ^^^^^^^^^^^^^ error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers --> $DIR/cast.rs:50:5 | -50 | 1usize as u32; //~ERROR casting usize to u32 may truncate the value on targets with 64-bit wide pointers +50 | 1usize as u32; | ^^^^^^^^^^^^^ error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers --> $DIR/cast.rs:51:5 | -51 | 1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers +51 | 1usize as i32; | ^^^^^^^^^^^^^ error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers --> $DIR/cast.rs:51:5 | -51 | 1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers +51 | 1usize as i32; | ^^^^^^^^^^^^^ error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers --> $DIR/cast.rs:54:5 | -54 | 1i64 as isize; //~ERROR casting i64 to isize may truncate the value on targets with 32-bit wide pointers +54 | 1i64 as isize; | ^^^^^^^^^^^^^ error: casting i64 to usize may lose the sign of the value --> $DIR/cast.rs:55:5 | -55 | 1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers +55 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers --> $DIR/cast.rs:55:5 | -55 | 1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers +55 | 1i64 as usize; | ^^^^^^^^^^^^^ error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers --> $DIR/cast.rs:57:5 | -57 | 1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers +57 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers --> $DIR/cast.rs:57:5 | -57 | 1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers +57 | 1u64 as isize; | ^^^^^^^^^^^^^ error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers --> $DIR/cast.rs:59:5 | -59 | 1u64 as usize; //~ERROR casting u64 to usize may truncate the value on targets with 32-bit wide pointers +59 | 1u64 as usize; | ^^^^^^^^^^^^^ error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers --> $DIR/cast.rs:60:5 | -60 | 1u32 as isize; //~ERROR casting u32 to isize may wrap around the value on targets with 32-bit wide pointers +60 | 1u32 as isize; | ^^^^^^^^^^^^^ error: casting i32 to usize may lose the sign of the value --> $DIR/cast.rs:63:5 | -63 | 1i32 as usize; //~ERROR casting i32 to usize may lose the sign of the value +63 | 1i32 as usize; | ^^^^^^^^^^^^^ error: aborting due to 42 previous errors diff --git a/tests/ui/char_lit_as_u8.rs b/tests/ui/char_lit_as_u8.rs index 4fca878c4..84f76fb01 100644 --- a/tests/ui/char_lit_as_u8.rs +++ b/tests/ui/char_lit_as_u8.rs @@ -4,5 +4,5 @@ #![deny(char_lit_as_u8)] #![allow(unused_variables)] fn main() { - let c = 'a' as u8; //~ERROR casting character literal + let c = 'a' as u8; } diff --git a/tests/ui/char_lit_as_u8.stderr b/tests/ui/char_lit_as_u8.stderr index f297f692d..95550194a 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:7:13 | -7 | let c = 'a' as u8; //~ERROR casting character literal +7 | let c = 'a' as u8; | ^^^^^^^^^ | note: lint level defined here diff --git a/tests/ui/cmp_nan.rs b/tests/ui/cmp_nan.rs index 8d173665a..53aaba617 100644 --- a/tests/ui/cmp_nan.rs +++ b/tests/ui/cmp_nan.rs @@ -5,18 +5,18 @@ #[allow(float_cmp, no_effect, unnecessary_operation)] fn main() { let x = 5f32; - x == std::f32::NAN; //~ERROR doomed comparison with NAN - x != std::f32::NAN; //~ERROR doomed comparison with NAN - x < std::f32::NAN; //~ERROR doomed comparison with NAN - x > std::f32::NAN; //~ERROR doomed comparison with NAN - x <= std::f32::NAN; //~ERROR doomed comparison with NAN - x >= std::f32::NAN; //~ERROR doomed comparison with NAN + x == std::f32::NAN; + x != std::f32::NAN; + x < std::f32::NAN; + x > std::f32::NAN; + x <= std::f32::NAN; + x >= std::f32::NAN; let y = 0f64; - y == std::f64::NAN; //~ERROR doomed comparison with NAN - y != std::f64::NAN; //~ERROR doomed comparison with NAN - y < std::f64::NAN; //~ERROR doomed comparison with NAN - y > std::f64::NAN; //~ERROR doomed comparison with NAN - y <= std::f64::NAN; //~ERROR doomed comparison with NAN - y >= std::f64::NAN; //~ERROR doomed comparison with NAN + y == std::f64::NAN; + y != std::f64::NAN; + y < std::f64::NAN; + y > std::f64::NAN; + y <= std::f64::NAN; + y >= std::f64::NAN; } diff --git a/tests/ui/cmp_nan.stderr b/tests/ui/cmp_nan.stderr index 9d76a076b..9015e2fd3 100644 --- a/tests/ui/cmp_nan.stderr +++ b/tests/ui/cmp_nan.stderr @@ -1,7 +1,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:8:5 | -8 | x == std::f32::NAN; //~ERROR doomed comparison with NAN +8 | x == std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -9,7 +9,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:9:5 | -9 | x != std::f32::NAN; //~ERROR doomed comparison with NAN +9 | x != std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -17,7 +17,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:10:5 | -10 | x < std::f32::NAN; //~ERROR doomed comparison with NAN +10 | x < std::f32::NAN; | ^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -25,7 +25,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:11:5 | -11 | x > std::f32::NAN; //~ERROR doomed comparison with NAN +11 | x > std::f32::NAN; | ^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -33,7 +33,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:12:5 | -12 | x <= std::f32::NAN; //~ERROR doomed comparison with NAN +12 | x <= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -41,7 +41,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:13:5 | -13 | x >= std::f32::NAN; //~ERROR doomed comparison with NAN +13 | x >= std::f32::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -49,7 +49,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:16:5 | -16 | y == std::f64::NAN; //~ERROR doomed comparison with NAN +16 | y == std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -57,7 +57,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:17:5 | -17 | y != std::f64::NAN; //~ERROR doomed comparison with NAN +17 | y != std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -65,7 +65,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:18:5 | -18 | y < std::f64::NAN; //~ERROR doomed comparison with NAN +18 | y < std::f64::NAN; | ^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -73,7 +73,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:19:5 | -19 | y > std::f64::NAN; //~ERROR doomed comparison with NAN +19 | y > std::f64::NAN; | ^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -81,7 +81,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:20:5 | -20 | y <= std::f64::NAN; //~ERROR doomed comparison with NAN +20 | y <= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default @@ -89,7 +89,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead --> $DIR/cmp_nan.rs:21:5 | -21 | y >= std::f64::NAN; //~ERROR doomed comparison with NAN +21 | y >= std::f64::NAN; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(cmp_nan)] on by default diff --git a/tests/ui/cmp_null.rs b/tests/ui/cmp_null.rs index a55ea6f5b..5449d2d31 100644 --- a/tests/ui/cmp_null.rs +++ b/tests/ui/cmp_null.rs @@ -8,12 +8,12 @@ use std::ptr; fn main() { let x = 0; let p : *const usize = &x; - if p == ptr::null() { //~ERROR: Comparing with null + if p == ptr::null() { println!("This is surprising!"); } let mut y = 0; let mut m : *mut usize = &mut y; - if m == ptr::null_mut() { //~ERROR: Comparing with null + if m == ptr::null_mut() { println!("This is surprising, too!"); } } diff --git a/tests/ui/cmp_null.stderr b/tests/ui/cmp_null.stderr index 45523cea3..f98edeaca 100644 --- a/tests/ui/cmp_null.stderr +++ b/tests/ui/cmp_null.stderr @@ -1,7 +1,7 @@ error: Comparing with null is better expressed by the .is_null() method --> $DIR/cmp_null.rs:11:8 | -11 | if p == ptr::null() { //~ERROR: Comparing with null +11 | if p == ptr::null() { | ^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: Comparing with null is better expressed by the .is_null() method --> $DIR/cmp_null.rs:16:8 | -16 | if m == ptr::null_mut() { //~ERROR: Comparing with null +16 | if m == ptr::null_mut() { | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/cmp_owned.rs b/tests/ui/cmp_owned.rs index f7c7824e9..30cd502a1 100644 --- a/tests/ui/cmp_owned.rs +++ b/tests/ui/cmp_owned.rs @@ -6,22 +6,22 @@ fn main() { fn with_to_string(x : &str) { x != "foo".to_string(); - //~^ ERROR this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation + "foo".to_string() != x; - //~^ ERROR this creates an owned instance just for comparison. Consider using `"foo" != x` to compare without allocation + } let x = "oh"; with_to_string(x); - x != "foo".to_owned(); //~ERROR this creates an owned instance + x != "foo".to_owned(); // removed String::from_str(..), as it has finally been removed in 1.4.0 // as of 2015-08-14 - x != String::from("foo"); //~ERROR this creates an owned instance + x != String::from("foo"); 42.to_string() == "42"; } diff --git a/tests/ui/cmp_owned.stderr b/tests/ui/cmp_owned.stderr index 5c4ff8338..231e2752c 100644 --- a/tests/ui/cmp_owned.stderr +++ b/tests/ui/cmp_owned.stderr @@ -19,13 +19,13 @@ error: this creates an owned instance just for comparison. Consider using `"foo" error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation --> $DIR/cmp_owned.rs:19:10 | -19 | x != "foo".to_owned(); //~ERROR this creates an owned instance +19 | x != "foo".to_owned(); | ^^^^^^^^^^^^^^^^ error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation --> $DIR/cmp_owned.rs:24:10 | -24 | x != String::from("foo"); //~ERROR this creates an owned instance +24 | x != String::from("foo"); | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index b23d6a6e4..6034bba84 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -6,54 +6,54 @@ fn main() { let x = "hello"; let y = "world"; if x == "hello" { - //~^ ERROR this if statement can be collapsed - //~| HELP try - //~| SUGGESTION if x == "hello" && y == "world" { + + + if y == "world" { println!("Hello world!"); } } if x == "hello" || x == "world" { - //~^ ERROR this if statement can be collapsed - //~| HELP try - //~| SUGGESTION if (x == "hello" || x == "world") && (y == "world" || y == "hello") { + + + if y == "world" || y == "hello" { println!("Hello world!"); } } if x == "hello" && x == "world" { - //~^ ERROR this if statement can be collapsed - //~| HELP try - //~| SUGGESTION if x == "hello" && x == "world" && (y == "world" || y == "hello") { + + + if y == "world" || y == "hello" { println!("Hello world!"); } } if x == "hello" || x == "world" { - //~^ ERROR this if statement can be collapsed - //~| HELP try - //~| SUGGESTION if (x == "hello" || x == "world") && y == "world" && y == "hello" { + + + if y == "world" && y == "hello" { println!("Hello world!"); } } if x == "hello" && x == "world" { - //~^ ERROR this if statement can be collapsed - //~| HELP try - //~| SUGGESTION if x == "hello" && x == "world" && y == "world" && y == "hello" { + + + if y == "world" && y == "hello" { println!("Hello world!"); } } if 42 == 1337 { - //~^ ERROR this if statement can be collapsed - //~| HELP try - //~| SUGGESTION if 42 == 1337 && 'a' != 'A' { + + + if 'a' != 'A' { println!("world!") } @@ -63,9 +63,9 @@ fn main() { if x == "hello" { print!("Hello "); } else { - //~^ ERROR: this `else { if .. }` - //~| HELP try - //~| SUGGESTION } else if y == "world" + + + if y == "world" { println!("world!") } @@ -74,9 +74,9 @@ fn main() { if x == "hello" { print!("Hello "); } else { - //~^ ERROR: this `else { if .. }` - //~| HELP try - //~| SUGGESTION } else if let Some(42) + + + if let Some(42) = Some(42) { println!("world!") } @@ -85,9 +85,9 @@ fn main() { if x == "hello" { print!("Hello "); } else { - //~^ ERROR this `else { if .. }` - //~| HELP try - //~| SUGGESTION } else if y == "world" + + + if y == "world" { println!("world") } @@ -99,9 +99,9 @@ fn main() { if x == "hello" { print!("Hello "); } else { - //~^ ERROR this `else { if .. }` - //~| HELP try - //~| SUGGESTION } else if let Some(42) + + + if let Some(42) = Some(42) { println!("world") } @@ -113,9 +113,9 @@ fn main() { if let Some(42) = Some(42) { print!("Hello "); } else { - //~^ ERROR this `else { if .. }` - //~| HELP try - //~| SUGGESTION } else if let Some(42) + + + if let Some(42) = Some(42) { println!("world") } @@ -127,9 +127,9 @@ fn main() { if let Some(42) = Some(42) { print!("Hello "); } else { - //~^ ERROR this `else { if .. }` - //~| HELP try - //~| SUGGESTION } else if x == "hello" + + + if x == "hello" { println!("world") } @@ -141,9 +141,9 @@ fn main() { if let Some(42) = Some(42) { print!("Hello "); } else { - //~^ ERROR this `else { if .. }` - //~| HELP try - //~| SUGGESTION } else if let Some(42) + + + if let Some(42) = Some(42) { println!("world") } diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index ed510f962..eeac9166a 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -3,9 +3,9 @@ error: this if statement can be collapsed | 8 | if x == "hello" { | _____^ starting here... -9 | | //~^ ERROR this if statement can be collapsed -10 | | //~| HELP try -11 | | //~| SUGGESTION if x == "hello" && y == "world" { +9 | | +10 | | +11 | | 12 | | if y == "world" { 13 | | println!("Hello world!"); 14 | | } @@ -27,9 +27,9 @@ error: this if statement can be collapsed | 17 | if x == "hello" || x == "world" { | _____^ starting here... -18 | | //~^ ERROR this if statement can be collapsed -19 | | //~| HELP try -20 | | //~| SUGGESTION if (x == "hello" || x == "world") && (y == "world" || y == "hello") { +18 | | +19 | | +20 | | 21 | | if y == "world" || y == "hello" { 22 | | println!("Hello world!"); 23 | | } @@ -46,9 +46,9 @@ error: this if statement can be collapsed | 26 | if x == "hello" && x == "world" { | _____^ starting here... -27 | | //~^ ERROR this if statement can be collapsed -28 | | //~| HELP try -29 | | //~| SUGGESTION if x == "hello" && x == "world" && (y == "world" || y == "hello") { +27 | | +28 | | +29 | | 30 | | if y == "world" || y == "hello" { 31 | | println!("Hello world!"); 32 | | } @@ -65,9 +65,9 @@ error: this if statement can be collapsed | 35 | if x == "hello" || x == "world" { | _____^ starting here... -36 | | //~^ ERROR this if statement can be collapsed -37 | | //~| HELP try -38 | | //~| SUGGESTION if (x == "hello" || x == "world") && y == "world" && y == "hello" { +36 | | +37 | | +38 | | 39 | | if y == "world" && y == "hello" { 40 | | println!("Hello world!"); 41 | | } @@ -84,9 +84,9 @@ error: this if statement can be collapsed | 44 | if x == "hello" && x == "world" { | _____^ starting here... -45 | | //~^ ERROR this if statement can be collapsed -46 | | //~| HELP try -47 | | //~| SUGGESTION if x == "hello" && x == "world" && y == "world" && y == "hello" { +45 | | +46 | | +47 | | 48 | | if y == "world" && y == "hello" { 49 | | println!("Hello world!"); 50 | | } @@ -103,9 +103,9 @@ error: this if statement can be collapsed | 53 | if 42 == 1337 { | _____^ starting here... -54 | | //~^ ERROR this if statement can be collapsed -55 | | //~| HELP try -56 | | //~| SUGGESTION if 42 == 1337 && 'a' != 'A' { +54 | | +55 | | +56 | | 57 | | if 'a' != 'A' { 58 | | println!("world!") 59 | | } @@ -122,9 +122,9 @@ error: this `else { if .. }` block can be collapsed | 65 | } else { | ____________^ starting here... -66 | | //~^ ERROR: this `else { if .. }` -67 | | //~| HELP try -68 | | //~| SUGGESTION } else if y == "world" +66 | | +67 | | +68 | | 69 | | if y == "world" { 70 | | println!("world!") 71 | | } @@ -141,9 +141,9 @@ error: this `else { if .. }` block can be collapsed | 76 | } else { | ____________^ starting here... -77 | | //~^ ERROR: this `else { if .. }` -78 | | //~| HELP try -79 | | //~| SUGGESTION } else if let Some(42) +77 | | +78 | | +79 | | 80 | | if let Some(42) = Some(42) { 81 | | println!("world!") 82 | | } diff --git a/tests/ui/complex_types.rs b/tests/ui/complex_types.rs index ad01e4fad..ef5cd6897 100644 --- a/tests/ui/complex_types.rs +++ b/tests/ui/complex_types.rs @@ -6,38 +6,38 @@ type Alias = Vec>>; // no warning here -const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type -static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type +const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); +static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); struct S { - f: Vec>>, //~ERROR very complex type + f: Vec>>, } -struct TS(Vec>>); //~ERROR very complex type +struct TS(Vec>>); enum E { - Tuple(Vec>>), //~ERROR very complex type - Struct { f: Vec>> }, //~ERROR very complex type + Tuple(Vec>>), + Struct { f: Vec>> }, } impl S { - const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type - fn impl_method(&self, p: Vec>>) { } //~ERROR very complex type + const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); + fn impl_method(&self, p: Vec>>) { } } trait T { - const A: Vec>>; //~ERROR very complex type - type B = Vec>>; //~ERROR very complex type - fn method(&self, p: Vec>>); //~ERROR very complex type - fn def_method(&self, p: Vec>>) { } //~ERROR very complex type + const A: Vec>>; + type B = Vec>>; + fn method(&self, p: Vec>>); + fn def_method(&self, p: Vec>>) { } } -fn test1() -> Vec>> { vec![] } //~ERROR very complex type +fn test1() -> Vec>> { vec![] } -fn test2(_x: Vec>>) { } //~ERROR very complex type +fn test2(_x: Vec>>) { } fn test3() { - let _y: Vec>> = vec![]; //~ERROR very complex type + let _y: Vec>> = vec![]; } fn main() { diff --git a/tests/ui/complex_types.stderr b/tests/ui/complex_types.stderr index b502a3fd5..a2e7f9384 100644 --- a/tests/ui/complex_types.stderr +++ b/tests/ui/complex_types.stderr @@ -1,7 +1,7 @@ error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:9:12 | -9 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type +9 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -14,7 +14,7 @@ note: lint level defined here error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:10:12 | -10 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type +10 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -22,7 +22,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:13:8 | -13 | f: Vec>>, //~ERROR very complex type +13 | f: Vec>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -30,7 +30,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:16:11 | -16 | struct TS(Vec>>); //~ERROR very complex type +16 | struct TS(Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -38,7 +38,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:19:11 | -19 | Tuple(Vec>>), //~ERROR very complex type +19 | Tuple(Vec>>), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -46,7 +46,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:20:17 | -20 | Struct { f: Vec>> }, //~ERROR very complex type +20 | Struct { f: Vec>> }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -54,7 +54,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:24:14 | -24 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type +24 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -62,7 +62,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:25:30 | -25 | fn impl_method(&self, p: Vec>>) { } //~ERROR very complex type +25 | fn impl_method(&self, p: Vec>>) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -70,7 +70,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:29:14 | -29 | const A: Vec>>; //~ERROR very complex type +29 | const A: Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -78,7 +78,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:30:14 | -30 | type B = Vec>>; //~ERROR very complex type +30 | type B = Vec>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -86,7 +86,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:31:25 | -31 | fn method(&self, p: Vec>>); //~ERROR very complex type +31 | fn method(&self, p: Vec>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -94,7 +94,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:32:29 | -32 | fn def_method(&self, p: Vec>>) { } //~ERROR very complex type +32 | fn def_method(&self, p: Vec>>) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -102,7 +102,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:35:15 | -35 | fn test1() -> Vec>> { vec![] } //~ERROR very complex type +35 | fn test1() -> Vec>> { vec![] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -110,7 +110,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:37:14 | -37 | fn test2(_x: Vec>>) { } //~ERROR very complex type +37 | fn test2(_x: Vec>>) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] @@ -118,7 +118,7 @@ error: very complex type used. Consider factoring parts into `type` definitions error: very complex type used. Consider factoring parts into `type` definitions --> $DIR/complex_types.rs:40:13 | -40 | let _y: Vec>> = vec![]; //~ERROR very complex type +40 | let _y: Vec>> = vec![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(type_complexity)] implied by #[deny(clippy)] diff --git a/tests/ui/conf_french_blacklisted_name.rs b/tests/ui/conf_french_blacklisted_name.rs index 4c306a98b..20cd6aba3 100644 --- a/tests/ui/conf_french_blacklisted_name.rs +++ b/tests/ui/conf_french_blacklisted_name.rs @@ -6,21 +6,21 @@ #![allow(unused_variables)] #![deny(blacklisted_name)] -fn test(toto: ()) {} //~ERROR use of a blacklisted/placeholder name `toto` +fn test(toto: ()) {} fn main() { - let toto = 42; //~ERROR use of a blacklisted/placeholder name `toto` - let tata = 42; //~ERROR use of a blacklisted/placeholder name `tata` - let titi = 42; //~ERROR use of a blacklisted/placeholder name `titi` + let toto = 42; + let tata = 42; + let titi = 42; let tatab = 42; let tatatataic = 42; match (42, Some(1337), Some(0)) { (toto, Some(tata), titi @ Some(_)) => (), - //~^ ERROR use of a blacklisted/placeholder name `toto` - //~| ERROR use of a blacklisted/placeholder name `tata` - //~| ERROR use of a blacklisted/placeholder name `titi` + + + _ => (), } } diff --git a/tests/ui/conf_french_blacklisted_name.stderr b/tests/ui/conf_french_blacklisted_name.stderr index 0c4996c2c..b750f4564 100644 --- a/tests/ui/conf_french_blacklisted_name.stderr +++ b/tests/ui/conf_french_blacklisted_name.stderr @@ -1,7 +1,7 @@ error: use of a blacklisted/placeholder name `toto` --> $DIR/conf_french_blacklisted_name.rs:9:9 | -9 | fn test(toto: ()) {} //~ERROR use of a blacklisted/placeholder name `toto` +9 | fn test(toto: ()) {} | ^^^^ | note: lint level defined here @@ -13,19 +13,19 @@ note: lint level defined here error: use of a blacklisted/placeholder name `toto` --> $DIR/conf_french_blacklisted_name.rs:12:9 | -12 | let toto = 42; //~ERROR use of a blacklisted/placeholder name `toto` +12 | let toto = 42; | ^^^^ error: use of a blacklisted/placeholder name `tata` --> $DIR/conf_french_blacklisted_name.rs:13:9 | -13 | let tata = 42; //~ERROR use of a blacklisted/placeholder name `tata` +13 | let tata = 42; | ^^^^ error: use of a blacklisted/placeholder name `titi` --> $DIR/conf_french_blacklisted_name.rs:14:9 | -14 | let titi = 42; //~ERROR use of a blacklisted/placeholder name `titi` +14 | let titi = 42; | ^^^^ error: use of a blacklisted/placeholder name `toto` diff --git a/tests/ui/conf_path_non_string.rs b/tests/ui/conf_path_non_string.rs index f26f581f5..ba78ccce7 100644 --- a/tests/ui/conf_path_non_string.rs +++ b/tests/ui/conf_path_non_string.rs @@ -1,6 +1,6 @@ #![feature(attr_literals)] #![feature(plugin)] #![plugin(clippy(conf_file=42))] -//~^ ERROR `conf_file` value must be a string + fn main() {} diff --git a/tests/ui/copies.rs b/tests/ui/copies.rs index 9b1e1ec80..15c149141 100644 --- a/tests/ui/copies.rs +++ b/tests/ui/copies.rs @@ -28,7 +28,7 @@ pub enum Abc { #[deny(match_same_arms)] fn if_same_then_else() -> Result<&'static str, ()> { if true { - //~^NOTE same as this + Foo { bar: 42 }; 0..10; ..; @@ -37,7 +37,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { 0...10; foo(); } - else { //~ERROR this `if` has identical blocks + else { Foo { bar: 42 }; 0..10; ..; @@ -78,8 +78,8 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match 42 { 42 => { - //~^ NOTE same as this - //~| NOTE removing + + foo(); let mut a = 42 + [23].len() as i32; if true { @@ -88,7 +88,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { a = -31-a; a } - _ => { //~ERROR this `match` has identical arm bodies + _ => { foo(); let mut a = 42 + [23].len() as i32; if true { @@ -101,10 +101,10 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match Abc::A { Abc::A => 0, - //~^ NOTE same as this - //~| NOTE removing + + Abc::B => 1, - _ => 0, //~ERROR this `match` has identical arm bodies + _ => 0, }; if true { @@ -112,15 +112,15 @@ fn if_same_then_else() -> Result<&'static str, ()> { } let _ = if true { - //~^NOTE same as this + 42 } - else { //~ERROR this `if` has identical blocks + else { 42 }; if true { - //~^NOTE same as this + for _ in &[42] { let foo: &Option<_> = &Some::(42); if true { @@ -130,7 +130,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { } } } - else { //~ERROR this `if` has identical blocks + else { for _ in &[42] { let foo: &Option<_> = &Some::(42); if true { @@ -142,7 +142,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - //~^NOTE same as this + let bar = if true { 42 } @@ -153,7 +153,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { while foo() { break; } bar + 1; } - else { //~ERROR this `if` has identical blocks + else { let bar = if true { 42 } @@ -166,7 +166,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - //~^NOTE same as this + let _ = match 42 { 42 => 1, a if a > 0 => 2, @@ -177,7 +177,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { else if false { foo(); } - else if foo() { //~ERROR this `if` has identical blocks + else if foo() { let _ = match 42 { 42 => 1, a if a > 0 => 2, @@ -187,18 +187,18 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - //~^NOTE same as this + if let Some(a) = Some(42) {} } - else { //~ERROR this `if` has identical blocks + else { if let Some(a) = Some(42) {} } if true { - //~^NOTE same as this + if let (1, .., 3) = (1, 2, 3) {} } - else { //~ERROR this `if` has identical blocks + else { if let (1, .., 3) = (1, 2, 3) {} } @@ -253,17 +253,17 @@ fn if_same_then_else() -> Result<&'static str, ()> { let _ = match 42 { 42 => foo(), - //~^NOTE same as this - //~|NOTE `42 | 51` - 51 => foo(), //~ERROR this `match` has identical arm bodies + + + 51 => foo(), _ => true, }; let _ = match Some(42) { Some(_) => 24, - //~^NOTE same as this - //~|NOTE `Some(_) | None` - None => 24, //~ERROR this `match` has identical arm bodies + + + None => 24, }; let _ = match Some(42) { @@ -285,39 +285,39 @@ fn if_same_then_else() -> Result<&'static str, ()> { match (Some(42), Some(42)) { (Some(a), None) => bar(a), - //~^NOTE same as this - //~|NOTE `(Some(a), None) | (None, Some(a))` - (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies + + + (None, Some(a)) => bar(a), _ => (), } match (Some(42), Some(42)) { (Some(a), ..) => bar(a), - //~^NOTE same as this - //~|NOTE `(Some(a), ..) | (.., Some(a))` - (.., Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies + + + (.., Some(a)) => bar(a), _ => (), } match (1, 2, 3) { (1, .., 3) => 42, - //~^NOTE same as this - //~|NOTE `(1, .., 3) | (.., 3)` - (.., 3) => 42, //~ERROR this `match` has identical arm bodies + + + (.., 3) => 42, _ => 0, }; let _ = if true { - //~^NOTE same as this + 0.0 - } else { //~ERROR this `if` has identical blocks + } else { 0.0 }; let _ = if true { - //~^NOTE same as this + -0.0 - } else { //~ERROR this `if` has identical blocks + } else { -0.0 }; @@ -336,9 +336,9 @@ fn if_same_then_else() -> Result<&'static str, ()> { // Same NaNs let _ = if true { - //~^NOTE same as this + std::f32::NAN - } else { //~ERROR this `if` has identical blocks + } else { std::f32::NAN }; @@ -354,15 +354,15 @@ fn if_same_then_else() -> Result<&'static str, ()> { } if true { - //~^NOTE same as this + try!(Ok("foo")); } - else { //~ERROR this `if` has identical blocks + else { try!(Ok("foo")); } if true { - //~^NOTE same as this + let foo = ""; return Ok(&foo[0..]); } @@ -370,7 +370,7 @@ fn if_same_then_else() -> Result<&'static str, ()> { let foo = "bar"; return Ok(&foo[0..]); } - else { //~ERROR this `if` has identical blocks + else { let foo = ""; return Ok(&foo[0..]); } @@ -383,23 +383,23 @@ fn ifs_same_cond() { let b = false; if b { - //~^NOTE same as this + } - else if b { //~ERROR this `if` has the same condition as a previous if + else if b { } if a == 1 { - //~^NOTE same as this + } - else if a == 1 { //~ERROR this `if` has the same condition as a previous if + else if a == 1 { } if 2*a == 1 { - //~^NOTE same as this + } else if 2*a == 2 { } - else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if + else if 2*a == 1 { } else if a == 1 { } diff --git a/tests/ui/copies.stderr b/tests/ui/copies.stderr index 634eb5d54..7f5cfe070 100644 --- a/tests/ui/copies.stderr +++ b/tests/ui/copies.stderr @@ -1,7 +1,7 @@ error: this `if` has identical blocks --> $DIR/copies.rs:40:10 | -40 | else { //~ERROR this `if` has identical blocks +40 | else { | __________^ starting here... 41 | | Foo { bar: 42 }; 42 | | 0..10; @@ -27,7 +27,7 @@ note: same as this error: this `match` has identical arm bodies --> $DIR/copies.rs:91:14 | -91 | _ => { //~ERROR this `match` has identical arm bodies +91 | _ => { | ______________^ starting here... 92 | | foo(); 93 | | let mut a = 42 + [23].len() as i32; @@ -58,7 +58,7 @@ note: `42` has the same arm body as the `_` wildcard, consider removing it` error: this `match` has identical arm bodies --> $DIR/copies.rs:107:14 | -107 | _ => 0, //~ERROR this `match` has identical arm bodies +107 | _ => 0, | ^ | note: same as this @@ -75,7 +75,7 @@ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it` error: this `if` has identical blocks --> $DIR/copies.rs:118:10 | -118 | else { //~ERROR this `if` has identical blocks +118 | else { | __________^ starting here... 119 | | 42 120 | | }; @@ -86,7 +86,7 @@ note: same as this | 114 | let _ = if true { | _____________________^ starting here... -115 | | //~^NOTE same as this +115 | | 116 | | 42 117 | | } | |_____^ ...ending here @@ -94,7 +94,7 @@ note: same as this error: this `if` has identical blocks --> $DIR/copies.rs:133:10 | -133 | else { //~ERROR this `if` has identical blocks +133 | else { | ^ | note: same as this @@ -106,7 +106,7 @@ note: same as this error: this `if` has identical blocks --> $DIR/copies.rs:156:10 | -156 | else { //~ERROR this `if` has identical blocks +156 | else { | ^ | note: same as this @@ -118,7 +118,7 @@ note: same as this error: this `if` has identical blocks --> $DIR/copies.rs:180:19 | -180 | else if foo() { //~ERROR this `if` has identical blocks +180 | else if foo() { | ___________________^ starting here... 181 | | let _ = match 42 { 182 | | 42 => 1, @@ -134,7 +134,7 @@ note: same as this | 168 | if true { | _____________^ starting here... -169 | | //~^NOTE same as this +169 | | 170 | | let _ = match 42 { 171 | | 42 => 1, 172 | | a if a > 0 => 2, @@ -147,7 +147,7 @@ note: same as this error: this `if` has identical blocks --> $DIR/copies.rs:193:10 | -193 | else { //~ERROR this `if` has identical blocks +193 | else { | __________^ starting here... 194 | | if let Some(a) = Some(42) {} 195 | | } @@ -158,7 +158,7 @@ note: same as this | 189 | if true { | _____________^ starting here... -190 | | //~^NOTE same as this +190 | | 191 | | if let Some(a) = Some(42) {} 192 | | } | |_____^ ...ending here @@ -166,7 +166,7 @@ note: same as this error: this `if` has identical blocks --> $DIR/copies.rs:201:10 | -201 | else { //~ERROR this `if` has identical blocks +201 | else { | __________^ starting here... 202 | | if let (1, .., 3) = (1, 2, 3) {} 203 | | } @@ -177,7 +177,7 @@ note: same as this | 197 | if true { | _____________^ starting here... -198 | | //~^NOTE same as this +198 | | 199 | | if let (1, .., 3) = (1, 2, 3) {} 200 | | } | |_____^ ...ending here @@ -185,7 +185,7 @@ note: same as this error: this `match` has identical arm bodies --> $DIR/copies.rs:258:15 | -258 | 51 => foo(), //~ERROR this `match` has identical arm bodies +258 | 51 => foo(), | ^^^^^ | note: same as this @@ -202,7 +202,7 @@ note: consider refactoring into `42 | 51` error: this `match` has identical arm bodies --> $DIR/copies.rs:266:17 | -266 | None => 24, //~ERROR this `match` has identical arm bodies +266 | None => 24, | ^^ | note: same as this @@ -219,7 +219,7 @@ note: consider refactoring into `Some(_) | None` error: this `match` has identical arm bodies --> $DIR/copies.rs:290:28 | -290 | (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies +290 | (None, Some(a)) => bar(a), | ^^^^^^ | note: same as this @@ -236,7 +236,7 @@ note: consider refactoring into `(Some(a), None) | (None, Some(a))` error: this `match` has identical arm bodies --> $DIR/copies.rs:298:26 | -298 | (.., Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies +298 | (.., Some(a)) => bar(a), | ^^^^^^ | note: same as this @@ -253,7 +253,7 @@ note: consider refactoring into `(Some(a), ..) | (.., Some(a))` error: this `match` has identical arm bodies --> $DIR/copies.rs:306:20 | -306 | (.., 3) => 42, //~ERROR this `match` has identical arm bodies +306 | (.., 3) => 42, | ^^ | note: same as this @@ -270,7 +270,7 @@ note: consider refactoring into `(1, .., 3) | (.., 3)` error: this `if` has identical blocks --> $DIR/copies.rs:313:12 | -313 | } else { //~ERROR this `if` has identical blocks +313 | } else { | ____________^ starting here... 314 | | 0.0 315 | | }; @@ -281,15 +281,15 @@ note: same as this | 310 | let _ = if true { | _____________________^ starting here... -311 | | //~^NOTE same as this +311 | | 312 | | 0.0 -313 | | } else { //~ERROR this `if` has identical blocks +313 | | } else { | |_____^ ...ending here error: this `if` has identical blocks --> $DIR/copies.rs:320:12 | -320 | } else { //~ERROR this `if` has identical blocks +320 | } else { | ____________^ starting here... 321 | | -0.0 322 | | }; @@ -300,15 +300,15 @@ note: same as this | 317 | let _ = if true { | _____________________^ starting here... -318 | | //~^NOTE same as this +318 | | 319 | | -0.0 -320 | | } else { //~ERROR this `if` has identical blocks +320 | | } else { | |_____^ ...ending here error: this `if` has identical blocks --> $DIR/copies.rs:341:12 | -341 | } else { //~ERROR this `if` has identical blocks +341 | } else { | ____________^ starting here... 342 | | std::f32::NAN 343 | | }; @@ -319,15 +319,15 @@ note: same as this | 338 | let _ = if true { | _____________________^ starting here... -339 | | //~^NOTE same as this +339 | | 340 | | std::f32::NAN -341 | | } else { //~ERROR this `if` has identical blocks +341 | | } else { | |_____^ ...ending here error: this `if` has identical blocks --> $DIR/copies.rs:360:10 | -360 | else { //~ERROR this `if` has identical blocks +360 | else { | __________^ starting here... 361 | | try!(Ok("foo")); 362 | | } @@ -338,7 +338,7 @@ note: same as this | 356 | if true { | _____________^ starting here... -357 | | //~^NOTE same as this +357 | | 358 | | try!(Ok("foo")); 359 | | } | |_____^ ...ending here @@ -346,7 +346,7 @@ note: same as this error: this `if` has identical blocks --> $DIR/copies.rs:373:10 | -373 | else { //~ERROR this `if` has identical blocks +373 | else { | __________^ starting here... 374 | | let foo = ""; 375 | | return Ok(&foo[0..]); @@ -358,7 +358,7 @@ note: same as this | 364 | if true { | _____________^ starting here... -365 | | //~^NOTE same as this +365 | | 366 | | let foo = ""; 367 | | return Ok(&foo[0..]); 368 | | } @@ -367,7 +367,7 @@ note: same as this error: this `if` has the same condition as a previous if --> $DIR/copies.rs:388:13 | -388 | else if b { //~ERROR this `if` has the same condition as a previous if +388 | else if b { | ^ | note: lint level defined here @@ -384,7 +384,7 @@ note: same as this error: this `if` has the same condition as a previous if --> $DIR/copies.rs:394:13 | -394 | else if a == 1 { //~ERROR this `if` has the same condition as a previous if +394 | else if a == 1 { | ^^^^^^ | note: same as this @@ -396,7 +396,7 @@ note: same as this error: this `if` has the same condition as a previous if --> $DIR/copies.rs:402:13 | -402 | else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if +402 | else if 2*a == 1 { | ^^^^^^^^ | note: same as this diff --git a/tests/ui/cyclomatic_complexity.rs b/tests/ui/cyclomatic_complexity.rs index 30bbcc6cb..0b02c937b 100644 --- a/tests/ui/cyclomatic_complexity.rs +++ b/tests/ui/cyclomatic_complexity.rs @@ -4,7 +4,7 @@ #![deny(cyclomatic_complexity)] #![allow(unused)] -fn main() { //~ERROR the function has a cyclomatic complexity of 28 +fn main() { if true { println!("a"); } @@ -89,7 +89,7 @@ fn main() { //~ERROR the function has a cyclomatic complexity of 28 } #[cyclomatic_complexity = "0"] -fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 7 +fn kaboom() { let n = 0; 'a: for i in 0..20 { 'b: for j in i..20 { @@ -135,18 +135,18 @@ fn bloo() { } #[cyclomatic_complexity = "0"] -fn lots_of_short_circuits() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1 +fn lots_of_short_circuits() -> bool { true && false && true && false && true && false && true } #[cyclomatic_complexity = "0"] -fn lots_of_short_circuits2() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1 +fn lots_of_short_circuits2() -> bool { true || false || true || false || true || false || true } #[cyclomatic_complexity = "0"] -fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2 - let x = || match 99 { //~ ERROR: the function has a cyclomatic complexity of 2 +fn baa() { + let x = || match 99 { 0 => 0, 1 => 1, 2 => 2, @@ -163,7 +163,7 @@ fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2 } #[cyclomatic_complexity = "0"] -fn bar() { //~ ERROR: the function has a cyclomatic complexity of 2 +fn bar() { match 99 { 0 => println!("hi"), _ => println!("bye"), @@ -182,7 +182,7 @@ fn dont_warn_on_tests() { } #[cyclomatic_complexity = "0"] -fn barr() { //~ ERROR: the function has a cyclomatic complexity of 2 +fn barr() { match 99 { 0 => println!("hi"), 1 => println!("bla"), @@ -192,7 +192,7 @@ fn barr() { //~ ERROR: the function has a cyclomatic complexity of 2 } #[cyclomatic_complexity = "0"] -fn barr2() { //~ ERROR: the function has a cyclomatic complexity of 3 +fn barr2() { match 99 { 0 => println!("hi"), 1 => println!("bla"), @@ -208,7 +208,7 @@ fn barr2() { //~ ERROR: the function has a cyclomatic complexity of 3 } #[cyclomatic_complexity = "0"] -fn barrr() { //~ ERROR: the function has a cyclomatic complexity of 2 +fn barrr() { match 99 { 0 => println!("hi"), 1 => panic!("bla"), @@ -218,7 +218,7 @@ fn barrr() { //~ ERROR: the function has a cyclomatic complexity of 2 } #[cyclomatic_complexity = "0"] -fn barrr2() { //~ ERROR: the function has a cyclomatic complexity of 3 +fn barrr2() { match 99 { 0 => println!("hi"), 1 => panic!("bla"), @@ -234,7 +234,7 @@ fn barrr2() { //~ ERROR: the function has a cyclomatic complexity of 3 } #[cyclomatic_complexity = "0"] -fn barrrr() { //~ ERROR: the function has a cyclomatic complexity of 2 +fn barrrr() { match 99 { 0 => println!("hi"), 1 => println!("bla"), @@ -244,7 +244,7 @@ fn barrrr() { //~ ERROR: the function has a cyclomatic complexity of 2 } #[cyclomatic_complexity = "0"] -fn barrrr2() { //~ ERROR: the function has a cyclomatic complexity of 3 +fn barrrr2() { match 99 { 0 => println!("hi"), 1 => println!("bla"), @@ -260,7 +260,7 @@ fn barrrr2() { //~ ERROR: the function has a cyclomatic complexity of 3 } #[cyclomatic_complexity = "0"] -fn cake() { //~ ERROR: the function has a cyclomatic complexity of 2 +fn cake() { if 4 == 5 { println!("yea"); } else { @@ -271,7 +271,7 @@ fn cake() { //~ ERROR: the function has a cyclomatic complexity of 2 #[cyclomatic_complexity = "0"] -pub fn read_file(input_path: &str) -> String { //~ ERROR: the function has a cyclomatic complexity of 4 +pub fn read_file(input_path: &str) -> String { use std::fs::File; use std::io::{Read, Write}; use std::path::Path; @@ -302,7 +302,7 @@ pub fn read_file(input_path: &str) -> String { //~ ERROR: the function has a cyc enum Void {} #[cyclomatic_complexity = "0"] -fn void(void: Void) { //~ ERROR: the function has a cyclomatic complexity of 1 +fn void(void: Void) { if true { match void { } @@ -316,7 +316,7 @@ fn mcarton_sees_all() { } #[cyclomatic_complexity = "0"] -fn try() -> Result { //~ ERROR: cyclomatic complexity of 1 +fn try() -> Result { match 5 { 5 => Ok(5), _ => return Err("bla"), @@ -324,7 +324,7 @@ fn try() -> Result { //~ ERROR: cyclomatic complexity of 1 } #[cyclomatic_complexity = "0"] -fn try_again() -> Result { //~ ERROR: cyclomatic complexity of 1 +fn try_again() -> Result { let _ = try!(Ok(42)); let _ = try!(Ok(43)); let _ = try!(Ok(44)); @@ -340,7 +340,7 @@ fn try_again() -> Result { //~ ERROR: cyclomatic complexity o } #[cyclomatic_complexity = "0"] -fn early() -> Result { //~ ERROR: cyclomatic complexity of 1 +fn early() -> Result { return Ok(5); return Ok(5); return Ok(5); @@ -353,7 +353,7 @@ fn early() -> Result { //~ ERROR: cyclomatic complexity of 1 } #[cyclomatic_complexity = "0"] -fn early_ret() -> i32 { //~ ERROR: cyclomatic complexity of 8 +fn early_ret() -> i32 { let a = if true { 42 } else { return 0; }; let a = if a < 99 { 42 } else { return 0; }; let a = if a < 99 { 42 } else { return 0; }; diff --git a/tests/ui/cyclomatic_complexity.stderr b/tests/ui/cyclomatic_complexity.stderr index 45f258f95..70eb05e8d 100644 --- a/tests/ui/cyclomatic_complexity.stderr +++ b/tests/ui/cyclomatic_complexity.stderr @@ -1,7 +1,7 @@ error: the function has a cyclomatic complexity of 28 --> $DIR/cyclomatic_complexity.rs:7:1 | -7 | fn main() { //~ERROR the function has a cyclomatic complexity of 28 +7 | fn main() { | ^ | note: lint level defined here @@ -14,7 +14,7 @@ note: lint level defined here error: the function has a cyclomatic complexity of 7 --> $DIR/cyclomatic_complexity.rs:92:1 | -92 | fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 7 +92 | fn kaboom() { | ^ | = help: you could split it up into multiple smaller functions @@ -22,7 +22,7 @@ error: the function has a cyclomatic complexity of 7 error: the function has a cyclomatic complexity of 1 --> $DIR/cyclomatic_complexity.rs:138:1 | -138 | fn lots_of_short_circuits() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1 +138 | fn lots_of_short_circuits() -> bool { | _^ starting here... 139 | | true && false && true && false && true && false && true 140 | | } @@ -33,7 +33,7 @@ error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1 --> $DIR/cyclomatic_complexity.rs:143:1 | -143 | fn lots_of_short_circuits2() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1 +143 | fn lots_of_short_circuits2() -> bool { | _^ starting here... 144 | | true || false || true || false || true || false || true 145 | | } @@ -44,7 +44,7 @@ error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 2 --> $DIR/cyclomatic_complexity.rs:148:1 | -148 | fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2 +148 | fn baa() { | ^ | = help: you could split it up into multiple smaller functions @@ -52,7 +52,7 @@ error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2 --> $DIR/cyclomatic_complexity.rs:149:13 | -149 | let x = || match 99 { //~ ERROR: the function has a cyclomatic complexity of 2 +149 | let x = || match 99 { | _____________^ starting here... 150 | | 0 => 0, 151 | | 1 => 1, @@ -69,7 +69,7 @@ error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2 --> $DIR/cyclomatic_complexity.rs:166:1 | -166 | fn bar() { //~ ERROR: the function has a cyclomatic complexity of 2 +166 | fn bar() { | _^ starting here... 167 | | match 99 { 168 | | 0 => println!("hi"), @@ -83,7 +83,7 @@ error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 2 --> $DIR/cyclomatic_complexity.rs:185:1 | -185 | fn barr() { //~ ERROR: the function has a cyclomatic complexity of 2 +185 | fn barr() { | _^ starting here... 186 | | match 99 { 187 | | 0 => println!("hi"), @@ -99,7 +99,7 @@ error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 3 --> $DIR/cyclomatic_complexity.rs:195:1 | -195 | fn barr2() { //~ ERROR: the function has a cyclomatic complexity of 3 +195 | fn barr2() { | ^ | = help: you could split it up into multiple smaller functions @@ -107,7 +107,7 @@ error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 2 --> $DIR/cyclomatic_complexity.rs:211:1 | -211 | fn barrr() { //~ ERROR: the function has a cyclomatic complexity of 2 +211 | fn barrr() { | _^ starting here... 212 | | match 99 { 213 | | 0 => println!("hi"), @@ -123,7 +123,7 @@ error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 3 --> $DIR/cyclomatic_complexity.rs:221:1 | -221 | fn barrr2() { //~ ERROR: the function has a cyclomatic complexity of 3 +221 | fn barrr2() { | ^ | = help: you could split it up into multiple smaller functions @@ -131,7 +131,7 @@ error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 2 --> $DIR/cyclomatic_complexity.rs:237:1 | -237 | fn barrrr() { //~ ERROR: the function has a cyclomatic complexity of 2 +237 | fn barrrr() { | _^ starting here... 238 | | match 99 { 239 | | 0 => println!("hi"), @@ -147,7 +147,7 @@ error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 3 --> $DIR/cyclomatic_complexity.rs:247:1 | -247 | fn barrrr2() { //~ ERROR: the function has a cyclomatic complexity of 3 +247 | fn barrrr2() { | ^ | = help: you could split it up into multiple smaller functions @@ -155,7 +155,7 @@ error: the function has a cyclomatic complexity of 3 error: the function has a cyclomatic complexity of 2 --> $DIR/cyclomatic_complexity.rs:263:1 | -263 | fn cake() { //~ ERROR: the function has a cyclomatic complexity of 2 +263 | fn cake() { | _^ starting here... 264 | | if 4 == 5 { 265 | | println!("yea"); @@ -171,7 +171,7 @@ error: the function has a cyclomatic complexity of 2 error: the function has a cyclomatic complexity of 4 --> $DIR/cyclomatic_complexity.rs:274:1 | -274 | pub fn read_file(input_path: &str) -> String { //~ ERROR: the function has a cyclomatic complexity of 4 +274 | pub fn read_file(input_path: &str) -> String { | ^ | = help: you could split it up into multiple smaller functions @@ -179,7 +179,7 @@ error: the function has a cyclomatic complexity of 4 error: the function has a cyclomatic complexity of 1 --> $DIR/cyclomatic_complexity.rs:305:1 | -305 | fn void(void: Void) { //~ ERROR: the function has a cyclomatic complexity of 1 +305 | fn void(void: Void) { | _^ starting here... 306 | | if true { 307 | | match void { @@ -193,7 +193,7 @@ error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1 --> $DIR/cyclomatic_complexity.rs:319:1 | -319 | fn try() -> Result { //~ ERROR: cyclomatic complexity of 1 +319 | fn try() -> Result { | _^ starting here... 320 | | match 5 { 321 | | 5 => Ok(5), @@ -207,7 +207,7 @@ error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1 --> $DIR/cyclomatic_complexity.rs:327:1 | -327 | fn try_again() -> Result { //~ ERROR: cyclomatic complexity of 1 +327 | fn try_again() -> Result { | ^ | = help: you could split it up into multiple smaller functions @@ -215,7 +215,7 @@ error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 1 --> $DIR/cyclomatic_complexity.rs:343:1 | -343 | fn early() -> Result { //~ ERROR: cyclomatic complexity of 1 +343 | fn early() -> Result { | ^ | = help: you could split it up into multiple smaller functions @@ -223,7 +223,7 @@ error: the function has a cyclomatic complexity of 1 error: the function has a cyclomatic complexity of 8 --> $DIR/cyclomatic_complexity.rs:356:1 | -356 | fn early_ret() -> i32 { //~ ERROR: cyclomatic complexity of 8 +356 | fn early_ret() -> i32 { | ^ | = help: you could split it up into multiple smaller functions diff --git a/tests/ui/cyclomatic_complexity_attr_used.rs b/tests/ui/cyclomatic_complexity_attr_used.rs index f322a7b51..143888279 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.rs +++ b/tests/ui/cyclomatic_complexity_attr_used.rs @@ -8,7 +8,7 @@ fn main() { } #[cyclomatic_complexity = "0"] -fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 3 +fn kaboom() { if 42 == 43 { panic!(); } else if "cake" == "lie" { diff --git a/tests/ui/cyclomatic_complexity_attr_used.stderr b/tests/ui/cyclomatic_complexity_attr_used.stderr index aa87b7505..f5ee0e799 100644 --- a/tests/ui/cyclomatic_complexity_attr_used.stderr +++ b/tests/ui/cyclomatic_complexity_attr_used.stderr @@ -1,7 +1,7 @@ error: the function has a cyclomatic complexity of 3 --> $DIR/cyclomatic_complexity_attr_used.rs:11:1 | -11 | fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 3 +11 | fn kaboom() { | _^ starting here... 12 | | if 42 == 43 { 13 | | panic!(); diff --git a/tests/ui/derive.rs b/tests/ui/derive.rs index cf4467f30..7274c0fb7 100644 --- a/tests/ui/derive.rs +++ b/tests/ui/derive.rs @@ -16,7 +16,7 @@ impl PartialEq for Foo { } #[derive(Hash)] -//~^ ERROR you are deriving `Hash` but have implemented `PartialEq` explicitly + struct Bar; impl PartialEq for Bar { @@ -24,7 +24,7 @@ impl PartialEq for Bar { } #[derive(Hash)] -//~^ ERROR you are deriving `Hash` but have implemented `PartialEq` explicitly + struct Baz; impl PartialEq for Baz { @@ -35,7 +35,7 @@ impl PartialEq for Baz { struct Bah; impl Hash for Bah { -//~^ ERROR you are implementing `Hash` explicitly but have derived `PartialEq` + fn hash(&self, _: &mut H) {} } @@ -43,7 +43,7 @@ impl Hash for Bah { struct Qux; impl Clone for Qux { -//~^ ERROR you are implementing `Clone` explicitly on a `Copy` type + fn clone(&self) -> Self { Qux } } @@ -68,7 +68,7 @@ struct Lt<'a> { } impl<'a> Clone for Lt<'a> { -//~^ ERROR you are implementing `Clone` explicitly on a `Copy` type + fn clone(&self) -> Self { unimplemented!() } } diff --git a/tests/ui/derive.stderr b/tests/ui/derive.stderr index 97b5344ee..d435b52db 100644 --- a/tests/ui/derive.stderr +++ b/tests/ui/derive.stderr @@ -40,7 +40,7 @@ error: you are implementing `Hash` explicitly but have derived `PartialEq` | 37 | impl Hash for Bah { | _^ starting here... -38 | | //~^ ERROR you are implementing `Hash` explicitly but have derived `PartialEq` +38 | | 39 | | fn hash(&self, _: &mut H) {} 40 | | } | |_^ ...ending here @@ -57,7 +57,7 @@ error: you are implementing `Clone` explicitly on a `Copy` type | 45 | impl Clone for Qux { | _^ starting here... -46 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type +46 | | 47 | | fn clone(&self) -> Self { Qux } 48 | | } | |_^ ...ending here @@ -73,7 +73,7 @@ note: consider deriving `Clone` or removing `Copy` | 45 | impl Clone for Qux { | _^ starting here... -46 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type +46 | | 47 | | fn clone(&self) -> Self { Qux } 48 | | } | |_^ ...ending here @@ -83,7 +83,7 @@ error: you are implementing `Clone` explicitly on a `Copy` type | 70 | impl<'a> Clone for Lt<'a> { | _^ starting here... -71 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type +71 | | 72 | | fn clone(&self) -> Self { unimplemented!() } 73 | | } | |_^ ...ending here @@ -94,7 +94,7 @@ note: consider deriving `Clone` or removing `Copy` | 70 | impl<'a> Clone for Lt<'a> { | _^ starting here... -71 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type +71 | | 72 | | fn clone(&self) -> Self { unimplemented!() } 73 | | } | |_^ ...ending here diff --git a/tests/ui/diverging_sub_expression.rs b/tests/ui/diverging_sub_expression.rs index 02e6d0693..57e7a545b 100644 --- a/tests/ui/diverging_sub_expression.rs +++ b/tests/ui/diverging_sub_expression.rs @@ -15,8 +15,8 @@ impl A { #[allow(unused_variables, unnecessary_operation, short_circuit_statement)] fn main() { let b = true; - b || diverge(); //~ ERROR sub-expression diverges - b || A.foo(); //~ ERROR sub-expression diverges + b || diverge(); + b || A.foo(); } #[allow(dead_code, unused_variables)] @@ -25,16 +25,16 @@ fn foobar() { let x = match 5 { 4 => return, 5 => continue, - 6 => true || return, //~ ERROR sub-expression diverges - 7 => true || continue, //~ ERROR sub-expression diverges + 6 => true || return, + 7 => true || continue, 8 => break, 9 => diverge(), - 3 => true || diverge(), //~ ERROR sub-expression diverges + 3 => true || diverge(), 10 => match 42 { 99 => return, _ => true || panic!("boo"), }, - _ => true || break, //~ ERROR sub-expression diverges + _ => true || break, }; } } diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index 805a01840..108c228fd 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -1,7 +1,7 @@ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:18:10 | -18 | b || diverge(); //~ ERROR sub-expression diverges +18 | b || diverge(); | ^^^^^^^^^ | note: lint level defined here @@ -13,31 +13,31 @@ note: lint level defined here error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:19:10 | -19 | b || A.foo(); //~ ERROR sub-expression diverges +19 | b || A.foo(); | ^^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:28:26 | -28 | 6 => true || return, //~ ERROR sub-expression diverges +28 | 6 => true || return, | ^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:29:26 | -29 | 7 => true || continue, //~ ERROR sub-expression diverges +29 | 7 => true || continue, | ^^^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:32:26 | -32 | 3 => true || diverge(), //~ ERROR sub-expression diverges +32 | 3 => true || diverge(), | ^^^^^^^^^ error: sub-expression diverges --> $DIR/diverging_sub_expression.rs:37:26 | -37 | _ => true || break, //~ ERROR sub-expression diverges +37 | _ => true || break, | ^^^^^ error: aborting due to 6 previous errors diff --git a/tests/ui/dlist.rs b/tests/ui/dlist.rs index 63c678eb6..10d0beab8 100644 --- a/tests/ui/dlist.rs +++ b/tests/ui/dlist.rs @@ -10,9 +10,9 @@ extern crate collections; use collections::linked_list::LinkedList; trait Foo { - type Baz = LinkedList; //~ ERROR I see you're using a LinkedList! - fn foo(LinkedList); //~ ERROR I see you're using a LinkedList! - const BAR : Option>; //~ ERROR I see you're using a LinkedList! + type Baz = LinkedList; + fn foo(LinkedList); + const BAR : Option>; } // ok, we don’t want to warn for implementations, see #605 @@ -23,14 +23,14 @@ impl Foo for LinkedList { struct Bar; impl Bar { - fn foo(_: LinkedList) {} //~ ERROR I see you're using a LinkedList! + fn foo(_: LinkedList) {} } -pub fn test(my_favourite_linked_list: LinkedList) { //~ ERROR I see you're using a LinkedList! +pub fn test(my_favourite_linked_list: LinkedList) { println!("{:?}", my_favourite_linked_list) } -pub fn test_ret() -> Option> { //~ ERROR I see you're using a LinkedList! +pub fn test_ret() -> Option> { unimplemented!(); } diff --git a/tests/ui/dlist.stderr b/tests/ui/dlist.stderr index 1d0507d1e..7af01a32e 100644 --- a/tests/ui/dlist.stderr +++ b/tests/ui/dlist.stderr @@ -1,7 +1,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:13:16 | -13 | type Baz = LinkedList; //~ ERROR I see you're using a LinkedList! +13 | type Baz = LinkedList; | ^^^^^^^^^^^^^^ | = note: #[deny(linkedlist)] implied by #[deny(clippy)] @@ -15,7 +15,7 @@ note: lint level defined here error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:14:12 | -14 | fn foo(LinkedList); //~ ERROR I see you're using a LinkedList! +14 | fn foo(LinkedList); | ^^^^^^^^^^^^^^ | = note: #[deny(linkedlist)] implied by #[deny(clippy)] @@ -24,7 +24,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:15:24 | -15 | const BAR : Option>; //~ ERROR I see you're using a LinkedList! +15 | const BAR : Option>; | ^^^^^^^^^^^^^^ | = note: #[deny(linkedlist)] implied by #[deny(clippy)] @@ -33,7 +33,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:26:15 | -26 | fn foo(_: LinkedList) {} //~ ERROR I see you're using a LinkedList! +26 | fn foo(_: LinkedList) {} | ^^^^^^^^^^^^^^ | = note: #[deny(linkedlist)] implied by #[deny(clippy)] @@ -42,7 +42,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:29:39 | -29 | pub fn test(my_favourite_linked_list: LinkedList) { //~ ERROR I see you're using a LinkedList! +29 | pub fn test(my_favourite_linked_list: LinkedList) { | ^^^^^^^^^^^^^^ | = note: #[deny(linkedlist)] implied by #[deny(clippy)] @@ -51,7 +51,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct error: I see you're using a LinkedList! Perhaps you meant some other data structure? --> $DIR/dlist.rs:33:29 | -33 | pub fn test_ret() -> Option> { //~ ERROR I see you're using a LinkedList! +33 | pub fn test_ret() -> Option> { | ^^^^^^^^^^^^^^ | = note: #[deny(linkedlist)] implied by #[deny(clippy)] diff --git a/tests/ui/doc.rs b/tests/ui/doc.rs index 84283a831..1e34b3919 100644 --- a/tests/ui/doc.rs +++ b/tests/ui/doc.rs @@ -1,5 +1,5 @@ //! This file tests for the DOC_MARKDOWN lint -//~^ ERROR: you should put `DOC_MARKDOWN` between ticks + #![feature(plugin)] #![plugin(clippy)] @@ -7,17 +7,17 @@ #![deny(doc_markdown)] /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) -//~^ ERROR: you should put `foo_bar` between ticks -//~| ERROR: you should put `foo::bar` between ticks + + /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun -//~^ ERROR: you should put `Foo::some_fun` between ticks + /// which should be reported only once despite being __doubly bad__. /// Here be ::is::a::global:path. -//~^ ERROR: you should put `is::a::global:path` between ticks + /// That's not code ~NotInCodeBlock~. -//~^ ERROR: you should put `NotInCodeBlock` between ticks + /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn foo_bar() { } @@ -32,7 +32,7 @@ fn foo_bar() { /// _foo bar_ /// ~~~ /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn multiline_codeblock() { } @@ -40,7 +40,7 @@ fn multiline_codeblock() { /// multiline /// emphasis_. /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn test_emphasis() { } @@ -55,7 +55,7 @@ fn test_emphasis() { /// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb /// NaN /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn test_units() { } @@ -65,15 +65,15 @@ fn test_units() { /// `💣` /// `❤️` /// ß_foo -//~^ ERROR: you should put `ß_foo` between ticks + /// ℝ_foo -//~^ ERROR: you should put `ℝ_foo` between ticks + /// 💣_foo /// ❤️_foo /// foo_ß -//~^ ERROR: you should put `foo_ß` between ticks + /// foo_ℝ -//~^ ERROR: you should put `foo_ℝ` between ticks + /// foo_💣 /// foo_❤️ /// [ßdummy textß][foo_1ß] @@ -89,16 +89,16 @@ fn test_units() { /// [foo3_💣]: dummy text /// [foo4_❤️]: dummy text /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn test_unicode() { } /// This test has [a link_with_underscores][chunked-example] inside it. See #823. -//~^ ERROR: you should put `link_with_underscores` between ticks + /// See also [the issue tracker](https://github.com/Manishearth/rust-clippy/search?q=doc_markdown&type=Issues) /// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link]. /// It can also be [inline_link2]. -//~^ ERROR: you should put `inline_link2` between ticks + /// /// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example /// [inline_link]: https://foobar @@ -110,7 +110,7 @@ fn test_unicode() { /// expression of the type `_ m c` (where `` /// is one of {`&`, '|'} and `` is one of {`!=`, `>=`, `>` , /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn main() { foo_bar(); multiline_codeblock(); @@ -124,9 +124,9 @@ fn main() { /// # CamelCaseThing /// /// Not a title #897 CamelCaseThing -//~^ ERROR: you should put `CamelCaseThing` between ticks + /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn issue897() { } @@ -134,7 +134,7 @@ fn issue897() { /// I am confused by brackets? (foo `x_y`) /// I am confused by brackets? (`x_y` foo) /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn issue900() { } @@ -148,7 +148,7 @@ fn issue900() { /// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html /// [helper_types]: ../helper_types/index.html /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn issue883() { } @@ -167,9 +167,9 @@ That's in a code block: `PackedNode` And BarQuz too. be_sure_we_got_to_the_end_of_it */ -//~^^^^^^^^ ERROR: you should put `FooBar` between ticks -//~^^^^ ERROR: you should put `BarQuz` between ticks -//~^^^^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + + + fn issue1073() { } @@ -181,9 +181,9 @@ That's in a code block: PackedNode And BarQuz too. be_sure_we_got_to_the_end_of_it */ -//~^^^^^^^^ ERROR: you should put `FooBar` between ticks -//~^^^^ ERROR: you should put `BarQuz` between ticks -//~^^^^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + + + fn issue1073_alt() { } @@ -194,6 +194,6 @@ fn issue1073_alt() { /// StillDont /// ```` /// be_sure_we_got_to_the_end_of_it -//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks + fn four_quotes() { } diff --git a/tests/ui/double_neg.rs b/tests/ui/double_neg.rs index 790ca9372..362b3a72d 100644 --- a/tests/ui/double_neg.rs +++ b/tests/ui/double_neg.rs @@ -6,5 +6,5 @@ fn main() { let x = 1; -x; -(-x); - --x; //~ERROR: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op + --x; } diff --git a/tests/ui/double_neg.stderr b/tests/ui/double_neg.stderr index 296434402..aeabbc8df 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:9:5 | -9 | --x; //~ERROR: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op +9 | --x; | ^^^ | note: lint level defined here diff --git a/tests/ui/double_parens.rs b/tests/ui/double_parens.rs index 2e415d723..208482eb6 100644 --- a/tests/ui/double_parens.rs +++ b/tests/ui/double_parens.rs @@ -13,23 +13,23 @@ impl DummyStruct { } fn simple_double_parens() -> i32 { - ((0)) //~ERROR Consider removing unnecessary double parentheses + ((0)) } fn fn_double_parens() { - dummy_fn((0)); //~ERROR Consider removing unnecessary double parentheses + dummy_fn((0)); } fn method_double_parens(x: DummyStruct) { - x.dummy_method((0)); //~ERROR Consider removing unnecessary double parentheses + x.dummy_method((0)); } fn tuple_double_parens() -> (i32, i32) { - ((1, 2)) //~ERROR Consider removing unnecessary double parentheses + ((1, 2)) } fn unit_double_parens() { - (()) //~ERROR Consider removing unnecessary double parentheses + (()) } fn fn_tuple_ok() { diff --git a/tests/ui/double_parens.stderr b/tests/ui/double_parens.stderr index ba778c656..1011ad1c0 100644 --- a/tests/ui/double_parens.stderr +++ b/tests/ui/double_parens.stderr @@ -1,7 +1,7 @@ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:16:5 | -16 | ((0)) //~ERROR Consider removing unnecessary double parentheses +16 | ((0)) | ^^^^^ | note: lint level defined here @@ -13,25 +13,25 @@ note: lint level defined here error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:20:14 | -20 | dummy_fn((0)); //~ERROR Consider removing unnecessary double parentheses +20 | dummy_fn((0)); | ^^^ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:24:20 | -24 | x.dummy_method((0)); //~ERROR Consider removing unnecessary double parentheses +24 | x.dummy_method((0)); | ^^^ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:28:5 | -28 | ((1, 2)) //~ERROR Consider removing unnecessary double parentheses +28 | ((1, 2)) | ^^^^^^^^ error: Consider removing unnecessary double parentheses --> $DIR/double_parens.rs:32:5 | -32 | (()) //~ERROR Consider removing unnecessary double parentheses +32 | (()) | ^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/drop_forget_ref.rs b/tests/ui/drop_forget_ref.rs index 55cfe63da..911d3433e 100644 --- a/tests/ui/drop_forget_ref.rs +++ b/tests/ui/drop_forget_ref.rs @@ -9,43 +9,43 @@ use std::mem::{drop, forget}; struct SomeStruct; fn main() { - drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument - forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument + drop(&SomeStruct); + forget(&SomeStruct); let mut owned1 = SomeStruct; - drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument - drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument - drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument + drop(&owned1); + drop(&&owned1); + drop(&mut owned1); drop(owned1); //OK let mut owned2 = SomeStruct; - forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument - forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument - forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument + forget(&owned2); + forget(&&owned2); + forget(&mut owned2); forget(owned2); //OK let reference1 = &SomeStruct; - drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument - forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument + drop(reference1); + forget(&*reference1); let reference2 = &mut SomeStruct; - drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument + drop(reference2); let reference3 = &mut SomeStruct; - forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument + forget(reference3); let ref reference4 = SomeStruct; - drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument - forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument + drop(reference4); + forget(reference4); } #[allow(dead_code)] fn test_generic_fn_drop(val: T) { - drop(&val); //~ERROR call to `std::mem::drop` with a reference argument + drop(&val); drop(val); //OK } #[allow(dead_code)] fn test_generic_fn_forget(val: T) { - forget(&val); //~ERROR call to `std::mem::forget` with a reference argument + forget(&val); forget(val); //OK } @@ -53,8 +53,8 @@ fn test_generic_fn_forget(val: T) { fn test_similarly_named_function() { fn drop(_val: T) {} drop(&SomeStruct); //OK; call to unrelated function which happens to have the same name - std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument + std::mem::drop(&SomeStruct); fn forget(_val: T) {} forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name - std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument + std::mem::forget(&SomeStruct); } diff --git a/tests/ui/drop_forget_ref.stderr b/tests/ui/drop_forget_ref.stderr index 346426b72..80c724c19 100644 --- a/tests/ui/drop_forget_ref.stderr +++ b/tests/ui/drop_forget_ref.stderr @@ -1,7 +1,7 @@ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:12:5 | -12 | drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument +12 | drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -12,13 +12,13 @@ note: lint level defined here note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:12:10 | -12 | drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument +12 | drop(&SomeStruct); | ^^^^^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:13:5 | -13 | forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument +13 | forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -29,199 +29,199 @@ note: lint level defined here note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:13:12 | -13 | forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument +13 | forget(&SomeStruct); | ^^^^^^^^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:16:5 | -16 | drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument +16 | drop(&owned1); | ^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:16:10 | -16 | drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument +16 | drop(&owned1); | ^^^^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:17:5 | -17 | drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument +17 | drop(&&owned1); | ^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct --> $DIR/drop_forget_ref.rs:17:10 | -17 | drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument +17 | drop(&&owned1); | ^^^^^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:18:5 | -18 | drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument +18 | drop(&mut owned1); | ^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:18:10 | -18 | drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument +18 | drop(&mut owned1); | ^^^^^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:21:5 | -21 | forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument +21 | forget(&owned2); | ^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:21:12 | -21 | forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument +21 | forget(&owned2); | ^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:22:5 | -22 | forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument +22 | forget(&&owned2); | ^^^^^^^^^^^^^^^^ | note: argument has type &&SomeStruct --> $DIR/drop_forget_ref.rs:22:12 | -22 | forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument +22 | forget(&&owned2); | ^^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:23:5 | -23 | forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument +23 | forget(&mut owned2); | ^^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:23:12 | -23 | forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument +23 | forget(&mut owned2); | ^^^^^^^^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:27:5 | -27 | drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument +27 | drop(reference1); | ^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:27:10 | -27 | drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument +27 | drop(reference1); | ^^^^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:28:5 | -28 | forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument +28 | forget(&*reference1); | ^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:28:12 | -28 | forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument +28 | forget(&*reference1); | ^^^^^^^^^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:31:5 | -31 | drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument +31 | drop(reference2); | ^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:31:10 | -31 | drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument +31 | drop(reference2); | ^^^^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:33:5 | -33 | forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument +33 | forget(reference3); | ^^^^^^^^^^^^^^^^^^ | note: argument has type &mut SomeStruct --> $DIR/drop_forget_ref.rs:33:12 | -33 | forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument +33 | forget(reference3); | ^^^^^^^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:36:5 | -36 | drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument +36 | drop(reference4); | ^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:36:10 | -36 | drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument +36 | drop(reference4); | ^^^^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:37:5 | -37 | forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument +37 | forget(reference4); | ^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:37:12 | -37 | forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument +37 | forget(reference4); | ^^^^^^^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:42:5 | -42 | drop(&val); //~ERROR call to `std::mem::drop` with a reference argument +42 | drop(&val); | ^^^^^^^^^^ | note: argument has type &T --> $DIR/drop_forget_ref.rs:42:10 | -42 | drop(&val); //~ERROR call to `std::mem::drop` with a reference argument +42 | drop(&val); | ^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:48:5 | -48 | forget(&val); //~ERROR call to `std::mem::forget` with a reference argument +48 | forget(&val); | ^^^^^^^^^^^^ | note: argument has type &T --> $DIR/drop_forget_ref.rs:48:12 | -48 | forget(&val); //~ERROR call to `std::mem::forget` with a reference argument +48 | forget(&val); | ^^^^ error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing --> $DIR/drop_forget_ref.rs:56:5 | -56 | std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument +56 | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:56:20 | -56 | std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument +56 | std::mem::drop(&SomeStruct); | ^^^^^^^^^^^ error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing --> $DIR/drop_forget_ref.rs:59:5 | -59 | std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument +59 | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: argument has type &SomeStruct --> $DIR/drop_forget_ref.rs:59:22 | -59 | std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument +59 | std::mem::forget(&SomeStruct); | ^^^^^^^^^^^ error: aborting due to 18 previous errors diff --git a/tests/ui/duplicate_underscore_argument.rs b/tests/ui/duplicate_underscore_argument.rs index 4d908e7f0..ca02002bc 100644 --- a/tests/ui/duplicate_underscore_argument.rs +++ b/tests/ui/duplicate_underscore_argument.rs @@ -4,10 +4,10 @@ #![deny(duplicate_underscore_argument)] #[allow(dead_code, unused)] -fn join_the_dark_side(darth: i32, _darth: i32) {} //~ERROR `darth` already exists +fn join_the_dark_side(darth: i32, _darth: i32) {} fn join_the_light_side(knight: i32, _master: i32) {} // the Force is strong with this one fn main() { join_the_dark_side(0, 0); join_the_light_side(0, 0); -} \ No newline at end of file +} diff --git a/tests/ui/duplicate_underscore_argument.stderr b/tests/ui/duplicate_underscore_argument.stderr index 0550aaae5..3e507acd9 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:7:23 | -7 | fn join_the_dark_side(darth: i32, _darth: i32) {} //~ERROR `darth` already exists +7 | fn join_the_dark_side(darth: i32, _darth: i32) {} | ^^^^^ | note: lint level defined here diff --git a/tests/ui/empty_enum.rs b/tests/ui/empty_enum.rs index ac9b314c0..9f32b7ede 100644 --- a/tests/ui/empty_enum.rs +++ b/tests/ui/empty_enum.rs @@ -4,8 +4,8 @@ #![allow(dead_code)] #![deny(empty_enum)] -enum Empty {} //~ ERROR enum with no variants - //~^ HELP consider using the uninhabited type `!` or a wrapper around it +enum Empty {} + fn main() { } diff --git a/tests/ui/empty_enum.stderr b/tests/ui/empty_enum.stderr index 93aeb2ddb..2a5e1165f 100644 --- a/tests/ui/empty_enum.stderr +++ b/tests/ui/empty_enum.stderr @@ -1,7 +1,7 @@ error: enum with no variants --> $DIR/empty_enum.rs:7:1 | -7 | enum Empty {} //~ ERROR enum with no variants +7 | enum Empty {} | ^^^^^^^^^^^^^ | note: lint level defined here @@ -12,7 +12,7 @@ note: lint level defined here help: consider using the uninhabited type `!` or a wrapper around it --> $DIR/empty_enum.rs:7:1 | -7 | enum Empty {} //~ ERROR enum with no variants +7 | enum Empty {} | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/entry.rs b/tests/ui/entry.rs index ec3b75abb..816da06b9 100644 --- a/tests/ui/entry.rs +++ b/tests/ui/entry.rs @@ -11,51 +11,51 @@ fn foo() {} fn insert_if_absent0(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { m.insert(k, v); } - //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap` - //~| HELP consider - //~| SUGGESTION m.entry(k).or_insert(v) + + + } fn insert_if_absent1(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { foo(); m.insert(k, v); } - //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap` - //~| HELP consider - //~| SUGGESTION m.entry(k) + + + } fn insert_if_absent2(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { m.insert(k, v) } else { None }; - //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap` - //~| HELP consider - //~| SUGGESTION m.entry(k) + + + } fn insert_if_present2(m: &mut HashMap, k: K, v: V) { if m.contains_key(&k) { None } else { m.insert(k, v) }; - //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap` - //~| HELP consider - //~| SUGGESTION m.entry(k) + + + } fn insert_if_absent3(m: &mut HashMap, k: K, v: V) { if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap` - //~| HELP consider - //~| SUGGESTION m.entry(k) + + + } fn insert_if_present3(m: &mut HashMap, k: K, v: V) { if m.contains_key(&k) { None } else { foo(); m.insert(k, v) }; - //~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap` - //~| HELP consider - //~| SUGGESTION m.entry(k) + + + } fn insert_in_btreemap(m: &mut BTreeMap, k: K, v: V) { if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None }; - //~^ ERROR usage of `contains_key` followed by `insert` on a `BTreeMap` - //~| HELP consider - //~| SUGGESTION m.entry(k) + + + } fn insert_other_if_absent(m: &mut HashMap, k: K, o: K, v: V) { diff --git a/tests/ui/enum_glob_use.rs b/tests/ui/enum_glob_use.rs index 86539c2b1..6becdb3c9 100644 --- a/tests/ui/enum_glob_use.rs +++ b/tests/ui/enum_glob_use.rs @@ -3,13 +3,13 @@ #![deny(clippy, clippy_pedantic)] #![allow(unused_imports, dead_code, missing_docs_in_private_items)] -use std::cmp::Ordering::*; //~ ERROR: don't use glob imports for enum variants +use std::cmp::Ordering::*; enum Enum { _Foo, } -use self::Enum::*; //~ ERROR: don't use glob imports for enum variants +use self::Enum::*; fn blarg() { use self::Enum::*; // ok, just for a function diff --git a/tests/ui/enum_glob_use.stderr b/tests/ui/enum_glob_use.stderr index e109269dc..657ab13eb 100644 --- a/tests/ui/enum_glob_use.stderr +++ b/tests/ui/enum_glob_use.stderr @@ -1,7 +1,7 @@ error: don't use glob imports for enum variants --> $DIR/enum_glob_use.rs:6:1 | -6 | use std::cmp::Ordering::*; //~ ERROR: don't use glob imports for enum variants +6 | use std::cmp::Ordering::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(enum_glob_use)] implied by #[deny(clippy_pedantic)] @@ -14,7 +14,7 @@ note: lint level defined here error: don't use glob imports for enum variants --> $DIR/enum_glob_use.rs:12:1 | -12 | use self::Enum::*; //~ ERROR: don't use glob imports for enum variants +12 | use self::Enum::*; | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(enum_glob_use)] implied by #[deny(clippy_pedantic)] diff --git a/tests/ui/enum_variants.rs b/tests/ui/enum_variants.rs index 585535f9d..8d7a41b98 100644 --- a/tests/ui/enum_variants.rs +++ b/tests/ui/enum_variants.rs @@ -11,7 +11,7 @@ enum FakeCallType2 { } enum Foo { - cFoo, //~ ERROR: Variant name ends with the enum's name + cFoo, cBar, cBaz, } @@ -21,17 +21,17 @@ enum Fooo { cBar, } -enum Food { //~ ERROR: All variants have the same prefix: `Food` - FoodGood, //~ ERROR: Variant name starts with the enum's name - FoodMiddle, //~ ERROR: Variant name starts with the enum's name - FoodBad, //~ ERROR: Variant name starts with the enum's name +enum Food { + FoodGood, + FoodMiddle, + FoodBad, } enum Stuff { StuffBad, // no error } -enum BadCallType { //~ ERROR: All variants have the same prefix: `CallType` +enum BadCallType { CallTypeCall, CallTypeCreate, CallTypeDestroy, @@ -42,7 +42,7 @@ enum TwoCallType { // no error CallTypeCreate, } -enum Consts { //~ ERROR: All variants have the same prefix: `Constant` +enum Consts { ConstantInt, ConstantCake, ConstantLie, @@ -75,19 +75,19 @@ enum Sealll { WithOut, } -enum Seallll { //~ ERROR: All variants have the same prefix: `With` +enum Seallll { WithOutCake, WithOutTea, WithOut, } -enum NonCaps { //~ ERROR: All variants have the same prefix: `Prefix` +enum NonCaps { Prefix的, PrefixTea, PrefixCake, } -pub enum PubSeall { //~ ERROR: All variants have the same prefix: +pub enum PubSeall { WithOutCake, WithOutTea, WithOut, diff --git a/tests/ui/enum_variants.stderr b/tests/ui/enum_variants.stderr index 115fe8ea2..5ff441605 100644 --- a/tests/ui/enum_variants.stderr +++ b/tests/ui/enum_variants.stderr @@ -1,7 +1,7 @@ error: Variant name ends with the enum's name --> $DIR/enum_variants.rs:14:5 | -14 | cFoo, //~ ERROR: Variant name ends with the enum's name +14 | cFoo, | ^^^^ | = note: #[deny(enum_variant_names)] implied by #[deny(clippy)] @@ -14,7 +14,7 @@ note: lint level defined here error: Variant name starts with the enum's name --> $DIR/enum_variants.rs:25:5 | -25 | FoodGood, //~ ERROR: Variant name starts with the enum's name +25 | FoodGood, | ^^^^^^^^ | = note: #[deny(enum_variant_names)] implied by #[deny(clippy)] @@ -22,7 +22,7 @@ error: Variant name starts with the enum's name error: Variant name starts with the enum's name --> $DIR/enum_variants.rs:26:5 | -26 | FoodMiddle, //~ ERROR: Variant name starts with the enum's name +26 | FoodMiddle, | ^^^^^^^^^^ | = note: #[deny(enum_variant_names)] implied by #[deny(clippy)] @@ -30,7 +30,7 @@ error: Variant name starts with the enum's name error: Variant name starts with the enum's name --> $DIR/enum_variants.rs:27:5 | -27 | FoodBad, //~ ERROR: Variant name starts with the enum's name +27 | FoodBad, | ^^^^^^^ | = note: #[deny(enum_variant_names)] implied by #[deny(clippy)] @@ -38,11 +38,11 @@ error: Variant name starts with the enum's name error: All variants have the same prefix: `Food` --> $DIR/enum_variants.rs:24:1 | -24 | enum Food { //~ ERROR: All variants have the same prefix: `Food` +24 | enum Food { | _^ starting here... -25 | | FoodGood, //~ ERROR: Variant name starts with the enum's name -26 | | FoodMiddle, //~ ERROR: Variant name starts with the enum's name -27 | | FoodBad, //~ ERROR: Variant name starts with the enum's name +25 | | FoodGood, +26 | | FoodMiddle, +27 | | FoodBad, 28 | | } | |_^ ...ending here | @@ -52,7 +52,7 @@ error: All variants have the same prefix: `Food` error: All variants have the same prefix: `CallType` --> $DIR/enum_variants.rs:34:1 | -34 | enum BadCallType { //~ ERROR: All variants have the same prefix: `CallType` +34 | enum BadCallType { | _^ starting here... 35 | | CallTypeCall, 36 | | CallTypeCreate, @@ -66,7 +66,7 @@ error: All variants have the same prefix: `CallType` error: All variants have the same prefix: `Constant` --> $DIR/enum_variants.rs:45:1 | -45 | enum Consts { //~ ERROR: All variants have the same prefix: `Constant` +45 | enum Consts { | _^ starting here... 46 | | ConstantInt, 47 | | ConstantCake, @@ -80,7 +80,7 @@ error: All variants have the same prefix: `Constant` error: All variants have the same prefix: `With` --> $DIR/enum_variants.rs:78:1 | -78 | enum Seallll { //~ ERROR: All variants have the same prefix: `With` +78 | enum Seallll { | _^ starting here... 79 | | WithOutCake, 80 | | WithOutTea, @@ -94,7 +94,7 @@ error: All variants have the same prefix: `With` error: All variants have the same prefix: `Prefix` --> $DIR/enum_variants.rs:84:1 | -84 | enum NonCaps { //~ ERROR: All variants have the same prefix: `Prefix` +84 | enum NonCaps { | _^ starting here... 85 | | Prefix的, 86 | | PrefixTea, @@ -108,7 +108,7 @@ error: All variants have the same prefix: `Prefix` error: All variants have the same prefix: `With` --> $DIR/enum_variants.rs:90:1 | -90 | pub enum PubSeall { //~ ERROR: All variants have the same prefix: +90 | pub enum PubSeall { | _^ starting here... 91 | | WithOutCake, 92 | | WithOutTea, diff --git a/tests/ui/enums_clike.rs b/tests/ui/enums_clike.rs index c342bf8f3..9b4cdbb56 100644 --- a/tests/ui/enums_clike.rs +++ b/tests/ui/enums_clike.rs @@ -7,34 +7,34 @@ #[repr(usize)] enum NonPortable { - X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets + X = 0x1_0000_0000, Y = 0, Z = 0x7FFF_FFFF, A = 0xFFFF_FFFF, } enum NonPortableNoHint { - X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets + X = 0x1_0000_0000, Y = 0, Z = 0x7FFF_FFFF, - A = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets + A = 0xFFFF_FFFF, } #[repr(isize)] enum NonPortableSigned { X = -1, Y = 0x7FFF_FFFF, - Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets - A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets + Z = 0xFFFF_FFFF, + A = 0x1_0000_0000, B = std::i32::MIN as isize, - C = (std::i32::MIN as isize) - 1, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets + C = (std::i32::MIN as isize) - 1, } enum NonPortableSignedNoHint { X = -1, Y = 0x7FFF_FFFF, - Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets - A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets + Z = 0xFFFF_FFFF, + A = 0x1_0000_0000, } /* diff --git a/tests/ui/enums_clike.stderr b/tests/ui/enums_clike.stderr index a3b7ba411..0bfb732fe 100644 --- a/tests/ui/enums_clike.stderr +++ b/tests/ui/enums_clike.stderr @@ -1,7 +1,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:10:5 | -10 | X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +10 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] @@ -14,7 +14,7 @@ note: lint level defined here error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:17:5 | -17 | X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +17 | X = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] @@ -22,7 +22,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:20:5 | -20 | A = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +20 | A = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] @@ -30,7 +30,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:27:5 | -27 | Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +27 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] @@ -38,7 +38,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:28:5 | -28 | A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +28 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] @@ -46,7 +46,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:30:5 | -30 | C = (std::i32::MIN as isize) - 1, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +30 | C = (std::i32::MIN as isize) - 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] @@ -54,7 +54,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:36:5 | -36 | Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +36 | Z = 0xFFFF_FFFF, | ^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] @@ -62,7 +62,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets error: Clike enum variant discriminant is not portable to 32-bit targets --> $DIR/enums_clike.rs:37:5 | -37 | A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets +37 | A = 0x1_0000_0000, | ^^^^^^^^^^^^^^^^^ | = note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)] diff --git a/tests/ui/eq_op.rs b/tests/ui/eq_op.rs index c133f4227..842e5729f 100644 --- a/tests/ui/eq_op.rs +++ b/tests/ui/eq_op.rs @@ -7,56 +7,56 @@ #[deny(nonminimal_bool)] fn main() { // simple values and comparisons - 1 == 1; //~ERROR equal expressions - "no" == "no"; //~ERROR equal expressions + 1 == 1; + "no" == "no"; // even though I agree that no means no ;-) - false != false; //~ERROR equal expressions - 1.5 < 1.5; //~ERROR equal expressions - 1u64 >= 1u64; //~ERROR equal expressions + false != false; + 1.5 < 1.5; + 1u64 >= 1u64; // casts, methods, parentheses - (1 as u64) & (1 as u64); //~ERROR equal expressions - 1 ^ ((((((1)))))); //~ERROR equal expressions + (1 as u64) & (1 as u64); + 1 ^ ((((((1)))))); // unary and binary operators - (-(2) < -(2)); //~ERROR equal expressions + (-(2) < -(2)); ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1)); - //~^ ERROR equal expressions as operands to `==` - //~^^ ERROR equal expressions as operands to `&` - //~^^^ ERROR equal expressions as operands to `&` - (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; //~ERROR equal expressions + + + + (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; // various other things - ([1] != [1]); //~ERROR equal expressions - ((1, 2) != (1, 2)); //~ERROR equal expressions + ([1] != [1]); + ((1, 2) != (1, 2)); vec![1, 2, 3] == vec![1, 2, 3]; //no error yet, as we don't match macros // const folding - 1 + 1 == 2; //~ERROR equal expressions - 1 - 1 == 0; //~ERROR equal expressions as operands to `==` - //~^ ERROR equal expressions as operands to `-` + 1 + 1 == 2; + 1 - 1 == 0; + + + 1 - 1; + 1 / 1; + true && true; + + true || true; - 1 - 1; //~ERROR equal expressions - 1 / 1; //~ERROR equal expressions - true && true; //~ERROR equal expressions - //~|ERROR this boolean expression can be simplified - true || true; //~ERROR equal expressions - //~|ERROR this boolean expression can be simplified let a: u32 = 0; let b: u32 = 0; - a == b && b == a; //~ERROR equal expressions - //~|ERROR this boolean expression can be simplified - a != b && b != a; //~ERROR equal expressions - //~|ERROR this boolean expression can be simplified - a < b && b > a; //~ERROR equal expressions - //~|ERROR this boolean expression can be simplified - a <= b && b >= a; //~ERROR equal expressions - //~|ERROR this boolean expression can be simplified + a == b && b == a; + + a != b && b != a; + + a < b && b > a; + + a <= b && b >= a; + let mut a = vec![1]; - a == a; //~ERROR equal expressions + a == a; 2*a.len() == 2*a.len(); // ok, functions a.pop() == a.pop(); // ok, functions } diff --git a/tests/ui/eq_op.stderr b/tests/ui/eq_op.stderr index 867156f6c..dc2df524d 100644 --- a/tests/ui/eq_op.stderr +++ b/tests/ui/eq_op.stderr @@ -1,7 +1,7 @@ error: this boolean expression can be simplified --> $DIR/eq_op.rs:41:5 | -41 | true && true; //~ERROR equal expressions +41 | true && true; | ^^^^^^^^^^^^ | note: lint level defined here @@ -10,57 +10,57 @@ note: lint level defined here 7 | #[deny(nonminimal_bool)] | ^^^^^^^^^^^^^^^ help: try - | true; //~ERROR equal expressions + | true; error: this boolean expression can be simplified --> $DIR/eq_op.rs:43:5 | -43 | true || true; //~ERROR equal expressions +43 | true || true; | ^^^^^^^^^^^^ | help: try - | true; //~ERROR equal expressions + | true; error: this boolean expression can be simplified --> $DIR/eq_op.rs:49:5 | -49 | a == b && b == a; //~ERROR equal expressions +49 | a == b && b == a; | ^^^^^^^^^^^^^^^^ | help: try - | a == b; //~ERROR equal expressions + | a == b; error: this boolean expression can be simplified --> $DIR/eq_op.rs:51:5 | -51 | a != b && b != a; //~ERROR equal expressions +51 | a != b && b != a; | ^^^^^^^^^^^^^^^^ | help: try - | a != b; //~ERROR equal expressions + | a != b; error: this boolean expression can be simplified --> $DIR/eq_op.rs:53:5 | -53 | a < b && b > a; //~ERROR equal expressions +53 | a < b && b > a; | ^^^^^^^^^^^^^^ | help: try - | a < b; //~ERROR equal expressions + | a < b; error: this boolean expression can be simplified --> $DIR/eq_op.rs:55:5 | -55 | a <= b && b >= a; //~ERROR equal expressions +55 | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ | help: try - | a <= b; //~ERROR equal expressions + | a <= b; error: equal expressions as operands to `==` --> $DIR/eq_op.rs:10:5 | -10 | 1 == 1; //~ERROR equal expressions +10 | 1 == 1; | ^^^^^^ | note: lint level defined here @@ -72,43 +72,43 @@ note: lint level defined here error: equal expressions as operands to `==` --> $DIR/eq_op.rs:11:5 | -11 | "no" == "no"; //~ERROR equal expressions +11 | "no" == "no"; | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` --> $DIR/eq_op.rs:13:5 | -13 | false != false; //~ERROR equal expressions +13 | false != false; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `<` --> $DIR/eq_op.rs:14:5 | -14 | 1.5 < 1.5; //~ERROR equal expressions +14 | 1.5 < 1.5; | ^^^^^^^^^ error: equal expressions as operands to `>=` --> $DIR/eq_op.rs:15:5 | -15 | 1u64 >= 1u64; //~ERROR equal expressions +15 | 1u64 >= 1u64; | ^^^^^^^^^^^^ error: equal expressions as operands to `&` --> $DIR/eq_op.rs:18:5 | -18 | (1 as u64) & (1 as u64); //~ERROR equal expressions +18 | (1 as u64) & (1 as u64); | ^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `^` --> $DIR/eq_op.rs:19:5 | -19 | 1 ^ ((((((1)))))); //~ERROR equal expressions +19 | 1 ^ ((((((1)))))); | ^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `<` --> $DIR/eq_op.rs:22:5 | -22 | (-(2) < -(2)); //~ERROR equal expressions +22 | (-(2) < -(2)); | ^^^^^^^^^^^^^ error: equal expressions as operands to `==` @@ -132,91 +132,91 @@ error: equal expressions as operands to `&` error: equal expressions as operands to `==` --> $DIR/eq_op.rs:27:5 | -27 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; //~ERROR equal expressions +27 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `!=` --> $DIR/eq_op.rs:30:5 | -30 | ([1] != [1]); //~ERROR equal expressions +30 | ([1] != [1]); | ^^^^^^^^^^^^ error: equal expressions as operands to `!=` --> $DIR/eq_op.rs:31:5 | -31 | ((1, 2) != (1, 2)); //~ERROR equal expressions +31 | ((1, 2) != (1, 2)); | ^^^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:35:5 | -35 | 1 + 1 == 2; //~ERROR equal expressions +35 | 1 + 1 == 2; | ^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:36:5 | -36 | 1 - 1 == 0; //~ERROR equal expressions as operands to `==` +36 | 1 - 1 == 0; | ^^^^^^^^^^ error: equal expressions as operands to `-` --> $DIR/eq_op.rs:36:5 | -36 | 1 - 1 == 0; //~ERROR equal expressions as operands to `==` +36 | 1 - 1 == 0; | ^^^^^ error: equal expressions as operands to `-` --> $DIR/eq_op.rs:39:5 | -39 | 1 - 1; //~ERROR equal expressions +39 | 1 - 1; | ^^^^^ error: equal expressions as operands to `/` --> $DIR/eq_op.rs:40:5 | -40 | 1 / 1; //~ERROR equal expressions +40 | 1 / 1; | ^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:41:5 | -41 | true && true; //~ERROR equal expressions +41 | true && true; | ^^^^^^^^^^^^ error: equal expressions as operands to `||` --> $DIR/eq_op.rs:43:5 | -43 | true || true; //~ERROR equal expressions +43 | true || true; | ^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:49:5 | -49 | a == b && b == a; //~ERROR equal expressions +49 | a == b && b == a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:51:5 | -51 | a != b && b != a; //~ERROR equal expressions +51 | a != b && b != a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:53:5 | -53 | a < b && b > a; //~ERROR equal expressions +53 | a < b && b > a; | ^^^^^^^^^^^^^^ error: equal expressions as operands to `&&` --> $DIR/eq_op.rs:55:5 | -55 | a <= b && b >= a; //~ERROR equal expressions +55 | a <= b && b >= a; | ^^^^^^^^^^^^^^^^ error: equal expressions as operands to `==` --> $DIR/eq_op.rs:59:5 | -59 | a == a; //~ERROR equal expressions +59 | a == a; | ^^^^^^ error: aborting due to 32 previous errors diff --git a/tests/ui/escape_analysis.rs b/tests/ui/escape_analysis.rs index 1d4bc89ef..595857b82 100644 --- a/tests/ui/escape_analysis.rs +++ b/tests/ui/escape_analysis.rs @@ -30,11 +30,11 @@ fn ok_box_trait(boxed_trait: &Box) { } fn warn_call() { - let x = box A; //~ ERROR local variable + let x = box A; x.foo(); } -fn warn_arg(x: Box) { //~ ERROR local variable +fn warn_arg(x: Box) { x.foo(); } @@ -46,16 +46,16 @@ fn nowarn_closure_arg() { fn warn_rename_call() { let x = box A; - let y = x; //~ ERROR local variable + let y = x; y.foo(); // via autoderef } fn warn_notuse() { - let bz = box A; //~ ERROR local variable + let bz = box A; } fn warn_pass() { - let bz = box A; //~ ERROR local variable + let bz = box A; take_ref(&bz); // via deref coercion } @@ -85,7 +85,7 @@ fn take_ref(x: &A) {} fn nowarn_ref_take() { // false positive, should actually warn - let x = box A; //~ ERROR local variable + let x = box A; let y = &x; take_box(y); } @@ -98,7 +98,7 @@ fn nowarn_match() { } fn warn_match() { - let x = box A; //~ ERROR local variable + let x = box A; match &x { // not moved ref y => () } @@ -127,5 +127,5 @@ pub struct PeekableSeekable { _peeked: I::Item, } -pub fn new(_needs_name: Box>) -> () { //~ ERROR local variable doesn't need +pub fn new(_needs_name: Box>) -> () { } diff --git a/tests/ui/escape_analysis.stderr b/tests/ui/escape_analysis.stderr index f05f1b32d..e3898e4b2 100644 --- a/tests/ui/escape_analysis.stderr +++ b/tests/ui/escape_analysis.stderr @@ -1,7 +1,7 @@ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:33:9 | -33 | let x = box A; //~ ERROR local variable +33 | let x = box A; | ^ | note: lint level defined here @@ -13,43 +13,43 @@ note: lint level defined here error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:37:13 | -37 | fn warn_arg(x: Box) { //~ ERROR local variable +37 | fn warn_arg(x: Box) { | ^ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:49:9 | -49 | let y = x; //~ ERROR local variable +49 | let y = x; | ^ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:54:9 | -54 | let bz = box A; //~ ERROR local variable +54 | let bz = box A; | ^^ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:58:9 | -58 | let bz = box A; //~ ERROR local variable +58 | let bz = box A; | ^^ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:88:9 | -88 | let x = box A; //~ ERROR local variable +88 | let x = box A; | ^ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:101:9 | -101 | let x = box A; //~ ERROR local variable +101 | let x = box A; | ^ error: local variable doesn't need to be boxed here --> $DIR/escape_analysis.rs:130:12 | -130 | pub fn new(_needs_name: Box>) -> () { //~ ERROR local variable doesn't need +130 | pub fn new(_needs_name: Box>) -> () { | ^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/eta.rs b/tests/ui/eta.rs index c932f8f9a..90ffa6121 100644 --- a/tests/ui/eta.rs +++ b/tests/ui/eta.rs @@ -5,20 +5,20 @@ fn main() { let a = Some(1u8).map(|a| foo(a)); - //~^ ERROR redundant closure found - //~| HELP remove closure as shown - //~| SUGGESTION let a = Some(1u8).map(foo); + + + meta(|a| foo(a)); - //~^ ERROR redundant closure found - //~| HELP remove closure as shown - //~| SUGGESTION meta(foo); + + + let c = Some(1u8).map(|a| {1+2; foo}(a)); - //~^ ERROR redundant closure found - //~| HELP remove closure as shown - //~| SUGGESTION let c = Some(1u8).map({1+2; foo}); + + + let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted? all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted - //~^ WARN needless_borrow + unsafe { Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn } @@ -26,9 +26,9 @@ fn main() { // See #815 let e = Some(1u8).map(|a| divergent(a)); let e = Some(1u8).map(|a| generic(a)); - //~^ ERROR redundant closure found - //~| HELP remove closure as shown - //~| SUGGESTION map(generic); + + + let e = Some(1u8).map(generic); // See #515 diff --git a/tests/ui/eval_order_dependence.rs b/tests/ui/eval_order_dependence.rs index 0b2605d01..851a199f9 100644 --- a/tests/ui/eval_order_dependence.rs +++ b/tests/ui/eval_order_dependence.rs @@ -6,21 +6,21 @@ fn main() { let mut x = 0; let a = { x = 1; 1 } + x; - //~^ ERROR unsequenced read + // Example from iss#277 - x += { x = 20; 2 }; //~ERROR unsequenced read + x += { x = 20; 2 }; // Does it work in weird places? // ...in the base for a struct expression? struct Foo { a: i32, b: i32 }; let base = Foo { a: 4, b: 5 }; let foo = Foo { a: x, .. { x = 6; base } }; - //~^ ERROR unsequenced read + // ...inside a closure? let closure = || { let mut x = 0; - x += { x = 20; 2 }; //~ERROR unsequenced read + x += { x = 20; 2 }; }; // ...not across a closure? let mut y = 0; diff --git a/tests/ui/eval_order_dependence.stderr b/tests/ui/eval_order_dependence.stderr index d47e96862..ba985dd90 100644 --- a/tests/ui/eval_order_dependence.stderr +++ b/tests/ui/eval_order_dependence.stderr @@ -18,13 +18,13 @@ note: whether read occurs before this write depends on evaluation order error: unsequenced read of a variable --> $DIR/eval_order_dependence.rs:12:5 | -12 | x += { x = 20; 2 }; //~ERROR unsequenced read +12 | x += { x = 20; 2 }; | ^ | note: whether read occurs before this write depends on evaluation order --> $DIR/eval_order_dependence.rs:12:12 | -12 | x += { x = 20; 2 }; //~ERROR unsequenced read +12 | x += { x = 20; 2 }; | ^^^^^^ error: unsequenced read of a variable @@ -42,13 +42,13 @@ note: whether read occurs before this write depends on evaluation order error: unsequenced read of a variable --> $DIR/eval_order_dependence.rs:23:9 | -23 | x += { x = 20; 2 }; //~ERROR unsequenced read +23 | x += { x = 20; 2 }; | ^ | note: whether read occurs before this write depends on evaluation order --> $DIR/eval_order_dependence.rs:23:16 | -23 | x += { x = 20; 2 }; //~ERROR unsequenced read +23 | x += { x = 20; 2 }; | ^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/filter_methods.rs b/tests/ui/filter_methods.rs index 20803c8d0..922f9fba6 100644 --- a/tests/ui/filter_methods.rs +++ b/tests/ui/filter_methods.rs @@ -5,22 +5,22 @@ #![allow(missing_docs_in_private_items)] fn main() { - let _: Vec<_> = vec![5; 6].into_iter() //~ERROR called `filter(p).map(q)` on an `Iterator` + let _: Vec<_> = vec![5; 6].into_iter() .filter(|&x| x == 0) .map(|x| x * 2) .collect(); - let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter(p).flat_map(q)` on an `Iterator` + 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() //~ERROR called `filter_map(p).flat_map(q)` on an `Iterator` + 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() //~ERROR called `filter_map(p).map(q)` on an `Iterator` + 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/filter_methods.stderr b/tests/ui/filter_methods.stderr index 495e385d0..8de65e0f4 100644 --- a/tests/ui/filter_methods.stderr +++ b/tests/ui/filter_methods.stderr @@ -1,7 +1,7 @@ error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.filter_map(..)` instead. --> $DIR/filter_methods.rs:8:21 | -8 | let _: Vec<_> = vec![5; 6].into_iter() //~ERROR called `filter(p).map(q)` on an `Iterator` +8 | let _: Vec<_> = vec![5; 6].into_iter() | _____________________^ starting here... 9 | | .filter(|&x| x == 0) 10 | | .map(|x| x * 2) @@ -17,7 +17,7 @@ note: lint level defined here 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:13:21 | -13 | let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter(p).flat_map(q)` on an `Iterator` +13 | let _: Vec<_> = vec![5_i8; 6].into_iter() | _____________________^ starting here... 14 | | .filter(|&x| x == 0) 15 | | .flat_map(|x| x.checked_mul(2)) @@ -28,7 +28,7 @@ error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly 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:18:21 | -18 | let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter_map(p).flat_map(q)` on an `Iterator` +18 | let _: Vec<_> = vec![5_i8; 6].into_iter() | _____________________^ starting here... 19 | | .filter_map(|x| x.checked_mul(2)) 20 | | .flat_map(|x| x.checked_mul(2)) @@ -39,7 +39,7 @@ error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinc 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:23:21 | -23 | let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter_map(p).map(q)` on an `Iterator` +23 | let _: Vec<_> = vec![5_i8; 6].into_iter() | _____________________^ starting here... 24 | | .filter_map(|x| x.checked_mul(2)) 25 | | .map(|x| x.checked_mul(2)) diff --git a/tests/ui/float_cmp.rs b/tests/ui/float_cmp.rs index 314cc7214..de897caca 100644 --- a/tests/ui/float_cmp.rs +++ b/tests/ui/float_cmp.rs @@ -41,46 +41,46 @@ fn main() { ZERO + ZERO != 1.0; //no error, comparison with zero is ok ONE == 1f32; - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (ONE - 1f32).abs() < error + + + ONE == 1.0 + 0.0; - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (ONE - (1.0 + 0.0)).abs() < error + + + ONE + ONE == ZERO + ONE + ONE; - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (ONE + ONE - (ZERO + ONE + ONE)).abs() < error + + + ONE != 2.0; - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (ONE - 2.0).abs() < error + + + ONE != 0.0; // no error, comparison with zero is ok twice(ONE) != ONE; - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (twice(ONE) - ONE).abs() < error + + + ONE as f64 != 2.0; - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (ONE as f64 - 2.0).abs() < error + + + ONE as f64 != 0.0; // no error, comparison with zero is ok let x : f64 = 1.0; x == 1.0; - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (x - 1.0).abs() < error + + + x != 0f64; // no error, comparison with zero is ok twice(x) != twice(ONE as f64); - //~^ ERROR strict comparison of f32 or f64 - //~| HELP within some error - //~| SUGGESTION (twice(x) - twice(ONE as f64)).abs() < error + + + x < 0.0; // no errors, lower or greater comparisons need no fuzzyness diff --git a/tests/ui/for_loop.rs b/tests/ui/for_loop.rs index 09b0431c6..42599f851 100644 --- a/tests/ui/for_loop.rs +++ b/tests/ui/for_loop.rs @@ -16,43 +16,43 @@ fn for_loop_over_option_and_result() { // check FOR_LOOP_OVER_OPTION lint for x in option { - //~^ ERROR for loop over `option`, which is an `Option`. - //~| HELP consider replacing `for x in option` with `if let Some(x) = option` + + println!("{}", x); } // check FOR_LOOP_OVER_RESULT lint for x in result { - //~^ ERROR for loop over `result`, which is a `Result`. - //~| HELP consider replacing `for x in result` with `if let Ok(x) = result` + + println!("{}", x); } for x in option.ok_or("x not found") { - //~^ ERROR for loop over `option.ok_or("x not found")`, which is a `Result`. - //~| HELP consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")` + + println!("{}", x); } // make sure LOOP_OVER_NEXT lint takes precedence when next() is the last call in the chain for x in v.iter().next() { - //~^ ERROR you are iterating over `Iterator::next()` which is an Option + println!("{}", x); } // make sure we lint when next() is not the last call in the chain for x in v.iter().next().and(Some(0)) { - //~^ ERROR for loop over `v.iter().next().and(Some(0))`, which is an `Option` - //~| HELP consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))` + + println!("{}", x); } for x in v.iter().next().ok_or("x not found") { - //~^ ERROR for loop over `v.iter().next().ok_or("x not found")`, which is a `Result` - //~| HELP consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")` + + println!("{}", x); } @@ -97,47 +97,47 @@ fn main() { let mut vec = vec![1, 2, 3, 4]; let vec2 = vec![1, 2, 3, 4]; for i in 0..vec.len() { - //~^ ERROR `i` is only used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in &vec { + + + + println!("{}", vec[i]); } for i in 0..vec.len() { - //~^ WARNING unused variable + let i = 42; // make a different `i` println!("{}", vec[i]); // ok, not the `i` of the for-loop } for i in 0..vec.len() { let _ = vec[i]; } - //~^ ERROR `i` is only used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in &vec { let _ = vec[i]; } + + + + // ICE #746 for j in 0..4 { - //~^ ERROR `j` is only used to index `STATIC` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in STATIC.iter().take(4) { + + + + println!("{:?}", STATIC[j]); } for j in 0..4 { - //~^ ERROR `j` is only used to index `CONST` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in CONST.iter().take(4) { + + + + println!("{:?}", CONST[j]); } for i in 0..vec.len() { - //~^ ERROR `i` is used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for (i, ) in vec.iter().enumerate() { + + + + println!("{} {}", vec[i], i); } for i in 0..vec.len() { // not an error, indexing more than one variable @@ -145,90 +145,90 @@ fn main() { } for i in 0..vec.len() { - //~^ ERROR `i` is only used to index `vec2` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in vec2.iter().take(vec.len()) { + + + + println!("{}", vec2[i]); } for i in 5..vec.len() { - //~^ ERROR `i` is only used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in vec.iter().skip(5) { + + + + println!("{}", vec[i]); } for i in 0..MAX_LEN { - //~^ ERROR `i` is only used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in vec.iter().take(MAX_LEN) { + + + + println!("{}", vec[i]); } for i in 0...MAX_LEN { - //~^ ERROR `i` is only used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in vec.iter().take(MAX_LEN + 1) { + + + + println!("{}", vec[i]); } for i in 5..10 { - //~^ ERROR `i` is only used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in vec.iter().take(10).skip(5) { + + + + println!("{}", vec[i]); } for i in 5...10 { - //~^ ERROR `i` is only used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for in vec.iter().take(10 + 1).skip(5) { + + + + println!("{}", vec[i]); } for i in 5..vec.len() { - //~^ ERROR `i` is used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for (i, ) in vec.iter().enumerate().skip(5) { + + + + println!("{} {}", vec[i], i); } for i in 5..10 { - //~^ ERROR `i` is used to index `vec` - //~| HELP consider - //~| HELP consider - //~| SUGGESTION for (i, ) in vec.iter().enumerate().take(10).skip(5) { + + + + println!("{} {}", vec[i], i); } for i in 10..0 { - //~^ERROR this range is empty so this for loop will never run - //~|HELP consider - //~|SUGGESTION (0..10).rev() + + + println!("{}", i); } for i in 10...0 { - //~^ERROR this range is empty so this for loop will never run - //~|HELP consider - //~|SUGGESTION (0...10).rev() + + + println!("{}", i); } - for i in MAX_LEN..0 { //~ERROR this range is empty so this for loop will never run - //~|HELP consider - //~|SUGGESTION (0..MAX_LEN).rev() + for i in MAX_LEN..0 { + + println!("{}", i); } - for i in 5..5 { //~ERROR this range is empty so this for loop will never run + for i in 5..5 { println!("{}", i); } @@ -250,20 +250,20 @@ fn main() { // testing that the empty range lint folds constants for i in 10..5+4 { - //~^ ERROR this range is empty so this for loop will never run - //~| HELP if you are attempting to iterate over this range in reverse - //~| SUGGESTION for i in (5+4..10).rev() { + + + println!("{}", i); } for i in (5+2)..(3-1) { - //~^ ERROR this range is empty so this for loop will never run - //~| HELP if you are attempting to iterate over this range in reverse - //~| SUGGESTION for i in ((3-1)..(5+2)).rev() { + + + println!("{}", i); } - for i in (5+2)..(8-1) { //~ERROR this range is empty so this for loop will never run + for i in (5+2)..(8-1) { println!("{}", i); } @@ -287,98 +287,98 @@ fn main() { } for _v in vec.iter() { } - //~^ ERROR it is more idiomatic to loop over `&vec` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &vec { + + + for _v in vec.iter_mut() { } - //~^ ERROR it is more idiomatic to loop over `&mut vec` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &mut vec { + + + let out_vec = vec![1,2,3]; for _v in out_vec.into_iter() { } - //~^ ERROR it is more idiomatic to loop over `out_vec` instead of `out_vec.into_iter()` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in out_vec { + + + for _v in &vec { } // these are fine for _v in &mut vec { } // these are fine for _v in [1, 2, 3].iter() { } - //~^ ERROR it is more idiomatic to loop over `&[ - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &[1, 2, 3] { + + + for _v in (&mut [1, 2, 3]).iter() { } // no error for _v in [0; 32].iter() {} - //~^ ERROR it is more idiomatic to loop over `&[ - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &[0; 32] { + + + for _v in [0; 33].iter() {} // no error let ll: LinkedList<()> = LinkedList::new(); for _v in ll.iter() { } - //~^ ERROR it is more idiomatic to loop over `&ll` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &ll { + + + let vd: VecDeque<()> = VecDeque::new(); for _v in vd.iter() { } - //~^ ERROR it is more idiomatic to loop over `&vd` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &vd { + + + let bh: BinaryHeap<()> = BinaryHeap::new(); for _v in bh.iter() { } - //~^ ERROR it is more idiomatic to loop over `&bh` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &bh { + + + let hm: HashMap<(), ()> = HashMap::new(); for _v in hm.iter() { } - //~^ ERROR it is more idiomatic to loop over `&hm` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &hm { + + + let bt: BTreeMap<(), ()> = BTreeMap::new(); for _v in bt.iter() { } - //~^ ERROR it is more idiomatic to loop over `&bt` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &bt { + + + let hs: HashSet<()> = HashSet::new(); for _v in hs.iter() { } - //~^ ERROR it is more idiomatic to loop over `&hs` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &hs { + + + let bs: BTreeSet<()> = BTreeSet::new(); for _v in bs.iter() { } - //~^ ERROR it is more idiomatic to loop over `&bs` - //~| HELP to write this more concisely, try looping over - //~| SUGGESTION for _v in &bs { - for _v in vec.iter().next() { } //~ERROR you are iterating over `Iterator::next()` + + + + for _v in vec.iter().next() { } let u = Unrelated(vec![]); for _v in u.next() { } // no error for _v in u.iter() { } // no error let mut out = vec![]; - vec.iter().map(|x| out.push(x)).collect::>(); //~ERROR you are collect()ing an iterator + vec.iter().map(|x| out.push(x)).collect::>(); let _y = vec.iter().map(|x| out.push(x)).collect::>(); // this is fine // Loop with explicit counter variable let mut _index = 0; - for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter + for _v in &vec { _index += 1 } let mut _index = 1; _index = 0; - for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter + for _v in &vec { _index += 1 } // Potential false positives let mut _index = 0; @@ -439,19 +439,19 @@ fn main() { let m : HashMap = HashMap::new(); for (_, v) in &m { - //~^ you seem to want to iterate on a map's values - //~| HELP use the corresponding method - //~| HELP use the corresponding method - //~| SUGGESTION for v in m.values() { + + + + let _v = v; } let m : Rc> = Rc::new(HashMap::new()); for (_, v) in &*m { - //~^ you seem to want to iterate on a map's values - //~| HELP use the corresponding method - //~| HELP use the corresponding method - //~| SUGGESTION for v in (*m).values() { + + + + let _v = v; // Here the `*` is not actually necesarry, but the test tests that we don't suggest // `in *m.values()` as we used to @@ -459,29 +459,29 @@ fn main() { let mut m : HashMap = HashMap::new(); for (_, v) in &mut m { - //~^ you seem to want to iterate on a map's values - //~| HELP use the corresponding method - //~| HELP use the corresponding method - //~| SUGGESTION for v in m.values_mut() + + + + let _v = v; } let m: &mut HashMap = &mut HashMap::new(); for (_, v) in &mut *m { - //~^ you seem to want to iterate on a map's values - //~| HELP use the corresponding method - //~| HELP use the corresponding method - //~| SUGGESTION for v in (*m).values_mut() + + + + let _v = v; } let m : HashMap = HashMap::new(); let rm = &m; for (k, _value) in rm { - //~^ you seem to want to iterate on a map's keys - //~| HELP use the corresponding method - //~| HELP use the corresponding method - //~| SUGGESTION for k in rm.keys() { + + + + let _k = k; } diff --git a/tests/ui/for_loop.stderr b/tests/ui/for_loop.stderr index 2e73a3438..2e9e5d1fe 100644 --- a/tests/ui/for_loop.stderr +++ b/tests/ui/for_loop.stderr @@ -40,7 +40,7 @@ error: you are iterating over `Iterator::next()` which is an Option; this will c | 40 | for x in v.iter().next() { | _____^ starting here... -41 | | //~^ ERROR you are iterating over `Iterator::next()` which is an Option +41 | | 42 | | println!("{}", x); 43 | | } | |_____^ ...ending here @@ -75,10 +75,10 @@ error: the loop variable `i` is only used to index `vec`. | 99 | for i in 0..vec.len() { | _____^ starting here... -100 | | //~^ ERROR `i` is only used to index `vec` -101 | | //~| HELP consider -102 | | //~| HELP consider -103 | | //~| SUGGESTION for in &vec { +100 | | +101 | | +102 | | +103 | | 104 | | println!("{}", vec[i]); 105 | | } | |_____^ ...ending here @@ -113,10 +113,10 @@ error: the loop variable `j` is only used to index `STATIC`. | 120 | for j in 0..4 { | _____^ starting here... -121 | | //~^ ERROR `j` is only used to index `STATIC` -122 | | //~| HELP consider -123 | | //~| HELP consider -124 | | //~| SUGGESTION for in STATIC.iter().take(4) { +121 | | +122 | | +123 | | +124 | | 125 | | println!("{:?}", STATIC[j]); 126 | | } | |_____^ ...ending here @@ -129,10 +129,10 @@ error: the loop variable `j` is only used to index `CONST`. | 128 | for j in 0..4 { | _____^ starting here... -129 | | //~^ ERROR `j` is only used to index `CONST` -130 | | //~| HELP consider -131 | | //~| HELP consider -132 | | //~| SUGGESTION for in CONST.iter().take(4) { +129 | | +130 | | +131 | | +132 | | 133 | | println!("{:?}", CONST[j]); 134 | | } | |_____^ ...ending here @@ -145,10 +145,10 @@ error: the loop variable `i` is used to index `vec` | 136 | for i in 0..vec.len() { | _____^ starting here... -137 | | //~^ ERROR `i` is used to index `vec` -138 | | //~| HELP consider -139 | | //~| HELP consider -140 | | //~| SUGGESTION for (i, ) in vec.iter().enumerate() { +137 | | +138 | | +139 | | +140 | | 141 | | println!("{} {}", vec[i], i); 142 | | } | |_____^ ...ending here @@ -161,10 +161,10 @@ error: the loop variable `i` is only used to index `vec2`. | 147 | for i in 0..vec.len() { | _____^ starting here... -148 | | //~^ ERROR `i` is only used to index `vec2` -149 | | //~| HELP consider -150 | | //~| HELP consider -151 | | //~| SUGGESTION for in vec2.iter().take(vec.len()) { +148 | | +149 | | +150 | | +151 | | 152 | | println!("{}", vec2[i]); 153 | | } | |_____^ ...ending here @@ -177,10 +177,10 @@ error: the loop variable `i` is only used to index `vec`. | 155 | for i in 5..vec.len() { | _____^ starting here... -156 | | //~^ ERROR `i` is only used to index `vec` -157 | | //~| HELP consider -158 | | //~| HELP consider -159 | | //~| SUGGESTION for in vec.iter().skip(5) { +156 | | +157 | | +158 | | +159 | | 160 | | println!("{}", vec[i]); 161 | | } | |_____^ ...ending here @@ -193,10 +193,10 @@ error: the loop variable `i` is only used to index `vec`. | 163 | for i in 0..MAX_LEN { | _____^ starting here... -164 | | //~^ ERROR `i` is only used to index `vec` -165 | | //~| HELP consider -166 | | //~| HELP consider -167 | | //~| SUGGESTION for in vec.iter().take(MAX_LEN) { +164 | | +165 | | +166 | | +167 | | 168 | | println!("{}", vec[i]); 169 | | } | |_____^ ...ending here @@ -209,10 +209,10 @@ error: the loop variable `i` is only used to index `vec`. | 171 | for i in 0...MAX_LEN { | _____^ starting here... -172 | | //~^ ERROR `i` is only used to index `vec` -173 | | //~| HELP consider -174 | | //~| HELP consider -175 | | //~| SUGGESTION for in vec.iter().take(MAX_LEN + 1) { +172 | | +173 | | +174 | | +175 | | 176 | | println!("{}", vec[i]); 177 | | } | |_____^ ...ending here @@ -225,10 +225,10 @@ error: the loop variable `i` is only used to index `vec`. | 179 | for i in 5..10 { | _____^ starting here... -180 | | //~^ ERROR `i` is only used to index `vec` -181 | | //~| HELP consider -182 | | //~| HELP consider -183 | | //~| SUGGESTION for in vec.iter().take(10).skip(5) { +180 | | +181 | | +182 | | +183 | | 184 | | println!("{}", vec[i]); 185 | | } | |_____^ ...ending here @@ -241,10 +241,10 @@ error: the loop variable `i` is only used to index `vec`. | 187 | for i in 5...10 { | _____^ starting here... -188 | | //~^ ERROR `i` is only used to index `vec` -189 | | //~| HELP consider -190 | | //~| HELP consider -191 | | //~| SUGGESTION for in vec.iter().take(10 + 1).skip(5) { +188 | | +189 | | +190 | | +191 | | 192 | | println!("{}", vec[i]); 193 | | } | |_____^ ...ending here @@ -257,10 +257,10 @@ error: the loop variable `i` is used to index `vec` | 195 | for i in 5..vec.len() { | _____^ starting here... -196 | | //~^ ERROR `i` is used to index `vec` -197 | | //~| HELP consider -198 | | //~| HELP consider -199 | | //~| SUGGESTION for (i, ) in vec.iter().enumerate().skip(5) { +196 | | +197 | | +198 | | +199 | | 200 | | println!("{} {}", vec[i], i); 201 | | } | |_____^ ...ending here @@ -273,10 +273,10 @@ error: the loop variable `i` is used to index `vec` | 203 | for i in 5..10 { | _____^ starting here... -204 | | //~^ ERROR `i` is used to index `vec` -205 | | //~| HELP consider -206 | | //~| HELP consider -207 | | //~| SUGGESTION for (i, ) in vec.iter().enumerate().take(10).skip(5) { +204 | | +205 | | +206 | | +207 | | 208 | | println!("{} {}", vec[i], i); 209 | | } | |_____^ ...ending here @@ -289,9 +289,9 @@ error: this range is empty so this for loop will never run | 211 | for i in 10..0 { | _____^ starting here... -212 | | //~^ERROR this range is empty so this for loop will never run -213 | | //~|HELP consider -214 | | //~|SUGGESTION (0..10).rev() +212 | | +213 | | +214 | | 215 | | println!("{}", i); 216 | | } | |_____^ ...ending here @@ -309,9 +309,9 @@ error: this range is empty so this for loop will never run | 218 | for i in 10...0 { | _____^ starting here... -219 | | //~^ERROR this range is empty so this for loop will never run -220 | | //~|HELP consider -221 | | //~|SUGGESTION (0...10).rev() +219 | | +220 | | +221 | | 222 | | println!("{}", i); 223 | | } | |_____^ ...ending here @@ -322,21 +322,21 @@ help: consider using the following if you are attempting to iterate over this ra error: this range is empty so this for loop will never run --> $DIR/for_loop.rs:225:5 | -225 | for i in MAX_LEN..0 { //~ERROR this range is empty so this for loop will never run +225 | for i in MAX_LEN..0 { | _____^ starting here... -226 | | //~|HELP consider -227 | | //~|SUGGESTION (0..MAX_LEN).rev() +226 | | +227 | | 228 | | println!("{}", i); 229 | | } | |_____^ ...ending here | help: consider using the following if you are attempting to iterate over this range in reverse - | for i in (0..MAX_LEN).rev() { //~ERROR this range is empty so this for loop will never run + | for i in (0..MAX_LEN).rev() { error: this range is empty so this for loop will never run --> $DIR/for_loop.rs:231:5 | -231 | for i in 5..5 { //~ERROR this range is empty so this for loop will never run +231 | for i in 5..5 { | _____^ starting here... 232 | | println!("{}", i); 233 | | } @@ -347,9 +347,9 @@ error: this range is empty so this for loop will never run | 252 | for i in 10..5+4 { | _____^ starting here... -253 | | //~^ ERROR this range is empty so this for loop will never run -254 | | //~| HELP if you are attempting to iterate over this range in reverse -255 | | //~| SUGGESTION for i in (5+4..10).rev() { +253 | | +254 | | +255 | | 256 | | println!("{}", i); 257 | | } | |_____^ ...ending here @@ -362,9 +362,9 @@ error: this range is empty so this for loop will never run | 259 | for i in (5+2)..(3-1) { | _____^ starting here... -260 | | //~^ ERROR this range is empty so this for loop will never run -261 | | //~| HELP if you are attempting to iterate over this range in reverse -262 | | //~| SUGGESTION for i in ((3-1)..(5+2)).rev() { +260 | | +261 | | +262 | | 263 | | println!("{}", i); 264 | | } | |_____^ ...ending here @@ -375,7 +375,7 @@ help: consider using the following if you are attempting to iterate over this ra error: this range is empty so this for loop will never run --> $DIR/for_loop.rs:266:5 | -266 | for i in (5+2)..(8-1) { //~ERROR this range is empty so this for loop will never run +266 | for i in (5+2)..(8-1) { | _____^ starting here... 267 | | println!("{}", i); 268 | | } @@ -502,7 +502,7 @@ help: to write this more concisely, try looping over 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:365:5 | -365 | for _v in vec.iter().next() { } //~ERROR you are iterating over `Iterator::next()` +365 | for _v in vec.iter().next() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -514,7 +514,7 @@ note: lint level defined here 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:372:5 | -372 | vec.iter().map(|x| out.push(x)).collect::>(); //~ERROR you are collect()ing an iterator +372 | vec.iter().map(|x| out.push(x)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -526,7 +526,7 @@ note: lint level defined here error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators --> $DIR/for_loop.rs:377:5 | -377 | for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter +377 | for _v in &vec { _index += 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -538,7 +538,7 @@ note: lint level defined here error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators --> $DIR/for_loop.rs:381:5 | -381 | for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter +381 | for _v in &vec { _index += 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values @@ -546,10 +546,10 @@ error: you seem to want to iterate on a map's values | 441 | for (_, v) in &m { | _____^ starting here... -442 | | //~^ you seem to want to iterate on a map's values -443 | | //~| HELP use the corresponding method -444 | | //~| HELP use the corresponding method -445 | | //~| SUGGESTION for v in m.values() { +442 | | +443 | | +444 | | +445 | | 446 | | let _v = v; 447 | | } | |_____^ ...ending here @@ -567,10 +567,10 @@ error: you seem to want to iterate on a map's values | 450 | for (_, v) in &*m { | _____^ starting here... -451 | | //~^ you seem to want to iterate on a map's values -452 | | //~| HELP use the corresponding method -453 | | //~| HELP use the corresponding method -454 | | //~| SUGGESTION for v in (*m).values() { +451 | | +452 | | +453 | | +454 | | 455 | | let _v = v; 456 | | // Here the `*` is not actually necesarry, but the test tests that we don't suggest 457 | | // `in *m.values()` as we used to @@ -585,10 +585,10 @@ error: you seem to want to iterate on a map's values | 461 | for (_, v) in &mut m { | _____^ starting here... -462 | | //~^ you seem to want to iterate on a map's values -463 | | //~| HELP use the corresponding method -464 | | //~| HELP use the corresponding method -465 | | //~| SUGGESTION for v in m.values_mut() +462 | | +463 | | +464 | | +465 | | 466 | | let _v = v; 467 | | } | |_____^ ...ending here @@ -601,10 +601,10 @@ error: you seem to want to iterate on a map's values | 470 | for (_, v) in &mut *m { | _____^ starting here... -471 | | //~^ you seem to want to iterate on a map's values -472 | | //~| HELP use the corresponding method -473 | | //~| HELP use the corresponding method -474 | | //~| SUGGESTION for v in (*m).values_mut() +471 | | +472 | | +473 | | +474 | | 475 | | let _v = v; 476 | | } | |_____^ ...ending here @@ -617,10 +617,10 @@ error: you seem to want to iterate on a map's keys | 480 | for (k, _value) in rm { | _____^ starting here... -481 | | //~^ you seem to want to iterate on a map's keys -482 | | //~| HELP use the corresponding method -483 | | //~| HELP use the corresponding method -484 | | //~| SUGGESTION for k in rm.keys() { +481 | | +482 | | +483 | | +484 | | 485 | | let _k = k; 486 | | } | |_____^ ...ending here diff --git a/tests/ui/format.rs b/tests/ui/format.rs index 4fff131f6..67561dca8 100644 --- a/tests/ui/format.rs +++ b/tests/ui/format.rs @@ -3,16 +3,16 @@ #![deny(useless_format)] fn main() { - format!("foo"); //~ERROR useless use of `format!` + format!("foo"); - format!("{}", "foo"); //~ERROR useless use of `format!` + format!("{}", "foo"); format!("{:?}", "foo"); // we only want to warn about `{}` format!("{:+}", "foo"); // we only want to warn about `{}` format!("foo {}", "bar"); format!("{} bar", "foo"); let arg: String = "".to_owned(); - format!("{}", arg); //~ERROR useless use of `format!` + format!("{}", arg); format!("{:?}", arg); // we only want to warn about `{}` format!("{:+}", arg); // we only want to warn about `{}` format!("foo {}", arg); diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index a913ef24b..51e0c5b6d 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -1,7 +1,7 @@ error: useless use of `format!` --> $DIR/format.rs:6:5 | -6 | format!("foo"); //~ERROR useless use of `format!` +6 | format!("foo"); | ^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,13 +13,13 @@ note: lint level defined here error: useless use of `format!` --> $DIR/format.rs:8:5 | -8 | format!("{}", "foo"); //~ERROR useless use of `format!` +8 | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^^ error: useless use of `format!` --> $DIR/format.rs:15:5 | -15 | format!("{}", arg); //~ERROR useless use of `format!` +15 | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/formatting.rs b/tests/ui/formatting.rs index 6c6671b0a..8d3c1d938 100644 --- a/tests/ui/formatting.rs +++ b/tests/ui/formatting.rs @@ -13,8 +13,8 @@ fn main() { // weird `else if` formatting: if foo() { } if foo() { - //~^ ERROR this looks like an `else if` but the `else` is missing - //~| NOTE add the missing `else` or + + } let _ = { // if as the last expression @@ -22,8 +22,8 @@ fn main() { if foo() { } if foo() { - //~^ ERROR this looks like an `else if` but the `else` is missing - //~| NOTE add the missing `else` or + + } else { } @@ -32,8 +32,8 @@ fn main() { let _ = { // if in the middle of a block if foo() { } if foo() { - //~^ ERROR this looks like an `else if` but the `else` is missing - //~| NOTE add the missing `else` or + + } else { } @@ -43,15 +43,15 @@ fn main() { if foo() { } else - //~^ ERROR this is an `else if` but the formatting might hide it - //~| NOTE remove the `else` or + + if foo() { // the span of the above error should continue here } if foo() { } - //~^ ERROR this is an `else if` but the formatting might hide it - //~| NOTE remove the `else` or + + else if foo() { // the span of the above error should continue here } @@ -81,16 +81,16 @@ fn main() { // weird op_eq formatting: let mut a = 42; a =- 35; - //~^ ERROR this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)` - //~| NOTE to remove this lint, use either `-=` or `= -` + + a =* &191; - //~^ ERROR this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)` - //~| NOTE to remove this lint, use either `*=` or `= *` + + let mut b = true; b =! false; - //~^ ERROR this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)` - //~| NOTE to remove this lint, use either `!=` or `= !` + + // those are ok: a = -35; @@ -100,14 +100,14 @@ fn main() { // possible missing comma in an array let _ = &[ -1, -2, -3 // <= no coma here - //~^ ERROR possibly missing a comma here - //~| NOTE to remove this lint, add a comma or write the expr in a single line + + -4, -5, -6 ]; let _ = &[ -1, -2, -3 // <= no coma here - //~^ ERROR possibly missing a comma here - //~| NOTE to remove this lint, add a comma or write the expr in a single line + + *4, -5, -6 ]; diff --git a/tests/ui/formatting.stderr b/tests/ui/formatting.stderr index 46ff2a45f..68260410f 100644 --- a/tests/ui/formatting.stderr +++ b/tests/ui/formatting.stderr @@ -35,8 +35,8 @@ error: this is an `else if` but the formatting might hide it | 45 | } else | ______^ starting here... -46 | | //~^ ERROR this is an `else if` but the formatting might hide it -47 | | //~| NOTE remove the `else` or +46 | | +47 | | 48 | | if foo() { // the span of the above error should continue here | |____^ ...ending here | @@ -48,8 +48,8 @@ error: this is an `else if` but the formatting might hide it | 52 | } | ______^ starting here... -53 | | //~^ ERROR this is an `else if` but the formatting might hide it -54 | | //~| NOTE remove the `else` or +53 | | +54 | | 55 | | else 56 | | if foo() { // the span of the above error should continue here | |____^ ...ending here diff --git a/tests/ui/functions.rs b/tests/ui/functions.rs index 60a074df0..bb09be575 100644 --- a/tests/ui/functions.rs +++ b/tests/ui/functions.rs @@ -9,7 +9,7 @@ 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: ()) { - //~^ ERROR: this function has too many arguments (8/7) + } // don't lint extern fns @@ -18,7 +18,7 @@ extern fn extern_fn(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, pub trait Foo { 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: ()); - //~^ ERROR: this function has too many arguments (8/7) + fn ptr(p: *const u8); } @@ -28,7 +28,7 @@ pub struct Bar; impl Bar { fn good_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {} fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {} - //~^ ERROR: this function has too many arguments (8/7) + } // ok, we don’t want to warn implementations @@ -38,11 +38,11 @@ impl Foo for Bar { fn ptr(p: *const u8) { println!("{}", unsafe { *p }); - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + println!("{:?}", unsafe { p.as_ref() }); - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + unsafe { std::ptr::read(p) }; - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + } } @@ -54,11 +54,11 @@ fn private(p: *const u8) { pub fn public(p: *const u8) { println!("{}", unsafe { *p }); - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + println!("{:?}", unsafe { p.as_ref() }); - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + unsafe { std::ptr::read(p) }; - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + } impl Bar { @@ -68,11 +68,11 @@ impl Bar { pub fn public(self, p: *const u8) { println!("{}", unsafe { *p }); - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + println!("{:?}", unsafe { p.as_ref() }); - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + unsafe { std::ptr::read(p) }; - //~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe` + } pub fn public_ok(self, p: *const u8) { diff --git a/tests/ui/functions.stderr b/tests/ui/functions.stderr index a66ea4b88..4a21f9466 100644 --- a/tests/ui/functions.stderr +++ b/tests/ui/functions.stderr @@ -3,7 +3,7 @@ error: this function has too many arguments (8/7) | 11 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) { | _^ starting here... -12 | | //~^ ERROR: this function has too many arguments (8/7) +12 | | 13 | | } | |_^ ...ending here | diff --git a/tests/ui/identity_op.rs b/tests/ui/identity_op.rs index 6a0b5e927..ea68ec3e1 100644 --- a/tests/ui/identity_op.rs +++ b/tests/ui/identity_op.rs @@ -10,21 +10,21 @@ const ZERO : i64 = 0; fn main() { let x = 0; - x + 0; //~ERROR the operation is ineffective - x + (1 - 1); //~ERROR the operation is ineffective + x + 0; + x + (1 - 1); x + 1; - 0 + x; //~ERROR the operation is ineffective + 0 + x; 1 + x; x - ZERO; //no error, as we skip lookups (for now) - x | (0); //~ERROR the operation is ineffective + x | (0); ((ZERO)) | x; //no error, as we skip lookups (for now) - x * 1; //~ERROR the operation is ineffective - 1 * x; //~ERROR the operation is ineffective + x * 1; + 1 * x; x / ONE; //no error, as we skip lookups (for now) x / 2; //no false positive x & NEG_ONE; //no error, as we skip lookups (for now) - -1 & x; //~ERROR the operation is ineffective + -1 & x; } diff --git a/tests/ui/identity_op.stderr b/tests/ui/identity_op.stderr index 7590a99ef..ab455ad15 100644 --- a/tests/ui/identity_op.stderr +++ b/tests/ui/identity_op.stderr @@ -1,7 +1,7 @@ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:13:5 | -13 | x + 0; //~ERROR the operation is ineffective +13 | x + 0; | ^^^^^ | note: lint level defined here @@ -13,37 +13,37 @@ note: lint level defined here error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:14:5 | -14 | x + (1 - 1); //~ERROR the operation is ineffective +14 | x + (1 - 1); | ^^^^^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:16:5 | -16 | 0 + x; //~ERROR the operation is ineffective +16 | 0 + x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:19:5 | -19 | x | (0); //~ERROR the operation is ineffective +19 | x | (0); | ^^^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:22:5 | -22 | x * 1; //~ERROR the operation is ineffective +22 | x * 1; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:23:5 | -23 | 1 * x; //~ERROR the operation is ineffective +23 | 1 * x; | ^^^^^ error: the operation is ineffective. Consider reducing it to `x` --> $DIR/identity_op.rs:29:5 | -29 | -1 & x; //~ERROR the operation is ineffective +29 | -1 & x; | ^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/if_let_redundant_pattern_matching.rs b/tests/ui/if_let_redundant_pattern_matching.rs index 24a3864b0..c48518304 100644 --- a/tests/ui/if_let_redundant_pattern_matching.rs +++ b/tests/ui/if_let_redundant_pattern_matching.rs @@ -7,26 +7,26 @@ fn main() { if let Ok(_) = Ok::(42) {} - //~^ERROR redundant pattern matching, consider using `is_ok()` - //~| HELP try this - //~| SUGGESTION if Ok::(42).is_ok() { + + + if let Err(_) = Err::(42) { - //~^ERROR redundant pattern matching, consider using `is_err()` - //~| HELP try this - //~| SUGGESTION if Err::(42).is_err() { + + + } if let None = None::<()> { - //~^ERROR redundant pattern matching, consider using `is_none()` - //~| HELP try this - //~| SUGGESTION if None::<()>.is_none() { + + + } if let Some(_) = Some(42) { - //~^ERROR redundant pattern matching, consider using `is_some()` - //~| HELP try this - //~| SUGGESTION if Some(42).is_some() { + + + } if Ok::(42).is_ok() { diff --git a/tests/ui/if_not_else.rs b/tests/ui/if_not_else.rs index a72699ada..5cdc6ce86 100644 --- a/tests/ui/if_not_else.rs +++ b/tests/ui/if_not_else.rs @@ -6,12 +6,12 @@ fn bla() -> bool { unimplemented!() } fn main() { - if !bla() { //~ ERROR: Unnecessary boolean `not` operation + if !bla() { println!("Bugs"); } else { println!("Bunny"); } - if 4 != 5 { //~ ERROR: Unnecessary `!=` operation + if 4 != 5 { println!("Bugs"); } else { println!("Bunny"); diff --git a/tests/ui/if_not_else.stderr b/tests/ui/if_not_else.stderr index f31be63dd..ecdd7254d 100644 --- a/tests/ui/if_not_else.stderr +++ b/tests/ui/if_not_else.stderr @@ -1,7 +1,7 @@ error: Unnecessary boolean `not` operation --> $DIR/if_not_else.rs:9:5 | -9 | if !bla() { //~ ERROR: Unnecessary boolean `not` operation +9 | if !bla() { | _____^ starting here... 10 | | println!("Bugs"); 11 | | } else { @@ -19,7 +19,7 @@ note: lint level defined here error: Unnecessary `!=` operation --> $DIR/if_not_else.rs:14:5 | -14 | if 4 != 5 { //~ ERROR: Unnecessary `!=` operation +14 | if 4 != 5 { | _____^ starting here... 15 | | println!("Bugs"); 16 | | } else { diff --git a/tests/ui/invalid_upcast_comparisons.rs b/tests/ui/invalid_upcast_comparisons.rs index 9635f3afe..952cf1e43 100644 --- a/tests/ui/invalid_upcast_comparisons.rs +++ b/tests/ui/invalid_upcast_comparisons.rs @@ -7,22 +7,22 @@ fn main() { let zero: u32 = 0; let u8_max: u8 = 255; - (u8_max as u32) > 300; //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false + (u8_max as u32) > 300; (u8_max as u32) > 20; - (zero as i32) < -5; //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false + (zero as i32) < -5; (zero as i32) < 10; - -5 < (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always true - 0 <= (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always true + -5 < (zero as i32); + 0 <= (zero as i32); 0 < (zero as i32); - -5 > (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false - -5 >= (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false - 1337 == (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false + -5 > (zero as i32); + -5 >= (u8_max as i32); + 1337 == (u8_max as i32); - -5 == (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false - -5 != (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always true + -5 == (zero as i32); + -5 != (u8_max as i32); // Those are Ok: 42 == (u8_max as i32); diff --git a/tests/ui/invalid_upcast_comparisons.stderr b/tests/ui/invalid_upcast_comparisons.stderr index 1fd96e4de..e7eda752f 100644 --- a/tests/ui/invalid_upcast_comparisons.stderr +++ b/tests/ui/invalid_upcast_comparisons.stderr @@ -1,7 +1,7 @@ error: because of the numeric bounds on `u8_max` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:10:5 | -10 | (u8_max as u32) > 300; //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false +10 | (u8_max as u32) > 300; | ^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,49 +13,49 @@ note: lint level defined here error: because of the numeric bounds on `zero` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:13:5 | -13 | (zero as i32) < -5; //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false +13 | (zero as i32) < -5; | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `zero` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:16:5 | -16 | -5 < (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always true +16 | -5 < (zero as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `zero` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:17:5 | -17 | 0 <= (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always true +17 | 0 <= (zero as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `zero` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:20:5 | -20 | -5 > (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false +20 | -5 > (zero as i32); | ^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8_max` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:21:5 | -21 | -5 >= (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false +21 | -5 >= (u8_max as i32); | ^^^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8_max` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:22:5 | -22 | 1337 == (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false +22 | 1337 == (u8_max as i32); | ^^^^^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `zero` prior to casting, this expression is always false --> $DIR/invalid_upcast_comparisons.rs:24:5 | -24 | -5 == (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false +24 | -5 == (zero as i32); | ^^^^^^^^^^^^^^^^^^^ error: because of the numeric bounds on `u8_max` prior to casting, this expression is always true --> $DIR/invalid_upcast_comparisons.rs:25:5 | -25 | -5 != (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always true +25 | -5 != (u8_max as i32); | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/item_after_statement.rs b/tests/ui/item_after_statement.rs index 4be89176f..09b509673 100644 --- a/tests/ui/item_after_statement.rs +++ b/tests/ui/item_after_statement.rs @@ -9,11 +9,11 @@ fn ok() { fn last() { foo(); - fn foo() { println!("foo"); } //~ ERROR adding items after statements is confusing + fn foo() { println!("foo"); } } fn main() { foo(); - fn foo() { println!("foo"); } //~ ERROR adding items after statements is confusing + fn foo() { println!("foo"); } foo(); } diff --git a/tests/ui/item_after_statement.stderr b/tests/ui/item_after_statement.stderr index be3455c2a..318db240c 100644 --- a/tests/ui/item_after_statement.stderr +++ b/tests/ui/item_after_statement.stderr @@ -1,7 +1,7 @@ error: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:12:5 | -12 | fn foo() { println!("foo"); } //~ ERROR adding items after statements is confusing +12 | fn foo() { println!("foo"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: adding items after statements is confusing, since items exist from the start of the scope --> $DIR/item_after_statement.rs:17:5 | -17 | fn foo() { println!("foo"); } //~ ERROR adding items after statements is confusing +17 | fn foo() { println!("foo"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/large_enum_variant.rs b/tests/ui/large_enum_variant.rs index 8d289a328..5bbcb9391 100644 --- a/tests/ui/large_enum_variant.rs +++ b/tests/ui/large_enum_variant.rs @@ -7,19 +7,19 @@ enum LargeEnum { A(i32), - B([i32; 8000]), //~ ERROR large enum variant found - //~^ HELP consider boxing the large fields to reduce the total size of the enum - //~| SUGGESTION Box<[i32; 8000]> + B([i32; 8000]), + + } enum GenericEnum { A(i32), - B([i32; 8000]), //~ ERROR large enum variant found - //~^ HELP consider boxing the large fields to reduce the total size of the enum - //~| SUGGESTION Box<[i32; 8000]> + B([i32; 8000]), + + C([T; 8000]), - D(T, [i32; 8000]), //~ ERROR large enum variant found - //~^ HELP consider boxing the large fields to reduce the total size of the enum + D(T, [i32; 8000]), + } trait SomeTrait { @@ -32,19 +32,19 @@ enum LargeEnumGeneric { enum AnotherLargeEnum { VariantOk(i32, u32), - ContainingLargeEnum(LargeEnum), //~ ERROR large enum variant found - //~^ HELP consider boxing the large fields to reduce the total size of the enum - //~| SUGGESTION Box - ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), //~ ERROR large enum variant found - //~^ HELP consider boxing the large fields to reduce the total size of the enum + ContainingLargeEnum(LargeEnum), + + + ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), + VoidVariant, StructLikeLittle { x: i32, y: i32 }, - StructLikeLarge { x: [i32; 8000], y: i32 }, //~ ERROR large enum variant found - //~^ HELP consider boxing the large fields to reduce the total size of the enum - StructLikeLarge2 { //~ ERROR large enum variant found + StructLikeLarge { x: [i32; 8000], y: i32 }, + + StructLikeLarge2 { x: - [i32; 8000] //~ SUGGESTION Box<[i32; 8000]> - //~^ HELP consider boxing the large fields to reduce the total size of the enum + [i32; 8000] + }, } diff --git a/tests/ui/large_enum_variant.stderr b/tests/ui/large_enum_variant.stderr index 8b7b39902..77155b6ab 100644 --- a/tests/ui/large_enum_variant.stderr +++ b/tests/ui/large_enum_variant.stderr @@ -1,7 +1,7 @@ error: large enum variant found --> $DIR/large_enum_variant.rs:10:5 | -10 | B([i32; 8000]), //~ ERROR large enum variant found +10 | B([i32; 8000]), | ^^^^^^^^^^^^^^ | note: lint level defined here @@ -10,75 +10,75 @@ note: lint level defined here 6 | #![deny(large_enum_variant)] | ^^^^^^^^^^^^^^^^^^ help: consider boxing the large fields to reduce the total size of the enum - | B(Box<[i32; 8000]>), //~ ERROR large enum variant found + | B(Box<[i32; 8000]>), error: large enum variant found --> $DIR/large_enum_variant.rs:17:5 | -17 | B([i32; 8000]), //~ ERROR large enum variant found +17 | B([i32; 8000]), | ^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - | B(Box<[i32; 8000]>), //~ ERROR large enum variant found + | B(Box<[i32; 8000]>), error: large enum variant found --> $DIR/large_enum_variant.rs:21:5 | -21 | D(T, [i32; 8000]), //~ ERROR large enum variant found +21 | D(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum --> $DIR/large_enum_variant.rs:21:5 | -21 | D(T, [i32; 8000]), //~ ERROR large enum variant found +21 | D(T, [i32; 8000]), | ^^^^^^^^^^^^^^^^^ error: large enum variant found --> $DIR/large_enum_variant.rs:35:5 | -35 | ContainingLargeEnum(LargeEnum), //~ ERROR large enum variant found +35 | ContainingLargeEnum(LargeEnum), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider boxing the large fields to reduce the total size of the enum - | ContainingLargeEnum(Box), //~ ERROR large enum variant found + | ContainingLargeEnum(Box), error: large enum variant found --> $DIR/large_enum_variant.rs:38:5 | -38 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), //~ ERROR large enum variant found +38 | 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:38:5 | -38 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), //~ ERROR large enum variant found +38 | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large enum variant found --> $DIR/large_enum_variant.rs:42:5 | -42 | StructLikeLarge { x: [i32; 8000], y: i32 }, //~ ERROR large enum variant found +42 | 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:42:5 | -42 | StructLikeLarge { x: [i32; 8000], y: i32 }, //~ ERROR large enum variant found +42 | StructLikeLarge { x: [i32; 8000], y: i32 }, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: large enum variant found --> $DIR/large_enum_variant.rs:44:5 | -44 | StructLikeLarge2 { //~ ERROR large enum variant found +44 | StructLikeLarge2 { | _____^ starting here... 45 | | x: -46 | | [i32; 8000] //~ SUGGESTION Box<[i32; 8000]> -47 | | //~^ HELP consider boxing the large fields to reduce the total size of the enum +46 | | [i32; 8000] +47 | | 48 | | }, | |_____^ ...ending here | help: consider boxing the large fields to reduce the total size of the enum - | Box<[i32; 8000]> //~ SUGGESTION Box<[i32; 8000]> + | Box<[i32; 8000]> error: aborting due to 7 previous errors diff --git a/tests/ui/len_zero.rs b/tests/ui/len_zero.rs index b640c6db3..a310eeef3 100644 --- a/tests/ui/len_zero.rs +++ b/tests/ui/len_zero.rs @@ -7,7 +7,7 @@ pub struct PubOne; impl PubOne { - pub fn len(self: &Self) -> isize { //~ERROR item `PubOne` has a public `len` method but no corresponding `is_empty` + pub fn len(self: &Self) -> isize { 1 } } @@ -29,7 +29,7 @@ impl One { } pub trait PubTraitsToo { - fn len(self: &Self) -> isize; //~ERROR trait `PubTraitsToo` has a `len` method but no `is_empty` + fn len(self: &Self) -> isize; } impl PubTraitsToo for One { @@ -63,7 +63,7 @@ impl HasPrivateIsEmpty { pub struct HasIsEmpty; impl HasIsEmpty { - pub fn len(self: &Self) -> isize { //~ERROR item `HasIsEmpty` has a public `len` method but a private `is_empty` + pub fn len(self: &Self) -> isize { 1 } @@ -92,7 +92,7 @@ impl WithIsEmpty for Wither { pub struct HasWrongIsEmpty; impl HasWrongIsEmpty { - pub fn len(self: &Self) -> isize { //~ERROR item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` + pub fn len(self: &Self) -> isize { 1 } @@ -104,16 +104,16 @@ impl HasWrongIsEmpty { fn main() { let x = [1, 2]; if x.len() == 0 { - //~^ERROR length comparison to zero - //~|HELP consider using `is_empty` - //~|SUGGESTION x.is_empty() + + + println!("This should not happen!"); } if "".len() == 0 { - //~^ERROR length comparison to zero - //~|HELP consider using `is_empty` - //~|SUGGESTION "".is_empty() + + + } let y = One; @@ -128,30 +128,30 @@ fn main() { let has_is_empty = HasIsEmpty; if has_is_empty.len() == 0 { - //~^ERROR length comparison to zero - //~|HELP consider using `is_empty` - //~|SUGGESTION has_is_empty.is_empty() + + + println!("Or this!"); } if has_is_empty.len() != 0 { - //~^ERROR length comparison to zero - //~|HELP consider using `is_empty` - //~|SUGGESTION !has_is_empty.is_empty() + + + println!("Or this!"); } if has_is_empty.len() > 0 { - //~^ERROR length comparison to zero - //~|HELP consider using `is_empty` - //~|SUGGESTION !has_is_empty.is_empty() + + + println!("Or this!"); } assert!(!has_is_empty.is_empty()); let with_is_empty: &WithIsEmpty = &Wither; if with_is_empty.len() == 0 { - //~^ERROR length comparison to zero - //~|HELP consider using `is_empty` - //~|SUGGESTION with_is_empty.is_empty() + + + println!("Or this!"); } assert!(!with_is_empty.is_empty()); diff --git a/tests/ui/len_zero.stderr b/tests/ui/len_zero.stderr index 48ee0a7ff..5aaaecf55 100644 --- a/tests/ui/len_zero.stderr +++ b/tests/ui/len_zero.stderr @@ -1,7 +1,7 @@ error: item `PubOne` has a public `len` method but no corresponding `is_empty` method --> $DIR/len_zero.rs:10:5 | -10 | pub fn len(self: &Self) -> isize { //~ERROR item `PubOne` has a public `len` method but no corresponding `is_empty` +10 | pub fn len(self: &Self) -> isize { | _____^ starting here... 11 | | 1 12 | | } @@ -16,13 +16,13 @@ note: lint level defined here error: trait `PubTraitsToo` has a `len` method but no `is_empty` method --> $DIR/len_zero.rs:32:5 | -32 | fn len(self: &Self) -> isize; //~ERROR trait `PubTraitsToo` has a `len` method but no `is_empty` +32 | fn len(self: &Self) -> isize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` method --> $DIR/len_zero.rs:66:5 | -66 | pub fn len(self: &Self) -> isize { //~ERROR item `HasIsEmpty` has a public `len` method but a private `is_empty` +66 | pub fn len(self: &Self) -> isize { | _____^ starting here... 67 | | 1 68 | | } @@ -31,7 +31,7 @@ error: item `HasIsEmpty` has a public `len` method but a private `is_empty` meth error: item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` method --> $DIR/len_zero.rs:95:5 | -95 | pub fn len(self: &Self) -> isize { //~ERROR item `HasWrongIsEmpty` has a public `len` method but no corresponding `is_empty` +95 | pub fn len(self: &Self) -> isize { | _____^ starting here... 96 | | 1 97 | | } diff --git a/tests/ui/let_if_seq.rs b/tests/ui/let_if_seq.rs index b49e5a261..9e221cc5b 100644 --- a/tests/ui/let_if_seq.rs +++ b/tests/ui/let_if_seq.rs @@ -55,17 +55,17 @@ fn main() { issue985_alt(); let mut foo = 0; - //~^ ERROR `if _ { .. } else { .. }` is an expression - //~| HELP more idiomatic - //~| SUGGESTION let foo = if f() { 42 } else { 0 }; + + + if f() { foo = 42; } let mut bar = 0; - //~^ ERROR `if _ { .. } else { .. }` is an expression - //~| HELP more idiomatic - //~| SUGGESTION let bar = if f() { ..; 42 } else { ..; 0 }; + + + if f() { f(); bar = 42; @@ -75,9 +75,9 @@ fn main() { } let quz; - //~^ ERROR `if _ { .. } else { .. }` is an expression - //~| HELP more idiomatic - //~| SUGGESTION let quz = if f() { 42 } else { 0 }; + + + if f() { quz = 42; @@ -109,9 +109,9 @@ fn main() { // baz needs to be mut let mut baz = 0; - //~^ ERROR `if _ { .. } else { .. }` is an expression - //~| HELP more idiomatic - //~| SUGGESTION let baz = if f() { 42 } else { 0 }; + + + if f() { baz = 42; } diff --git a/tests/ui/let_if_seq.stderr b/tests/ui/let_if_seq.stderr index 47ca7d2af..fb5ef47ce 100644 --- a/tests/ui/let_if_seq.stderr +++ b/tests/ui/let_if_seq.stderr @@ -3,9 +3,9 @@ error: `if _ { .. } else { .. }` is an expression | 57 | let mut foo = 0; | _____^ starting here... -58 | | //~^ ERROR `if _ { .. } else { .. }` is an expression -59 | | //~| HELP more idiomatic -60 | | //~| SUGGESTION let foo = if f() { 42 } else { 0 }; +58 | | +59 | | +60 | | 61 | | if f() { 62 | | foo = 42; 63 | | } @@ -44,9 +44,9 @@ error: `if _ { .. } else { .. }` is an expression | 111 | let mut baz = 0; | _____^ starting here... -112 | | //~^ ERROR `if _ { .. } else { .. }` is an expression -113 | | //~| HELP more idiomatic -114 | | //~| SUGGESTION let baz = if f() { 42 } else { 0 }; +112 | | +113 | | +114 | | 115 | | if f() { 116 | | baz = 42; 117 | | } diff --git a/tests/ui/let_return.rs b/tests/ui/let_return.rs index 477786813..de0bb9b3c 100644 --- a/tests/ui/let_return.rs +++ b/tests/ui/let_return.rs @@ -6,14 +6,14 @@ fn test() -> i32 { let _y = 0; // no warning - let x = 5; //~NOTE this expression can be directly returned - x //~ERROR returning the result of a let binding + let x = 5; + x } fn test_inner() -> i32 { if true { - let x = 5; //~NOTE this expression can be directly returned - x //~ERROR returning the result of a let binding + let x = 5; + x } else { 0 } diff --git a/tests/ui/let_return.stderr b/tests/ui/let_return.stderr index 13197e541..8b5cfa6f3 100644 --- a/tests/ui/let_return.stderr +++ b/tests/ui/let_return.stderr @@ -1,7 +1,7 @@ error: returning the result of a let binding from a block. Consider returning the expression directly. --> $DIR/let_return.rs:10:5 | -10 | x //~ERROR returning the result of a let binding +10 | x | ^ | note: lint level defined here @@ -12,19 +12,19 @@ note: lint level defined here note: this expression can be directly returned --> $DIR/let_return.rs:9:13 | -9 | let x = 5; //~NOTE this expression can be directly returned +9 | let x = 5; | ^ error: returning the result of a let binding from a block. Consider returning the expression directly. --> $DIR/let_return.rs:16:9 | -16 | x //~ERROR returning the result of a let binding +16 | x | ^ | note: this expression can be directly returned --> $DIR/let_return.rs:15:17 | -15 | let x = 5; //~NOTE this expression can be directly returned +15 | let x = 5; | ^ error: aborting due to 2 previous errors diff --git a/tests/ui/let_unit.rs b/tests/ui/let_unit.rs index a0143406e..fe541f305 100644 --- a/tests/ui/let_unit.rs +++ b/tests/ui/let_unit.rs @@ -11,11 +11,11 @@ macro_rules! let_and_return { } fn main() { - let _x = println!("x"); //~ERROR this let-binding has unit value + let _x = println!("x"); let _y = 1; // this is fine let _z = ((), 1); // this as well if true { - let _a = (); //~ERROR this let-binding has unit value + let _a = (); } let_and_return!(()) // should be fine diff --git a/tests/ui/let_unit.stderr b/tests/ui/let_unit.stderr index 863b9dc59..abeeb3b39 100644 --- a/tests/ui/let_unit.stderr +++ b/tests/ui/let_unit.stderr @@ -1,7 +1,7 @@ error: this let-binding has unit value. Consider omitting `let _x =` --> $DIR/let_unit.rs:14:5 | -14 | let _x = println!("x"); //~ERROR this let-binding has unit value +14 | let _x = println!("x"); | ^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: this let-binding has unit value. Consider omitting `let _a =` --> $DIR/let_unit.rs:18:9 | -18 | let _a = (); //~ERROR this let-binding has unit value +18 | let _a = (); | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/lifetimes.rs b/tests/ui/lifetimes.rs index 408b6762d..ade0deeea 100644 --- a/tests/ui/lifetimes.rs +++ b/tests/ui/lifetimes.rs @@ -5,10 +5,10 @@ #![allow(dead_code)] fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) { } -//~^ERROR explicit lifetimes given + fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) { } -//~^ERROR explicit lifetimes given + fn same_lifetime_on_input<'a>(_x: &'a u8, _y: &'a u8) { } // no error, same lifetime on two params @@ -17,7 +17,7 @@ fn only_static_on_input(_x: &u8, _y: &u8, _z: &'static u8) { } // no error, stat fn mut_and_static_input(_x: &mut u8, _y: &'static str) { } fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 { x } -//~^ERROR explicit lifetimes given + fn multiple_in_and_out_1<'a>(x: &'a u8, _y: &'a u8) -> &'a u8 { x } // no error, multiple input refs @@ -30,18 +30,18 @@ fn deep_reference_1<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> { Ok(x) 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) } -//~^ERROR explicit lifetimes given + // 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) } -//~^ERROR explicit lifetimes given + 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_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) { } -//~^ERROR explicit lifetimes given + fn lifetime_param_3<'a, 'b: 'a>(_x: Ref<'a>, _y: &'b u8) { } // no error, bounded lifetime @@ -55,7 +55,7 @@ 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!() } -fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> //~ERROR explicit lifetimes given +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!() } @@ -65,12 +65,12 @@ struct X { impl X { fn self_and_out<'s>(&'s self) -> &'s u8 { &self.x } - //~^ERROR explicit lifetimes given + 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) { } - //~^ERROR explicit lifetimes given + fn self_and_same_in<'s>(&'s self, _x: &'s u8) { } // no error, same lifetimes on two params } @@ -86,7 +86,7 @@ fn already_elided<'a>(_: &u8, _: &'a u8) -> &'a u8 { unimplemented!() } -fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } //~ERROR explicit lifetimes given +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!() } @@ -106,11 +106,11 @@ 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!() } //~ERROR explicit lifetimes given +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!() } //~ERROR explicit lifetimes given +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!() } @@ -121,11 +121,11 @@ 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 named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } //~ERROR explicit lifetimes given +fn named_input_elided_output<'a>(_arg: &'a str) -> &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!() } //~ERROR explicit lifetimes given +fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } fn trait_bound<'a, T: WithLifetime<'a>>(_: &'a u8, _: T) { unimplemented!() } fn main() { diff --git a/tests/ui/lifetimes.stderr b/tests/ui/lifetimes.stderr index 0d5f75c89..6d213ad45 100644 --- a/tests/ui/lifetimes.stderr +++ b/tests/ui/lifetimes.stderr @@ -43,7 +43,7 @@ error: explicit lifetimes given in parameter types where they could be elided error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:58:1 | -58 | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> //~ERROR explicit lifetimes given +58 | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I> | _^ starting here... 59 | | where for<'x> F: Fn(Lt<'x, I>) -> Lt<'x, I> 60 | | { unreachable!() } @@ -64,31 +64,31 @@ error: explicit lifetimes given in parameter types where they could be elided error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:89:1 | -89 | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } //~ERROR explicit lifetimes given +89 | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:109:1 | -109 | fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { unimplemented!() } //~ERROR explicit lifetimes given +109 | fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:113:1 | -113 | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } //~ERROR explicit lifetimes given +113 | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:124:1 | -124 | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } //~ERROR explicit lifetimes given +124 | fn named_input_elided_output<'a>(_arg: &'a str) -> &str { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: explicit lifetimes given in parameter types where they could be elided --> $DIR/lifetimes.rs:128:1 | -128 | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } //~ERROR explicit lifetimes given +128 | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) { unimplemented!() } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/lint_pass.rs b/tests/ui/lint_pass.rs index 980ae5cb7..5b65a5c3a 100644 --- a/tests/ui/lint_pass.rs +++ b/tests/ui/lint_pass.rs @@ -10,7 +10,7 @@ use rustc::lint::{LintPass, LintArray}; declare_lint! { GOOD_LINT, Warn, "good lint" } declare_lint! { MISSING_LINT, Warn, "missing lint" } -//~^ ERROR: the lint `MISSING_LINT` is not added to any `LintPass` + pub struct Pass; diff --git a/tests/ui/literals.rs b/tests/ui/literals.rs index 6c8a27c2e..e4cee81d5 100644 --- a/tests/ui/literals.rs +++ b/tests/ui/literals.rs @@ -11,27 +11,27 @@ fn main() { let ok4 = 0xab_cd_i32; let ok5 = 0xAB_CD_u32; let ok5 = 0xAB_CD_isize; - let fail1 = 0xabCD; //~ERROR inconsistent casing in hexadecimal literal - let fail2 = 0xabCD_u32; //~ERROR inconsistent casing in hexadecimal literal - let fail2 = 0xabCD_isize; //~ERROR inconsistent casing in hexadecimal literal + let fail1 = 0xabCD; + let fail2 = 0xabCD_u32; + let fail2 = 0xabCD_isize; let ok6 = 1234_i32; let ok7 = 1234_f32; let ok8 = 1234_isize; - let fail3 = 1234i32; //~ERROR integer type suffix should be separated - let fail4 = 1234u32; //~ERROR integer type suffix should be separated - let fail5 = 1234isize; //~ERROR integer type suffix should be separated - let fail6 = 1234usize; //~ERROR integer type suffix should be separated - let fail7 = 1.5f32; //~ERROR float type suffix should be separated + let fail3 = 1234i32; + let fail4 = 1234u32; + let fail5 = 1234isize; + let fail6 = 1234usize; + let fail7 = 1.5f32; let ok9 = 0; let ok10 = 0_i64; let fail8 = 0123; - //~^ERROR decimal constant - //~|HELP remove the `0` - //~|SUGGESTION = 123; - //~|HELP use `0o` - //~|SUGGESTION = 0o123; + + + + + let ok11 = 0o123; let ok12 = 0b101010; diff --git a/tests/ui/literals.stderr b/tests/ui/literals.stderr index 2806e688c..b9a0fc041 100644 --- a/tests/ui/literals.stderr +++ b/tests/ui/literals.stderr @@ -1,7 +1,7 @@ error: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:14:17 | -14 | let fail1 = 0xabCD; //~ERROR inconsistent casing in hexadecimal literal +14 | let fail1 = 0xabCD; | ^^^^^^ | note: lint level defined here @@ -13,19 +13,19 @@ note: lint level defined here error: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:15:17 | -15 | let fail2 = 0xabCD_u32; //~ERROR inconsistent casing in hexadecimal literal +15 | let fail2 = 0xabCD_u32; | ^^^^^^^^^^ error: inconsistent casing in hexadecimal literal --> $DIR/literals.rs:16:17 | -16 | let fail2 = 0xabCD_isize; //~ERROR inconsistent casing in hexadecimal literal +16 | let fail2 = 0xabCD_isize; | ^^^^^^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:21:17 | -21 | let fail3 = 1234i32; //~ERROR integer type suffix should be separated +21 | let fail3 = 1234i32; | ^^^^^^^ | note: lint level defined here @@ -37,25 +37,25 @@ note: lint level defined here error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:22:17 | -22 | let fail4 = 1234u32; //~ERROR integer type suffix should be separated +22 | let fail4 = 1234u32; | ^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:23:17 | -23 | let fail5 = 1234isize; //~ERROR integer type suffix should be separated +23 | let fail5 = 1234isize; | ^^^^^^^^^ error: integer type suffix should be separated by an underscore --> $DIR/literals.rs:24:17 | -24 | let fail6 = 1234usize; //~ERROR integer type suffix should be separated +24 | let fail6 = 1234usize; | ^^^^^^^^^ error: float type suffix should be separated by an underscore --> $DIR/literals.rs:25:17 | -25 | let fail7 = 1.5f32; //~ERROR float type suffix should be separated +25 | let fail7 = 1.5f32; | ^^^^^^ error: this is a decimal constant diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index b4f97ae8e..f62d73532 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -9,30 +9,30 @@ use std::ops::Deref; fn map_clone_iter() { let x = [1,2,3]; - x.iter().map(|y| y.clone()); //~ ERROR you seem to be using .map() - //~^ HELP try - x.iter().map(|&y| y); //~ ERROR you seem to be using .map() - //~^ HELP try - x.iter().map(|y| *y); //~ ERROR you seem to be using .map() - //~^ HELP try - x.iter().map(|y| { y.clone() }); //~ ERROR you seem to be using .map() - //~^ HELP try - x.iter().map(|&y| { y }); //~ ERROR you seem to be using .map() - //~^ HELP try - x.iter().map(|y| { *y }); //~ ERROR you seem to be using .map() - //~^ HELP try - x.iter().map(Clone::clone); //~ ERROR you seem to be using .map() - //~^ HELP try + x.iter().map(|y| y.clone()); + + x.iter().map(|&y| y); + + x.iter().map(|y| *y); + + x.iter().map(|y| { y.clone() }); + + x.iter().map(|&y| { y }); + + x.iter().map(|y| { *y }); + + x.iter().map(Clone::clone); + } fn map_clone_option() { let x = Some(4); - x.as_ref().map(|y| y.clone()); //~ ERROR you seem to be using .map() - //~^ HELP try - x.as_ref().map(|&y| y); //~ ERROR you seem to be using .map() - //~^ HELP try - x.as_ref().map(|y| *y); //~ ERROR you seem to be using .map() - //~^ HELP try + x.as_ref().map(|y| y.clone()); + + x.as_ref().map(|&y| y); + + x.as_ref().map(|y| *y); + } fn not_linted_option() { @@ -87,8 +87,8 @@ impl Deref for UnusualDeref { fn map_clone_deref() { let x = Some(UnusualDeref); - let _: Option = x.as_ref().map(|y| *y); //~ ERROR you seem to be using .map() - //~^ HELP try + let _: Option = x.as_ref().map(|y| *y); + // Not linted: using deref conversion let _: Option = x.map(|y| *y); diff --git a/tests/ui/map_clone.stderr b/tests/ui/map_clone.stderr index aa44340dc..0a8a659d7 100644 --- a/tests/ui/map_clone.stderr +++ b/tests/ui/map_clone.stderr @@ -1,7 +1,7 @@ error: you seem to be using .map() to clone the contents of an iterator, consider using `.cloned()` --> $DIR/map_clone.rs:12:5 | -12 | x.iter().map(|y| y.clone()); //~ ERROR you seem to be using .map() +12 | x.iter().map(|y| y.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -15,7 +15,7 @@ note: lint level defined here error: you seem to be using .map() to clone the contents of an iterator, consider using `.cloned()` --> $DIR/map_clone.rs:14:5 | -14 | x.iter().map(|&y| y); //~ ERROR you seem to be using .map() +14 | x.iter().map(|&y| y); | ^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -24,7 +24,7 @@ error: you seem to be using .map() to clone the contents of an iterator, conside error: you seem to be using .map() to clone the contents of an iterator, consider using `.cloned()` --> $DIR/map_clone.rs:16:5 | -16 | x.iter().map(|y| *y); //~ ERROR you seem to be using .map() +16 | x.iter().map(|y| *y); | ^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -33,7 +33,7 @@ error: you seem to be using .map() to clone the contents of an iterator, conside error: you seem to be using .map() to clone the contents of an iterator, consider using `.cloned()` --> $DIR/map_clone.rs:18:5 | -18 | x.iter().map(|y| { y.clone() }); //~ ERROR you seem to be using .map() +18 | x.iter().map(|y| { y.clone() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -42,7 +42,7 @@ error: you seem to be using .map() to clone the contents of an iterator, conside error: you seem to be using .map() to clone the contents of an iterator, consider using `.cloned()` --> $DIR/map_clone.rs:20:5 | -20 | x.iter().map(|&y| { y }); //~ ERROR you seem to be using .map() +20 | x.iter().map(|&y| { y }); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -51,7 +51,7 @@ error: you seem to be using .map() to clone the contents of an iterator, conside error: you seem to be using .map() to clone the contents of an iterator, consider using `.cloned()` --> $DIR/map_clone.rs:22:5 | -22 | x.iter().map(|y| { *y }); //~ ERROR you seem to be using .map() +22 | x.iter().map(|y| { *y }); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -60,7 +60,7 @@ error: you seem to be using .map() to clone the contents of an iterator, conside error: you seem to be using .map() to clone the contents of an iterator, consider using `.cloned()` --> $DIR/map_clone.rs:24:5 | -24 | x.iter().map(Clone::clone); //~ ERROR you seem to be using .map() +24 | x.iter().map(Clone::clone); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -69,7 +69,7 @@ error: you seem to be using .map() to clone the contents of an iterator, conside error: you seem to be using .map() to clone the contents of an Option, consider using `.cloned()` --> $DIR/map_clone.rs:30:5 | -30 | x.as_ref().map(|y| y.clone()); //~ ERROR you seem to be using .map() +30 | x.as_ref().map(|y| y.clone()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -78,7 +78,7 @@ error: you seem to be using .map() to clone the contents of an Option, consider error: you seem to be using .map() to clone the contents of an Option, consider using `.cloned()` --> $DIR/map_clone.rs:32:5 | -32 | x.as_ref().map(|&y| y); //~ ERROR you seem to be using .map() +32 | x.as_ref().map(|&y| y); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -87,7 +87,7 @@ error: you seem to be using .map() to clone the contents of an Option, consider error: you seem to be using .map() to clone the contents of an Option, consider using `.cloned()` --> $DIR/map_clone.rs:34:5 | -34 | x.as_ref().map(|y| *y); //~ ERROR you seem to be using .map() +34 | x.as_ref().map(|y| *y); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: try @@ -96,7 +96,7 @@ error: you seem to be using .map() to clone the contents of an Option, consider error: you seem to be using .map() to clone the contents of an Option, consider using `.cloned()` --> $DIR/map_clone.rs:90:35 | -90 | let _: Option = x.as_ref().map(|y| *y); //~ ERROR you seem to be using .map() +90 | let _: Option = x.as_ref().map(|y| *y); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: try diff --git a/tests/ui/matches.rs b/tests/ui/matches.rs index 6cfb45e1f..00faed268 100644 --- a/tests/ui/matches.rs +++ b/tests/ui/matches.rs @@ -24,9 +24,9 @@ fn dummy() { fn unwrap_addr() -> Option<&'static ExprNode> { match ExprNode::Butterflies { - //~^ ERROR you seem to be trying to use match - //~| HELP try - //~| SUGGESTION if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None } + + + ExprNode::ExprAddrOf => Some(&NODE), _ => { let x = 5; None }, } @@ -36,18 +36,18 @@ fn single_match(){ let x = Some(1u8); match x { - //~^ ERROR you seem to be trying to use match - //~| HELP try - //~| SUGGESTION if let Some(y) = x { println!("{:?}", y); }; + + + Some(y) => { println!("{:?}", y); } _ => () }; let z = (1u8,1u8); match z { - //~^ ERROR you seem to be trying to use match - //~| HELP try - //~| SUGGESTION if let (2...3, 7...9) = z { dummy() }; + + + (2...3, 7...9) => dummy(), _ => {} }; @@ -70,17 +70,17 @@ fn single_match_know_enum() { let y : Result<_, i8> = Ok(1i8); match x { - //~^ ERROR you seem to be trying to use match - //~| HELP try - //~| SUGGESTION if let Some(y) = x { dummy() }; + + + Some(y) => dummy(), None => () }; match y { - //~^ ERROR you seem to be trying to use match - //~| HELP try - //~| SUGGESTION if let Ok(y) = y { dummy() }; + + + Ok(y) => dummy(), Err(..) => () }; @@ -88,9 +88,9 @@ fn single_match_know_enum() { let c = Cow::Borrowed(""); match c { - //~^ ERROR you seem to be trying to use match - //~| HELP try - //~| SUGGESTION if let Cow::Borrowed(..) = c { dummy() }; + + + Cow::Borrowed(..) => dummy(), Cow::Owned(..) => (), }; @@ -112,51 +112,51 @@ fn match_bool() { let test: bool = true; match test { - //~^ ERROR you seem to be trying to match on a boolean expression - //~| HELP consider - //~| SUGGESTION if test { 0 } else { 42 }; + + + true => 0, false => 42, }; let option = 1; match option == 1 { - //~^ ERROR you seem to be trying to match on a boolean expression - //~| HELP consider - //~| SUGGESTION if option == 1 { 1 } else { 0 }; + + + true => 1, false => 0, }; match test { - //~^ ERROR you seem to be trying to match on a boolean expression - //~| HELP consider - //~| SUGGESTION if !test { println!("Noooo!"); }; + + + true => (), false => { println!("Noooo!"); } }; match test { - //~^ ERROR you seem to be trying to match on a boolean expression - //~| HELP consider - //~| SUGGESTION if !test { println!("Noooo!"); }; + + + false => { println!("Noooo!"); } _ => (), }; match test && test { - //~^ ERROR you seem to be trying to match on a boolean expression - //~| HELP consider - //~| SUGGESTION if !(test && test) { println!("Noooo!"); }; - //~| ERROR equal expressions as operands + + + + false => { println!("Noooo!"); } _ => (), }; match test { - //~^ ERROR you seem to be trying to match on a boolean expression - //~| HELP consider - //~| SUGGESTION if test { println!("Yes!"); } else { println!("Noooo!"); }; + + + false => { println!("Noooo!"); } true => { println!("Yes!"); } }; @@ -173,9 +173,9 @@ fn ref_pats() { { let v = &Some(0); match v { - //~^ERROR add `&` to all patterns - //~|HELP instead of - //~|SUGGESTION match *v { .. } + + + &Some(v) => println!("{:?}", v), &None => println!("none"), } @@ -186,18 +186,18 @@ fn ref_pats() { } let tup =& (1, 2); match tup { - //~^ERROR add `&` to all patterns - //~|HELP instead of - //~|SUGGESTION match *tup { .. } + + + &(v, 1) => println!("{}", v), _ => println!("none"), } // special case: using & both in expr and pats let w = Some(0); match &w { - //~^ERROR add `&` to both - //~|HELP try - //~|SUGGESTION match w { .. } + + + &Some(v) => println!("{:?}", v), &None => println!("none"), } @@ -209,17 +209,17 @@ fn ref_pats() { let a = &Some(0); if let &None = a { - //~^ERROR add `&` to all patterns - //~|HELP instead of - //~|SUGGESTION if let .. = *a { .. } + + + println!("none"); } let b = Some(0); if let &None = &b { - //~^ERROR add `&` to both - //~|HELP try - //~|SUGGESTION if let .. = b { .. } + + + println!("none"); } } @@ -228,27 +228,27 @@ fn overlapping() { const FOO : u64 = 2; match 42 { - 0 ... 10 => println!("0 ... 10"), //~ERROR: some ranges overlap - 0 ... 11 => println!("0 ... 11"), //~NOTE overlaps with this + 0 ... 10 => println!("0 ... 10"), + 0 ... 11 => println!("0 ... 11"), _ => (), } match 42 { - 0 ... 5 => println!("0 ... 5"), //~ERROR: some ranges overlap + 0 ... 5 => println!("0 ... 5"), 6 ... 7 => println!("6 ... 7"), - FOO ... 11 => println!("0 ... 11"), //~NOTE overlaps with this + FOO ... 11 => println!("0 ... 11"), _ => (), } match 42 { - 2 => println!("2"), //~NOTE overlaps with this - 0 ... 5 => println!("0 ... 5"), //~ERROR: some ranges overlap + 2 => println!("2"), + 0 ... 5 => println!("0 ... 5"), _ => (), } match 42 { - 2 => println!("2"), //~NOTE overlaps with this - 0 ... 2 => println!("0 ... 2"), //~ERROR: some ranges overlap + 2 => println!("2"), + 0 ... 2 => println!("0 ... 2"), _ => (), } @@ -271,8 +271,8 @@ fn overlapping() { } match 42 { - 0 .. 11 => println!("0 .. 11"), //~ERROR: some ranges overlap - 0 ... 11 => println!("0 ... 11"), //~NOTE overlaps with this + 0 .. 11 => println!("0 .. 11"), + 0 ... 11 => println!("0 ... 11"), _ => (), } diff --git a/tests/ui/matches.stderr b/tests/ui/matches.stderr index d24bb6cb1..bc254cb0b 100644 --- a/tests/ui/matches.stderr +++ b/tests/ui/matches.stderr @@ -3,9 +3,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 26 | match ExprNode::Butterflies { | _____^ starting here... -27 | | //~^ ERROR you seem to be trying to use match -28 | | //~| HELP try -29 | | //~| SUGGESTION if let ExprNode::ExprAddrOf = ExprNode::Butterflies { Some(&NODE) } else { let x = 5; None } +27 | | +28 | | +29 | | 30 | | ExprNode::ExprAddrOf => Some(&NODE), 31 | | _ => { let x = 5; None }, 32 | | } @@ -24,9 +24,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 38 | match x { | _____^ starting here... -39 | | //~^ ERROR you seem to be trying to use match -40 | | //~| HELP try -41 | | //~| SUGGESTION if let Some(y) = x { println!("{:?}", y); }; +39 | | +40 | | +41 | | 42 | | Some(y) => { println!("{:?}", y); } 43 | | _ => () 44 | | }; @@ -46,9 +46,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 47 | match z { | _____^ starting here... -48 | | //~^ ERROR you seem to be trying to use match -49 | | //~| HELP try -50 | | //~| SUGGESTION if let (2...3, 7...9) = z { dummy() }; +48 | | +49 | | +50 | | 51 | | (2...3, 7...9) => dummy(), 52 | | _ => {} 53 | | }; @@ -63,9 +63,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 72 | match x { | _____^ starting here... -73 | | //~^ ERROR you seem to be trying to use match -74 | | //~| HELP try -75 | | //~| SUGGESTION if let Some(y) = x { dummy() }; +73 | | +74 | | +75 | | 76 | | Some(y) => dummy(), 77 | | None => () 78 | | }; @@ -80,9 +80,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 80 | match y { | _____^ starting here... -81 | | //~^ ERROR you seem to be trying to use match -82 | | //~| HELP try -83 | | //~| SUGGESTION if let Ok(y) = y { dummy() }; +81 | | +82 | | +83 | | 84 | | Ok(y) => dummy(), 85 | | Err(..) => () 86 | | }; @@ -97,9 +97,9 @@ error: you seem to be trying to use match for destructuring a single pattern. Co | 90 | match c { | _____^ starting here... -91 | | //~^ ERROR you seem to be trying to use match -92 | | //~| HELP try -93 | | //~| SUGGESTION if let Cow::Borrowed(..) = c { dummy() }; +91 | | +92 | | +93 | | 94 | | Cow::Borrowed(..) => dummy(), 95 | | Cow::Owned(..) => (), 96 | | }; @@ -114,9 +114,9 @@ error: you seem to be trying to match on a boolean expression | 114 | match test { | _____^ starting here... -115 | | //~^ ERROR you seem to be trying to match on a boolean expression -116 | | //~| HELP consider -117 | | //~| SUGGESTION if test { 0 } else { 42 }; +115 | | +116 | | +117 | | 118 | | true => 0, 119 | | false => 42, 120 | | }; @@ -136,9 +136,9 @@ error: you seem to be trying to match on a boolean expression | 123 | match option == 1 { | _____^ starting here... -124 | | //~^ ERROR you seem to be trying to match on a boolean expression -125 | | //~| HELP consider -126 | | //~| SUGGESTION if option == 1 { 1 } else { 0 }; +124 | | +125 | | +126 | | 127 | | true => 1, 128 | | false => 0, 129 | | }; @@ -153,9 +153,9 @@ error: you seem to be trying to match on a boolean expression | 131 | match test { | _____^ starting here... -132 | | //~^ ERROR you seem to be trying to match on a boolean expression -133 | | //~| HELP consider -134 | | //~| SUGGESTION if !test { println!("Noooo!"); }; +132 | | +133 | | +134 | | 135 | | true => (), 136 | | false => { println!("Noooo!"); } 137 | | }; @@ -170,9 +170,9 @@ error: you seem to be trying to match on a boolean expression | 139 | match test { | _____^ starting here... -140 | | //~^ ERROR you seem to be trying to match on a boolean expression -141 | | //~| HELP consider -142 | | //~| SUGGESTION if !test { println!("Noooo!"); }; +140 | | +141 | | +142 | | 143 | | false => { println!("Noooo!"); } 144 | | _ => (), 145 | | }; @@ -187,10 +187,10 @@ error: you seem to be trying to match on a boolean expression | 147 | match test && test { | _____^ starting here... -148 | | //~^ ERROR you seem to be trying to match on a boolean expression -149 | | //~| HELP consider -150 | | //~| SUGGESTION if !(test && test) { println!("Noooo!"); }; -151 | | //~| ERROR equal expressions as operands +148 | | +149 | | +150 | | +151 | | 152 | | false => { println!("Noooo!"); } 153 | | _ => (), 154 | | }; @@ -218,9 +218,9 @@ error: you seem to be trying to match on a boolean expression | 156 | match test { | _____^ starting here... -157 | | //~^ ERROR you seem to be trying to match on a boolean expression -158 | | //~| HELP consider -159 | | //~| SUGGESTION if test { println!("Yes!"); } else { println!("Noooo!"); }; +157 | | +158 | | +159 | | 160 | | false => { println!("Noooo!"); } 161 | | true => { println!("Yes!"); } 162 | | }; @@ -235,9 +235,9 @@ error: you don't need to add `&` to all patterns | 175 | match v { | _________^ starting here... -176 | | //~^ERROR add `&` to all patterns -177 | | //~|HELP instead of -178 | | //~|SUGGESTION match *v { .. } +176 | | +177 | | +178 | | 179 | | &Some(v) => println!("{:?}", v), 180 | | &None => println!("none"), 181 | | } @@ -257,9 +257,9 @@ error: you don't need to add `&` to all patterns | 188 | match tup { | _____^ starting here... -189 | | //~^ERROR add `&` to all patterns -190 | | //~|HELP instead of -191 | | //~|SUGGESTION match *tup { .. } +189 | | +190 | | +191 | | 192 | | &(v, 1) => println!("{}", v), 193 | | _ => println!("none"), 194 | | } @@ -274,9 +274,9 @@ error: you don't need to add `&` to both the expression and the patterns | 197 | match &w { | _____^ starting here... -198 | | //~^ERROR add `&` to both -199 | | //~|HELP try -200 | | //~|SUGGESTION match w { .. } +198 | | +199 | | +200 | | 201 | | &Some(v) => println!("{:?}", v), 202 | | &None => println!("none"), 203 | | } @@ -291,9 +291,9 @@ error: you don't need to add `&` to all patterns | 211 | if let &None = a { | _____^ starting here... -212 | | //~^ERROR add `&` to all patterns -213 | | //~|HELP instead of -214 | | //~|SUGGESTION if let .. = *a { .. } +212 | | +213 | | +214 | | 215 | | println!("none"); 216 | | } | |_____^ ...ending here @@ -307,9 +307,9 @@ error: you don't need to add `&` to both the expression and the patterns | 219 | if let &None = &b { | _____^ starting here... -220 | | //~^ERROR add `&` to both -221 | | //~|HELP try -222 | | //~|SUGGESTION if let .. = b { .. } +220 | | +221 | | +222 | | 223 | | println!("none"); 224 | | } | |_____^ ...ending here @@ -321,7 +321,7 @@ help: try error: some ranges overlap --> $DIR/matches.rs:231:9 | -231 | 0 ... 10 => println!("0 ... 10"), //~ERROR: some ranges overlap +231 | 0 ... 10 => println!("0 ... 10"), | ^^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] @@ -333,59 +333,59 @@ note: lint level defined here note: overlaps with this --> $DIR/matches.rs:232:9 | -232 | 0 ... 11 => println!("0 ... 11"), //~NOTE overlaps with this +232 | 0 ... 11 => println!("0 ... 11"), | ^^^^^^^^ error: some ranges overlap --> $DIR/matches.rs:237:9 | -237 | 0 ... 5 => println!("0 ... 5"), //~ERROR: some ranges overlap +237 | 0 ... 5 => println!("0 ... 5"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this --> $DIR/matches.rs:239:9 | -239 | FOO ... 11 => println!("0 ... 11"), //~NOTE overlaps with this +239 | FOO ... 11 => println!("0 ... 11"), | ^^^^^^^^^^ error: some ranges overlap --> $DIR/matches.rs:245:9 | -245 | 0 ... 5 => println!("0 ... 5"), //~ERROR: some ranges overlap +245 | 0 ... 5 => println!("0 ... 5"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this --> $DIR/matches.rs:244:9 | -244 | 2 => println!("2"), //~NOTE overlaps with this +244 | 2 => println!("2"), | ^ error: some ranges overlap --> $DIR/matches.rs:251:9 | -251 | 0 ... 2 => println!("0 ... 2"), //~ERROR: some ranges overlap +251 | 0 ... 2 => println!("0 ... 2"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this --> $DIR/matches.rs:250:9 | -250 | 2 => println!("2"), //~NOTE overlaps with this +250 | 2 => println!("2"), | ^ error: some ranges overlap --> $DIR/matches.rs:274:9 | -274 | 0 .. 11 => println!("0 .. 11"), //~ERROR: some ranges overlap +274 | 0 .. 11 => println!("0 .. 11"), | ^^^^^^^ | = note: #[deny(match_overlapping_arm)] implied by #[deny(clippy)] note: overlaps with this --> $DIR/matches.rs:275:9 | -275 | 0 ... 11 => println!("0 ... 11"), //~NOTE overlaps with this +275 | 0 ... 11 => println!("0 ... 11"), | ^^^^^^^^ error: aborting due to 23 previous errors diff --git a/tests/ui/mem_forget.rs b/tests/ui/mem_forget.rs index c8cebcb2a..9832bd992 100644 --- a/tests/ui/mem_forget.rs +++ b/tests/ui/mem_forget.rs @@ -14,15 +14,15 @@ fn main() { let six: Arc = Arc::new(6); memstuff::forget(six); - //~^ ERROR usage of mem::forget on Drop type + let seven: Rc = Rc::new(7); std::mem::forget(seven); - //~^ ERROR usage of mem::forget on Drop type + let eight: Vec = vec![8]; forgetSomething(eight); - //~^ ERROR usage of mem::forget on Drop type + std::mem::forget(7); } diff --git a/tests/ui/methods.rs b/tests/ui/methods.rs index 43a438688..da37ac8f5 100644 --- a/tests/ui/methods.rs +++ b/tests/ui/methods.rs @@ -15,21 +15,21 @@ use std::iter::FromIterator; struct T; impl T { - fn add(self, other: T) -> T { self } //~ERROR defining a method called `add` - fn drop(&mut self) { } //~ERROR defining a method called `drop` + fn add(self, other: T) -> T { self } + fn drop(&mut self) { } fn sub(&self, other: T) -> &T { self } // no error, self is a ref fn div(self) -> T { self } // no error, different #arguments fn rem(self, other: T) { } // no error, wrong return type fn into_u32(self) -> u32 { 0 } // fine - fn into_u16(&self) -> u16 { 0 } //~ERROR methods called `into_*` usually take self by value + fn into_u16(&self) -> u16 { 0 } - fn to_something(self) -> u32 { 0 } //~ERROR methods called `to_*` usually take self by reference + fn to_something(self) -> u32 { 0 } fn new(self) {} - //~^ ERROR methods called `new` usually take no self - //~| ERROR methods called `new` usually return `Self` + + } struct Lt<'a> { @@ -96,15 +96,15 @@ fn option_methods() { // Check OPTION_MAP_UNWRAP_OR // single line case - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)` - //~| NOTE replace `map(|x| x + 1).unwrap_or(0)` + let _ = opt.map(|x| x + 1) + .unwrap_or(0); // should lint even though this call is on a separate line // multi line cases - let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or(a)` + let _ = opt.map(|x| { x + 1 } ).unwrap_or(0); - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)` + let _ = opt.map(|x| x + 1) .unwrap_or({ 0 }); @@ -113,15 +113,15 @@ fn option_methods() { // Check OPTION_MAP_UNWRAP_OR_ELSE // single line case - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)` - //~| NOTE replace `map(|x| x + 1).unwrap_or_else(|| 0)` + let _ = opt.map(|x| x + 1) + .unwrap_or_else(|| 0); // should lint even though this call is on a separate line // multi line cases - let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or_else(g)` + let _ = opt.map(|x| { x + 1 } ).unwrap_or_else(|| 0); - let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)` + let _ = opt.map(|x| x + 1) .unwrap_or_else(|| 0 ); @@ -194,11 +194,11 @@ fn filter_next() { // check single-line case let _ = v.iter().filter(|&x| *x < 0).next(); - //~^ ERROR called `filter(p).next()` on an `Iterator`. - //~| NOTE replace `filter(|&x| *x < 0).next()` + + // check multi-line case - let _ = v.iter().filter(|&x| { //~ERROR called `filter(p).next()` on an `Iterator`. + let _ = v.iter().filter(|&x| { *x < 0 } ).next(); @@ -214,33 +214,33 @@ fn search_is_some() { // check `find().is_some()`, single-line let _ = v.iter().find(|&x| *x < 0).is_some(); - //~^ ERROR called `is_some()` after searching - //~| NOTE replace `find(|&x| *x < 0).is_some()` + + // check `find().is_some()`, multi-line - let _ = v.iter().find(|&x| { //~ERROR called `is_some()` after searching + let _ = v.iter().find(|&x| { *x < 0 } ).is_some(); // check `position().is_some()`, single-line let _ = v.iter().position(|&x| x < 0).is_some(); - //~^ ERROR called `is_some()` after searching - //~| NOTE replace `position(|&x| x < 0).is_some()` + + // check `position().is_some()`, multi-line - let _ = v.iter().position(|&x| { //~ERROR called `is_some()` after searching + let _ = v.iter().position(|&x| { x < 0 } ).is_some(); // check `rposition().is_some()`, single-line let _ = v.iter().rposition(|&x| x < 0).is_some(); - //~^ ERROR called `is_some()` after searching - //~| NOTE replace `rposition(|&x| x < 0).is_some()` + + // check `rposition().is_some()`, multi-line - let _ = v.iter().rposition(|&x| { //~ERROR called `is_some()` after searching + let _ = v.iter().rposition(|&x| { x < 0 } ).is_some(); @@ -276,75 +276,75 @@ fn or_fun_call() { let with_constructor = Some(vec![1]); with_constructor.unwrap_or(make()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_constructor.unwrap_or_else(make) + + + let with_new = Some(vec![1]); with_new.unwrap_or(Vec::new()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_new.unwrap_or_default(); + + + let with_const_args = Some(vec![1]); with_const_args.unwrap_or(Vec::with_capacity(12)); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_const_args.unwrap_or_else(|| Vec::with_capacity(12)); + + + let with_err : Result<_, ()> = Ok(vec![1]); with_err.unwrap_or(make()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_err.unwrap_or_else(|_| make()); + + + let with_err_args : Result<_, ()> = Ok(vec![1]); with_err_args.unwrap_or(Vec::with_capacity(12)); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_err_args.unwrap_or_else(|_| Vec::with_capacity(12)); + + + let with_default_trait = Some(1); with_default_trait.unwrap_or(Default::default()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_default_trait.unwrap_or_default(); + + + let with_default_type = Some(1); with_default_type.unwrap_or(u64::default()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION with_default_type.unwrap_or_default(); + + + let with_vec = Some(vec![1]); with_vec.unwrap_or(vec![]); - //~^ERROR use of `unwrap_or` - //~|HELP try this + + // FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]); let without_default = Some(Foo); without_default.unwrap_or(Foo::new()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION without_default.unwrap_or_else(Foo::new); + + + let mut map = HashMap::::new(); map.entry(42).or_insert(String::new()); - //~^ERROR use of `or_insert` followed by a function call - //~|HELP try this - //~|SUGGESTION map.entry(42).or_insert_with(String::new); + + + let mut btree = BTreeMap::::new(); btree.entry(42).or_insert(String::new()); - //~^ERROR use of `or_insert` followed by a function call - //~|HELP try this - //~|SUGGESTION btree.entry(42).or_insert_with(String::new); + + + let stringy = Some(String::from("")); let _ = stringy.unwrap_or("".to_owned()); - //~^ERROR use of `unwrap_or` - //~|HELP try this - //~|SUGGESTION stringy.unwrap_or_else(|| "".to_owned()); + + + } /// Checks implementation of `ITER_NTH` lint @@ -356,27 +356,27 @@ fn iter_nth() { { // Make sure we lint `.iter()` for relevant types let bad_vec = some_vec.iter().nth(3); - //~^ERROR called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable + let bad_slice = &some_vec[..].iter().nth(3); - //~^ERROR called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable + let bad_boxed_slice = boxed_slice.iter().nth(3); - //~^ERROR called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable + let bad_vec_deque = some_vec_deque.iter().nth(3); - //~^ERROR called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable + } { // Make sure we lint `.iter_mut()` for relevant types let bad_vec = some_vec.iter_mut().nth(3); - //~^ERROR called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable + } { let bad_slice = &some_vec[..].iter_mut().nth(3); - //~^ERROR called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable + } { let bad_vec_deque = some_vec_deque.iter_mut().nth(3); - //~^ERROR called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable + } // Make sure we don't lint for non-relevant types @@ -390,16 +390,16 @@ fn iter_skip_next() { let mut some_vec = vec![0, 1, 2, 3]; let _ = some_vec.iter().skip(42).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let _ = some_vec.iter().cycle().skip(42).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let _ = (1..10).skip(10).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let _ = &some_vec[..].iter().skip(3).next(); - //~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)` + let foo = IteratorFalsePositives { foo : 0 }; let _ = foo.skip(42).next(); @@ -427,50 +427,50 @@ fn get_unwrap() { { // Test `get().unwrap()` let _ = boxed_slice.get(1).unwrap(); - //~^ERROR called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION boxed_slice[1] + + + let _ = some_slice.get(0).unwrap(); - //~^ERROR called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_slice[0] + + + let _ = some_vec.get(0).unwrap(); - //~^ERROR called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_vec[0] + + + let _ = some_vecdeque.get(0).unwrap(); - //~^ERROR called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_vecdeque[0] + + + let _ = some_hashmap.get(&1).unwrap(); - //~^ERROR called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_hashmap[&1] + + + let _ = some_btreemap.get(&1).unwrap(); - //~^ERROR called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION some_btreemap[&1] + + + let _ = false_positive.get(0).unwrap(); } { // Test `get_mut().unwrap()` *boxed_slice.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut boxed_slice[0] + + + *some_slice.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut some_slice[0] + + + *some_vec.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut some_vec[0] + + + *some_vecdeque.get_mut(0).unwrap() = 1; - //~^ERROR called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise - //~|HELP try this - //~|SUGGESTION &mut some_vecdeque[0] + + + // Check false positives *some_hashmap.get_mut(&1).unwrap() = 'b'; @@ -485,24 +485,24 @@ fn main() { use std::io; let opt = Some(0); - let _ = opt.unwrap(); //~ERROR used unwrap() on an Option + let _ = opt.unwrap(); let res: Result = Ok(0); - let _ = res.unwrap(); //~ERROR used unwrap() on a Result + let _ = res.unwrap(); - res.ok().expect("disaster!"); //~ERROR called `ok().expect()` + res.ok().expect("disaster!"); // the following should not warn, since `expect` isn't implemented unless // the error type implements `Debug` let res2: Result = Ok(0); res2.ok().expect("oh noes!"); let res3: Result>= Ok(0); - res3.ok().expect("whoof"); //~ERROR called `ok().expect()` + res3.ok().expect("whoof"); let res4: Result = Ok(0); - res4.ok().expect("argh"); //~ERROR called `ok().expect()` + res4.ok().expect("argh"); let res5: io::Result = Ok(0); - res5.ok().expect("oops"); //~ERROR called `ok().expect()` + res5.ok().expect("oops"); let res6: Result = Ok(0); - res6.ok().expect("meh"); //~ERROR called `ok().expect()` + res6.ok().expect("meh"); } struct MyError(()); // doesn't implement Debug @@ -515,14 +515,14 @@ struct MyErrorWithParam { #[allow(unnecessary_operation)] fn starts_with() { "".chars().next() == Some(' '); - //~^ ERROR starts_with - //~| HELP like this - //~| SUGGESTION "".starts_with(' ') + + + Some(' ') != "".chars().next(); - //~^ ERROR starts_with - //~| HELP like this - //~| SUGGESTION !"".starts_with(' ') + + + } fn str_extend_chars() { @@ -532,21 +532,21 @@ fn str_extend_chars() { s.push_str(abc); s.extend(abc.chars()); - //~^ERROR calling `.extend(_.chars())` - //~|HELP try this - //~|SUGGESTION s.push_str(abc) + + + s.push_str("abc"); s.extend("abc".chars()); - //~^ERROR calling `.extend(_.chars())` - //~|HELP try this - //~|SUGGESTION s.push_str("abc") + + + s.push_str(&def); s.extend(def.chars()); - //~^ERROR calling `.extend(_.chars())` - //~|HELP try this - //~|SUGGESTION s.push_str(&def) + + + s.extend(abc.chars().skip(1)); s.extend("abc".chars().skip(1)); @@ -557,40 +557,40 @@ fn str_extend_chars() { } fn clone_on_copy() { - 42.clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try removing the `clone` call - //~| SUGGESTION 42 + 42.clone(); + + vec![1].clone(); // ok, not a Copy type Some(vec![1]).clone(); // ok, not a Copy type - (&42).clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try dereferencing it - //~| SUGGESTION *(&42) + (&42).clone(); + + } fn clone_on_copy_generic(t: T) { - t.clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try removing the `clone` call - //~| SUGGESTION t - Some(t).clone(); //~ERROR using `clone` on a `Copy` type - //~| HELP try removing the `clone` call - //~| SUGGESTION Some(t) + t.clone(); + + + Some(t).clone(); + + } fn clone_on_double_ref() { let x = vec![1]; let y = &&x; - let z: &Vec<_> = y.clone(); //~ERROR using `clone` on a double - //~| HELP try dereferencing it - //~| SUGGESTION let z: &Vec<_> = (*y).clone(); + let z: &Vec<_> = y.clone(); + + println!("{:p} {:p}",*y, z); } fn single_char_pattern() { let x = "foo"; x.split("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.split('x'); + + + x.split("xx"); @@ -612,69 +612,69 @@ fn single_char_pattern() { x.split("❤️"); x.contains("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.contains('x'); + + + x.starts_with("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.starts_with('x'); + + + x.ends_with("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.ends_with('x'); + + + x.find("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.find('x'); + + + x.rfind("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rfind('x'); + + + x.rsplit("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rsplit('x'); + + + x.split_terminator("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.split_terminator('x'); + + + x.rsplit_terminator("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rsplit_terminator('x'); + + + x.splitn(0, "x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.splitn(0, 'x'); + + + x.rsplitn(0, "x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rsplitn(0, 'x'); + + + x.matches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.matches('x'); + + + x.rmatches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rmatches('x'); + + + x.match_indices("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.match_indices('x'); + + + x.rmatch_indices("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.rmatch_indices('x'); + + + x.trim_left_matches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.trim_left_matches('x'); + + + x.trim_right_matches("x"); - //~^ ERROR single-character string constant used as pattern - //~| HELP try using a char instead: - //~| SUGGESTION x.trim_right_matches('x'); + + + let h = HashSet::::new(); h.contains("X"); // should not warn @@ -685,7 +685,7 @@ fn temporary_cstring() { use std::ffi::CString; CString::new("foo").unwrap().as_ptr(); - //~^ ERROR you are getting the inner pointer of a temporary `CString` - //~| NOTE that pointer will be invalid outside this expression - //~| HELP assign the `CString` to a variable to extend its lifetime + + + } diff --git a/tests/ui/methods.stderr b/tests/ui/methods.stderr index 6b3470f11..f4294d8b3 100644 --- a/tests/ui/methods.stderr +++ b/tests/ui/methods.stderr @@ -1,7 +1,7 @@ error: defining a method called `add` on this type; consider implementing the `std::ops::Add` trait or choosing a less ambiguous name --> $DIR/methods.rs:18:5 | -18 | fn add(self, other: T) -> T { self } //~ERROR defining a method called `add` +18 | fn add(self, other: T) -> T { self } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(should_implement_trait)] implied by #[deny(clippy)] @@ -14,7 +14,7 @@ note: lint level defined here error: defining a method called `drop` on this type; consider implementing the `std::ops::Drop` trait or choosing a less ambiguous name --> $DIR/methods.rs:19:5 | -19 | fn drop(&mut self) { } //~ERROR defining a method called `drop` +19 | fn drop(&mut self) { } | ^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(should_implement_trait)] implied by #[deny(clippy)] @@ -22,7 +22,7 @@ error: defining a method called `drop` on this type; consider implementing the ` error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name --> $DIR/methods.rs:26:17 | -26 | fn into_u16(&self) -> u16 { 0 } //~ERROR methods called `into_*` usually take self by value +26 | fn into_u16(&self) -> u16 { 0 } | ^^^^^ | = note: #[deny(wrong_self_convention)] implied by #[deny(clippy)] @@ -35,7 +35,7 @@ note: lint level defined here error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name --> $DIR/methods.rs:28:21 | -28 | fn to_something(self) -> u32 { 0 } //~ERROR methods called `to_*` usually take self by reference +28 | fn to_something(self) -> u32 { 0 } | ^^^^ | = note: #[deny(wrong_self_convention)] implied by #[deny(clippy)] @@ -64,9 +64,9 @@ note: lint level defined here error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead --> $DIR/methods.rs:99:13 | -99 | let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)` +99 | let _ = opt.map(|x| x + 1) | _____________^ starting here... -100 | | //~| NOTE replace `map(|x| x + 1).unwrap_or(0)` +100 | | 101 | | .unwrap_or(0); // should lint even though this call is on a separate line | |____________________________^ ...ending here | @@ -81,7 +81,7 @@ note: lint level defined here error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead --> $DIR/methods.rs:103:13 | -103 | let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or(a)` +103 | let _ = opt.map(|x| { | _____________^ starting here... 104 | | x + 1 105 | | } @@ -93,7 +93,7 @@ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more di error: called `map(f).unwrap_or(a)` on an Option value. This can be done more directly by calling `map_or(a, f)` instead --> $DIR/methods.rs:107:13 | -107 | let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)` +107 | let _ = opt.map(|x| x + 1) | _____________^ starting here... 108 | | .unwrap_or({ 109 | | 0 @@ -105,9 +105,9 @@ error: called `map(f).unwrap_or(a)` on an Option value. This can be done more di error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead --> $DIR/methods.rs:116:13 | -116 | let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)` +116 | let _ = opt.map(|x| x + 1) | _____________^ starting here... -117 | | //~| NOTE replace `map(|x| x + 1).unwrap_or_else(|| 0)` +117 | | 118 | | .unwrap_or_else(|| 0); // should lint even though this call is on a separate line | |____________________________________^ ...ending here | @@ -122,7 +122,7 @@ note: lint level defined here error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead --> $DIR/methods.rs:120:13 | -120 | let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or_else(g)` +120 | let _ = opt.map(|x| { | _____________^ starting here... 121 | | x + 1 122 | | } @@ -134,7 +134,7 @@ error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done mo error: called `map(f).unwrap_or_else(g)` on an Option value. This can be done more directly by calling `map_or_else(g, f)` instead --> $DIR/methods.rs:124:13 | -124 | let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)` +124 | let _ = opt.map(|x| x + 1) | _____________^ starting here... 125 | | .unwrap_or_else(|| 126 | | 0 @@ -160,7 +160,7 @@ note: lint level defined here error: called `filter(p).next()` on an `Iterator`. This is more succinctly expressed by calling `.find(p)` instead. --> $DIR/methods.rs:201:13 | -201 | let _ = v.iter().filter(|&x| { //~ERROR called `filter(p).next()` on an `Iterator`. +201 | let _ = v.iter().filter(|&x| { | _____________^ starting here... 202 | | *x < 0 203 | | } @@ -186,7 +186,7 @@ note: lint level defined here error: called `is_some()` after searching an `Iterator` with find. This is more succinctly expressed by calling `any()`. --> $DIR/methods.rs:221:13 | -221 | let _ = v.iter().find(|&x| { //~ERROR called `is_some()` after searching +221 | let _ = v.iter().find(|&x| { | _____________^ starting here... 222 | | *x < 0 223 | | } @@ -207,7 +207,7 @@ error: called `is_some()` after searching an `Iterator` with position. This is m error: called `is_some()` after searching an `Iterator` with position. This is more succinctly expressed by calling `any()`. --> $DIR/methods.rs:232:13 | -232 | let _ = v.iter().position(|&x| { //~ERROR called `is_some()` after searching +232 | let _ = v.iter().position(|&x| { | _____________^ starting here... 233 | | x < 0 234 | | } @@ -228,7 +228,7 @@ error: called `is_some()` after searching an `Iterator` with rposition. This is error: called `is_some()` after searching an `Iterator` with rposition. This is more succinctly expressed by calling `any()`. --> $DIR/methods.rs:243:13 | -243 | let _ = v.iter().rposition(|&x| { //~ERROR called `is_some()` after searching +243 | let _ = v.iter().rposition(|&x| { | _____________^ starting here... 244 | | x < 0 245 | | } @@ -568,7 +568,7 @@ help: try this error: used unwrap() on an Option value. If you don't want to handle the None case gracefully, consider using expect() to provide a better panic message --> $DIR/methods.rs:488:13 | -488 | let _ = opt.unwrap(); //~ERROR used unwrap() on an Option +488 | let _ = opt.unwrap(); | ^^^^^^^^^^^^ | = note: #[deny(option_unwrap_used)] implied by #[deny(clippy_pedantic)] @@ -581,7 +581,7 @@ note: lint level defined here error: used unwrap() on a Result value. If you don't want to handle the Err case gracefully, consider using expect() to provide a better panic message --> $DIR/methods.rs:491:13 | -491 | let _ = res.unwrap(); //~ERROR used unwrap() on a Result +491 | let _ = res.unwrap(); | ^^^^^^^^^^^^ | = note: #[deny(result_unwrap_used)] implied by #[deny(clippy_pedantic)] @@ -594,7 +594,7 @@ note: lint level defined here error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/methods.rs:493:5 | -493 | res.ok().expect("disaster!"); //~ERROR called `ok().expect()` +493 | res.ok().expect("disaster!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] @@ -607,7 +607,7 @@ note: lint level defined here error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/methods.rs:499:5 | -499 | res3.ok().expect("whoof"); //~ERROR called `ok().expect()` +499 | res3.ok().expect("whoof"); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] @@ -615,7 +615,7 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/methods.rs:501:5 | -501 | res4.ok().expect("argh"); //~ERROR called `ok().expect()` +501 | res4.ok().expect("argh"); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] @@ -623,7 +623,7 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/methods.rs:503:5 | -503 | res5.ok().expect("oops"); //~ERROR called `ok().expect()` +503 | res5.ok().expect("oops"); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] @@ -631,7 +631,7 @@ error: called `ok().expect()` on a Result value. You can call `expect` directly error: called `ok().expect()` on a Result value. You can call `expect` directly on the `Result` --> $DIR/methods.rs:505:5 | -505 | res6.ok().expect("meh"); //~ERROR called `ok().expect()` +505 | res6.ok().expect("meh"); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(ok_expect)] implied by #[deny(clippy)] @@ -699,7 +699,7 @@ help: try this error: using `clone` on a `Copy` type --> $DIR/methods.rs:560:5 | -560 | 42.clone(); //~ERROR using `clone` on a `Copy` type +560 | 42.clone(); | ^^^^^^^^^^ | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] @@ -709,42 +709,42 @@ note: lint level defined here 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ help: try removing the `clone` call - | 42; //~ERROR using `clone` on a `Copy` type + | 42; error: using `clone` on a `Copy` type --> $DIR/methods.rs:565:5 | -565 | (&42).clone(); //~ERROR using `clone` on a `Copy` type +565 | (&42).clone(); | ^^^^^^^^^^^^^ | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] help: try dereferencing it - | *(&42); //~ERROR using `clone` on a `Copy` type + | *(&42); error: using `clone` on a `Copy` type --> $DIR/methods.rs:571:5 | -571 | t.clone(); //~ERROR using `clone` on a `Copy` type +571 | t.clone(); | ^^^^^^^^^ | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] help: try removing the `clone` call - | t; //~ERROR using `clone` on a `Copy` type + | t; error: using `clone` on a `Copy` type --> $DIR/methods.rs:574:5 | -574 | Some(t).clone(); //~ERROR using `clone` on a `Copy` type +574 | Some(t).clone(); | ^^^^^^^^^^^^^^^ | = note: #[deny(clone_on_copy)] implied by #[deny(clippy)] help: try removing the `clone` call - | Some(t); //~ERROR using `clone` on a `Copy` type + | Some(t); error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type --> $DIR/methods.rs:582:22 | -582 | let z: &Vec<_> = y.clone(); //~ERROR using `clone` on a double +582 | let z: &Vec<_> = y.clone(); | ^^^^^^^^^ | = note: #[deny(clone_double_ref)] implied by #[deny(clippy)] @@ -754,7 +754,7 @@ note: lint level defined here 5 | #![deny(clippy, clippy_pedantic)] | ^^^^^^ help: try dereferencing it - | let z: &Vec<_> = (*y).clone(); //~ERROR using `clone` on a double + | let z: &Vec<_> = (*y).clone(); error: single-character string constant used as pattern --> $DIR/methods.rs:590:13 diff --git a/tests/ui/min_max.rs b/tests/ui/min_max.rs index 9a6794afe..d74e52732 100644 --- a/tests/ui/min_max.rs +++ b/tests/ui/min_max.rs @@ -12,12 +12,12 @@ const LARGE : usize = 3; fn main() { let x; x = 2usize; - min(1, max(3, x)); //~ERROR this min/max combination leads to constant result - min(max(3, x), 1); //~ERROR this min/max combination leads to constant result - max(min(x, 1), 3); //~ERROR this min/max combination leads to constant result - max(3, min(x, 1)); //~ERROR this min/max combination leads to constant result + min(1, max(3, x)); + min(max(3, x), 1); + max(min(x, 1), 3); + max(3, min(x, 1)); - my_max(3, my_min(x, 1)); //~ERROR this min/max combination leads to constant result + my_max(3, my_min(x, 1)); min(3, max(1, x)); // ok, could be 1, 2 or 3 depending on x @@ -26,8 +26,8 @@ fn main() { let s; s = "Hello"; - min("Apple", max("Zoo", s)); //~ERROR this min/max combination leads to constant result - max(min(s, "Apple"), "Zoo"); //~ERROR this min/max combination leads to constant result + min("Apple", max("Zoo", s)); + max(min(s, "Apple"), "Zoo"); max("Apple", min(s, "Zoo")); // ok } diff --git a/tests/ui/min_max.stderr b/tests/ui/min_max.stderr index 3cb562e26..1170373ab 100644 --- a/tests/ui/min_max.stderr +++ b/tests/ui/min_max.stderr @@ -1,7 +1,7 @@ error: this min/max combination leads to constant result --> $DIR/min_max.rs:15:5 | -15 | min(1, max(3, x)); //~ERROR this min/max combination leads to constant result +15 | min(1, max(3, x)); | ^^^^^^^^^^^^^^^^^ | = note: #[deny(min_max)] implied by #[deny(clippy)] @@ -14,7 +14,7 @@ note: lint level defined here error: this min/max combination leads to constant result --> $DIR/min_max.rs:16:5 | -16 | min(max(3, x), 1); //~ERROR this min/max combination leads to constant result +16 | min(max(3, x), 1); | ^^^^^^^^^^^^^^^^^ | = note: #[deny(min_max)] implied by #[deny(clippy)] @@ -22,7 +22,7 @@ error: this min/max combination leads to constant result error: this min/max combination leads to constant result --> $DIR/min_max.rs:17:5 | -17 | max(min(x, 1), 3); //~ERROR this min/max combination leads to constant result +17 | max(min(x, 1), 3); | ^^^^^^^^^^^^^^^^^ | = note: #[deny(min_max)] implied by #[deny(clippy)] @@ -30,7 +30,7 @@ error: this min/max combination leads to constant result error: this min/max combination leads to constant result --> $DIR/min_max.rs:18:5 | -18 | max(3, min(x, 1)); //~ERROR this min/max combination leads to constant result +18 | max(3, min(x, 1)); | ^^^^^^^^^^^^^^^^^ | = note: #[deny(min_max)] implied by #[deny(clippy)] @@ -38,7 +38,7 @@ error: this min/max combination leads to constant result error: this min/max combination leads to constant result --> $DIR/min_max.rs:20:5 | -20 | my_max(3, my_min(x, 1)); //~ERROR this min/max combination leads to constant result +20 | my_max(3, my_min(x, 1)); | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(min_max)] implied by #[deny(clippy)] @@ -46,7 +46,7 @@ error: this min/max combination leads to constant result error: this min/max combination leads to constant result --> $DIR/min_max.rs:29:5 | -29 | min("Apple", max("Zoo", s)); //~ERROR this min/max combination leads to constant result +29 | min("Apple", max("Zoo", s)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(min_max)] implied by #[deny(clippy)] @@ -54,7 +54,7 @@ error: this min/max combination leads to constant result error: this min/max combination leads to constant result --> $DIR/min_max.rs:30:5 | -30 | max(min(s, "Apple"), "Zoo"); //~ERROR this min/max combination leads to constant result +30 | max(min(s, "Apple"), "Zoo"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(min_max)] implied by #[deny(clippy)] diff --git a/tests/ui/missing-doc.rs b/tests/ui/missing-doc.rs index acd86f18e..cd69ef1b0 100644 --- a/tests/ui/missing-doc.rs +++ b/tests/ui/missing-doc.rs @@ -23,17 +23,17 @@ //! Some garbage docs for the crate here #![doc="More garbage"] -type Typedef = String; //~ ERROR: missing documentation for a type alias -pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias +type Typedef = String; +pub type PubTypedef = String; -struct Foo { //~ ERROR: missing documentation for a struct - a: isize, //~ ERROR: missing documentation for a struct field - b: isize, //~ ERROR: missing documentation for a struct field +struct Foo { + a: isize, + b: isize, } -pub struct PubFoo { //~ ERROR: missing documentation for a struct - pub a: isize, //~ ERROR: missing documentation for a struct field - b: isize, //~ ERROR: missing documentation for a struct field +pub struct PubFoo { + pub a: isize, + b: isize, } #[allow(missing_docs_in_private_items)] @@ -42,13 +42,13 @@ pub struct PubFoo2 { pub c: isize, } -mod module_no_dox {} //~ ERROR: missing documentation for a module -pub mod pub_module_no_dox {} //~ ERROR: missing documentation for a module +mod module_no_dox {} +pub mod pub_module_no_dox {} /// dox pub fn foo() {} -pub fn foo2() {} //~ ERROR: missing documentation for a function -fn foo3() {} //~ ERROR: missing documentation for a function +pub fn foo2() {} +fn foo3() {} #[allow(missing_docs_in_private_items)] pub fn foo4() {} /// dox @@ -65,9 +65,9 @@ trait B { fn foo_with_impl(&self) {} } -pub trait C { //~ ERROR: missing documentation for a trait - fn foo(&self); //~ ERROR: missing documentation for a trait method - fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method +pub trait C { + fn foo(&self); + fn foo_with_impl(&self) {} } #[allow(missing_docs_in_private_items)] @@ -77,8 +77,8 @@ pub trait D { /// dox pub trait E { - type AssociatedType; //~ ERROR: missing documentation for an associated type - type AssociatedTypeDef = Self; //~ ERROR: missing documentation for an associated type + type AssociatedType; + type AssociatedTypeDef = Self; /// dox type DocumentedType; @@ -89,15 +89,15 @@ pub trait E { } impl Foo { - pub fn foo() {} //~ ERROR: missing documentation for a method - fn bar() {} //~ ERROR: missing documentation for a method + pub fn foo() {} + fn bar() {} } impl PubFoo { - pub fn foo() {} //~ ERROR: missing documentation for a method + pub fn foo() {} /// dox pub fn foo1() {} - fn foo2() {} //~ ERROR: missing documentation for a method + fn foo2() {} #[allow(missing_docs_in_private_items)] pub fn foo3() {} } @@ -123,17 +123,17 @@ mod a { } } -enum Baz { //~ ERROR: missing documentation for an enum - BazA { //~ ERROR: missing documentation for a variant - a: isize, //~ ERROR: missing documentation for a struct field - b: isize //~ ERROR: missing documentation for a struct field +enum Baz { + BazA { + a: isize, + b: isize }, - BarB //~ ERROR: missing documentation for a variant + BarB } -pub enum PubBaz { //~ ERROR: missing documentation for an enum - PubBazA { //~ ERROR: missing documentation for a variant - a: isize, //~ ERROR: missing documentation for a struct field +pub enum PubBaz { + PubBazA { + a: isize, }, } @@ -157,38 +157,38 @@ pub enum PubBaz3 { pub fn baz() {} -const FOO: u32 = 0; //~ ERROR: missing documentation for a const +const FOO: u32 = 0; /// dox pub const FOO1: u32 = 0; #[allow(missing_docs_in_private_items)] pub const FOO2: u32 = 0; #[doc(hidden)] pub const FOO3: u32 = 0; -pub const FOO4: u32 = 0; //~ ERROR: missing documentation for a const +pub const FOO4: u32 = 0; -static BAR: u32 = 0; //~ ERROR: missing documentation for a static +static BAR: u32 = 0; /// dox pub static BAR1: u32 = 0; #[allow(missing_docs_in_private_items)] pub static BAR2: u32 = 0; #[doc(hidden)] pub static BAR3: u32 = 0; -pub static BAR4: u32 = 0; //~ ERROR: missing documentation for a static +pub static BAR4: u32 = 0; -mod internal_impl { //~ ERROR: missing documentation for a module +mod internal_impl { /// dox pub fn documented() {} - pub fn undocumented1() {} //~ ERROR: missing documentation for a function - pub fn undocumented2() {} //~ ERROR: missing documentation for a function - fn undocumented3() {} //~ ERROR: missing documentation for a function + pub fn undocumented1() {} + pub fn undocumented2() {} + fn undocumented3() {} /// dox pub mod globbed { /// dox pub fn also_documented() {} - pub fn also_undocumented1() {} //~ ERROR: missing documentation for a function - fn also_undocumented2() {} //~ ERROR: missing documentation for a function + pub fn also_undocumented1() {} + fn also_undocumented2() {} } } /// dox @@ -199,4 +199,4 @@ pub mod public_interface { pub use internal_impl::globbed::*; } -fn main() {} //~ ERROR: missing documentation for a function +fn main() {} diff --git a/tests/ui/missing-doc.stderr b/tests/ui/missing-doc.stderr index b81f46eaa..6e3a146ee 100644 --- a/tests/ui/missing-doc.stderr +++ b/tests/ui/missing-doc.stderr @@ -1,7 +1,7 @@ error: missing documentation for a type alias --> $DIR/missing-doc.rs:26:1 | -26 | type Typedef = String; //~ ERROR: missing documentation for a type alias +26 | type Typedef = String; | ^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,183 +13,183 @@ note: lint level defined here error: missing documentation for a type alias --> $DIR/missing-doc.rs:27:1 | -27 | pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias +27 | pub type PubTypedef = String; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a struct --> $DIR/missing-doc.rs:29:1 | -29 | struct Foo { //~ ERROR: missing documentation for a struct +29 | struct Foo { | _^ starting here... -30 | | a: isize, //~ ERROR: missing documentation for a struct field -31 | | b: isize, //~ ERROR: missing documentation for a struct field +30 | | a: isize, +31 | | b: isize, 32 | | } | |_^ ...ending here error: missing documentation for a struct field --> $DIR/missing-doc.rs:30:5 | -30 | a: isize, //~ ERROR: missing documentation for a struct field +30 | a: isize, | ^^^^^^^^ error: missing documentation for a struct field --> $DIR/missing-doc.rs:31:5 | -31 | b: isize, //~ ERROR: missing documentation for a struct field +31 | b: isize, | ^^^^^^^^ error: missing documentation for a struct --> $DIR/missing-doc.rs:34:1 | -34 | pub struct PubFoo { //~ ERROR: missing documentation for a struct +34 | pub struct PubFoo { | _^ starting here... -35 | | pub a: isize, //~ ERROR: missing documentation for a struct field -36 | | b: isize, //~ ERROR: missing documentation for a struct field +35 | | pub a: isize, +36 | | b: isize, 37 | | } | |_^ ...ending here error: missing documentation for a struct field --> $DIR/missing-doc.rs:35:5 | -35 | pub a: isize, //~ ERROR: missing documentation for a struct field +35 | pub a: isize, | ^^^^^^^^^^^^ error: missing documentation for a struct field --> $DIR/missing-doc.rs:36:5 | -36 | b: isize, //~ ERROR: missing documentation for a struct field +36 | b: isize, | ^^^^^^^^ error: missing documentation for a module --> $DIR/missing-doc.rs:45:1 | -45 | mod module_no_dox {} //~ ERROR: missing documentation for a module +45 | mod module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module --> $DIR/missing-doc.rs:46:1 | -46 | pub mod pub_module_no_dox {} //~ ERROR: missing documentation for a module +46 | pub mod pub_module_no_dox {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:50:1 | -50 | pub fn foo2() {} //~ ERROR: missing documentation for a function +50 | pub fn foo2() {} | ^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:51:1 | -51 | fn foo3() {} //~ ERROR: missing documentation for a function +51 | fn foo3() {} | ^^^^^^^^^^^^ error: missing documentation for a trait --> $DIR/missing-doc.rs:68:1 | -68 | pub trait C { //~ ERROR: missing documentation for a trait +68 | pub trait C { | _^ starting here... -69 | | fn foo(&self); //~ ERROR: missing documentation for a trait method -70 | | fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method +69 | | fn foo(&self); +70 | | fn foo_with_impl(&self) {} 71 | | } | |_^ ...ending here error: missing documentation for a trait method --> $DIR/missing-doc.rs:69:5 | -69 | fn foo(&self); //~ ERROR: missing documentation for a trait method +69 | fn foo(&self); | ^^^^^^^^^^^^^^ error: missing documentation for a trait method --> $DIR/missing-doc.rs:70:5 | -70 | fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method +70 | fn foo_with_impl(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type --> $DIR/missing-doc.rs:80:5 | -80 | type AssociatedType; //~ ERROR: missing documentation for an associated type +80 | type AssociatedType; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for an associated type --> $DIR/missing-doc.rs:81:5 | -81 | type AssociatedTypeDef = Self; //~ ERROR: missing documentation for an associated type +81 | type AssociatedTypeDef = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a method --> $DIR/missing-doc.rs:92:5 | -92 | pub fn foo() {} //~ ERROR: missing documentation for a method +92 | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method --> $DIR/missing-doc.rs:93:5 | -93 | fn bar() {} //~ ERROR: missing documentation for a method +93 | fn bar() {} | ^^^^^^^^^^^ error: missing documentation for a method --> $DIR/missing-doc.rs:97:5 | -97 | pub fn foo() {} //~ ERROR: missing documentation for a method +97 | pub fn foo() {} | ^^^^^^^^^^^^^^^ error: missing documentation for a method --> $DIR/missing-doc.rs:100:5 | -100 | fn foo2() {} //~ ERROR: missing documentation for a method +100 | fn foo2() {} | ^^^^^^^^^^^^ error: missing documentation for an enum --> $DIR/missing-doc.rs:126:1 | -126 | enum Baz { //~ ERROR: missing documentation for an enum +126 | enum Baz { | _^ starting here... -127 | | BazA { //~ ERROR: missing documentation for a variant -128 | | a: isize, //~ ERROR: missing documentation for a struct field -129 | | b: isize //~ ERROR: missing documentation for a struct field +127 | | BazA { +128 | | a: isize, +129 | | b: isize 130 | | }, -131 | | BarB //~ ERROR: missing documentation for a variant +131 | | BarB 132 | | } | |_^ ...ending here error: missing documentation for a variant --> $DIR/missing-doc.rs:127:5 | -127 | BazA { //~ ERROR: missing documentation for a variant +127 | BazA { | _____^ starting here... -128 | | a: isize, //~ ERROR: missing documentation for a struct field -129 | | b: isize //~ ERROR: missing documentation for a struct field +128 | | a: isize, +129 | | b: isize 130 | | }, | |_____^ ...ending here error: missing documentation for a struct field --> $DIR/missing-doc.rs:128:9 | -128 | a: isize, //~ ERROR: missing documentation for a struct field +128 | a: isize, | ^^^^^^^^ error: missing documentation for a struct field --> $DIR/missing-doc.rs:129:9 | -129 | b: isize //~ ERROR: missing documentation for a struct field +129 | b: isize | ^^^^^^^^ error: missing documentation for a variant --> $DIR/missing-doc.rs:131:5 | -131 | BarB //~ ERROR: missing documentation for a variant +131 | BarB | ^^^^ error: missing documentation for an enum --> $DIR/missing-doc.rs:134:1 | -134 | pub enum PubBaz { //~ ERROR: missing documentation for an enum +134 | pub enum PubBaz { | _^ starting here... -135 | | PubBazA { //~ ERROR: missing documentation for a variant -136 | | a: isize, //~ ERROR: missing documentation for a struct field +135 | | PubBazA { +136 | | a: isize, 137 | | }, 138 | | } | |_^ ...ending here @@ -197,82 +197,82 @@ error: missing documentation for an enum error: missing documentation for a variant --> $DIR/missing-doc.rs:135:5 | -135 | PubBazA { //~ ERROR: missing documentation for a variant +135 | PubBazA { | _____^ starting here... -136 | | a: isize, //~ ERROR: missing documentation for a struct field +136 | | a: isize, 137 | | }, | |_____^ ...ending here error: missing documentation for a struct field --> $DIR/missing-doc.rs:136:9 | -136 | a: isize, //~ ERROR: missing documentation for a struct field +136 | a: isize, | ^^^^^^^^ error: missing documentation for a constant --> $DIR/missing-doc.rs:160:1 | -160 | const FOO: u32 = 0; //~ ERROR: missing documentation for a const +160 | const FOO: u32 = 0; | ^^^^^^^^^^^^^^^^^^^ error: missing documentation for a constant --> $DIR/missing-doc.rs:167:1 | -167 | pub const FOO4: u32 = 0; //~ ERROR: missing documentation for a const +167 | pub const FOO4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static --> $DIR/missing-doc.rs:170:1 | -170 | static BAR: u32 = 0; //~ ERROR: missing documentation for a static +170 | static BAR: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a static --> $DIR/missing-doc.rs:177:1 | -177 | pub static BAR4: u32 = 0; //~ ERROR: missing documentation for a static +177 | pub static BAR4: u32 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a module --> $DIR/missing-doc.rs:180:1 | -180 | mod internal_impl { //~ ERROR: missing documentation for a module +180 | mod internal_impl { | ^ error: missing documentation for a function --> $DIR/missing-doc.rs:183:5 | -183 | pub fn undocumented1() {} //~ ERROR: missing documentation for a function +183 | pub fn undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:184:5 | -184 | pub fn undocumented2() {} //~ ERROR: missing documentation for a function +184 | pub fn undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:185:5 | -185 | fn undocumented3() {} //~ ERROR: missing documentation for a function +185 | fn undocumented3() {} | ^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:190:9 | -190 | pub fn also_undocumented1() {} //~ ERROR: missing documentation for a function +190 | pub fn also_undocumented1() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:191:9 | -191 | fn also_undocumented2() {} //~ ERROR: missing documentation for a function +191 | fn also_undocumented2() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: missing documentation for a function --> $DIR/missing-doc.rs:202:1 | -202 | fn main() {} //~ ERROR: missing documentation for a function +202 | fn main() {} | ^^^^^^^^^^^^ error: aborting due to 40 previous errors diff --git a/tests/ui/module_inception.rs b/tests/ui/module_inception.rs index 861ed504c..f102057c1 100644 --- a/tests/ui/module_inception.rs +++ b/tests/ui/module_inception.rs @@ -4,12 +4,12 @@ mod foo { mod bar { - mod bar { //~ ERROR module has the same name as its containing module + mod bar { mod foo {} } mod foo {} } - mod foo { //~ ERROR module has the same name as its containing module + mod foo { mod bar {} } } diff --git a/tests/ui/module_inception.stderr b/tests/ui/module_inception.stderr index de0ff78eb..b61b8557a 100644 --- a/tests/ui/module_inception.stderr +++ b/tests/ui/module_inception.stderr @@ -1,7 +1,7 @@ error: module has the same name as its containing module --> $DIR/module_inception.rs:7:9 | -7 | mod bar { //~ ERROR module has the same name as its containing module +7 | mod bar { | _________^ starting here... 8 | | mod foo {} 9 | | } @@ -16,7 +16,7 @@ note: lint level defined here error: module has the same name as its containing module --> $DIR/module_inception.rs:12:5 | -12 | mod foo { //~ ERROR module has the same name as its containing module +12 | mod foo { | _____^ starting here... 13 | | mod bar {} 14 | | } diff --git a/tests/ui/modulo_one.rs b/tests/ui/modulo_one.rs index 496c1c60d..d9ab7492e 100644 --- a/tests/ui/modulo_one.rs +++ b/tests/ui/modulo_one.rs @@ -4,6 +4,6 @@ #![allow(no_effect, unnecessary_operation)] fn main() { - 10 % 1; //~ERROR any number modulo 1 will be 0 + 10 % 1; 10 % 2; } diff --git a/tests/ui/modulo_one.stderr b/tests/ui/modulo_one.stderr index c938afb0d..2e5aef675 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:7:5 | -7 | 10 % 1; //~ERROR any number modulo 1 will be 0 +7 | 10 % 1; | ^^^^^^ | note: lint level defined here diff --git a/tests/ui/mut_mut.rs b/tests/ui/mut_mut.rs index edcc6906f..457a79152 100644 --- a/tests/ui/mut_mut.rs +++ b/tests/ui/mut_mut.rs @@ -7,7 +7,7 @@ //#![plugin(regex_macros)] //extern crate regex; -fn fun(x : &mut &mut u32) -> bool { //~ERROR generally you want to avoid `&mut &mut +fn fun(x : &mut &mut u32) -> bool { **x > 0 } @@ -17,37 +17,37 @@ fn less_fun(x : *mut *mut u32) { macro_rules! mut_ptr { ($p:expr) => { &mut $p } - //~^ ERROR generally you want to avoid `&mut &mut + } #[allow(unused_mut, unused_variables)] fn main() { - let mut x = &mut &mut 1u32; //~ERROR generally you want to avoid `&mut &mut + let mut x = &mut &mut 1u32; { - let mut y = &mut x; //~ERROR this expression mutably borrows a mutable reference + let mut y = &mut x; } if fun(x) { let y : &mut &mut u32 = &mut &mut 2; - //~^ ERROR generally you want to avoid `&mut &mut - //~| ERROR generally you want to avoid `&mut &mut - //~| ERROR generally you want to avoid `&mut &mut + + + **y + **x; } if fun(x) { let y : &mut &mut &mut u32 = &mut &mut &mut 2; - //~^ ERROR generally you want to avoid `&mut &mut - //~| ERROR generally you want to avoid `&mut &mut - //~| ERROR generally you want to avoid `&mut &mut - //~| ERROR generally you want to avoid `&mut &mut - //~| ERROR generally you want to avoid `&mut &mut - //~| ERROR generally you want to avoid `&mut &mut + + + + + + ***y + **x; } let mut z = mut_ptr!(&mut 3u32); - //~^ NOTE in this expansion of mut_ptr! + } fn issue939() { diff --git a/tests/ui/mut_mut.stderr b/tests/ui/mut_mut.stderr index 55125f8d5..2149d3d88 100644 --- a/tests/ui/mut_mut.stderr +++ b/tests/ui/mut_mut.stderr @@ -1,7 +1,7 @@ error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:10:12 | -10 | fn fun(x : &mut &mut u32) -> bool { //~ERROR generally you want to avoid `&mut &mut +10 | fn fun(x : &mut &mut u32) -> bool { | ^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: generally you want to avoid `&mut &mut _` if possible --> $DIR/mut_mut.rs:25:17 | -25 | let mut x = &mut &mut 1u32; //~ERROR generally you want to avoid `&mut &mut +25 | let mut x = &mut &mut 1u32; | ^^^^^^^^^^^^^^ error: generally you want to avoid `&mut &mut _` if possible @@ -28,7 +28,7 @@ error: generally you want to avoid `&mut &mut _` if possible error: this expression mutably borrows a mutable reference. Consider reborrowing --> $DIR/mut_mut.rs:27:21 | -27 | let mut y = &mut x; //~ERROR this expression mutably borrows a mutable reference +27 | let mut y = &mut x; | ^^^^^^ error: generally you want to avoid `&mut &mut _` if possible diff --git a/tests/ui/mut_reference.rs b/tests/ui/mut_reference.rs index 0bb59a318..a3b9a965e 100644 --- a/tests/ui/mut_reference.rs +++ b/tests/ui/mut_reference.rs @@ -19,13 +19,13 @@ impl MyStruct { #[deny(unnecessary_mut_passed)] fn main() { // Functions - takes_an_immutable_reference(&mut 42); //~ERROR The function/method "takes_an_immutable_reference" doesn't need a mutable reference + takes_an_immutable_reference(&mut 42); let as_ptr: fn(&i32) = takes_an_immutable_reference; - as_ptr(&mut 42); //~ERROR The function/method "as_ptr" doesn't need a mutable reference + as_ptr(&mut 42); // Methods let my_struct = MyStruct; - my_struct.takes_an_immutable_reference(&mut 42); //~ERROR The function/method "takes_an_immutable_reference" doesn't need a mutable reference + my_struct.takes_an_immutable_reference(&mut 42); // No error diff --git a/tests/ui/mut_reference.stderr b/tests/ui/mut_reference.stderr index 52e483477..f4c2b6074 100644 --- a/tests/ui/mut_reference.stderr +++ b/tests/ui/mut_reference.stderr @@ -1,7 +1,7 @@ error: The function/method "takes_an_immutable_reference" doesn't need a mutable reference --> $DIR/mut_reference.rs:22:34 | -22 | takes_an_immutable_reference(&mut 42); //~ERROR The function/method "takes_an_immutable_reference" doesn't need a mutable reference +22 | takes_an_immutable_reference(&mut 42); | ^^^^^^^ | note: lint level defined here @@ -13,13 +13,13 @@ note: lint level defined here error: The function/method "as_ptr" doesn't need a mutable reference --> $DIR/mut_reference.rs:24:12 | -24 | as_ptr(&mut 42); //~ERROR The function/method "as_ptr" doesn't need a mutable reference +24 | as_ptr(&mut 42); | ^^^^^^^ error: The function/method "takes_an_immutable_reference" doesn't need a mutable reference --> $DIR/mut_reference.rs:28:44 | -28 | my_struct.takes_an_immutable_reference(&mut 42); //~ERROR The function/method "takes_an_immutable_reference" doesn't need a mutable reference +28 | my_struct.takes_an_immutable_reference(&mut 42); | ^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/mutex_atomic.rs b/tests/ui/mutex_atomic.rs index 20a34ba55..5a5289c2c 100644 --- a/tests/ui/mutex_atomic.rs +++ b/tests/ui/mutex_atomic.rs @@ -6,13 +6,13 @@ fn main() { use std::sync::Mutex; - Mutex::new(true); //~ERROR Consider using an AtomicBool instead of a Mutex here. - Mutex::new(5usize); //~ERROR Consider using an AtomicUsize instead of a Mutex here. - Mutex::new(9isize); //~ERROR Consider using an AtomicIsize instead of a Mutex here. + Mutex::new(true); + Mutex::new(5usize); + Mutex::new(9isize); let mut x = 4u32; - Mutex::new(&x as *const u32); //~ERROR Consider using an AtomicPtr instead of a Mutex here. - Mutex::new(&mut x as *mut u32); //~ERROR Consider using an AtomicPtr instead of a Mutex here. - Mutex::new(0u32); //~ERROR Consider using an AtomicUsize instead of a Mutex here. - Mutex::new(0i32); //~ERROR Consider using an AtomicIsize instead of a Mutex here. + Mutex::new(&x as *const u32); + Mutex::new(&mut x as *mut u32); + Mutex::new(0u32); + Mutex::new(0i32); Mutex::new(0f32); // there are no float atomics, so this should not lint } diff --git a/tests/ui/mutex_atomic.stderr b/tests/ui/mutex_atomic.stderr index 9554f42d2..6a61c42cb 100644 --- a/tests/ui/mutex_atomic.stderr +++ b/tests/ui/mutex_atomic.stderr @@ -1,7 +1,7 @@ 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:9:5 | -9 | Mutex::new(true); //~ERROR Consider using an AtomicBool instead of a Mutex here. +9 | Mutex::new(true); | ^^^^^^^^^^^^^^^^ | = note: #[deny(mutex_atomic)] implied by #[deny(clippy)] @@ -14,7 +14,7 @@ note: lint level defined here 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:10:5 | -10 | Mutex::new(5usize); //~ERROR Consider using an AtomicUsize instead of a Mutex here. +10 | Mutex::new(5usize); | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(mutex_atomic)] implied by #[deny(clippy)] @@ -22,7 +22,7 @@ error: Consider using an AtomicUsize instead of a Mutex here. If you just want t 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:11:5 | -11 | Mutex::new(9isize); //~ERROR Consider using an AtomicIsize instead of a Mutex here. +11 | Mutex::new(9isize); | ^^^^^^^^^^^^^^^^^^ | = note: #[deny(mutex_atomic)] implied by #[deny(clippy)] @@ -30,7 +30,7 @@ error: Consider using an AtomicIsize instead of a Mutex here. If you just want t 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:13:5 | -13 | Mutex::new(&x as *const u32); //~ERROR Consider using an AtomicPtr instead of a Mutex here. +13 | Mutex::new(&x as *const u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(mutex_atomic)] implied by #[deny(clippy)] @@ -38,7 +38,7 @@ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the 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:14:5 | -14 | Mutex::new(&mut x as *mut u32); //~ERROR Consider using an AtomicPtr instead of a Mutex here. +14 | Mutex::new(&mut x as *mut u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[deny(mutex_atomic)] implied by #[deny(clippy)] @@ -46,7 +46,7 @@ error: Consider using an AtomicPtr instead of a Mutex here. If you just want the 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:15:5 | -15 | Mutex::new(0u32); //~ERROR Consider using an AtomicUsize instead of a Mutex here. +15 | Mutex::new(0u32); | ^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -58,7 +58,7 @@ note: lint level defined here 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:16:5 | -16 | Mutex::new(0i32); //~ERROR Consider using an AtomicIsize instead of a Mutex here. +16 | Mutex::new(0i32); | ^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/needless_bool.rs b/tests/ui/needless_bool.rs index fb81d4430..ebbff1454 100644 --- a/tests/ui/needless_bool.rs +++ b/tests/ui/needless_bool.rs @@ -6,20 +6,20 @@ fn main() { let x = true; let y = false; - if x { true } else { true }; //~ERROR this if-then-else expression will always return true - if x { false } else { false }; //~ERROR this if-then-else expression will always return false + if x { true } else { true }; + if x { false } else { false }; if x { true } else { false }; - //~^ ERROR this if-then-else expression returns a bool literal - //~| HELP you can reduce it to - //~| SUGGESTION x + + + if x { false } else { true }; - //~^ ERROR this if-then-else expression returns a bool literal - //~| HELP you can reduce it to - //~| SUGGESTION !x + + + if x && y { false } else { true }; - //~^ ERROR this if-then-else expression returns a bool literal - //~| HELP you can reduce it to - //~| SUGGESTION !(x && y) + + + if x { x } else { false }; // would also be questionable, but we don't catch this yet bool_ret(x); bool_ret2(x); @@ -32,43 +32,43 @@ fn main() { #[allow(if_same_then_else, needless_return)] fn bool_ret(x: bool) -> bool { if x { return true } else { return true }; - //~^ ERROR this if-then-else expression will always return true + } #[allow(if_same_then_else, needless_return)] fn bool_ret2(x: bool) -> bool { if x { return false } else { return false }; - //~^ ERROR this if-then-else expression will always return false + } #[allow(needless_return)] fn bool_ret3(x: bool) -> bool { if x { return true } else { return false }; - //~^ ERROR this if-then-else expression returns a bool literal - //~| HELP you can reduce it to - //~| SUGGESTION return x + + + } #[allow(needless_return)] fn bool_ret5(x: bool, y: bool) -> bool { if x && y { return true } else { return false }; - //~^ ERROR this if-then-else expression returns a bool literal - //~| HELP you can reduce it to - //~| SUGGESTION return x && y + + + } #[allow(needless_return)] fn bool_ret4(x: bool) -> bool { if x { return false } else { return true }; - //~^ ERROR this if-then-else expression returns a bool literal - //~| HELP you can reduce it to - //~| SUGGESTION return !x + + + } #[allow(needless_return)] fn bool_ret6(x: bool, y: bool) -> bool { if x && y { return false } else { return true }; - //~^ ERROR this if-then-else expression returns a bool literal - //~| HELP you can reduce it to - //~| SUGGESTION return !(x && y) + + + } diff --git a/tests/ui/needless_bool.stderr b/tests/ui/needless_bool.stderr index 0042598e1..930a3cba5 100644 --- a/tests/ui/needless_bool.stderr +++ b/tests/ui/needless_bool.stderr @@ -1,7 +1,7 @@ error: this if-then-else expression will always return true --> $DIR/needless_bool.rs:9:5 | -9 | if x { true } else { true }; //~ERROR this if-then-else expression will always return true +9 | if x { true } else { true }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: this if-then-else expression will always return false --> $DIR/needless_bool.rs:10:5 | -10 | if x { false } else { false }; //~ERROR this if-then-else expression will always return false +10 | if x { false } else { false }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this if-then-else expression returns a bool literal diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index 77992252e..1fc36c0be 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -10,14 +10,14 @@ fn x(y: &i32) -> i32 { fn main() { let a = 5; let b = x(&a); - let c = x(&&a); //~ ERROR: this expression borrows a reference that is immediately dereferenced by the compiler + let c = x(&&a); let s = &String::from("hi"); let s_ident = f(&s); // should not error, because `&String` implements Copy, but `String` does not let g_val = g(&Vec::new()); // should not error, because `&Vec` derefs to `&[T]` let vec = Vec::new(); let vec_val = g(&vec); // should not error, because `&Vec` derefs to `&[T]` h(&"foo"); // should not error, because the `&&str` is required, due to `&Trait` - if let Some(ref cake) = Some(&5) {} //~ ERROR: this pattern creates a reference to a reference + if let Some(ref cake) = Some(&5) {} } fn f(y: &T) -> T { @@ -39,6 +39,6 @@ fn issue_1432() { let mut v = Vec::::new(); let _ = v.iter_mut().filter(|&ref a| a.is_empty()); let _ = v.iter().filter(|&ref a| a.is_empty()); - //~^WARNING this pattern creates a reference to a reference + let _ = v.iter().filter(|&a| a.is_empty()); } diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index e607185fe..a5d549c98 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -1,7 +1,7 @@ error: this expression borrows a reference that is immediately dereferenced by the compiler --> $DIR/needless_borrow.rs:13:15 | -13 | let c = x(&&a); //~ ERROR: this expression borrows a reference that is immediately dereferenced by the compiler +13 | let c = x(&&a); | ^^^ | = note: #[deny(needless_borrow)] implied by #[deny(clippy)] @@ -14,7 +14,7 @@ note: lint level defined here error: this pattern creates a reference to a reference --> $DIR/needless_borrow.rs:20:17 | -20 | if let Some(ref cake) = Some(&5) {} //~ ERROR: this pattern creates a reference to a reference +20 | if let Some(ref cake) = Some(&5) {} | ^^^^^^^^ | = note: #[deny(needless_borrow)] implied by #[deny(clippy)] diff --git a/tests/ui/needless_return.rs b/tests/ui/needless_return.rs index 442a0b925..2751089bd 100644 --- a/tests/ui/needless_return.rs +++ b/tests/ui/needless_return.rs @@ -9,44 +9,44 @@ fn test_end_of_fn() -> bool { return true; } return true; - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION true + + + } fn test_no_semicolon() -> bool { return true - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION true + + + } fn test_if_block() -> bool { if true { return true; - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION true + + + } else { return false; - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION false + + + } } fn test_match(x: bool) -> bool { match x { true => return false, - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION false + + + false => { return true; - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION true + + + } } } @@ -54,14 +54,14 @@ fn test_match(x: bool) -> bool { fn test_closure() { let _ = || { return true; - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION true + + + }; let _ = || return true; - //~^ ERROR unneeded return statement - //~| HELP remove `return` as shown - //~| SUGGESTION true + + + } fn main() { diff --git a/tests/ui/needless_update.rs b/tests/ui/needless_update.rs index 55cfed76d..a8eb232f0 100644 --- a/tests/ui/needless_update.rs +++ b/tests/ui/needless_update.rs @@ -13,5 +13,5 @@ fn main() { let base = S { a: 0, b: 0 }; S { ..base }; // no error S { a: 1, ..base }; // no error - S { a: 1, b: 1, ..base }; //~ERROR struct update has no effect + S { a: 1, b: 1, ..base }; } diff --git a/tests/ui/needless_update.stderr b/tests/ui/needless_update.stderr index 630d48331..ab1441508 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:16:23 | -16 | S { a: 1, b: 1, ..base }; //~ERROR struct update has no effect +16 | S { a: 1, b: 1, ..base }; | ^^^^ | note: lint level defined here diff --git a/tests/ui/neg_multiply.rs b/tests/ui/neg_multiply.rs index 90c63c5f2..748a2e536 100644 --- a/tests/ui/neg_multiply.rs +++ b/tests/ui/neg_multiply.rs @@ -28,10 +28,10 @@ fn main() { let x = 0; x * -1; - //~^ ERROR Negation by multiplying with -1 + -1 * x; - //~^ ERROR Negation by multiplying with -1 + -1 * -1; // should be ok diff --git a/tests/ui/new_without_default.rs b/tests/ui/new_without_default.rs index 65f6805e1..a5673b622 100644 --- a/tests/ui/new_without_default.rs +++ b/tests/ui/new_without_default.rs @@ -5,23 +5,23 @@ #![deny(new_without_default, new_without_default_derive)] pub struct Foo; -//~^HELP try this -//~^^SUGGESTION #[derive(Default)] -//~^^SUGGESTION pub struct Foo + + + impl Foo { pub fn new() -> Foo { Foo } - //~^ERROR: you should consider deriving a `Default` implementation for `Foo` + } pub struct Bar; -//~^HELP try this -//~^^SUGGESTION #[derive(Default)] -//~^^SUGGESTION pub struct Bar + + + impl Bar { pub fn new() -> Self { Bar } - //~^ERROR: you should consider deriving a `Default` implementation for `Bar` + } pub struct Ok; @@ -70,13 +70,13 @@ pub struct LtKo<'a> { impl<'c> LtKo<'c> { pub fn new() -> LtKo<'c> { unimplemented!() } - //~^ERROR: you should consider adding a `Default` implementation for - //~^^HELP try - //~^^^SUGGESTION impl Default for LtKo<'c> { - //~^^^SUGGESTION fn default() -> Self { - //~^^^SUGGESTION Self::new() - //~^^^SUGGESTION } - //~^^^SUGGESTION } + + + + + + + // FIXME: that suggestion is missing lifetimes } diff --git a/tests/ui/no_effect.rs b/tests/ui/no_effect.rs index 30a66a715..3759986ae 100644 --- a/tests/ui/no_effect.rs +++ b/tests/ui/no_effect.rs @@ -31,92 +31,92 @@ fn main() { let s = get_struct(); let s2 = get_struct(); - 0; //~ERROR statement with no effect - s2; //~ERROR statement with no effect - Unit; //~ERROR statement with no effect - Tuple(0); //~ERROR statement with no effect - Struct { field: 0 }; //~ERROR statement with no effect - Struct { ..s }; //~ERROR statement with no effect - Union { a: 0 }; //~ERROR statement with no effect - Enum::Tuple(0); //~ERROR statement with no effect - Enum::Struct { field: 0 }; //~ERROR statement with no effect - 5 + 6; //~ERROR statement with no effect - *&42; //~ERROR statement with no effect - &6; //~ERROR statement with no effect - (5, 6, 7); //~ERROR statement with no effect - box 42; //~ERROR statement with no effect - ..; //~ERROR statement with no effect - 5..; //~ERROR statement with no effect - ..5; //~ERROR statement with no effect - 5..6; //~ERROR statement with no effect - 5...6; //~ERROR statement with no effect - [42, 55]; //~ERROR statement with no effect - [42, 55][1]; //~ERROR statement with no effect - (42, 55).1; //~ERROR statement with no effect - [42; 55]; //~ERROR statement with no effect - [42; 55][13]; //~ERROR statement with no effect + 0; + s2; + Unit; + Tuple(0); + Struct { field: 0 }; + Struct { ..s }; + Union { a: 0 }; + Enum::Tuple(0); + Enum::Struct { field: 0 }; + 5 + 6; + *&42; + &6; + (5, 6, 7); + box 42; + ..; + 5..; + ..5; + 5..6; + 5...6; + [42, 55]; + [42, 55][1]; + (42, 55).1; + [42; 55]; + [42; 55][13]; let mut x = 0; - || x += 5; //~ERROR statement with no effect + || x += 5; // Do not warn get_number(); unsafe { unsafe_fn() }; - Tuple(get_number()); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - Struct { field: get_number() }; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - Struct { ..get_struct() }; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_struct(); - Enum::Tuple(get_number()); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - Enum::Struct { field: get_number() }; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - 5 + get_number(); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION 5;get_number(); - *&get_number(); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - &get_number(); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - (5, 6, get_number()); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION 5;6;get_number(); - box get_number(); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - get_number()..; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - ..get_number(); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - 5..get_number(); //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION 5;get_number(); - [42, get_number()]; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION 42;get_number(); - [42, 55][get_number() as usize]; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION [42, 55];get_number() as usize; - (42, get_number()).1; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION 42;get_number(); - [get_number(); 55]; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); - [42; 55][get_number() as usize]; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION [42; 55];get_number() as usize; - {get_number()}; //~ERROR statement can be reduced - //~^HELP replace it with - //~|SUGGESTION get_number(); + Tuple(get_number()); + + + Struct { field: get_number() }; + + + Struct { ..get_struct() }; + + + Enum::Tuple(get_number()); + + + Enum::Struct { field: get_number() }; + + + 5 + get_number(); + + + *&get_number(); + + + &get_number(); + + + (5, 6, get_number()); + + + box get_number(); + + + get_number()..; + + + ..get_number(); + + + 5..get_number(); + + + [42, get_number()]; + + + [42, 55][get_number() as usize]; + + + (42, get_number()).1; + + + [get_number(); 55]; + + + [42; 55][get_number() as usize]; + + + {get_number()}; + + } diff --git a/tests/ui/no_effect.stderr b/tests/ui/no_effect.stderr index da65c5e8d..5fd1d7c42 100644 --- a/tests/ui/no_effect.stderr +++ b/tests/ui/no_effect.stderr @@ -1,7 +1,7 @@ error: statement with no effect --> $DIR/no_effect.rs:34:5 | -34 | 0; //~ERROR statement with no effect +34 | 0; | ^^ | note: lint level defined here @@ -13,151 +13,151 @@ note: lint level defined here error: statement with no effect --> $DIR/no_effect.rs:35:5 | -35 | s2; //~ERROR statement with no effect +35 | s2; | ^^^ error: statement with no effect --> $DIR/no_effect.rs:36:5 | -36 | Unit; //~ERROR statement with no effect +36 | Unit; | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:37:5 | -37 | Tuple(0); //~ERROR statement with no effect +37 | Tuple(0); | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:38:5 | -38 | Struct { field: 0 }; //~ERROR statement with no effect +38 | Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:39:5 | -39 | Struct { ..s }; //~ERROR statement with no effect +39 | Struct { ..s }; | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:40:5 | -40 | Union { a: 0 }; //~ERROR statement with no effect +40 | Union { a: 0 }; | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:41:5 | -41 | Enum::Tuple(0); //~ERROR statement with no effect +41 | Enum::Tuple(0); | ^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:42:5 | -42 | Enum::Struct { field: 0 }; //~ERROR statement with no effect +42 | Enum::Struct { field: 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:43:5 | -43 | 5 + 6; //~ERROR statement with no effect +43 | 5 + 6; | ^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:44:5 | -44 | *&42; //~ERROR statement with no effect +44 | *&42; | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:45:5 | -45 | &6; //~ERROR statement with no effect +45 | &6; | ^^^ error: statement with no effect --> $DIR/no_effect.rs:46:5 | -46 | (5, 6, 7); //~ERROR statement with no effect +46 | (5, 6, 7); | ^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:47:5 | -47 | box 42; //~ERROR statement with no effect +47 | box 42; | ^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:48:5 | -48 | ..; //~ERROR statement with no effect +48 | ..; | ^^^ error: statement with no effect --> $DIR/no_effect.rs:49:5 | -49 | 5..; //~ERROR statement with no effect +49 | 5..; | ^^^^ error: statement with no effect --> $DIR/no_effect.rs:50:5 | -50 | ..5; //~ERROR statement with no effect +50 | ..5; | ^^^^ error: statement with no effect --> $DIR/no_effect.rs:51:5 | -51 | 5..6; //~ERROR statement with no effect +51 | 5..6; | ^^^^^ error: statement with no effect --> $DIR/no_effect.rs:52:5 | -52 | 5...6; //~ERROR statement with no effect +52 | 5...6; | ^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:53:5 | -53 | [42, 55]; //~ERROR statement with no effect +53 | [42, 55]; | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:54:5 | -54 | [42, 55][1]; //~ERROR statement with no effect +54 | [42, 55][1]; | ^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:55:5 | -55 | (42, 55).1; //~ERROR statement with no effect +55 | (42, 55).1; | ^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:56:5 | -56 | [42; 55]; //~ERROR statement with no effect +56 | [42; 55]; | ^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:57:5 | -57 | [42; 55][13]; //~ERROR statement with no effect +57 | [42; 55][13]; | ^^^^^^^^^^^^^ error: statement with no effect --> $DIR/no_effect.rs:59:5 | -59 | || x += 5; //~ERROR statement with no effect +59 | || x += 5; | ^^^^^^^^^^ error: statement can be reduced --> $DIR/no_effect.rs:65:5 | -65 | Tuple(get_number()); //~ERROR statement can be reduced +65 | Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -166,169 +166,169 @@ note: lint level defined here 4 | #![deny(no_effect, unnecessary_operation)] | ^^^^^^^^^^^^^^^^^^^^^ help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:68:5 | -68 | Struct { field: get_number() }; //~ERROR statement can be reduced +68 | Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:71:5 | -71 | Struct { ..get_struct() }; //~ERROR statement can be reduced +71 | Struct { ..get_struct() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | get_struct(); //~ERROR statement can be reduced + | get_struct(); error: statement can be reduced --> $DIR/no_effect.rs:74:5 | -74 | Enum::Tuple(get_number()); //~ERROR statement can be reduced +74 | Enum::Tuple(get_number()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:77:5 | -77 | Enum::Struct { field: get_number() }; //~ERROR statement can be reduced +77 | Enum::Struct { field: get_number() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:80:5 | -80 | 5 + get_number(); //~ERROR statement can be reduced +80 | 5 + get_number(); | ^^^^^^^^^^^^^^^^^ | help: replace it with - | 5;get_number(); //~ERROR statement can be reduced + | 5;get_number(); error: statement can be reduced --> $DIR/no_effect.rs:83:5 | -83 | *&get_number(); //~ERROR statement can be reduced +83 | *&get_number(); | ^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:86:5 | -86 | &get_number(); //~ERROR statement can be reduced +86 | &get_number(); | ^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:89:5 | -89 | (5, 6, get_number()); //~ERROR statement can be reduced +89 | (5, 6, get_number()); | ^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | 5;6;get_number(); //~ERROR statement can be reduced + | 5;6;get_number(); error: statement can be reduced --> $DIR/no_effect.rs:92:5 | -92 | box get_number(); //~ERROR statement can be reduced +92 | box get_number(); | ^^^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:95:5 | -95 | get_number()..; //~ERROR statement can be reduced +95 | get_number()..; | ^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:98:5 | -98 | ..get_number(); //~ERROR statement can be reduced +98 | ..get_number(); | ^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:101:5 | -101 | 5..get_number(); //~ERROR statement can be reduced +101 | 5..get_number(); | ^^^^^^^^^^^^^^^^ | help: replace it with - | 5;get_number(); //~ERROR statement can be reduced + | 5;get_number(); error: statement can be reduced --> $DIR/no_effect.rs:104:5 | -104 | [42, get_number()]; //~ERROR statement can be reduced +104 | [42, get_number()]; | ^^^^^^^^^^^^^^^^^^^ | help: replace it with - | 42;get_number(); //~ERROR statement can be reduced + | 42;get_number(); error: statement can be reduced --> $DIR/no_effect.rs:107:5 | -107 | [42, 55][get_number() as usize]; //~ERROR statement can be reduced +107 | [42, 55][get_number() as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | [42, 55];get_number() as usize; //~ERROR statement can be reduced + | [42, 55];get_number() as usize; error: statement can be reduced --> $DIR/no_effect.rs:110:5 | -110 | (42, get_number()).1; //~ERROR statement can be reduced +110 | (42, get_number()).1; | ^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | 42;get_number(); //~ERROR statement can be reduced + | 42;get_number(); error: statement can be reduced --> $DIR/no_effect.rs:113:5 | -113 | [get_number(); 55]; //~ERROR statement can be reduced +113 | [get_number(); 55]; | ^^^^^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: statement can be reduced --> $DIR/no_effect.rs:116:5 | -116 | [42; 55][get_number() as usize]; //~ERROR statement can be reduced +116 | [42; 55][get_number() as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: replace it with - | [42; 55];get_number() as usize; //~ERROR statement can be reduced + | [42; 55];get_number() as usize; error: statement can be reduced --> $DIR/no_effect.rs:119:5 | -119 | {get_number()}; //~ERROR statement can be reduced +119 | {get_number()}; | ^^^^^^^^^^^^^^^ | help: replace it with - | get_number(); //~ERROR statement can be reduced + | get_number(); error: aborting due to 44 previous errors diff --git a/tests/ui/non_expressive_names.rs b/tests/ui/non_expressive_names.rs index 778041f49..649a5ecb8 100644 --- a/tests/ui/non_expressive_names.rs +++ b/tests/ui/non_expressive_names.rs @@ -1,17 +1,17 @@ #![feature(plugin)] #![plugin(clippy)] #![deny(clippy,similar_names)] -//~^ NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here -//~| NOTE: lint level defined here + + + + + + + + + + + #![allow(unused)] @@ -24,12 +24,12 @@ fn main() { let specter: i32; let spectre: i32; - let apple: i32; //~ NOTE: existing binding defined here - //~^ NOTE: existing binding defined here - let bpple: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `b_pple` - let cpple: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `c_pple` + let apple: i32; + + let bpple: i32; + + let cpple: i32; + let a_bar: i32; let b_bar: i32; @@ -52,13 +52,13 @@ fn main() { let blubrhs: i32; let blublhs: i32; - let blubx: i32; //~ NOTE: existing binding defined here - let bluby: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `blub_y` + let blubx: i32; + let bluby: i32; - let cake: i32; //~ NOTE: existing binding defined here + + let cake: i32; let cakes: i32; - let coke: i32; //~ ERROR: name is too similar + let coke: i32; match 5 { cheese @ 1 => {}, @@ -74,14 +74,14 @@ fn main() { let ipv6: i32; let abcd1: i32; let abdc2: i32; - let xyz1abc: i32; //~ NOTE: existing binding defined here + let xyz1abc: i32; let xyz2abc: i32; - let xyzeabc: i32; //~ ERROR: name is too similar + let xyzeabc: i32; - let parser: i32; //~ NOTE: existing binding defined here + let parser: i32; let parsed: i32; - let parsee: i32; //~ ERROR: name is too similar - //~| HELP: separate the discriminating character by an underscore like: `parse_e` + let parsee: i32; + let setter: i32; let getter: i32; @@ -93,8 +93,8 @@ fn main() { fn foo() { let Foo { apple, bpple } = unimplemented!(); - let Foo { apple: spring, //~NOTE existing binding defined here - bpple: sprang } = unimplemented!(); //~ ERROR: name is too similar + let Foo { apple: spring, + bpple: sprang } = unimplemented!(); } #[derive(Clone, Debug)] @@ -128,19 +128,19 @@ fn bla() { let blar: i32; } { - let e: i32; //~ ERROR: 5th binding whose name is just one char - //~^ NOTE implied by + let e: i32; + } { - let e: i32; //~ ERROR: 5th binding whose name is just one char - //~^ NOTE implied by - let f: i32; //~ ERROR: 6th binding whose name is just one char - //~^ NOTE implied by + let e: i32; + + let f: i32; + } match 5 { 1 => println!(""), - e => panic!(), //~ ERROR: 5th binding whose name is just one char - //~^ NOTE implied by + e => panic!(), + } match 5 { 1 => println!(""), diff --git a/tests/ui/non_expressive_names.stderr b/tests/ui/non_expressive_names.stderr index 4ddb5c84a..c47f5a449 100644 --- a/tests/ui/non_expressive_names.stderr +++ b/tests/ui/non_expressive_names.stderr @@ -1,7 +1,7 @@ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:29:9 | -29 | let bpple: i32; //~ ERROR: name is too similar +29 | let bpple: i32; | ^^^^^ | note: lint level defined here @@ -12,105 +12,105 @@ note: lint level defined here note: existing binding defined here --> $DIR/non_expressive_names.rs:27:9 | -27 | let apple: i32; //~ NOTE: existing binding defined here +27 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `b_pple` --> $DIR/non_expressive_names.rs:29:9 | -29 | let bpple: i32; //~ ERROR: name is too similar +29 | let bpple: i32; | ^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:31:9 | -31 | let cpple: i32; //~ ERROR: name is too similar +31 | let cpple: i32; | ^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:27:9 | -27 | let apple: i32; //~ NOTE: existing binding defined here +27 | let apple: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `c_pple` --> $DIR/non_expressive_names.rs:31:9 | -31 | let cpple: i32; //~ ERROR: name is too similar +31 | let cpple: i32; | ^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:56:9 | -56 | let bluby: i32; //~ ERROR: name is too similar +56 | let bluby: i32; | ^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:55:9 | -55 | let blubx: i32; //~ NOTE: existing binding defined here +55 | let blubx: i32; | ^^^^^ help: separate the discriminating character by an underscore like: `blub_y` --> $DIR/non_expressive_names.rs:56:9 | -56 | let bluby: i32; //~ ERROR: name is too similar +56 | let bluby: i32; | ^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:61:9 | -61 | let coke: i32; //~ ERROR: name is too similar +61 | let coke: i32; | ^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:59:9 | -59 | let cake: i32; //~ NOTE: existing binding defined here +59 | let cake: i32; | ^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:79:9 | -79 | let xyzeabc: i32; //~ ERROR: name is too similar +79 | let xyzeabc: i32; | ^^^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:77:9 | -77 | let xyz1abc: i32; //~ NOTE: existing binding defined here +77 | let xyz1abc: i32; | ^^^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:83:9 | -83 | let parsee: i32; //~ ERROR: name is too similar +83 | let parsee: i32; | ^^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:81:9 | -81 | let parser: i32; //~ NOTE: existing binding defined here +81 | let parser: i32; | ^^^^^^ help: separate the discriminating character by an underscore like: `parse_e` --> $DIR/non_expressive_names.rs:83:9 | -83 | let parsee: i32; //~ ERROR: name is too similar +83 | let parsee: i32; | ^^^^^^ error: binding's name is too similar to existing binding --> $DIR/non_expressive_names.rs:97:16 | -97 | bpple: sprang } = unimplemented!(); //~ ERROR: name is too similar +97 | bpple: sprang } = unimplemented!(); | ^^^^^^ | note: existing binding defined here --> $DIR/non_expressive_names.rs:96:22 | -96 | let Foo { apple: spring, //~NOTE existing binding defined here +96 | let Foo { apple: spring, | ^^^^^^ error: 5th binding whose name is just one char --> $DIR/non_expressive_names.rs:131:17 | -131 | let e: i32; //~ ERROR: 5th binding whose name is just one char +131 | let e: i32; | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] @@ -123,7 +123,7 @@ note: lint level defined here error: 5th binding whose name is just one char --> $DIR/non_expressive_names.rs:135:17 | -135 | let e: i32; //~ ERROR: 5th binding whose name is just one char +135 | let e: i32; | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] @@ -131,7 +131,7 @@ error: 5th binding whose name is just one char error: 6th binding whose name is just one char --> $DIR/non_expressive_names.rs:137:17 | -137 | let f: i32; //~ ERROR: 6th binding whose name is just one char +137 | let f: i32; | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] @@ -139,7 +139,7 @@ error: 6th binding whose name is just one char error: 5th binding whose name is just one char --> $DIR/non_expressive_names.rs:142:13 | -142 | e => panic!(), //~ ERROR: 5th binding whose name is just one char +142 | e => panic!(), | ^ | = note: #[deny(many_single_char_names)] implied by #[deny(clippy)] diff --git a/tests/ui/ok_if_let.rs b/tests/ui/ok_if_let.rs index 3676f473b..414176f8d 100644 --- a/tests/ui/ok_if_let.rs +++ b/tests/ui/ok_if_let.rs @@ -5,7 +5,7 @@ fn str_to_int(x: &str) -> i32 { if let Some(y) = x.parse().ok() { - //~^ERROR Matching on `Some` with `ok()` is redundant + y } else { 0 diff --git a/tests/ui/ok_if_let.stderr b/tests/ui/ok_if_let.stderr index e39b58554..d3eaaddae 100644 --- a/tests/ui/ok_if_let.stderr +++ b/tests/ui/ok_if_let.stderr @@ -3,7 +3,7 @@ error: Matching on `Some` with `ok()` is redundant | 7 | if let Some(y) = x.parse().ok() { | _____^ starting here... -8 | | //~^ERROR Matching on `Some` with `ok()` is redundant +8 | | 9 | | y 10 | | } else { 11 | | 0 diff --git a/tests/ui/open_options.rs b/tests/ui/open_options.rs index 08024e37d..e1ce69af7 100644 --- a/tests/ui/open_options.rs +++ b/tests/ui/open_options.rs @@ -5,12 +5,12 @@ use std::fs::OpenOptions; #[allow(unused_must_use)] #[deny(nonsensical_open_options)] fn main() { - OpenOptions::new().read(true).truncate(true).open("foo.txt"); //~ERROR file opened with "truncate" and "read" - OpenOptions::new().append(true).truncate(true).open("foo.txt"); //~ERROR file opened with "append" and "truncate" + OpenOptions::new().read(true).truncate(true).open("foo.txt"); + OpenOptions::new().append(true).truncate(true).open("foo.txt"); - OpenOptions::new().read(true).read(false).open("foo.txt"); //~ERROR the method "read" is called more than once - OpenOptions::new().create(true).create(false).open("foo.txt"); //~ERROR the method "create" is called more than once - OpenOptions::new().write(true).write(false).open("foo.txt"); //~ERROR the method "write" is called more than once - OpenOptions::new().append(true).append(false).open("foo.txt"); //~ERROR the method "append" is called more than once - OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); //~ERROR the method "truncate" is called more than once + OpenOptions::new().read(true).read(false).open("foo.txt"); + OpenOptions::new().create(true).create(false).open("foo.txt"); + OpenOptions::new().write(true).write(false).open("foo.txt"); + OpenOptions::new().append(true).append(false).open("foo.txt"); + OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); } diff --git a/tests/ui/open_options.stderr b/tests/ui/open_options.stderr index f7d3d85ed..0f9779c27 100644 --- a/tests/ui/open_options.stderr +++ b/tests/ui/open_options.stderr @@ -1,7 +1,7 @@ error: file opened with "truncate" and "read" --> $DIR/open_options.rs:8:5 | -8 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); //~ERROR file opened with "truncate" and "read" +8 | OpenOptions::new().read(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,37 +13,37 @@ note: lint level defined here error: file opened with "append" and "truncate" --> $DIR/open_options.rs:9:5 | -9 | OpenOptions::new().append(true).truncate(true).open("foo.txt"); //~ERROR file opened with "append" and "truncate" +9 | OpenOptions::new().append(true).truncate(true).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "read" is called more than once --> $DIR/open_options.rs:11:5 | -11 | OpenOptions::new().read(true).read(false).open("foo.txt"); //~ERROR the method "read" is called more than once +11 | OpenOptions::new().read(true).read(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "create" is called more than once --> $DIR/open_options.rs:12:5 | -12 | OpenOptions::new().create(true).create(false).open("foo.txt"); //~ERROR the method "create" is called more than once +12 | OpenOptions::new().create(true).create(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "write" is called more than once --> $DIR/open_options.rs:13:5 | -13 | OpenOptions::new().write(true).write(false).open("foo.txt"); //~ERROR the method "write" is called more than once +13 | OpenOptions::new().write(true).write(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "append" is called more than once --> $DIR/open_options.rs:14:5 | -14 | OpenOptions::new().append(true).append(false).open("foo.txt"); //~ERROR the method "append" is called more than once +14 | OpenOptions::new().append(true).append(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the method "truncate" is called more than once --> $DIR/open_options.rs:15:5 | -15 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); //~ERROR the method "truncate" is called more than once +15 | OpenOptions::new().truncate(true).truncate(false).open("foo.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 7 previous errors diff --git a/tests/ui/overflow_check_conditional.rs b/tests/ui/overflow_check_conditional.rs index 24310eb81..51503003b 100644 --- a/tests/ui/overflow_check_conditional.rs +++ b/tests/ui/overflow_check_conditional.rs @@ -8,28 +8,28 @@ fn main() { let a: u32 = 1; let b: u32 = 2; let c: u32 = 3; - if a + b < a { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. + if a + b < a { } - if a > a + b { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. + if a > a + b { } - if a + b < b { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. + if a + b < b { } - if b > a + b { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. + if b > a + b { } - if a - b > b { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. + if a - b > b { } - if b < a - b { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. + if b < a - b { } - if a - b > a { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. + if a - b > a { } - if a < a - b { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. + if a < a - b { } if a + b < c { diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index f3c330b16..8705f3d72 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -1,7 +1,7 @@ error: You are trying to use classic C overflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:11:5 | -11 | \tif a + b < a { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. +11 | \tif a + b < a { | \t ^^^^^^^^^ | note: lint level defined here @@ -13,43 +13,43 @@ note: lint level defined here error: You are trying to use classic C overflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:14:5 | -14 | \tif a > a + b { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. +14 | \tif a > a + b { | \t ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:17:5 | -17 | \tif a + b < b { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. +17 | \tif a + b < b { | \t ^^^^^^^^^ error: You are trying to use classic C overflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:20:5 | -20 | \tif b > a + b { //~ERROR You are trying to use classic C overflow conditions that will fail in Rust. +20 | \tif b > a + b { | \t ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:23:5 | -23 | \tif a - b > b { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. +23 | \tif a - b > b { | \t ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:26:5 | -26 | \tif b < a - b { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. +26 | \tif b < a - b { | \t ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:29:5 | -29 | \tif a - b > a { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. +29 | \tif a - b > a { | \t ^^^^^^^^^ error: You are trying to use classic C underflow conditions that will fail in Rust. --> $DIR/overflow_check_conditional.rs:32:5 | -32 | \tif a < a - b { //~ERROR You are trying to use classic C underflow conditions that will fail in Rust. +32 | \tif a < a - b { | \t ^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/panic.rs b/tests/ui/panic.rs index 7e535d69b..741c80903 100644 --- a/tests/ui/panic.rs +++ b/tests/ui/panic.rs @@ -5,11 +5,11 @@ fn missing() { if true { - panic!("{}"); //~ERROR: you probably are missing some parameter + panic!("{}"); } else if false { - panic!("{:?}"); //~ERROR: you probably are missing some parameter + panic!("{:?}"); } else { - assert!(true, "here be missing values: {}"); //~ERROR you probably are missing some parameter + assert!(true, "here be missing values: {}"); } } diff --git a/tests/ui/panic.stderr b/tests/ui/panic.stderr index 41317288c..e77add7a3 100644 --- a/tests/ui/panic.stderr +++ b/tests/ui/panic.stderr @@ -1,7 +1,7 @@ error: you probably are missing some parameter in your format string --> $DIR/panic.rs:8:16 | -8 | panic!("{}"); //~ERROR: you probably are missing some parameter +8 | panic!("{}"); | ^^^^ | note: lint level defined here @@ -13,13 +13,13 @@ note: lint level defined here error: you probably are missing some parameter in your format string --> $DIR/panic.rs:10:16 | -10 | panic!("{:?}"); //~ERROR: you probably are missing some parameter +10 | panic!("{:?}"); | ^^^^^^ error: you probably are missing some parameter in your format string --> $DIR/panic.rs:12:23 | -12 | assert!(true, "here be missing values: {}"); //~ERROR you probably are missing some parameter +12 | assert!(true, "here be missing values: {}"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/partialeq_ne_impl.rs b/tests/ui/partialeq_ne_impl.rs index f4ecdd426..9ee1f48b0 100644 --- a/tests/ui/partialeq_ne_impl.rs +++ b/tests/ui/partialeq_ne_impl.rs @@ -9,7 +9,7 @@ struct Foo; impl PartialEq for Foo { fn eq(&self, _: &Foo) -> bool { true } fn ne(&self, _: &Foo) -> bool { false } - //~^ ERROR re-implementing `PartialEq::ne` is unnecessary + } fn main() {} diff --git a/tests/ui/patterns.rs b/tests/ui/patterns.rs index 62bd2c43c..d4aa513ea 100644 --- a/tests/ui/patterns.rs +++ b/tests/ui/patterns.rs @@ -7,7 +7,7 @@ fn main() { let v = Some(true); match v { Some(x) => (), - y @ _ => (), //~ERROR the `y @ _` pattern can be written as just `y` + y @ _ => (), } match v { Some(x) => (), diff --git a/tests/ui/patterns.stderr b/tests/ui/patterns.stderr index b55f9e477..515ae4cae 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:10:9 | -10 | y @ _ => (), //~ERROR the `y @ _` pattern can be written as just `y` +10 | y @ _ => (), | ^^^^^ | = note: #[deny(redundant_pattern)] implied by #[deny(clippy)] diff --git a/tests/ui/precedence.rs b/tests/ui/precedence.rs index 28cc9e643..1c6019fde 100644 --- a/tests/ui/precedence.rs +++ b/tests/ui/precedence.rs @@ -6,33 +6,33 @@ #[allow(eq_op)] fn main() { 1 << 2 + 3; - //~^ ERROR operator precedence can trip - //~| SUGGESTION 1 << (2 + 3) + + 1 + 2 << 3; - //~^ERROR operator precedence can trip - //~| SUGGESTION (1 + 2) << 3 + + 4 >> 1 + 1; - //~^ERROR operator precedence can trip - //~| SUGGESTION 4 >> (1 + 1) + + 1 + 3 >> 2; - //~^ERROR operator precedence can trip - //~| SUGGESTION (1 + 3) >> 2 + + 1 ^ 1 - 1; - //~^ERROR operator precedence can trip - //~| SUGGESTION 1 ^ (1 - 1) + + 3 | 2 - 1; - //~^ERROR operator precedence can trip - //~| SUGGESTION 3 | (2 - 1) + + 3 & 5 - 2; - //~^ERROR operator precedence can trip - //~| SUGGESTION 3 & (5 - 2) + + -1i32.abs(); - //~^ERROR unary minus has lower precedence - //~| SUGGESTION -(1i32.abs()) + + -1f32.abs(); - //~^ERROR unary minus has lower precedence - //~| SUGGESTION -(1f32.abs()) + + // These should not trigger an error let _ = (-1i32).abs(); diff --git a/tests/ui/print.rs b/tests/ui/print.rs index 34c38dca2..e6b114b89 100644 --- a/tests/ui/print.rs +++ b/tests/ui/print.rs @@ -10,7 +10,7 @@ struct Foo; impl Display for Foo { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, "{:?}", 43.1415) - //~^ ERROR use of `Debug`-based formatting + } } @@ -22,18 +22,18 @@ impl Debug for Foo { } fn main() { - println!("Hello"); //~ERROR use of `println!` - print!("Hello"); //~ERROR use of `print!` + println!("Hello"); + print!("Hello"); - print!("Hello {}", "World"); //~ERROR use of `print!` + print!("Hello {}", "World"); print!("Hello {:?}", "World"); - //~^ ERROR use of `print!` - //~| ERROR use of `Debug`-based formatting + + print!("Hello {:#?}", "#orld"); - //~^ ERROR use of `print!` - //~| ERROR use of `Debug`-based formatting + + assert_eq!(42, 1337); diff --git a/tests/ui/print.stderr b/tests/ui/print.stderr index efa574f56..5afb8ae50 100644 --- a/tests/ui/print.stderr +++ b/tests/ui/print.stderr @@ -13,7 +13,7 @@ note: lint level defined here error: use of `println!` --> $DIR/print.rs:25:5 | -25 | println!("Hello"); //~ERROR use of `println!` +25 | println!("Hello"); | ^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -25,13 +25,13 @@ note: lint level defined here error: use of `print!` --> $DIR/print.rs:26:5 | -26 | print!("Hello"); //~ERROR use of `print!` +26 | print!("Hello"); | ^^^^^^^^^^^^^^^^ error: use of `print!` --> $DIR/print.rs:28:5 | -28 | print!("Hello {}", "World"); //~ERROR use of `print!` +28 | print!("Hello {}", "World"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of `print!` diff --git a/tests/ui/print_with_newline.rs b/tests/ui/print_with_newline.rs index 4c1ebd9fe..3e2b31a52 100644 --- a/tests/ui/print_with_newline.rs +++ b/tests/ui/print_with_newline.rs @@ -3,10 +3,10 @@ #![deny(print_with_newline)] fn main() { - print!("Hello\n"); //~ERROR using `print!()` with a format string - print!("Hello {}\n", "world"); //~ERROR using `print!()` with a format string - print!("Hello {} {}\n\n", "world", "#2"); //~ERROR using `print!()` with a format string - print!("{}\n", 1265); //~ERROR using `print!()` with a format string + print!("Hello\n"); + print!("Hello {}\n", "world"); + print!("Hello {} {}\n\n", "world", "#2"); + print!("{}\n", 1265); // these are all fine print!(""); diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr index 94edc5325..44beb5302 100644 --- a/tests/ui/print_with_newline.stderr +++ b/tests/ui/print_with_newline.stderr @@ -1,7 +1,7 @@ error: using `print!()` with a format string that ends in a newline, consider using `println!()` instead --> $DIR/print_with_newline.rs:6:5 | -6 | print!("Hello/n"); //~ERROR using `print!()` with a format string +6 | print!("Hello/n"); | ^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,19 +13,19 @@ note: lint level defined here error: using `print!()` with a format string that ends in a newline, consider using `println!()` instead --> $DIR/print_with_newline.rs:7:5 | -7 | print!("Hello {}/n", "world"); //~ERROR using `print!()` with a format string +7 | print!("Hello {}/n", "world"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a newline, consider using `println!()` instead --> $DIR/print_with_newline.rs:8:5 | -8 | print!("Hello {} {}/n/n", "world", "#2"); //~ERROR using `print!()` with a format string +8 | print!("Hello {} {}/n/n", "world", "#2"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: using `print!()` with a format string that ends in a newline, consider using `println!()` instead --> $DIR/print_with_newline.rs:9:5 | -9 | print!("{}/n", 1265); //~ERROR using `print!()` with a format string +9 | print!("{}/n", 1265); | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs index e49712087..f262d2a8d 100644 --- a/tests/ui/ptr_arg.rs +++ b/tests/ui/ptr_arg.rs @@ -3,7 +3,7 @@ #![allow(unused)] #![deny(ptr_arg)] -fn do_vec(x: &Vec) { //~ERROR writing `&Vec<_>` instead of `&[_]` +fn do_vec(x: &Vec) { //Nothing here } @@ -11,7 +11,7 @@ fn do_vec_mut(x: &mut Vec) { // no error here //Nothing here } -fn do_str(x: &String) { //~ERROR writing `&String` instead of `&str` +fn do_str(x: &String) { //Nothing here either } @@ -24,7 +24,7 @@ fn main() { trait Foo { type Item; - fn do_vec(x: &Vec); //~ERROR writing `&Vec<_>` + fn do_vec(x: &Vec); fn do_item(x: &Self::Item); } diff --git a/tests/ui/ptr_arg.stderr b/tests/ui/ptr_arg.stderr index a022f0e55..ce9c1e856 100644 --- a/tests/ui/ptr_arg.stderr +++ b/tests/ui/ptr_arg.stderr @@ -1,7 +1,7 @@ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. Consider changing the type to `&[...]` --> $DIR/ptr_arg.rs:6:14 | -6 | fn do_vec(x: &Vec) { //~ERROR writing `&Vec<_>` instead of `&[_]` +6 | fn do_vec(x: &Vec) { | ^^^^^^^^^ | note: lint level defined here @@ -13,13 +13,13 @@ note: lint level defined here error: writing `&String` instead of `&str` involves a new object where a slice will do. Consider changing the type to `&str` --> $DIR/ptr_arg.rs:14:14 | -14 | fn do_str(x: &String) { //~ERROR writing `&String` instead of `&str` +14 | fn do_str(x: &String) { | ^^^^^^^ error: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices. Consider changing the type to `&[...]` --> $DIR/ptr_arg.rs:27:18 | -27 | fn do_vec(x: &Vec); //~ERROR writing `&Vec<_>` +27 | fn do_vec(x: &Vec); | ^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/range.rs b/tests/ui/range.rs index fc12155ce..8e2bf6a7e 100644 --- a/tests/ui/range.rs +++ b/tests/ui/range.rs @@ -10,15 +10,15 @@ impl NotARange { #[deny(range_step_by_zero, range_zip_with_len)] fn main() { - (0..1).step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator + (0..1).step_by(0); // No warning for non-zero step (0..1).step_by(1); - (1..).step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator - (1...2).step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator + (1..).step_by(0); + (1...2).step_by(0); let x = 0..1; - x.step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator + x.step_by(0); // No error, not a range. let y = NotARange; @@ -26,6 +26,6 @@ fn main() { let v1 = vec![1,2,3]; let v2 = vec![4,5]; - let _x = v1.iter().zip(0..v1.len()); //~ERROR It is more idiomatic to use v1.iter().enumerate() + let _x = v1.iter().zip(0..v1.len()); let _y = v1.iter().zip(0..v2.len()); // No error } diff --git a/tests/ui/range.stderr b/tests/ui/range.stderr index a7c4d4fcf..09e9f8a47 100644 --- a/tests/ui/range.stderr +++ b/tests/ui/range.stderr @@ -1,7 +1,7 @@ error: Range::step_by(0) produces an infinite iterator. Consider using `std::iter::repeat()` instead --> $DIR/range.rs:13:5 | -13 | (0..1).step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator +13 | (0..1).step_by(0); | ^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,25 +13,25 @@ note: lint level defined here error: Range::step_by(0) produces an infinite iterator. Consider using `std::iter::repeat()` instead --> $DIR/range.rs:17:5 | -17 | (1..).step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator +17 | (1..).step_by(0); | ^^^^^^^^^^^^^^^^ error: Range::step_by(0) produces an infinite iterator. Consider using `std::iter::repeat()` instead --> $DIR/range.rs:18:5 | -18 | (1...2).step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator +18 | (1...2).step_by(0); | ^^^^^^^^^^^^^^^^^^ error: Range::step_by(0) produces an infinite iterator. Consider using `std::iter::repeat()` instead --> $DIR/range.rs:21:5 | -21 | x.step_by(0); //~ERROR Range::step_by(0) produces an infinite iterator +21 | x.step_by(0); | ^^^^^^^^^^^^ error: It is more idiomatic to use v1.iter().enumerate() --> $DIR/range.rs:29:14 | -29 | let _x = v1.iter().zip(0..v1.len()); //~ERROR It is more idiomatic to use v1.iter().enumerate() +29 | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here diff --git a/tests/ui/redundant_closure_call.rs b/tests/ui/redundant_closure_call.rs index 73830ecc9..a431e05e7 100644 --- a/tests/ui/redundant_closure_call.rs +++ b/tests/ui/redundant_closure_call.rs @@ -5,20 +5,20 @@ fn main() { let a = (|| 42)(); - //~^ ERROR Try not to call a closure in the expression where it is declared. - //~| HELP Try doing something like: - //~| SUGGESTION let a = 42; + + + let mut i = 1; - let k = (|m| m+1)(i); //~ERROR Try not to call a closure in the expression where it is declared. + let k = (|m| m+1)(i); - k = (|a,b| a*b)(1,5); //~ERROR Try not to call a closure in the expression where it is declared. + k = (|a,b| a*b)(1,5); let closure = || 32; - i = closure(); //~ERROR Closure called just once immediately after it was declared + i = closure(); let closure = |i| i+1; - i = closure(3); //~ERROR Closure called just once immediately after it was declared + i = closure(3); i = closure(4); } diff --git a/tests/ui/redundant_closure_call.stderr b/tests/ui/redundant_closure_call.stderr index 94facfa0f..287f465bb 100644 --- a/tests/ui/redundant_closure_call.stderr +++ b/tests/ui/redundant_closure_call.stderr @@ -1,7 +1,7 @@ error: Closure called just once immediately after it was declared --> $DIR/redundant_closure_call.rs:18:2 | -18 | \ti = closure(); //~ERROR Closure called just once immediately after it was declared +18 | \ti = closure(); | \t^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: Closure called just once immediately after it was declared --> $DIR/redundant_closure_call.rs:21:2 | -21 | \ti = closure(3); //~ERROR Closure called just once immediately after it was declared +21 | \ti = closure(3); | \t^^^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. @@ -28,13 +28,13 @@ help: Try doing something like: error: Try not to call a closure in the expression where it is declared. --> $DIR/redundant_closure_call.rs:13:10 | -13 | \tlet k = (|m| m+1)(i); //~ERROR Try not to call a closure in the expression where it is declared. +13 | \tlet k = (|m| m+1)(i); | \t ^^^^^^^^^^^^ error: Try not to call a closure in the expression where it is declared. --> $DIR/redundant_closure_call.rs:15:6 | -15 | \tk = (|a,b| a*b)(1,5); //~ERROR Try not to call a closure in the expression where it is declared. +15 | \tk = (|a,b| a*b)(1,5); | \t ^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/reference.rs b/tests/ui/reference.rs index 789425e71..d1160df9e 100644 --- a/tests/ui/reference.rs +++ b/tests/ui/reference.rs @@ -17,63 +17,63 @@ fn main() { let aref = &a; let b = *&a; - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = a; + + + let b = *&get_number(); - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = get_number(); + + + let b = *get_reference(&a); let bytes : Vec = vec![1, 2, 3, 4]; let b = *&bytes[1..2][0]; - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = bytes[1..2][0]; + + + //This produces a suggestion of 'let b = (a);' which //will trigger the 'unused_parens' lint let b = *&(a); - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = (a) + + + let b = *(&a); - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = a; + + + let b = *((&a)); - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = a + + + let b = *&&a; - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = &a; + + + let b = **&aref; - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = *aref; + + + //This produces a suggestion of 'let b = *&a;' which //will trigger the 'deref_addrof' lint again let b = **&&a; - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let b = *&a; + + + { let mut x = 10; let y = *&mut x; - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let y = x; + + + } { @@ -81,8 +81,8 @@ fn main() { //will trigger the 'deref_addrof' lint again let mut x = 10; let y = **&mut &mut x; - //~^ERROR immediately dereferencing a reference - //~|HELP try this - //~|SUGGESTION let y = *&mut x; + + + } } diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs index d6287b881..245ceb835 100644 --- a/tests/ui/regex.rs +++ b/tests/ui/regex.rs @@ -14,23 +14,23 @@ const NOT_A_REAL_REGEX : &'static str = "foobar"; fn syntax_error() { let pipe_in_wrong_position = Regex::new("|"); - //~^ERROR: regex syntax error: empty alternate + let pipe_in_wrong_position_builder = RegexBuilder::new("|"); - //~^ERROR: regex syntax error: empty alternate + let wrong_char_ranice = Regex::new("[z-a]"); - //~^ERROR: regex syntax error: invalid character class range + let some_unicode = Regex::new("[é-è]"); - //~^ERROR: regex syntax error: invalid character class range + let some_regex = Regex::new(OPENING_PAREN); - //~^ERROR: regex syntax error on position 0: unclosed + let binary_pipe_in_wrong_position = BRegex::new("|"); - //~^ERROR: regex syntax error: empty alternate + let some_binary_regex = BRegex::new(OPENING_PAREN); - //~^ERROR: regex syntax error on position 0: unclosed + let some_binary_regex_builder = BRegexBuilder::new(OPENING_PAREN); - //~^ERROR: regex syntax error on position 0: unclosed + let closing_paren = ")"; let not_linted = Regex::new(closing_paren); @@ -46,61 +46,61 @@ fn syntax_error() { let set_error = RegexSet::new(&[ OPENING_PAREN, - //~^ERROR: regex syntax error on position 0: unclosed + r"[a-z]+\.(com|org|net)", ]); let bset_error = BRegexSet::new(&[ OPENING_PAREN, - //~^ERROR: regex syntax error on position 0: unclosed + r"[a-z]+\.(com|org|net)", ]); } fn trivial_regex() { let trivial_eq = Regex::new("^foobar$"); - //~^ERROR: trivial regex - //~|HELP consider using `==` on `str`s + + let trivial_eq_builder = RegexBuilder::new("^foobar$"); - //~^ERROR: trivial regex - //~|HELP consider using `==` on `str`s + + let trivial_starts_with = Regex::new("^foobar"); - //~^ERROR: trivial regex - //~|HELP consider using `str::starts_with` + + let trivial_ends_with = Regex::new("foobar$"); - //~^ERROR: trivial regex - //~|HELP consider using `str::ends_with` + + let trivial_contains = Regex::new("foobar"); - //~^ERROR: trivial regex - //~|HELP consider using `str::contains` + + let trivial_contains = Regex::new(NOT_A_REAL_REGEX); - //~^ERROR: trivial regex - //~|HELP consider using `str::contains` + + let trivial_backslash = Regex::new("a\\.b"); - //~^ERROR: trivial regex - //~|HELP consider using `str::contains` + + // unlikely corner cases let trivial_empty = Regex::new(""); - //~^ERROR: trivial regex - //~|HELP the regex is unlikely to be useful + + let trivial_empty = Regex::new("^"); - //~^ERROR: trivial regex - //~|HELP the regex is unlikely to be useful + + let trivial_empty = Regex::new("^$"); - //~^ERROR: trivial regex - //~|HELP consider using `str::is_empty` + + let binary_trivial_empty = BRegex::new("^$"); - //~^ERROR: trivial regex - //~|HELP consider using `str::is_empty` + + // non-trivial regexes let non_trivial_dot = Regex::new("a.b"); diff --git a/tests/ui/serde.rs b/tests/ui/serde.rs index a0671f071..78aabf352 100644 --- a/tests/ui/serde.rs +++ b/tests/ui/serde.rs @@ -37,7 +37,7 @@ impl serde::de::Visitor for B { } fn visit_string(self, _v: String) -> Result - //~^ ERROR you should not implement `visit_string` without also implementing `visit_str` + where E: serde::de::Error, { unimplemented!() diff --git a/tests/ui/serde.stderr b/tests/ui/serde.stderr index e7b493eb2..6aa5adabe 100644 --- a/tests/ui/serde.stderr +++ b/tests/ui/serde.stderr @@ -3,7 +3,7 @@ error: you should not implement `visit_string` without also implementing `visit_ | 39 | fn visit_string(self, _v: String) -> Result | _____^ starting here... -40 | | //~^ ERROR you should not implement `visit_string` without also implementing `visit_str` +40 | | 41 | | where E: serde::de::Error, 42 | | { 43 | | unimplemented!() diff --git a/tests/ui/shadow.rs b/tests/ui/shadow.rs index bf0bdd818..5a2c9ba66 100644 --- a/tests/ui/shadow.rs +++ b/tests/ui/shadow.rs @@ -10,17 +10,17 @@ fn first(x: (isize, isize)) -> isize { x.0 } fn main() { let mut x = 1; - let x = &mut x; //~ERROR `x` is shadowed by itself in `&mut x` - let x = { x }; //~ERROR `x` is shadowed by itself in `{ x }` - let x = (&*x); //~ERROR `x` is shadowed by itself in `(&*x)` - let x = { *x + 1 }; //~ERROR `x` is shadowed by `{ *x + 1 }` which reuses - let x = id(x); //~ERROR `x` is shadowed by `id(x)` which reuses - let x = (1, x); //~ERROR `x` is shadowed by `(1, x)` which reuses - let x = first(x); //~ERROR `x` is shadowed by `first(x)` which reuses + let x = &mut x; + let x = { x }; + let x = (&*x); + let x = { *x + 1 }; + let x = id(x); + let x = (1, x); + let x = first(x); let y = 1; - let x = y; //~ERROR `x` is shadowed by `y` + let x = y; - let x; //~ERROR `x` shadows a previous declaration + let x; x = 42; let o = Some(1_u8); diff --git a/tests/ui/shadow.stderr b/tests/ui/shadow.stderr index e5ed3f18c..212192a28 100644 --- a/tests/ui/shadow.stderr +++ b/tests/ui/shadow.stderr @@ -1,7 +1,7 @@ error: `x` is shadowed by itself in `&mut x` --> $DIR/shadow.rs:13:9 | -13 | let x = &mut x; //~ERROR `x` is shadowed by itself in `&mut x` +13 | let x = &mut x; | ^^^^^^^^^^ | = note: #[deny(shadow_same)] implied by #[deny(clippy_pedantic)] @@ -19,33 +19,33 @@ note: previous binding is here error: `x` is shadowed by itself in `{ x }` --> $DIR/shadow.rs:14:9 | -14 | let x = { x }; //~ERROR `x` is shadowed by itself in `{ x }` +14 | let x = { x }; | ^^^^^^^^^ | = note: #[deny(shadow_same)] implied by #[deny(clippy_pedantic)] note: previous binding is here --> $DIR/shadow.rs:13:9 | -13 | let x = &mut x; //~ERROR `x` is shadowed by itself in `&mut x` +13 | let x = &mut x; | ^ error: `x` is shadowed by itself in `(&*x)` --> $DIR/shadow.rs:15:9 | -15 | let x = (&*x); //~ERROR `x` is shadowed by itself in `(&*x)` +15 | let x = (&*x); | ^^^^^^^^^ | = note: #[deny(shadow_same)] implied by #[deny(clippy_pedantic)] note: previous binding is here --> $DIR/shadow.rs:14:9 | -14 | let x = { x }; //~ERROR `x` is shadowed by itself in `{ x }` +14 | let x = { x }; | ^ error: `x` is shadowed by `{ *x + 1 }` which reuses the original value --> $DIR/shadow.rs:16:9 | -16 | let x = { *x + 1 }; //~ERROR `x` is shadowed by `{ *x + 1 }` which reuses +16 | let x = { *x + 1 }; | ^ | = note: #[deny(shadow_reuse)] implied by #[deny(clippy_pedantic)] @@ -57,72 +57,72 @@ note: lint level defined here note: initialization happens here --> $DIR/shadow.rs:16:13 | -16 | let x = { *x + 1 }; //~ERROR `x` is shadowed by `{ *x + 1 }` which reuses +16 | let x = { *x + 1 }; | ^^^^^^^^^^ note: previous binding is here --> $DIR/shadow.rs:15:9 | -15 | let x = (&*x); //~ERROR `x` is shadowed by itself in `(&*x)` +15 | let x = (&*x); | ^ error: `x` is shadowed by `id(x)` which reuses the original value --> $DIR/shadow.rs:17:9 | -17 | let x = id(x); //~ERROR `x` is shadowed by `id(x)` which reuses +17 | let x = id(x); | ^ | = note: #[deny(shadow_reuse)] implied by #[deny(clippy_pedantic)] note: initialization happens here --> $DIR/shadow.rs:17:13 | -17 | let x = id(x); //~ERROR `x` is shadowed by `id(x)` which reuses +17 | let x = id(x); | ^^^^^ note: previous binding is here --> $DIR/shadow.rs:16:9 | -16 | let x = { *x + 1 }; //~ERROR `x` is shadowed by `{ *x + 1 }` which reuses +16 | let x = { *x + 1 }; | ^ error: `x` is shadowed by `(1, x)` which reuses the original value --> $DIR/shadow.rs:18:9 | -18 | let x = (1, x); //~ERROR `x` is shadowed by `(1, x)` which reuses +18 | let x = (1, x); | ^ | = note: #[deny(shadow_reuse)] implied by #[deny(clippy_pedantic)] note: initialization happens here --> $DIR/shadow.rs:18:13 | -18 | let x = (1, x); //~ERROR `x` is shadowed by `(1, x)` which reuses +18 | let x = (1, x); | ^^^^^^ note: previous binding is here --> $DIR/shadow.rs:17:9 | -17 | let x = id(x); //~ERROR `x` is shadowed by `id(x)` which reuses +17 | let x = id(x); | ^ error: `x` is shadowed by `first(x)` which reuses the original value --> $DIR/shadow.rs:19:9 | -19 | let x = first(x); //~ERROR `x` is shadowed by `first(x)` which reuses +19 | let x = first(x); | ^ | = note: #[deny(shadow_reuse)] implied by #[deny(clippy_pedantic)] note: initialization happens here --> $DIR/shadow.rs:19:13 | -19 | let x = first(x); //~ERROR `x` is shadowed by `first(x)` which reuses +19 | let x = first(x); | ^^^^^^^^ note: previous binding is here --> $DIR/shadow.rs:18:9 | -18 | let x = (1, x); //~ERROR `x` is shadowed by `(1, x)` which reuses +18 | let x = (1, x); | ^ error: `x` is shadowed by `y` --> $DIR/shadow.rs:21:9 | -21 | let x = y; //~ERROR `x` is shadowed by `y` +21 | let x = y; | ^ | = note: #[deny(shadow_unrelated)] implied by #[deny(clippy_pedantic)] @@ -134,25 +134,25 @@ note: lint level defined here note: initialization happens here --> $DIR/shadow.rs:21:13 | -21 | let x = y; //~ERROR `x` is shadowed by `y` +21 | let x = y; | ^ note: previous binding is here --> $DIR/shadow.rs:19:9 | -19 | let x = first(x); //~ERROR `x` is shadowed by `first(x)` which reuses +19 | let x = first(x); | ^ error: `x` shadows a previous declaration --> $DIR/shadow.rs:23:9 | -23 | let x; //~ERROR `x` shadows a previous declaration +23 | let x; | ^ | = note: #[deny(shadow_unrelated)] implied by #[deny(clippy_pedantic)] note: previous binding is here --> $DIR/shadow.rs:21:9 | -21 | let x = y; //~ERROR `x` is shadowed by `y` +21 | let x = y; | ^ error: aborting due to 9 previous errors diff --git a/tests/ui/short_circuit_statement.rs b/tests/ui/short_circuit_statement.rs index 23dfc0ebc..55ff4a83b 100644 --- a/tests/ui/short_circuit_statement.rs +++ b/tests/ui/short_circuit_statement.rs @@ -5,17 +5,17 @@ fn main() { f() && g(); - //~^ ERROR boolean short circuit operator - //~| HELP replace it with - //~| SUGGESTION if f() { g(); } + + + f() || g(); - //~^ ERROR boolean short circuit operator - //~| HELP replace it with - //~| SUGGESTION if !f() { g(); } + + + 1 == 2 || g(); - //~^ ERROR boolean short circuit operator - //~| HELP replace it with - //~| SUGGESTION if !(1 == 2) { g(); } + + + } fn f() -> bool { diff --git a/tests/ui/strings.rs b/tests/ui/strings.rs index 7cfc8a41e..f893d9949 100644 --- a/tests/ui/strings.rs +++ b/tests/ui/strings.rs @@ -7,11 +7,11 @@ fn add_only() { // ignores assignment distinction let mut x = "".to_owned(); for _ in 1..3 { - x = x + "."; //~ERROR you added something to a string. + x = x + "."; } let y = "".to_owned(); - let z = y + "..."; //~ERROR you added something to a string. + let z = y + "..."; assert_eq!(&x, &z); } @@ -21,7 +21,7 @@ fn add_assign_only() { let mut x = "".to_owned(); for _ in 1..3 { - x = x + "."; //~ERROR you assigned the result of adding something to this string. + x = x + "."; } let y = "".to_owned(); @@ -35,11 +35,11 @@ fn both() { let mut x = "".to_owned(); for _ in 1..3 { - x = x + "."; //~ERROR you assigned the result of adding something to this string. + x = x + "."; } let y = "".to_owned(); - let z = y + "..."; //~ERROR you added something to a string. + let z = y + "..."; assert_eq!(&x, &z); } @@ -48,9 +48,9 @@ fn both() { #[deny(string_lit_as_bytes)] fn str_lit_as_bytes() { let bs = "hello there".as_bytes(); - //~^ERROR calling `as_bytes()` - //~|HELP byte string literal - //~|SUGGESTION b"hello there" + + + // no warning, because this cannot be written as a byte string literal: let ubs = "☃".as_bytes(); @@ -66,8 +66,8 @@ fn main() { // the add is only caught for `String` let mut x = 1; ; x = x + 1; - //~^ WARN manual implementation of an assign operation - //~| HELP replace - //~| SUGGESTION ; x += 1; + + + assert_eq!(2, x); } diff --git a/tests/ui/strings.stderr b/tests/ui/strings.stderr index 892f04c7e..b16724261 100644 --- a/tests/ui/strings.stderr +++ b/tests/ui/strings.stderr @@ -1,7 +1,7 @@ error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/strings.rs:10:13 | -10 | x = x + "."; //~ERROR you added something to a string. +10 | x = x + "."; | ^^^^^^^ | note: lint level defined here @@ -13,13 +13,13 @@ note: lint level defined here error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/strings.rs:14:13 | -14 | let z = y + "..."; //~ERROR you added something to a string. +14 | let z = y + "..."; | ^^^^^^^^^ error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead --> $DIR/strings.rs:24:9 | -24 | x = x + "."; //~ERROR you assigned the result of adding something to this string. +24 | x = x + "."; | ^^^^^^^^^^^ | note: lint level defined here @@ -31,7 +31,7 @@ note: lint level defined here error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead --> $DIR/strings.rs:38:9 | -38 | x = x + "."; //~ERROR you assigned the result of adding something to this string. +38 | x = x + "."; | ^^^^^^^^^^^ | note: lint level defined here @@ -43,7 +43,7 @@ note: lint level defined here error: you added something to a string. Consider using `String::push_str()` instead --> $DIR/strings.rs:42:13 | -42 | let z = y + "..."; //~ERROR you added something to a string. +42 | let z = y + "..."; | ^^^^^^^^^ | note: lint level defined here diff --git a/tests/ui/stutter.rs b/tests/ui/stutter.rs index 0c99859c1..922ab080d 100644 --- a/tests/ui/stutter.rs +++ b/tests/ui/stutter.rs @@ -5,10 +5,10 @@ mod foo { pub fn foo() {} - pub fn foo_bar() {} //~ ERROR: item name starts with its containing module's name - pub fn bar_foo() {} //~ ERROR: item name ends with its containing module's name - pub struct FooCake {} //~ ERROR: item name starts with its containing module's name - pub enum CakeFoo {} //~ ERROR: item name ends with its containing module's name + pub fn foo_bar() {} + pub fn bar_foo() {} + pub struct FooCake {} + pub enum CakeFoo {} } fn main() {} diff --git a/tests/ui/stutter.stderr b/tests/ui/stutter.stderr index 108fccb77..03f4c7396 100644 --- a/tests/ui/stutter.stderr +++ b/tests/ui/stutter.stderr @@ -1,7 +1,7 @@ error: item name starts with its containing module's name --> $DIR/stutter.rs:8:5 | -8 | pub fn foo_bar() {} //~ ERROR: item name starts with its containing module's name +8 | pub fn foo_bar() {} | ^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,19 +13,19 @@ note: lint level defined here error: item name ends with its containing module's name --> $DIR/stutter.rs:9:5 | -9 | pub fn bar_foo() {} //~ ERROR: item name ends with its containing module's name +9 | pub fn bar_foo() {} | ^^^^^^^^^^^^^^^^^^^ error: item name starts with its containing module's name --> $DIR/stutter.rs:10:5 | -10 | pub struct FooCake {} //~ ERROR: item name starts with its containing module's name +10 | pub struct FooCake {} | ^^^^^^^^^^^^^^^^^^^^^ error: item name ends with its containing module's name --> $DIR/stutter.rs:11:5 | -11 | pub enum CakeFoo {} //~ ERROR: item name ends with its containing module's name +11 | pub enum CakeFoo {} | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index 0e56d5ca8..95478dda0 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -8,36 +8,36 @@ struct Foo(u32); fn array() { let mut foo = [1, 2]; - let temp = foo[0]; //~ NOTE implied by + let temp = foo[0]; foo[0] = foo[1]; foo[1] = temp; - //~^^^ ERROR this looks like you are swapping elements of `foo` manually - //~| HELP try - //~| SUGGESTION foo.swap(0, 1); + + + foo.swap(0, 1); } fn slice() { let foo = &mut [1, 2]; - let temp = foo[0]; //~ NOTE implied by + let temp = foo[0]; foo[0] = foo[1]; foo[1] = temp; - //~^^^ ERROR this looks like you are swapping elements of `foo` manually - //~| HELP try - //~| SUGGESTION foo.swap(0, 1); + + + foo.swap(0, 1); } fn vec() { let mut foo = vec![1, 2]; - let temp = foo[0]; //~ NOTE implied by + let temp = foo[0]; foo[0] = foo[1]; foo[1] = temp; - //~^^^ ERROR this looks like you are swapping elements of `foo` manually - //~| HELP try - //~| SUGGESTION foo.swap(0, 1); + + + foo.swap(0, 1); } @@ -50,35 +50,35 @@ fn main() { let mut a = 42; let mut b = 1337; - a = b; //~ NOTE implied by + a = b; b = a; - //~^^ ERROR this looks like you are trying to swap `a` and `b` - //~| HELP try - //~| SUGGESTION std::mem::swap(&mut a, &mut b); - //~| NOTE or maybe you should use `std::mem::replace`? - ; let t = a; //~ NOTE implied by + + + + + ; let t = a; a = b; b = t; - //~^^^ ERROR this looks like you are swapping `a` and `b` manually - //~| HELP try - //~| SUGGESTION ; std::mem::swap(&mut a, &mut b); - //~| NOTE or maybe you should use `std::mem::replace`? + + + + let mut c = Foo(42); - c.0 = a; //~ NOTE implied by + c.0 = a; a = c.0; - //~^^ ERROR this looks like you are trying to swap `c.0` and `a` - //~| HELP try - //~| SUGGESTION std::mem::swap(&mut c.0, &mut a); - //~| NOTE or maybe you should use `std::mem::replace`? - ; let t = c.0; //~ NOTE implied by + + + + + ; let t = c.0; c.0 = a; a = t; - //~^^^ ERROR this looks like you are swapping `c.0` and `a` manually - //~| HELP try - //~| SUGGESTION ; std::mem::swap(&mut c.0, &mut a); - //~| NOTE or maybe you should use `std::mem::replace`? + + + + } diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index f4fd80ec9..714b6859f 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,7 +1,7 @@ error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:11:5 | -11 | let temp = foo[0]; //~ NOTE implied by +11 | let temp = foo[0]; | _____^ starting here... 12 | | foo[0] = foo[1]; 13 | | foo[1] = temp; @@ -19,7 +19,7 @@ help: try error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:23:5 | -23 | let temp = foo[0]; //~ NOTE implied by +23 | let temp = foo[0]; | _____^ starting here... 24 | | foo[0] = foo[1]; 25 | | foo[1] = temp; @@ -32,7 +32,7 @@ help: try error: this looks like you are swapping elements of `foo` manually --> $DIR/swap.rs:35:5 | -35 | let temp = foo[0]; //~ NOTE implied by +35 | let temp = foo[0]; | _____^ starting here... 36 | | foo[0] = foo[1]; 37 | | foo[1] = temp; @@ -45,7 +45,7 @@ help: try error: this looks like you are swapping `a` and `b` manually --> $DIR/swap.rs:60:7 | -60 | ; let t = a; //~ NOTE implied by +60 | ; let t = a; | _______^ starting here... 61 | | a = b; 62 | | b = t; @@ -59,7 +59,7 @@ help: try error: this looks like you are swapping `c.0` and `a` manually --> $DIR/swap.rs:77:7 | -77 | ; let t = c.0; //~ NOTE implied by +77 | ; let t = c.0; | _______^ starting here... 78 | | c.0 = a; 79 | | a = t; @@ -73,7 +73,7 @@ help: try error: this looks like you are trying to swap `a` and `b` --> $DIR/swap.rs:53:5 | -53 | a = b; //~ NOTE implied by +53 | a = b; | _____^ starting here... 54 | | b = a; | |_________^ ...ending here @@ -91,7 +91,7 @@ help: try error: this looks like you are trying to swap `c.0` and `a` --> $DIR/swap.rs:70:5 | -70 | c.0 = a; //~ NOTE implied by +70 | c.0 = a; | _____^ starting here... 71 | | a = c.0; | |___________^ ...ending here diff --git a/tests/ui/temporary_assignment.rs b/tests/ui/temporary_assignment.rs index b1c2b9900..752d897d0 100644 --- a/tests/ui/temporary_assignment.rs +++ b/tests/ui/temporary_assignment.rs @@ -26,8 +26,8 @@ fn main() { let mut s = Struct { field: 0 }; let mut t = (0, 0); - Struct { field: 0 }.field = 1; //~ERROR assignment to temporary - (0, 0).0 = 1; //~ERROR assignment to temporary + Struct { field: 0 }.field = 1; + (0, 0).0 = 1; // no error s.field = 1; diff --git a/tests/ui/temporary_assignment.stderr b/tests/ui/temporary_assignment.stderr index 953fd4e77..ea39d798e 100644 --- a/tests/ui/temporary_assignment.stderr +++ b/tests/ui/temporary_assignment.stderr @@ -1,7 +1,7 @@ error: assignment to temporary --> $DIR/temporary_assignment.rs:29:5 | -29 | Struct { field: 0 }.field = 1; //~ERROR assignment to temporary +29 | Struct { field: 0 }.field = 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: assignment to temporary --> $DIR/temporary_assignment.rs:30:5 | -30 | (0, 0).0 = 1; //~ERROR assignment to temporary +30 | (0, 0).0 = 1; | ^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/toplevel_ref_arg.rs b/tests/ui/toplevel_ref_arg.rs index 86459ea97..a69600899 100644 --- a/tests/ui/toplevel_ref_arg.rs +++ b/tests/ui/toplevel_ref_arg.rs @@ -4,7 +4,7 @@ #![deny(clippy)] #![allow(unused)] -fn the_answer(ref mut x: u8) { //~ ERROR `ref` directly on a function argument is ignored +fn the_answer(ref mut x: u8) { *x = 42; } @@ -16,24 +16,24 @@ fn main() { y(1u8); let ref x = 1; - //~^ ERROR `ref` on an entire `let` pattern is discouraged - //~| HELP try - //~| SUGGESTION let x = &1; + + + let ref y: (&_, u8) = (&1, 2); - //~^ ERROR `ref` on an entire `let` pattern is discouraged - //~| HELP try - //~| SUGGESTION let y: &(&_, u8) = &(&1, 2); + + + let ref z = 1 + 2; - //~^ ERROR `ref` on an entire `let` pattern is discouraged - //~| HELP try - //~| SUGGESTION let z = &(1 + 2); + + + let ref mut z = 1 + 2; - //~^ ERROR `ref` on an entire `let` pattern is discouraged - //~| HELP try - //~| SUGGESTION let z = &mut (1 + 2); + + + let (ref x, _) = (1,2); // okay, not top level println!("The answer is {}.", x); diff --git a/tests/ui/toplevel_ref_arg.stderr b/tests/ui/toplevel_ref_arg.stderr index 3e3ec712c..86dd880ed 100644 --- a/tests/ui/toplevel_ref_arg.stderr +++ b/tests/ui/toplevel_ref_arg.stderr @@ -1,7 +1,7 @@ error: `ref` directly on a function argument is ignored. Consider using a reference type instead. --> $DIR/toplevel_ref_arg.rs:7:15 | -7 | fn the_answer(ref mut x: u8) { //~ ERROR `ref` directly on a function argument is ignored +7 | fn the_answer(ref mut x: u8) { | ^^^^^^^^^ | = note: #[deny(toplevel_ref_arg)] implied by #[deny(clippy)] diff --git a/tests/ui/transmute.rs b/tests/ui/transmute.rs index c5ab854b0..1fae47c8a 100644 --- a/tests/ui/transmute.rs +++ b/tests/ui/transmute.rs @@ -20,68 +20,68 @@ fn my_vec() -> MyVec { #[deny(useless_transmute)] unsafe fn _generic<'a, T, U: 'a>(t: &'a T) { let _: &'a T = core::intrinsics::transmute(t); - //~^ ERROR transmute from a type (`&'a T`) to itself + let _: &'a U = core::intrinsics::transmute(t); let _: *const T = core::intrinsics::transmute(t); - //~^ ERROR transmute from a reference to a pointer - //~| HELP try - //~| SUGGESTION = t as *const T + + + let _: *mut T = core::intrinsics::transmute(t); - //~^ ERROR transmute from a reference to a pointer - //~| HELP try - //~| SUGGESTION = t as *const T as *mut T + + + let _: *const U = core::intrinsics::transmute(t); - //~^ ERROR transmute from a reference to a pointer - //~| HELP try - //~| SUGGESTION = t as *const T as *const U + + + } #[deny(transmute_ptr_to_ref)] unsafe fn _ptr_to_ref(p: *const T, m: *mut T, o: *const U, om: *mut U) { let _: &T = std::mem::transmute(p); - //~^ ERROR transmute from a pointer type (`*const T`) to a reference type (`&T`) - //~| HELP try - //~| SUGGESTION = &*p; + + + let _: &T = &*p; let _: &mut T = std::mem::transmute(m); - //~^ ERROR transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - //~| HELP try - //~| SUGGESTION = &mut *m; + + + let _: &mut T = &mut *m; let _: &T = std::mem::transmute(m); - //~^ ERROR transmute from a pointer type (`*mut T`) to a reference type (`&T`) - //~| HELP try - //~| SUGGESTION = &*m; + + + let _: &T = &*m; let _: &mut T = std::mem::transmute(p as *mut T); - //~^ ERROR transmute from a pointer type (`*mut T`) to a reference type (`&mut T`) - //~| HELP try - //~| SUGGESTION = &mut *(p as *mut T); + + + let _ = &mut *(p as *mut T); let _: &T = std::mem::transmute(o); - //~^ ERROR transmute from a pointer type (`*const U`) to a reference type (`&T`) - //~| HELP try - //~| SUGGESTION = &*(o as *const T); + + + let _: &T = &*(o as *const T); let _: &mut T = std::mem::transmute(om); - //~^ ERROR transmute from a pointer type (`*mut U`) to a reference type (`&mut T`) - //~| HELP try - //~| SUGGESTION = &mut *(om as *mut T); + + + let _: &mut T = &mut *(om as *mut T); let _: &T = std::mem::transmute(om); - //~^ ERROR transmute from a pointer type (`*mut U`) to a reference type (`&T`) - //~| HELP try - //~| SUGGESTION = &*(om as *const T); + + + let _: &T = &*(om as *const T); } @@ -93,40 +93,40 @@ fn issue1231() { let raw = 0 as *const i32; let _: &Foo = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) }; - //~^ ERROR transmute from a pointer type - //~| HELP try - //~| SUGGESTION unsafe { &*(raw as *const Foo<_>) }; + + + let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) }; - //~^ ERROR transmute from a pointer type - //~| HELP try - //~| SUGGESTION unsafe { &*(raw as *const Foo<&_>) }; + + + type Bar<'a> = &'a u8; let raw = 0 as *const i32; unsafe { std::mem::transmute::<_, Bar>(raw) }; - //~^ ERROR transmute from a pointer type - //~| HELP try - //~| SUGGESTION unsafe { &*(raw as *const u8) }; + + + } #[deny(useless_transmute)] fn useless() { unsafe { let _: Vec = core::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`std::vec::Vec`) to itself + let _: Vec = core::mem::transmute(my_vec()); - //~^ ERROR transmute from a type (`std::vec::Vec`) to itself + let _: Vec = std::intrinsics::transmute(my_vec()); - //~^ ERROR transmute from a type (`std::vec::Vec`) to itself + let _: Vec = std::mem::transmute(my_vec()); - //~^ ERROR transmute from a type (`std::vec::Vec`) to itself + let _: Vec = my_transmute(my_vec()); - //~^ ERROR transmute from a type (`std::vec::Vec`) to itself + let _: Vec = core::intrinsics::transmute(my_vec()); let _: Vec = core::mem::transmute(my_vec()); @@ -135,15 +135,15 @@ fn useless() { let _: Vec = my_transmute(my_vec()); let _: *const usize = std::mem::transmute(5_isize); - //~^ ERROR transmute from an integer to a pointer - //~| HELP try - //~| SUGGESTION 5_isize as *const usize + + + let _ = 5_isize as *const usize; let _: *const usize = std::mem::transmute(1+1usize); - //~^ ERROR transmute from an integer to a pointer - //~| HELP try - //~| SUGGESTION (1+1usize) as *const usize + + + let _ = (1+1_usize) as *const usize; } } @@ -158,16 +158,16 @@ fn crosspointer() { unsafe { let _: Usize = core::intrinsics::transmute(int_const_ptr); - //~^ ERROR transmute from a type (`*const Usize`) to the type that it points to (`Usize`) + let _: Usize = core::intrinsics::transmute(int_mut_ptr); - //~^ ERROR transmute from a type (`*mut Usize`) to the type that it points to (`Usize`) + let _: *const Usize = core::intrinsics::transmute(my_int()); - //~^ ERROR transmute from a type (`Usize`) to a pointer to that type (`*const Usize`) + let _: *mut Usize = core::intrinsics::transmute(my_int()); - //~^ ERROR transmute from a type (`Usize`) to a pointer to that type (`*mut Usize`) + } } diff --git a/tests/ui/transmute_32bit.rs b/tests/ui/transmute_32bit.rs index 1368ab501..9c63a6fe0 100644 --- a/tests/ui/transmute_32bit.rs +++ b/tests/ui/transmute_32bit.rs @@ -6,15 +6,15 @@ fn main() { unsafe { let _: *const usize = std::mem::transmute(6.0f32); - //~^ ERROR transmute from a `f32` to a pointer + let _: *mut usize = std::mem::transmute(6.0f32); - //~^ ERROR transmute from a `f32` to a pointer + let _: *const usize = std::mem::transmute('x'); - //~^ ERROR transmute from a `char` to a pointer + let _: *mut usize = std::mem::transmute('x'); - //~^ ERROR transmute from a `char` to a pointer + } } diff --git a/tests/ui/transmute_64bit.rs b/tests/ui/transmute_64bit.rs index 8bc6a2367..bf7066245 100644 --- a/tests/ui/transmute_64bit.rs +++ b/tests/ui/transmute_64bit.rs @@ -7,9 +7,9 @@ fn main() { unsafe { let _: *const usize = std::mem::transmute(6.0f64); - //~^ ERROR transmute from a `f64` to a pointer + let _: *mut usize = std::mem::transmute(6.0f64); - //~^ ERROR transmute from a `f64` to a pointer + } } diff --git a/tests/ui/unicode.rs b/tests/ui/unicode.rs index e55a0390f..a12276b98 100644 --- a/tests/ui/unicode.rs +++ b/tests/ui/unicode.rs @@ -4,19 +4,19 @@ #[deny(zero_width_space)] fn zero() { print!("Here >​< is a ZWS, and ​another"); - //~^ ERROR zero-width space detected + print!("This\u{200B}is\u{200B}fine"); } #[deny(unicode_not_nfc)] fn canon() { - print!("̀àh?"); //~ERROR non-nfc unicode sequence detected + print!("̀àh?"); print!("a\u{0300}h?"); // also okay } #[deny(non_ascii_literal)] fn uni() { - print!("Üben!"); //~ERROR literal non-ASCII character detected + print!("Üben!"); print!("\u{DC}ben!"); // this is okay } diff --git a/tests/ui/unicode.stderr b/tests/ui/unicode.stderr index b8ecb7c46..407220d1a 100644 --- a/tests/ui/unicode.stderr +++ b/tests/ui/unicode.stderr @@ -11,7 +11,7 @@ error: zero-width space detected error: non-nfc unicode sequence detected --> $DIR/unicode.rs:13:12 | -13 | print!("̀àh?"); //~ERROR non-nfc unicode sequence detected +13 | print!("̀àh?"); | ^^^^^^^ | note: lint level defined here @@ -25,7 +25,7 @@ note: lint level defined here error: literal non-ASCII character detected --> $DIR/unicode.rs:19:12 | -19 | print!("Üben!"); //~ERROR literal non-ASCII character detected +19 | print!("Üben!"); | ^^^^^^^ | note: lint level defined here diff --git a/tests/ui/unit_cmp.rs b/tests/ui/unit_cmp.rs index 13095ee6b..d5176a5ea 100644 --- a/tests/ui/unit_cmp.rs +++ b/tests/ui/unit_cmp.rs @@ -13,9 +13,9 @@ fn main() { } // this warns - if { true; } == { false; } { //~ERROR ==-comparison of unit values detected. This will always be true + if { true; } == { false; } { } - if { true; } > { false; } { //~ERROR >-comparison of unit values detected. This will always be false + if { true; } > { false; } { } } diff --git a/tests/ui/unit_cmp.stderr b/tests/ui/unit_cmp.stderr index a35c04b49..fa5f108fa 100644 --- a/tests/ui/unit_cmp.stderr +++ b/tests/ui/unit_cmp.stderr @@ -1,7 +1,7 @@ error: ==-comparison of unit values detected. This will always be true --> $DIR/unit_cmp.rs:16:8 | -16 | if { true; } == { false; } { //~ERROR ==-comparison of unit values detected. This will always be true +16 | if { true; } == { false; } { | ^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -13,7 +13,7 @@ note: lint level defined here error: >-comparison of unit values detected. This will always be false --> $DIR/unit_cmp.rs:19:8 | -19 | if { true; } > { false; } { //~ERROR >-comparison of unit values detected. This will always be false +19 | if { true; } > { false; } { | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/unneeded_field_pattern.rs b/tests/ui/unneeded_field_pattern.rs index 9c7623d85..9c1661e99 100644 --- a/tests/ui/unneeded_field_pattern.rs +++ b/tests/ui/unneeded_field_pattern.rs @@ -14,10 +14,10 @@ fn main() { let f = Foo { a: 0, b: 0, c: 0 }; match f { - Foo { a: _, b: 0, .. } => {} //~ERROR You matched a field with a wildcard pattern - //~^ HELP Try with `Foo { b: 0, .. }` - Foo { a: _, b: _, c: _ } => {} //~ERROR All the struct fields are matched to a - //~^ HELP Try with `Foo { .. }` + Foo { a: _, b: 0, .. } => {} + + Foo { a: _, b: _, c: _ } => {} + } match f { Foo { b: 0, .. } => {} // should be OK diff --git a/tests/ui/unneeded_field_pattern.stderr b/tests/ui/unneeded_field_pattern.stderr index cb721a2d6..fdf976fd5 100644 --- a/tests/ui/unneeded_field_pattern.stderr +++ b/tests/ui/unneeded_field_pattern.stderr @@ -1,7 +1,7 @@ error: You matched a field with a wildcard pattern. Consider using `..` instead --> $DIR/unneeded_field_pattern.rs:17:15 | -17 | Foo { a: _, b: 0, .. } => {} //~ERROR You matched a field with a wildcard pattern +17 | Foo { a: _, b: 0, .. } => {} | ^^^^ | note: lint level defined here @@ -14,7 +14,7 @@ note: lint level defined here error: All the struct fields are matched to a wildcard pattern, consider using `..`. --> $DIR/unneeded_field_pattern.rs:19:9 | -19 | Foo { a: _, b: _, c: _ } => {} //~ERROR All the struct fields are matched to a +19 | Foo { a: _, b: _, c: _ } => {} | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: Try with `Foo { .. }` instead diff --git a/tests/ui/unsafe_removed_from_name.rs b/tests/ui/unsafe_removed_from_name.rs index 3e5f6e58c..7ff20223b 100644 --- a/tests/ui/unsafe_removed_from_name.rs +++ b/tests/ui/unsafe_removed_from_name.rs @@ -5,10 +5,10 @@ #![deny(unsafe_removed_from_name)] use std::cell::{UnsafeCell as TotallySafeCell}; -//~^ ERROR removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCell` + use std::cell::UnsafeCell as TotallySafeCellAgain; -//~^ ERROR removed "unsafe" from the name of `UnsafeCell` in use as `TotallySafeCellAgain` + // Shouldn't error use std::cell::{UnsafeCell as SuperDangerousUnsafeCell}; @@ -23,7 +23,7 @@ mod mod_with_some_unsafe_things { } use mod_with_some_unsafe_things::Unsafe as LieAboutModSafety; -//~^ ERROR removed "unsafe" from the name of `Unsafe` in use as `LieAboutModSafety` + // Shouldn't error use mod_with_some_unsafe_things::Safe as IPromiseItsSafeThisTime; diff --git a/tests/ui/unused_io_amount.rs b/tests/ui/unused_io_amount.rs index 2e63705c5..7456a3602 100644 --- a/tests/ui/unused_io_amount.rs +++ b/tests/ui/unused_io_amount.rs @@ -15,19 +15,19 @@ fn try_macro(s: &mut T) -> io::Result<()> { fn question_mark(s: &mut T) -> io::Result<()> { s.write(b"test")?; - //~^ ERROR handle written amount returned + let mut buf = [0u8; 4]; s.read(&mut buf)?; - //~^ ERROR handle read amount returned + Ok(()) } fn unwrap(s: &mut T) { s.write(b"test").unwrap(); - //~^ ERROR handle written amount returned + let mut buf = [0u8; 4]; s.read(&mut buf).unwrap(); - //~^ ERROR handle read amount returned + } fn main() { diff --git a/tests/ui/unused_labels.rs b/tests/ui/unused_labels.rs index 26b4d4a2f..ce718c490 100644 --- a/tests/ui/unused_labels.rs +++ b/tests/ui/unused_labels.rs @@ -5,7 +5,7 @@ #![deny(unused_label)] fn unused_label() { - 'label: for i in 1..2 { //~ERROR: unused label `'label` + 'label: for i in 1..2 { if i > 4 { continue } } } @@ -18,7 +18,7 @@ fn foo() { fn bla() { - 'a: loop { break } //~ERROR: unused label `'a` + 'a: loop { break } fn blub() {} } @@ -29,7 +29,7 @@ fn main() { } } - 'same_label_in_two_fns: loop { //~ERROR: unused label `'same_label_in_two_fns` + 'same_label_in_two_fns: loop { let _ = 1; } } diff --git a/tests/ui/unused_labels.stderr b/tests/ui/unused_labels.stderr index 280ea148c..7b124477d 100644 --- a/tests/ui/unused_labels.stderr +++ b/tests/ui/unused_labels.stderr @@ -1,7 +1,7 @@ error: unused label `'label` --> $DIR/unused_labels.rs:8:5 | -8 | 'label: for i in 1..2 { //~ERROR: unused label `'label` +8 | 'label: for i in 1..2 { | _____^ starting here... 9 | | if i > 4 { continue } 10 | | } @@ -16,13 +16,13 @@ note: lint level defined here error: unused label `'a` --> $DIR/unused_labels.rs:21:5 | -21 | 'a: loop { break } //~ERROR: unused label `'a` +21 | 'a: loop { break } | ^^^^^^^^^^^^^^^^^^ error: unused label `'same_label_in_two_fns` --> $DIR/unused_labels.rs:32:5 | -32 | 'same_label_in_two_fns: loop { //~ERROR: unused label `'same_label_in_two_fns` +32 | 'same_label_in_two_fns: loop { | _____^ starting here... 33 | | let _ = 1; 34 | | } diff --git a/tests/ui/unused_lt.rs b/tests/ui/unused_lt.rs index 195027209..ec44420a3 100644 --- a/tests/ui/unused_lt.rs +++ b/tests/ui/unused_lt.rs @@ -13,11 +13,11 @@ fn used_lt<'a>(x: &'a u8) { } -fn unused_lt<'a>(x: u8) { //~ ERROR this lifetime +fn unused_lt<'a>(x: u8) { } -fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { //~ ERROR this lifetime +fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { // 'a is useless here since it's not directly bound } @@ -47,7 +47,7 @@ impl<'a> Foo<'a> for u8 { struct Bar; impl Bar { - fn x<'a>(&self) {} //~ ERROR this lifetime + fn x<'a>(&self) {} } // test for #489 (used lifetimes in bounds) diff --git a/tests/ui/unused_lt.stderr b/tests/ui/unused_lt.stderr index 1df4e285f..1e13f4c80 100644 --- a/tests/ui/unused_lt.stderr +++ b/tests/ui/unused_lt.stderr @@ -1,7 +1,7 @@ error: this lifetime isn't used in the function definition --> $DIR/unused_lt.rs:16:14 | -16 | fn unused_lt<'a>(x: u8) { //~ ERROR this lifetime +16 | fn unused_lt<'a>(x: u8) { | ^^ | note: lint level defined here @@ -13,13 +13,13 @@ note: lint level defined here error: this lifetime isn't used in the function definition --> $DIR/unused_lt.rs:20:25 | -20 | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { //~ ERROR this lifetime +20 | fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) { | ^^ error: this lifetime isn't used in the function definition --> $DIR/unused_lt.rs:50:10 | -50 | fn x<'a>(&self) {} //~ ERROR this lifetime +50 | fn x<'a>(&self) {} | ^^ error: aborting due to 3 previous errors diff --git a/tests/ui/used_underscore_binding.rs b/tests/ui/used_underscore_binding.rs index c3700d1b1..fe0db6346 100644 --- a/tests/ui/used_underscore_binding.rs +++ b/tests/ui/used_underscore_binding.rs @@ -14,16 +14,16 @@ macro_rules! test_macro { /// Test that we lint if we use a binding with a single leading underscore fn prefix_underscore(_foo: u32) -> u32 { - _foo + 1 //~ ERROR used binding `_foo` which is prefixed with an underscore + _foo + 1 } /// Test that we lint if we use a `_`-variable defined outside within a macro expansion fn in_macro(_foo: u32) { println!("{}", _foo); - //~^ ERROR used binding `_foo` which is prefixed with an underscore + assert_eq!(_foo, _foo); - //~^ ERROR used binding `_foo` which is prefixed with an underscore - //~| ERROR used binding `_foo` which is prefixed with an underscore + + test_macro!() + 1; } @@ -36,7 +36,7 @@ struct StructFieldTest { /// Test that we lint the use of a struct field which is prefixed with an underscore fn in_struct_field() { let mut s = StructFieldTest { _underscore_field: 0 }; - s._underscore_field += 1; //~ Error used binding `_underscore_field` which is prefixed with an underscore + s._underscore_field += 1; } /// Test that we do not lint if the underscore is not a prefix diff --git a/tests/ui/used_underscore_binding.stderr b/tests/ui/used_underscore_binding.stderr index 5377698a6..35179ac37 100644 --- a/tests/ui/used_underscore_binding.stderr +++ b/tests/ui/used_underscore_binding.stderr @@ -1,7 +1,7 @@ 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:17:5 | -17 | _foo + 1 //~ ERROR used binding `_foo` which is prefixed with an underscore +17 | _foo + 1 | ^^^^ | note: lint level defined here @@ -31,7 +31,7 @@ error: used binding `_foo` which is prefixed with an underscore. A leading under 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:39:5 | -39 | s._underscore_field += 1; //~ Error used binding `_underscore_field` which is prefixed with an underscore +39 | s._underscore_field += 1; | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index de3896f09..2b8a4cf56 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -2,9 +2,9 @@ #![plugin(clippy)] #![deny(useless_attribute)] -#[allow(dead_code)] //~ ERROR useless lint attribute -//~| HELP if you just forgot a `!`, use -//~| SUGGESTION #![allow(dead_code)] +#[allow(dead_code)] + + extern crate clippy_lints; // don't lint on unused_import for `use` items diff --git a/tests/ui/useless_attribute.stderr b/tests/ui/useless_attribute.stderr index a0a7936dc..05d3da4ca 100644 --- a/tests/ui/useless_attribute.stderr +++ b/tests/ui/useless_attribute.stderr @@ -1,7 +1,7 @@ error: useless lint attribute --> $DIR/useless_attribute.rs:5:1 | -5 | #[allow(dead_code)] //~ ERROR useless lint attribute +5 | #[allow(dead_code)] | ^^^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -10,7 +10,7 @@ note: lint level defined here 3 | #![deny(useless_attribute)] | ^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use - | #![allow(dead_code)] //~ ERROR useless lint attribute + | #![allow(dead_code)] error: aborting due to previous error diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index 7a790e621..3717192fb 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -22,33 +22,33 @@ impl Line { fn main() { on_slice(&vec![]); - //~^ ERROR useless use of `vec!` - //~| HELP you can use - //~| SUGGESTION on_slice(&[]) + + + on_slice(&[]); on_slice(&vec![1, 2]); - //~^ ERROR useless use of `vec!` - //~| HELP you can use - //~| SUGGESTION on_slice(&[1, 2]) + + + on_slice(&[1, 2]); on_slice(&vec ![1, 2]); - //~^ ERROR useless use of `vec!` - //~| HELP you can use - //~| SUGGESTION on_slice(&[1, 2]) + + + on_slice(&[1, 2]); on_slice(&vec!(1, 2)); - //~^ ERROR useless use of `vec!` - //~| HELP you can use - //~| SUGGESTION on_slice(&[1, 2]) + + + on_slice(&[1, 2]); on_slice(&vec![1; 2]); - //~^ ERROR useless use of `vec!` - //~| HELP you can use - //~| SUGGESTION on_slice(&[1; 2]) + + + on_slice(&[1; 2]); on_vec(&vec![]); @@ -62,9 +62,9 @@ fn main() { on_slice(&vec![2; line.length()]); for a in vec![1, 2, 3] { - //~^ ERROR useless use of `vec!` - //~| HELP you can use - //~| SUGGESTION for a in &[1, 2, 3] { + + + println!("{:?}", a); } diff --git a/tests/ui/while_loop.rs b/tests/ui/while_loop.rs index 7b0fb4357..2b75e5b83 100644 --- a/tests/ui/while_loop.rs +++ b/tests/ui/while_loop.rs @@ -7,9 +7,9 @@ fn main() { let y = Some(true); loop { - //~^ERROR this loop could be written as a `while let` loop - //~|HELP try - //~|SUGGESTION while let Some(_x) = y { + + + if let Some(_x) = y { let _v = 1; } else { @@ -23,18 +23,18 @@ fn main() { break; } loop { - //~^ERROR this loop could be written as a `while let` loop - //~|HELP try - //~|SUGGESTION while let Some(_x) = y { + + + match y { Some(_x) => true, None => break }; } loop { - //~^ERROR this loop could be written as a `while let` loop - //~|HELP try - //~|SUGGESTION while let Some(x) = y { + + + let x = match y { Some(x) => x, None => break @@ -43,9 +43,9 @@ fn main() { let _str = "foo"; } loop { - //~^ERROR this loop could be written as a `while let` loop - //~|HELP try - //~|SUGGESTION while let Some(x) = y { + + + let x = match y { Some(x) => x, None => break, @@ -68,9 +68,9 @@ fn main() { // #675, this used to have a wrong suggestion loop { - //~^ERROR this loop could be written as a `while let` loop - //~|HELP try - //~|SUGGESTION while let Some(word) = "".split_whitespace().next() { .. } + + + let (e, l) = match "".split_whitespace().next() { Some(word) => (word.is_empty(), word.len()), None => break @@ -81,25 +81,25 @@ fn main() { let mut iter = 1..20; while let Option::Some(x) = iter.next() { - //~^ ERROR this loop could be written as a `for` loop - //~| HELP try - //~| SUGGESTION for x in iter { + + + println!("{}", x); } let mut iter = 1..20; while let Some(x) = iter.next() { - //~^ ERROR this loop could be written as a `for` loop - //~| HELP try - //~| SUGGESTION for x in iter { + + + println!("{}", x); } let mut iter = 1..20; while let Some(_) = iter.next() {} - //~^ ERROR this loop could be written as a `for` loop - //~| HELP try - //~| SUGGESTION for _ in iter { + + + let mut iter = 1..20; while let None = iter.next() {} // this is fine (if nonsensical) @@ -140,14 +140,14 @@ fn main() { fn no_panic(slice: &[T]) { let mut iter = slice.iter(); loop { - //~^ ERROR - //~| HELP try - //~| SUGGESTION while let Some(ele) = iter.next() { .. } + + + let _ = match iter.next() { Some(ele) => ele, None => break }; - loop {} //~ERROR empty `loop {}` detected. + loop {} } } diff --git a/tests/ui/while_loop.stderr b/tests/ui/while_loop.stderr index 46f026087..a3bb0c34f 100644 --- a/tests/ui/while_loop.stderr +++ b/tests/ui/while_loop.stderr @@ -17,9 +17,9 @@ error: this loop could be written as a `while let` loop | 25 | loop { | _____^ starting here... -26 | | //~^ERROR this loop could be written as a `while let` loop -27 | | //~|HELP try -28 | | //~|SUGGESTION while let Some(_x) = y { +26 | | +27 | | +28 | | 29 | | match y { 30 | | Some(_x) => true, 31 | | None => break @@ -62,9 +62,9 @@ error: this loop could be written as a `for` loop | 83 | while let Option::Some(x) = iter.next() { | _____^ starting here... -84 | | //~^ ERROR this loop could be written as a `for` loop -85 | | //~| HELP try -86 | | //~| SUGGESTION for x in iter { +84 | | +85 | | +86 | | 87 | | println!("{}", x); 88 | | } | |_____^ ...ending here @@ -82,9 +82,9 @@ error: this loop could be written as a `for` loop | 91 | while let Some(x) = iter.next() { | _____^ starting here... -92 | | //~^ ERROR this loop could be written as a `for` loop -93 | | //~| HELP try -94 | | //~| SUGGESTION for x in iter { +92 | | +93 | | +94 | | 95 | | println!("{}", x); 96 | | } | |_____^ ...ending here @@ -113,7 +113,7 @@ help: try error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body. --> $DIR/while_loop.rs:150:9 | -150 | loop {} //~ERROR empty `loop {}` detected. +150 | loop {} | ^^^^^^^ | note: lint level defined here diff --git a/tests/ui/wrong_macro_span.rs_ b/tests/ui/wrong_macro_span.rs_ index f22efd810..fcacb030b 100644 --- a/tests/ui/wrong_macro_span.rs_ +++ b/tests/ui/wrong_macro_span.rs_ @@ -19,9 +19,9 @@ fn main() { let t = &thingy; match t.$idx { Foo::A(ref val) => { println!("42"); }, _ => {} } - //~^ ERROR you seem to be trying to use match - //~| HELP try this - //~| SUGGESTION if let Foo::A(ref val) = t.$idx { println!("42"); } + + + }} } diff --git a/tests/ui/wrong_self_convention.rs b/tests/ui/wrong_self_convention.rs index d22648c0c..8e81679aa 100644 --- a/tests/ui/wrong_self_convention.rs +++ b/tests/ui/wrong_self_convention.rs @@ -18,13 +18,13 @@ impl Foo { fn is_i32(self) {} fn is_u32(&self) {} fn to_i32(self) {} - fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self + fn from_i32(self) {} pub fn as_i64(self) {} pub fn into_i64(self) {} pub fn is_i64(self) {} pub fn to_i64(self) {} - pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self + pub fn from_i64(self) {} // check whether the lint can be allowed at the function level #[allow(wrong_self_convention)] pub fn from_cake(self) {} @@ -35,21 +35,21 @@ struct Bar; impl Bar { - fn as_i32(self) {} //~ERROR: methods called `as_*` usually take self by reference + fn as_i32(self) {} fn as_u32(&self) {} - fn into_i32(&self) {} //~ERROR: methods called `into_*` usually take self by value + fn into_i32(&self) {} fn into_u32(self) {} - fn is_i32(self) {} //~ERROR: methods called `is_*` usually take self by reference + fn is_i32(self) {} fn is_u32(&self) {} - fn to_i32(self) {} //~ERROR: methods called `to_*` usually take self by reference + fn to_i32(self) {} fn to_u32(&self) {} - fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self + fn from_i32(self) {} - pub fn as_i64(self) {} //~ERROR: methods called `as_*` usually take self by reference - pub fn into_i64(&self) {} //~ERROR: methods called `into_*` usually take self by value - pub fn is_i64(self) {} //~ERROR: methods called `is_*` usually take self by reference - pub fn to_i64(self) {} //~ERROR: methods called `to_*` usually take self by reference - pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self + pub fn as_i64(self) {} + pub fn into_i64(&self) {} + pub fn is_i64(self) {} + pub fn to_i64(self) {} + pub fn from_i64(self) {} // test for false positives fn as_(self) {} diff --git a/tests/ui/wrong_self_convention.stderr b/tests/ui/wrong_self_convention.stderr index 06781411b..cbee5bd45 100644 --- a/tests/ui/wrong_self_convention.stderr +++ b/tests/ui/wrong_self_convention.stderr @@ -1,7 +1,7 @@ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:21:17 | -21 | fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self +21 | fn from_i32(self) {} | ^^^^ | note: lint level defined here @@ -13,67 +13,67 @@ note: lint level defined here error: methods called `from_*` usually take no self; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:27:21 | -27 | pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self +27 | 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:38:15 | -38 | fn as_i32(self) {} //~ERROR: methods called `as_*` usually take self by reference +38 | fn as_i32(self) {} | ^^^^ error: methods called `into_*` usually take self by value; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:40:17 | -40 | fn into_i32(&self) {} //~ERROR: methods called `into_*` usually take self by value +40 | 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:42:15 | -42 | fn is_i32(self) {} //~ERROR: methods called `is_*` usually take self by reference +42 | fn is_i32(self) {} | ^^^^ error: methods called `to_*` usually take self by reference; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:44:15 | -44 | fn to_i32(self) {} //~ERROR: methods called `to_*` usually take self by reference +44 | fn to_i32(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:46:17 | -46 | fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self +46 | 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:48:19 | -48 | pub fn as_i64(self) {} //~ERROR: methods called `as_*` usually take self by reference +48 | 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:49:21 | -49 | pub fn into_i64(&self) {} //~ERROR: methods called `into_*` usually take self by value +49 | 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:50:19 | -50 | pub fn is_i64(self) {} //~ERROR: methods called `is_*` usually take self by reference +50 | 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:51:19 | -51 | pub fn to_i64(self) {} //~ERROR: methods called `to_*` usually take self by reference +51 | pub fn to_i64(self) {} | ^^^^ error: methods called `from_*` usually take no self; consider choosing a less ambiguous name --> $DIR/wrong_self_convention.rs:52:21 | -52 | pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self +52 | pub fn from_i64(self) {} | ^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/zero_div_zero.rs b/tests/ui/zero_div_zero.rs index c422e8387..6f1263372 100644 --- a/tests/ui/zero_div_zero.rs +++ b/tests/ui/zero_div_zero.rs @@ -4,14 +4,14 @@ #[allow(unused_variables)] #[deny(zero_divided_by_zero)] fn main() { - let nan = 0.0 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN - //~^ equal expressions as operands to `/` - let f64_nan = 0.0 / 0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN - //~^ equal expressions as operands to `/` - let other_f64_nan = 0.0f64 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN - //~^ equal expressions as operands to `/` - let one_more_f64_nan = 0.0f64/0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN - //~^ equal expressions as operands to `/` + 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 zero = 0.0; let other_zero = 0.0; let other_nan = zero / other_zero; // fine - this lint doesn't propegate constants. diff --git a/tests/ui/zero_div_zero.stderr b/tests/ui/zero_div_zero.stderr index a28d47257..6b34e2da1 100644 --- a/tests/ui/zero_div_zero.stderr +++ b/tests/ui/zero_div_zero.stderr @@ -1,7 +1,7 @@ warning: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:7:15 | -7 | let nan = 0.0 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +7 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | = note: #[warn(eq_op)] on by default @@ -9,7 +9,7 @@ warning: equal expressions as operands to `/` error: constant division of 0.0 with 0.0 will always result in NaN --> $DIR/zero_div_zero.rs:7:15 | -7 | let nan = 0.0 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +7 | let nan = 0.0 / 0.0; | ^^^^^^^^^ | note: lint level defined here @@ -22,7 +22,7 @@ note: lint level defined here warning: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:9:19 | -9 | let f64_nan = 0.0 / 0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +9 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ | = note: #[warn(eq_op)] on by default @@ -30,7 +30,7 @@ warning: equal expressions as operands to `/` error: constant division of 0.0 with 0.0 will always result in NaN --> $DIR/zero_div_zero.rs:9:19 | -9 | let f64_nan = 0.0 / 0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +9 | let f64_nan = 0.0 / 0.0f64; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN @@ -38,7 +38,7 @@ error: constant division of 0.0 with 0.0 will always result in NaN warning: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:11:25 | -11 | let other_f64_nan = 0.0f64 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +11 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ | = note: #[warn(eq_op)] on by default @@ -46,7 +46,7 @@ warning: equal expressions as operands to `/` error: constant division of 0.0 with 0.0 will always result in NaN --> $DIR/zero_div_zero.rs:11:25 | -11 | let other_f64_nan = 0.0f64 / 0.0; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +11 | let other_f64_nan = 0.0f64 / 0.0; | ^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN @@ -54,7 +54,7 @@ error: constant division of 0.0 with 0.0 will always result in NaN warning: equal expressions as operands to `/` --> $DIR/zero_div_zero.rs:13:28 | -13 | let one_more_f64_nan = 0.0f64/0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +13 | let one_more_f64_nan = 0.0f64/0.0f64; | ^^^^^^^^^^^^^ | = note: #[warn(eq_op)] on by default @@ -62,7 +62,7 @@ warning: equal expressions as operands to `/` error: constant division of 0.0 with 0.0 will always result in NaN --> $DIR/zero_div_zero.rs:13:28 | -13 | let one_more_f64_nan = 0.0f64/0.0f64; //~ERROR constant division of 0.0 with 0.0 will always result in NaN +13 | let one_more_f64_nan = 0.0f64/0.0f64; | ^^^^^^^^^^^^^ | = help: Consider using `std::f64::NAN` if you would like a constant representing NaN