mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
Add a reason to/remove some //@no-rustfix annotations (#14839)
changelog: none
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
use core::num::Wrapping;
|
||||
#![allow(clippy::useless_vec)]
|
||||
#![warn(clippy::assign_op_pattern)]
|
||||
|
||||
use core::num::Wrapping;
|
||||
use std::ops::{Mul, MulAssign};
|
||||
|
||||
#[allow(dead_code, unused_assignments, clippy::useless_vec)]
|
||||
#[warn(clippy::assign_op_pattern)]
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
a += 1;
|
||||
@@ -39,3 +41,35 @@ fn main() {
|
||||
v[0] = v[0] + v[1];
|
||||
let _ = || v[0] = v[0] + v[1];
|
||||
}
|
||||
|
||||
fn cow_add_assign() {
|
||||
use std::borrow::Cow;
|
||||
let mut buf = Cow::Owned(String::from("bar"));
|
||||
let cows = Cow::Borrowed("foo");
|
||||
|
||||
// this can be linted
|
||||
buf += cows.clone();
|
||||
//~^ assign_op_pattern
|
||||
|
||||
// this should not as cow<str> Add is not commutative
|
||||
buf = cows + buf;
|
||||
}
|
||||
|
||||
// check that we don't lint on op assign impls, because that's just the way to impl them
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Wrap(i64);
|
||||
|
||||
impl Mul<i64> for Wrap {
|
||||
type Output = Self;
|
||||
|
||||
fn mul(self, rhs: i64) -> Self {
|
||||
Wrap(self.0 * rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl MulAssign<i64> for Wrap {
|
||||
fn mul_assign(&mut self, rhs: i64) {
|
||||
*self = *self * rhs
|
||||
}
|
||||
}
|
||||
|
||||
+37
-3
@@ -1,7 +1,9 @@
|
||||
use core::num::Wrapping;
|
||||
#![allow(clippy::useless_vec)]
|
||||
#![warn(clippy::assign_op_pattern)]
|
||||
|
||||
use core::num::Wrapping;
|
||||
use std::ops::{Mul, MulAssign};
|
||||
|
||||
#[allow(dead_code, unused_assignments, clippy::useless_vec)]
|
||||
#[warn(clippy::assign_op_pattern)]
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
a = a + 1;
|
||||
@@ -39,3 +41,35 @@ fn main() {
|
||||
v[0] = v[0] + v[1];
|
||||
let _ = || v[0] = v[0] + v[1];
|
||||
}
|
||||
|
||||
fn cow_add_assign() {
|
||||
use std::borrow::Cow;
|
||||
let mut buf = Cow::Owned(String::from("bar"));
|
||||
let cows = Cow::Borrowed("foo");
|
||||
|
||||
// this can be linted
|
||||
buf = buf + cows.clone();
|
||||
//~^ assign_op_pattern
|
||||
|
||||
// this should not as cow<str> Add is not commutative
|
||||
buf = cows + buf;
|
||||
}
|
||||
|
||||
// check that we don't lint on op assign impls, because that's just the way to impl them
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Wrap(i64);
|
||||
|
||||
impl Mul<i64> for Wrap {
|
||||
type Output = Self;
|
||||
|
||||
fn mul(self, rhs: i64) -> Self {
|
||||
Wrap(self.0 * rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl MulAssign<i64> for Wrap {
|
||||
fn mul_assign(&mut self, rhs: i64) {
|
||||
*self = *self * rhs
|
||||
}
|
||||
}
|
||||
|
||||
+18
-12
@@ -1,5 +1,5 @@
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:7:5
|
||||
--> tests/ui/assign_ops.rs:9:5
|
||||
|
|
||||
LL | a = a + 1;
|
||||
| ^^^^^^^^^ help: replace it with: `a += 1`
|
||||
@@ -8,64 +8,70 @@ LL | a = a + 1;
|
||||
= help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:9:5
|
||||
--> tests/ui/assign_ops.rs:11:5
|
||||
|
|
||||
LL | a = 1 + a;
|
||||
| ^^^^^^^^^ help: replace it with: `a += 1`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:11:5
|
||||
--> tests/ui/assign_ops.rs:13:5
|
||||
|
|
||||
LL | a = a - 1;
|
||||
| ^^^^^^^^^ help: replace it with: `a -= 1`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:13:5
|
||||
--> tests/ui/assign_ops.rs:15:5
|
||||
|
|
||||
LL | a = a * 99;
|
||||
| ^^^^^^^^^^ help: replace it with: `a *= 99`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:15:5
|
||||
--> tests/ui/assign_ops.rs:17:5
|
||||
|
|
||||
LL | a = 42 * a;
|
||||
| ^^^^^^^^^^ help: replace it with: `a *= 42`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:17:5
|
||||
--> tests/ui/assign_ops.rs:19:5
|
||||
|
|
||||
LL | a = a / 2;
|
||||
| ^^^^^^^^^ help: replace it with: `a /= 2`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:19:5
|
||||
--> tests/ui/assign_ops.rs:21:5
|
||||
|
|
||||
LL | a = a % 5;
|
||||
| ^^^^^^^^^ help: replace it with: `a %= 5`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:21:5
|
||||
--> tests/ui/assign_ops.rs:23:5
|
||||
|
|
||||
LL | a = a & 1;
|
||||
| ^^^^^^^^^ help: replace it with: `a &= 1`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:28:5
|
||||
--> tests/ui/assign_ops.rs:30:5
|
||||
|
|
||||
LL | s = s + "bla";
|
||||
| ^^^^^^^^^^^^^ help: replace it with: `s += "bla"`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:33:5
|
||||
--> tests/ui/assign_ops.rs:35:5
|
||||
|
|
||||
LL | a = a + Wrapping(1u32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a += Wrapping(1u32)`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:36:5
|
||||
--> tests/ui/assign_ops.rs:38:5
|
||||
|
|
||||
LL | v[0] = v[0] + v[1];
|
||||
| ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:51:5
|
||||
|
|
||||
LL | buf = buf + cows.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
//@no-rustfix: overlapping suggestions
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
|
||||
#[allow(unused_assignments)]
|
||||
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
a += a + 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a += 1 + a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a -= a - 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= a * 99;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= 42 * a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a /= a / 2;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a %= a % 5;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a &= a & 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= a * a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * a * a;
|
||||
a = a * 42 * a;
|
||||
a = a * 2 + a;
|
||||
a -= 1 - a;
|
||||
a /= 5 / a;
|
||||
a %= 42 % a;
|
||||
a <<= 6 << a;
|
||||
}
|
||||
|
||||
// check that we don't lint on op assign impls, because that's just the way to impl them
|
||||
|
||||
use std::ops::{Mul, MulAssign};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Wrap(i64);
|
||||
|
||||
impl Mul<i64> for Wrap {
|
||||
type Output = Self;
|
||||
|
||||
fn mul(self, rhs: i64) -> Self {
|
||||
Wrap(self.0 * rhs)
|
||||
}
|
||||
}
|
||||
|
||||
impl MulAssign<i64> for Wrap {
|
||||
fn mul_assign(&mut self, rhs: i64) {
|
||||
*self = *self * rhs
|
||||
}
|
||||
}
|
||||
|
||||
fn cow_add_assign() {
|
||||
use std::borrow::Cow;
|
||||
let mut buf = Cow::Owned(String::from("bar"));
|
||||
let cows = Cow::Borrowed("foo");
|
||||
|
||||
// this can be linted
|
||||
buf = buf + cows.clone();
|
||||
//~^ assign_op_pattern
|
||||
|
||||
// this should not as cow<str> Add is not commutative
|
||||
buf = cows + buf;
|
||||
println!("{}", buf);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//@no-rustfix
|
||||
//@no-rustfix: only some diagnostics have suggestions
|
||||
|
||||
#![feature(repr128)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@revisions: 32bit 64bit
|
||||
//@[32bit]ignore-bitwidth: 64
|
||||
//@[64bit]ignore-bitwidth: 32
|
||||
//@no-rustfix
|
||||
//@no-rustfix: only some diagnostics have suggestions
|
||||
|
||||
#![warn(
|
||||
clippy::cast_precision_loss,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
clippy::branches_sharing_code,
|
||||
clippy::unnecessary_literal_unwrap
|
||||
)]
|
||||
//@no-rustfix
|
||||
//@no-rustfix: has placeholders
|
||||
fn test_nested() {
|
||||
fn nested() {
|
||||
let x = Some(());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//@no-rustfix: overlapping suggestions
|
||||
//@no-rustfix: has placeholders
|
||||
#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
||||
#![allow(
|
||||
clippy::if_same_then_else,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//@no-rustfix
|
||||
//@no-rustfix: has placeholders
|
||||
#![allow(dead_code)]
|
||||
#![warn(clippy::comparison_chain)]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//@no-rustfix
|
||||
//@no-rustfix: overlapping suggestions
|
||||
//@error-in-other-file:
|
||||
#![warn(clippy::dbg_macro)]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//@no-rustfix
|
||||
//@no-rustfix: requires manual changes
|
||||
#![warn(clippy::double_ended_iterator_last)]
|
||||
|
||||
// Should not be linted because applying the lint would move the original iterator. This can only be
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
|
||||
#![allow(clippy::needless_pass_by_value, clippy::collapsible_if)]
|
||||
#![warn(clippy::map_entry)]
|
||||
//@no-rustfix
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
--> tests/ui/entry_unfixable.rs:28:13
|
||||
--> tests/ui/entry_unfixable.rs:27:13
|
||||
|
|
||||
LL | / if !self.values.contains_key(&name) {
|
||||
LL | |
|
||||
@@ -14,7 +14,7 @@ LL | | }
|
||||
= help: to override `-D warnings` add `#[allow(clippy::map_entry)]`
|
||||
|
||||
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
--> tests/ui/entry_unfixable.rs:43:5
|
||||
--> tests/ui/entry_unfixable.rs:42:5
|
||||
|
|
||||
LL | / if hm.contains_key(&key) {
|
||||
LL | |
|
||||
@@ -26,7 +26,7 @@ LL | | }
|
||||
| |_____^
|
||||
|
||||
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
--> tests/ui/entry_unfixable.rs:81:13
|
||||
--> tests/ui/entry_unfixable.rs:80:13
|
||||
|
|
||||
LL | / if self.globals.contains_key(&name) {
|
||||
LL | |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![warn(clippy::explicit_counter_loop)]
|
||||
#![allow(clippy::uninlined_format_args, clippy::useless_vec)]
|
||||
//@no-rustfix
|
||||
//@no-rustfix: suggestion does not remove the `+= 1`
|
||||
fn main() {
|
||||
let mut vec = vec![1, 2, 3, 4];
|
||||
let mut _index = 0;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#![allow(clippy::question_mark, unused)]
|
||||
#![allow(clippy::question_mark)]
|
||||
#![warn(clippy::filter_map_bool_then)]
|
||||
//@no-rustfix
|
||||
|
||||
fn issue11617() {
|
||||
let mut x: Vec<usize> = vec![0; 10];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: usage of `bool::then` in `filter_map`
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:7:48
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:6:48
|
||||
|
|
||||
LL | let _ = (0..x.len()).zip(x.clone().iter()).filter_map(|(i, v)| {
|
||||
| ________________________________________________^
|
||||
@@ -16,7 +16,7 @@ LL | | });
|
||||
= help: to override `-D warnings` add `#[allow(clippy::filter_map_bool_then)]`
|
||||
|
||||
error: usage of `bool::then` in `filter_map`
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:23:26
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:22:26
|
||||
|
|
||||
LL | let _ = x.iter().filter_map(|&x| x?.then(|| do_something(())));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -24,7 +24,7 @@ LL | let _ = x.iter().filter_map(|&x| x?.then(|| do_something(())));
|
||||
= help: consider using `filter` then `map` instead
|
||||
|
||||
error: usage of `bool::then` in `filter_map`
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:27:14
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:26:14
|
||||
|
|
||||
LL | .filter_map(|&x| if let Some(x) = x { x } else { return None }.then(|| do_something(())));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -32,7 +32,7 @@ LL | .filter_map(|&x| if let Some(x) = x { x } else { return None }.
|
||||
= help: consider using `filter` then `map` instead
|
||||
|
||||
error: usage of `bool::then` in `filter_map`
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:29:26
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:28:26
|
||||
|
|
||||
LL | let _ = x.iter().filter_map(|&x| {
|
||||
| __________________________^
|
||||
@@ -47,7 +47,7 @@ LL | | });
|
||||
= help: consider using `filter` then `map` instead
|
||||
|
||||
error: usage of `bool::then` in `filter_map`
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:47:26
|
||||
--> tests/ui/filter_map_bool_then_unfixable.rs:46:26
|
||||
|
|
||||
LL | let _ = x.iter().filter_map(|&x| {
|
||||
| __________________________^
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(unused)]
|
||||
#![warn(clippy::impl_trait_in_params)]
|
||||
|
||||
//@no-rustfix
|
||||
//@no-rustfix: has placeholders
|
||||
pub trait Trait {}
|
||||
pub trait AnotherTrait<T> {}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//@no-rustfix
|
||||
|
||||
fn fn_val(i: i32) -> i32 {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:22:11
|
||||
--> tests/ui/infinite_loop.rs:20:11
|
||||
|
|
||||
LL | while y < 10 {
|
||||
| ^^^^^^
|
||||
@@ -8,7 +8,7 @@ LL | while y < 10 {
|
||||
= note: `#[deny(clippy::while_immutable_condition)]` on by default
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:29:11
|
||||
--> tests/ui/infinite_loop.rs:27:11
|
||||
|
|
||||
LL | while y < 10 && x < 3 {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
@@ -16,7 +16,7 @@ LL | while y < 10 && x < 3 {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:38:11
|
||||
--> tests/ui/infinite_loop.rs:36:11
|
||||
|
|
||||
LL | while !cond {
|
||||
| ^^^^^
|
||||
@@ -24,7 +24,7 @@ LL | while !cond {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:84:11
|
||||
--> tests/ui/infinite_loop.rs:82:11
|
||||
|
|
||||
LL | while i < 3 {
|
||||
| ^^^^^
|
||||
@@ -32,7 +32,7 @@ LL | while i < 3 {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:91:11
|
||||
--> tests/ui/infinite_loop.rs:89:11
|
||||
|
|
||||
LL | while i < 3 && j > 0 {
|
||||
| ^^^^^^^^^^^^^^
|
||||
@@ -40,7 +40,7 @@ LL | while i < 3 && j > 0 {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:97:11
|
||||
--> tests/ui/infinite_loop.rs:95:11
|
||||
|
|
||||
LL | while i < 3 {
|
||||
| ^^^^^
|
||||
@@ -48,7 +48,7 @@ LL | while i < 3 {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:114:11
|
||||
--> tests/ui/infinite_loop.rs:112:11
|
||||
|
|
||||
LL | while i < 3 {
|
||||
| ^^^^^
|
||||
@@ -56,7 +56,7 @@ LL | while i < 3 {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:121:11
|
||||
--> tests/ui/infinite_loop.rs:119:11
|
||||
|
|
||||
LL | while i < 3 {
|
||||
| ^^^^^
|
||||
@@ -64,7 +64,7 @@ LL | while i < 3 {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:189:15
|
||||
--> tests/ui/infinite_loop.rs:187:15
|
||||
|
|
||||
LL | while self.count < n {
|
||||
| ^^^^^^^^^^^^^^
|
||||
@@ -72,7 +72,7 @@ LL | while self.count < n {
|
||||
= note: this may lead to an infinite or to a never running loop
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:199:11
|
||||
--> tests/ui/infinite_loop.rs:197:11
|
||||
|
|
||||
LL | while y < 10 {
|
||||
| ^^^^^^
|
||||
@@ -82,7 +82,7 @@ LL | while y < 10 {
|
||||
= help: rewrite it as `if cond { loop { } }`
|
||||
|
||||
error: variables in the condition are not mutated in the loop body
|
||||
--> tests/ui/infinite_loop.rs:208:11
|
||||
--> tests/ui/infinite_loop.rs:206:11
|
||||
|
|
||||
LL | while y < 10 {
|
||||
| ^^^^^^
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//@no-rustfix
|
||||
//@no-rustfix: multiple suggestions add `-> !` to the same fn
|
||||
//@aux-build:proc_macros.rs
|
||||
|
||||
#![allow(clippy::never_loop)]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//@no-rustfix
|
||||
//@no-rustfix: suggestions reference out of scope lifetimes/types
|
||||
//@aux-build:proc_macros.rs
|
||||
#![warn(clippy::into_iter_without_iter)]
|
||||
extern crate proc_macros;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//@no-rustfix
|
||||
|
||||
#![deny(clippy::iter_out_of_bounds)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:12:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:10:14
|
||||
|
|
||||
LL | for _ in [1, 2, 3].iter().skip(4) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
note: the lint level is defined here
|
||||
--> tests/ui/iter_out_of_bounds.rs:3:9
|
||||
--> tests/ui/iter_out_of_bounds.rs:1:9
|
||||
|
|
||||
LL | #![deny(clippy::iter_out_of_bounds)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this `.take()` call takes more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:17:19
|
||||
--> tests/ui/iter_out_of_bounds.rs:15:19
|
||||
|
|
||||
LL | for (i, _) in [1, 2, 3].iter().take(4).enumerate() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -20,7 +20,7 @@ LL | for (i, _) in [1, 2, 3].iter().take(4).enumerate() {
|
||||
= note: this operation is useless and the returned iterator will simply yield the same items
|
||||
|
||||
error: this `.take()` call takes more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:24:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:22:14
|
||||
|
|
||||
LL | for _ in (&&&&&&[1, 2, 3]).iter().take(4) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -28,7 +28,7 @@ LL | for _ in (&&&&&&[1, 2, 3]).iter().take(4) {}
|
||||
= note: this operation is useless and the returned iterator will simply yield the same items
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:27:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:25:14
|
||||
|
|
||||
LL | for _ in [1, 2, 3].iter().skip(4) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -36,7 +36,7 @@ LL | for _ in [1, 2, 3].iter().skip(4) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:30:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:28:14
|
||||
|
|
||||
LL | for _ in [1; 3].iter().skip(4) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -44,7 +44,7 @@ LL | for _ in [1; 3].iter().skip(4) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:36:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:34:14
|
||||
|
|
||||
LL | for _ in vec![1, 2, 3].iter().skip(4) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -52,7 +52,7 @@ LL | for _ in vec![1, 2, 3].iter().skip(4) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:39:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:37:14
|
||||
|
|
||||
LL | for _ in vec![1; 3].iter().skip(4) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -60,7 +60,7 @@ LL | for _ in vec![1; 3].iter().skip(4) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:43:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:41:14
|
||||
|
|
||||
LL | for _ in x.iter().skip(4) {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
@@ -68,7 +68,7 @@ LL | for _ in x.iter().skip(4) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:47:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:45:14
|
||||
|
|
||||
LL | for _ in x.iter().skip(n) {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
@@ -76,7 +76,7 @@ LL | for _ in x.iter().skip(n) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:52:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:50:14
|
||||
|
|
||||
LL | for _ in empty().skip(1) {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
@@ -84,7 +84,7 @@ LL | for _ in empty().skip(1) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.take()` call takes more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:55:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:53:14
|
||||
|
|
||||
LL | for _ in empty().take(1) {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
@@ -92,7 +92,7 @@ LL | for _ in empty().take(1) {}
|
||||
= note: this operation is useless and the returned iterator will simply yield the same items
|
||||
|
||||
error: this `.skip()` call skips more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:58:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:56:14
|
||||
|
|
||||
LL | for _ in std::iter::once(1).skip(2) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -100,7 +100,7 @@ LL | for _ in std::iter::once(1).skip(2) {}
|
||||
= note: this operation is useless and will create an empty iterator
|
||||
|
||||
error: this `.take()` call takes more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:61:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:59:14
|
||||
|
|
||||
LL | for _ in std::iter::once(1).take(2) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -108,7 +108,7 @@ LL | for _ in std::iter::once(1).take(2) {}
|
||||
= note: this operation is useless and the returned iterator will simply yield the same items
|
||||
|
||||
error: this `.take()` call takes more items than the iterator will produce
|
||||
--> tests/ui/iter_out_of_bounds.rs:64:14
|
||||
--> tests/ui/iter_out_of_bounds.rs:62:14
|
||||
|
|
||||
LL | for x in [].iter().take(1) {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#![allow(clippy::eq_op)]
|
||||
#![warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
|
||||
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
a += 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a += 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a -= 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= 99;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= 42;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a /= 2;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a %= 5;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a &= 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * a * a;
|
||||
a = a * 42 * a;
|
||||
a = a * 2 + a;
|
||||
a -= 1 - a;
|
||||
a /= 5 / a;
|
||||
a %= 42 % a;
|
||||
a <<= 6 << a;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#![allow(clippy::eq_op)]
|
||||
#![warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
|
||||
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
a = a + a + 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a + 1 + a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a - (a - 1);
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * a * 99;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * 42 * a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a / (a / 2);
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a % (a % 5);
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a & a & 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * a * a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * a * a;
|
||||
a = a * 42 * a;
|
||||
a = a * 2 + a;
|
||||
a -= 1 - a;
|
||||
a /= 5 / a;
|
||||
a %= 42 % a;
|
||||
a <<= 6 << a;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#![allow(clippy::eq_op)]
|
||||
#![warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
|
||||
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
a += a + 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a += 1 + a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a -= a - 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= a * 99;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= 42 * a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a /= a / 2;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a %= a % 5;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a &= a & 1;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= a * a;
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * a * a;
|
||||
a = a * 42 * a;
|
||||
a = a * 2 + a;
|
||||
a -= 1 - a;
|
||||
a /= 5 / a;
|
||||
a %= 42 % a;
|
||||
a <<= 6 << a;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:8:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:6:5
|
||||
|
|
||||
LL | a += a + 1;
|
||||
| ^^^^^^^^^^
|
||||
@@ -18,7 +18,7 @@ LL + a = a + a + 1;
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:11:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:9:5
|
||||
|
|
||||
LL | a += 1 + a;
|
||||
| ^^^^^^^^^^
|
||||
@@ -35,7 +35,7 @@ LL + a = a + 1 + a;
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:14:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:12:5
|
||||
|
|
||||
LL | a -= a - 1;
|
||||
| ^^^^^^^^^^
|
||||
@@ -52,7 +52,7 @@ LL + a = a - (a - 1);
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:17:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:15:5
|
||||
|
|
||||
LL | a *= a * 99;
|
||||
| ^^^^^^^^^^^
|
||||
@@ -69,7 +69,7 @@ LL + a = a * a * 99;
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:20:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:18:5
|
||||
|
|
||||
LL | a *= 42 * a;
|
||||
| ^^^^^^^^^^^
|
||||
@@ -86,7 +86,7 @@ LL + a = a * 42 * a;
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:23:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:21:5
|
||||
|
|
||||
LL | a /= a / 2;
|
||||
| ^^^^^^^^^^
|
||||
@@ -103,7 +103,7 @@ LL + a = a / (a / 2);
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:26:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:24:5
|
||||
|
|
||||
LL | a %= a % 5;
|
||||
| ^^^^^^^^^^
|
||||
@@ -120,7 +120,7 @@ LL + a = a % (a % 5);
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:29:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:27:5
|
||||
|
|
||||
LL | a &= a & 1;
|
||||
| ^^^^^^^^^^
|
||||
@@ -137,7 +137,7 @@ LL + a = a & a & 1;
|
||||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:32:5
|
||||
--> tests/ui/misrefactored_assign_op.rs:30:5
|
||||
|
|
||||
LL | a *= a * a;
|
||||
| ^^^^^^^^^^
|
||||
@@ -153,14 +153,5 @@ LL - a *= a * a;
|
||||
LL + a = a * a * a;
|
||||
|
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops2.rs:71:5
|
||||
|
|
||||
LL | buf = buf + cows.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()`
|
||||
|
|
||||
= note: `-D clippy::assign-op-pattern` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
Reference in New Issue
Block a user