Merge remote-tracking branch 'upstream/master' into rustup
This commit is contained in:
commit
02e812af4d
2562 changed files with 34500 additions and 15442 deletions
|
|
@ -12,46 +12,64 @@ fn main() {
|
|||
const Z: u32 = 0;
|
||||
let u: u32 = 42;
|
||||
u <= 0;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u <= Z;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u < Z;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
Z >= u;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
Z > u;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u > u32::MAX;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u >= u32::MAX;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u32::MAX < u;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u32::MAX <= u;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
1-1 > u;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u >= !0;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u <= 12 - 2*6;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
let i: i8 = 0;
|
||||
i < -127 - 1;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
i8::MAX >= i;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
3-7 < i32::MIN;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
let b = false;
|
||||
b >= true;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
false > b;
|
||||
//~^ ERROR: this comparison involving the minimum or maximum element for this type con
|
||||
//~^ absurd_extreme_comparisons
|
||||
|
||||
u > 0; // ok
|
||||
// this is handled by clippy::unit_cmp
|
||||
() < {};
|
||||
//~^ ERROR: <-comparison of unit values detected. This will always be false
|
||||
//~| NOTE: `#[deny(clippy::unit_cmp)]` on by default
|
||||
//~^ unit_cmp
|
||||
|
||||
|
||||
}
|
||||
|
||||
use std::cmp::{Ordering, PartialEq, PartialOrd};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | u <= 0;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::absurd_extreme_comparisons)]`
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:16:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:17:5
|
||||
|
|
||||
LL | u <= Z;
|
||||
| ^^^^^^
|
||||
|
|
@ -17,7 +17,7 @@ LL | u <= Z;
|
|||
= help: because `Z` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `u == Z` instead
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:18:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:20:5
|
||||
|
|
||||
LL | u < Z;
|
||||
| ^^^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL | u < Z;
|
|||
= help: because `Z` is the minimum value for this type, this comparison is always false
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:20:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:23:5
|
||||
|
|
||||
LL | Z >= u;
|
||||
| ^^^^^^
|
||||
|
|
@ -33,7 +33,7 @@ LL | Z >= u;
|
|||
= help: because `Z` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `Z == u` instead
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:22:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:26:5
|
||||
|
|
||||
LL | Z > u;
|
||||
| ^^^^^
|
||||
|
|
@ -41,7 +41,7 @@ LL | Z > u;
|
|||
= help: because `Z` is the minimum value for this type, this comparison is always false
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:24:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:29:5
|
||||
|
|
||||
LL | u > u32::MAX;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -49,7 +49,7 @@ LL | u > u32::MAX;
|
|||
= help: because `u32::MAX` is the maximum value for this type, this comparison is always false
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:26:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:32:5
|
||||
|
|
||||
LL | u >= u32::MAX;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -57,7 +57,7 @@ LL | u >= u32::MAX;
|
|||
= help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == u32::MAX` instead
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:28:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:35:5
|
||||
|
|
||||
LL | u32::MAX < u;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -65,7 +65,7 @@ LL | u32::MAX < u;
|
|||
= help: because `u32::MAX` is the maximum value for this type, this comparison is always false
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:30:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:38:5
|
||||
|
|
||||
LL | u32::MAX <= u;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -73,7 +73,7 @@ LL | u32::MAX <= u;
|
|||
= help: because `u32::MAX` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u32::MAX == u` instead
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:32:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:41:5
|
||||
|
|
||||
LL | 1-1 > u;
|
||||
| ^^^^^^^
|
||||
|
|
@ -81,7 +81,7 @@ LL | 1-1 > u;
|
|||
= help: because `1-1` is the minimum value for this type, this comparison is always false
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:34:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:44:5
|
||||
|
|
||||
LL | u >= !0;
|
||||
| ^^^^^^^
|
||||
|
|
@ -89,7 +89,7 @@ LL | u >= !0;
|
|||
= help: because `!0` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `u == !0` instead
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:36:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:47:5
|
||||
|
|
||||
LL | u <= 12 - 2*6;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -97,7 +97,7 @@ LL | u <= 12 - 2*6;
|
|||
= help: because `12 - 2*6` is the minimum value for this type, the case where the two sides are not equal never occurs, consider using `u == 12 - 2*6` instead
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:39:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:51:5
|
||||
|
|
||||
LL | i < -127 - 1;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -105,7 +105,7 @@ LL | i < -127 - 1;
|
|||
= help: because `-127 - 1` is the minimum value for this type, this comparison is always false
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:41:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:54:5
|
||||
|
|
||||
LL | i8::MAX >= i;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -113,7 +113,7 @@ LL | i8::MAX >= i;
|
|||
= help: because `i8::MAX` is the maximum value for this type, this comparison is always true
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:43:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:57:5
|
||||
|
|
||||
LL | 3-7 < i32::MIN;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
@ -121,7 +121,7 @@ LL | 3-7 < i32::MIN;
|
|||
= help: because `i32::MIN` is the minimum value for this type, this comparison is always false
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:46:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:61:5
|
||||
|
|
||||
LL | b >= true;
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -129,7 +129,7 @@ LL | b >= true;
|
|||
= help: because `true` is the maximum value for this type, the case where the two sides are not equal never occurs, consider using `b == true` instead
|
||||
|
||||
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:48:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:64:5
|
||||
|
|
||||
LL | false > b;
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -137,7 +137,7 @@ LL | false > b;
|
|||
= help: because `false` is the minimum value for this type, this comparison is always false
|
||||
|
||||
error: <-comparison of unit values detected. This will always be false
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:52:5
|
||||
--> tests/ui/absurd-extreme-comparisons.rs:69:5
|
||||
|
|
||||
LL | () < {};
|
||||
| ^^^^^^^
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use proc_macros::{external, with_span};
|
|||
|
||||
// Should lint
|
||||
#[expect(dead_code)]
|
||||
//~^ allow_attributes
|
||||
struct T1;
|
||||
|
||||
struct T2; // Should not lint
|
||||
|
|
@ -20,6 +21,7 @@ struct T3;
|
|||
struct T4;
|
||||
// `panic = "unwind"` should always be true
|
||||
#[cfg_attr(panic = "unwind", expect(dead_code))]
|
||||
//~^ allow_attributes
|
||||
struct CfgT;
|
||||
|
||||
#[allow(clippy::allow_attributes, unused)]
|
||||
|
|
@ -51,6 +53,7 @@ fn ignore_inner_attr() {
|
|||
#[clippy::msrv = "1.81"]
|
||||
fn msrv_1_81() {
|
||||
#[expect(unused)]
|
||||
//~^ allow_attributes
|
||||
let x = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use proc_macros::{external, with_span};
|
|||
|
||||
// Should lint
|
||||
#[allow(dead_code)]
|
||||
//~^ allow_attributes
|
||||
struct T1;
|
||||
|
||||
struct T2; // Should not lint
|
||||
|
|
@ -20,6 +21,7 @@ struct T3;
|
|||
struct T4;
|
||||
// `panic = "unwind"` should always be true
|
||||
#[cfg_attr(panic = "unwind", allow(dead_code))]
|
||||
//~^ allow_attributes
|
||||
struct CfgT;
|
||||
|
||||
#[allow(clippy::allow_attributes, unused)]
|
||||
|
|
@ -51,6 +53,7 @@ fn ignore_inner_attr() {
|
|||
#[clippy::msrv = "1.81"]
|
||||
fn msrv_1_81() {
|
||||
#[allow(unused)]
|
||||
//~^ allow_attributes
|
||||
let x = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ LL | #[allow(dead_code)]
|
|||
= help: to override `-D warnings` add `#[allow(clippy::allow_attributes)]`
|
||||
|
||||
error: #[allow] attribute found
|
||||
--> tests/ui/allow_attributes.rs:22:30
|
||||
--> tests/ui/allow_attributes.rs:23:30
|
||||
|
|
||||
LL | #[cfg_attr(panic = "unwind", allow(dead_code))]
|
||||
| ^^^^^ help: replace it with: `expect`
|
||||
|
||||
error: #[allow] attribute found
|
||||
--> tests/ui/allow_attributes.rs:53:7
|
||||
--> tests/ui/allow_attributes.rs:55:7
|
||||
|
|
||||
LL | #[allow(unused)]
|
||||
| ^^^^^ help: replace it with: `expect`
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
#![deny(clippy::allow_attributes_without_reason)]
|
||||
#![allow(unfulfilled_lint_expectations, clippy::duplicated_attributes)]
|
||||
//~^ allow_attributes_without_reason
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::{external, with_span};
|
||||
|
||||
// These should trigger the lint
|
||||
#[allow(dead_code)]
|
||||
//~^ allow_attributes_without_reason
|
||||
#[allow(dead_code, deprecated)]
|
||||
//~^ allow_attributes_without_reason
|
||||
#[expect(dead_code)]
|
||||
//~^ allow_attributes_without_reason
|
||||
// These should be fine
|
||||
#[allow(dead_code, reason = "This should be allowed")]
|
||||
#[warn(dyn_drop, reason = "Warnings can also have reasons")]
|
||||
|
|
@ -44,6 +48,7 @@ pub fn trigger_fp_result() -> Result<(), &'static str> {
|
|||
#[clippy::msrv = "1.81"]
|
||||
fn msrv_1_81() {
|
||||
#[allow(unused)]
|
||||
//~^ allow_attributes_without_reason
|
||||
let _ = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ LL | #![deny(clippy::allow_attributes_without_reason)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `allow` attribute without specifying a reason
|
||||
--> tests/ui/allow_attributes_without_reason.rs:9:1
|
||||
--> tests/ui/allow_attributes_without_reason.rs:10:1
|
||||
|
|
||||
LL | #[allow(dead_code)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -20,7 +20,7 @@ LL | #[allow(dead_code)]
|
|||
= help: try adding a reason at the end with `, reason = ".."`
|
||||
|
||||
error: `allow` attribute without specifying a reason
|
||||
--> tests/ui/allow_attributes_without_reason.rs:10:1
|
||||
--> tests/ui/allow_attributes_without_reason.rs:12:1
|
||||
|
|
||||
LL | #[allow(dead_code, deprecated)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -28,7 +28,7 @@ LL | #[allow(dead_code, deprecated)]
|
|||
= help: try adding a reason at the end with `, reason = ".."`
|
||||
|
||||
error: `expect` attribute without specifying a reason
|
||||
--> tests/ui/allow_attributes_without_reason.rs:11:1
|
||||
--> tests/ui/allow_attributes_without_reason.rs:14:1
|
||||
|
|
||||
LL | #[expect(dead_code)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -36,7 +36,7 @@ LL | #[expect(dead_code)]
|
|||
= help: try adding a reason at the end with `, reason = ".."`
|
||||
|
||||
error: `allow` attribute without specifying a reason
|
||||
--> tests/ui/allow_attributes_without_reason.rs:46:5
|
||||
--> tests/ui/allow_attributes_without_reason.rs:50:5
|
||||
|
|
||||
LL | #[allow(unused)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ fn main() {
|
|||
#[rustfmt::skip]
|
||||
{
|
||||
let _ = ('a') ..='z';
|
||||
//~^ almost_complete_range
|
||||
let _ = 'A' ..= ('Z');
|
||||
//~^ almost_complete_range
|
||||
let _ = ((('0'))) ..= ('9');
|
||||
//~^ almost_complete_range
|
||||
}
|
||||
|
||||
let _ = 'b'..'z';
|
||||
|
|
@ -24,21 +27,30 @@ fn main() {
|
|||
let _ = '1'..'9';
|
||||
|
||||
let _ = (b'a')..=(b'z');
|
||||
//~^ almost_complete_range
|
||||
let _ = b'A'..=b'Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = b'0'..=b'9';
|
||||
//~^ almost_complete_range
|
||||
|
||||
let _ = b'b'..b'z';
|
||||
let _ = b'B'..b'Z';
|
||||
let _ = b'1'..b'9';
|
||||
|
||||
let _ = inline!('a')..='z';
|
||||
//~^ almost_complete_range
|
||||
let _ = inline!('A')..='Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = inline!('0')..='9';
|
||||
//~^ almost_complete_range
|
||||
|
||||
let _ = match 0u8 {
|
||||
b'a'..=b'z' if true => 1,
|
||||
//~^ almost_complete_range
|
||||
b'A'..=b'Z' if true => 2,
|
||||
//~^ almost_complete_range
|
||||
b'0'..=b'9' if true => 3,
|
||||
//~^ almost_complete_range
|
||||
b'b'..b'z' => 4,
|
||||
b'B'..b'Z' => 5,
|
||||
b'1'..b'9' => 6,
|
||||
|
|
@ -47,8 +59,11 @@ fn main() {
|
|||
|
||||
let _ = match 'x' {
|
||||
'a'..='z' if true => 1,
|
||||
//~^ almost_complete_range
|
||||
'A'..='Z' if true => 2,
|
||||
//~^ almost_complete_range
|
||||
'0'..='9' if true => 3,
|
||||
//~^ almost_complete_range
|
||||
'b'..'z' => 4,
|
||||
'B'..'Z' => 5,
|
||||
'1'..'9' => 6,
|
||||
|
|
@ -62,8 +77,11 @@ fn main() {
|
|||
);
|
||||
inline!(
|
||||
let _ = 'a'..='z';
|
||||
//~^ almost_complete_range
|
||||
let _ = 'A'..='Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = '0'..='9';
|
||||
//~^ almost_complete_range
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +89,11 @@ fn main() {
|
|||
fn _under_msrv() {
|
||||
let _ = match 'a' {
|
||||
'a'...'z' => 1,
|
||||
//~^ almost_complete_range
|
||||
'A'...'Z' => 2,
|
||||
//~^ almost_complete_range
|
||||
'0'...'9' => 3,
|
||||
//~^ almost_complete_range
|
||||
_ => 4,
|
||||
};
|
||||
}
|
||||
|
|
@ -80,12 +101,18 @@ fn _under_msrv() {
|
|||
#[clippy::msrv = "1.26"]
|
||||
fn _meets_msrv() {
|
||||
let _ = 'a'..='z';
|
||||
//~^ almost_complete_range
|
||||
let _ = 'A'..='Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = '0'..='9';
|
||||
//~^ almost_complete_range
|
||||
let _ = match 'a' {
|
||||
'a'..='z' => 1,
|
||||
//~^ almost_complete_range
|
||||
'A'..='Z' => 1,
|
||||
//~^ almost_complete_range
|
||||
'0'..='9' => 3,
|
||||
//~^ almost_complete_range
|
||||
_ => 4,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ fn main() {
|
|||
#[rustfmt::skip]
|
||||
{
|
||||
let _ = ('a') ..'z';
|
||||
//~^ almost_complete_range
|
||||
let _ = 'A' .. ('Z');
|
||||
//~^ almost_complete_range
|
||||
let _ = ((('0'))) .. ('9');
|
||||
//~^ almost_complete_range
|
||||
}
|
||||
|
||||
let _ = 'b'..'z';
|
||||
|
|
@ -24,21 +27,30 @@ fn main() {
|
|||
let _ = '1'..'9';
|
||||
|
||||
let _ = (b'a')..(b'z');
|
||||
//~^ almost_complete_range
|
||||
let _ = b'A'..b'Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = b'0'..b'9';
|
||||
//~^ almost_complete_range
|
||||
|
||||
let _ = b'b'..b'z';
|
||||
let _ = b'B'..b'Z';
|
||||
let _ = b'1'..b'9';
|
||||
|
||||
let _ = inline!('a')..'z';
|
||||
//~^ almost_complete_range
|
||||
let _ = inline!('A')..'Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = inline!('0')..'9';
|
||||
//~^ almost_complete_range
|
||||
|
||||
let _ = match 0u8 {
|
||||
b'a'..b'z' if true => 1,
|
||||
//~^ almost_complete_range
|
||||
b'A'..b'Z' if true => 2,
|
||||
//~^ almost_complete_range
|
||||
b'0'..b'9' if true => 3,
|
||||
//~^ almost_complete_range
|
||||
b'b'..b'z' => 4,
|
||||
b'B'..b'Z' => 5,
|
||||
b'1'..b'9' => 6,
|
||||
|
|
@ -47,8 +59,11 @@ fn main() {
|
|||
|
||||
let _ = match 'x' {
|
||||
'a'..'z' if true => 1,
|
||||
//~^ almost_complete_range
|
||||
'A'..'Z' if true => 2,
|
||||
//~^ almost_complete_range
|
||||
'0'..'9' if true => 3,
|
||||
//~^ almost_complete_range
|
||||
'b'..'z' => 4,
|
||||
'B'..'Z' => 5,
|
||||
'1'..'9' => 6,
|
||||
|
|
@ -62,8 +77,11 @@ fn main() {
|
|||
);
|
||||
inline!(
|
||||
let _ = 'a'..'z';
|
||||
//~^ almost_complete_range
|
||||
let _ = 'A'..'Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = '0'..'9';
|
||||
//~^ almost_complete_range
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +89,11 @@ fn main() {
|
|||
fn _under_msrv() {
|
||||
let _ = match 'a' {
|
||||
'a'..'z' => 1,
|
||||
//~^ almost_complete_range
|
||||
'A'..'Z' => 2,
|
||||
//~^ almost_complete_range
|
||||
'0'..'9' => 3,
|
||||
//~^ almost_complete_range
|
||||
_ => 4,
|
||||
};
|
||||
}
|
||||
|
|
@ -80,12 +101,18 @@ fn _under_msrv() {
|
|||
#[clippy::msrv = "1.26"]
|
||||
fn _meets_msrv() {
|
||||
let _ = 'a'..'z';
|
||||
//~^ almost_complete_range
|
||||
let _ = 'A'..'Z';
|
||||
//~^ almost_complete_range
|
||||
let _ = '0'..'9';
|
||||
//~^ almost_complete_range
|
||||
let _ = match 'a' {
|
||||
'a'..'z' => 1,
|
||||
//~^ almost_complete_range
|
||||
'A'..'Z' => 1,
|
||||
//~^ almost_complete_range
|
||||
'0'..'9' => 3,
|
||||
//~^ almost_complete_range
|
||||
_ => 4,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ LL | let _ = ('a') ..'z';
|
|||
= help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:18:17
|
||||
--> tests/ui/almost_complete_range.rs:19:17
|
||||
|
|
||||
LL | let _ = 'A' .. ('Z');
|
||||
| ^^^^--^^^^^^
|
||||
|
|
@ -18,7 +18,7 @@ LL | let _ = 'A' .. ('Z');
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:19:17
|
||||
--> tests/ui/almost_complete_range.rs:21:17
|
||||
|
|
||||
LL | let _ = ((('0'))) .. ('9');
|
||||
| ^^^^^^^^^^--^^^^^^
|
||||
|
|
@ -26,7 +26,7 @@ LL | let _ = ((('0'))) .. ('9');
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:26:13
|
||||
--> tests/ui/almost_complete_range.rs:29:13
|
||||
|
|
||||
LL | let _ = (b'a')..(b'z');
|
||||
| ^^^^^^--^^^^^^
|
||||
|
|
@ -34,7 +34,7 @@ LL | let _ = (b'a')..(b'z');
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:27:13
|
||||
--> tests/ui/almost_complete_range.rs:31:13
|
||||
|
|
||||
LL | let _ = b'A'..b'Z';
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -42,7 +42,7 @@ LL | let _ = b'A'..b'Z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:28:13
|
||||
--> tests/ui/almost_complete_range.rs:33:13
|
||||
|
|
||||
LL | let _ = b'0'..b'9';
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -50,7 +50,7 @@ LL | let _ = b'0'..b'9';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:34:13
|
||||
--> tests/ui/almost_complete_range.rs:40:13
|
||||
|
|
||||
LL | let _ = inline!('a')..'z';
|
||||
| ^^^^^^^^^^^^--^^^
|
||||
|
|
@ -58,7 +58,7 @@ LL | let _ = inline!('a')..'z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:35:13
|
||||
--> tests/ui/almost_complete_range.rs:42:13
|
||||
|
|
||||
LL | let _ = inline!('A')..'Z';
|
||||
| ^^^^^^^^^^^^--^^^
|
||||
|
|
@ -66,7 +66,7 @@ LL | let _ = inline!('A')..'Z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:36:13
|
||||
--> tests/ui/almost_complete_range.rs:44:13
|
||||
|
|
||||
LL | let _ = inline!('0')..'9';
|
||||
| ^^^^^^^^^^^^--^^^
|
||||
|
|
@ -74,7 +74,7 @@ LL | let _ = inline!('0')..'9';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:39:9
|
||||
--> tests/ui/almost_complete_range.rs:48:9
|
||||
|
|
||||
LL | b'a'..b'z' if true => 1,
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -82,7 +82,7 @@ LL | b'a'..b'z' if true => 1,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:40:9
|
||||
--> tests/ui/almost_complete_range.rs:50:9
|
||||
|
|
||||
LL | b'A'..b'Z' if true => 2,
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -90,7 +90,7 @@ LL | b'A'..b'Z' if true => 2,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:41:9
|
||||
--> tests/ui/almost_complete_range.rs:52:9
|
||||
|
|
||||
LL | b'0'..b'9' if true => 3,
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -98,7 +98,7 @@ LL | b'0'..b'9' if true => 3,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:49:9
|
||||
--> tests/ui/almost_complete_range.rs:61:9
|
||||
|
|
||||
LL | 'a'..'z' if true => 1,
|
||||
| ^^^--^^^
|
||||
|
|
@ -106,7 +106,7 @@ LL | 'a'..'z' if true => 1,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:50:9
|
||||
--> tests/ui/almost_complete_range.rs:63:9
|
||||
|
|
||||
LL | 'A'..'Z' if true => 2,
|
||||
| ^^^--^^^
|
||||
|
|
@ -114,7 +114,7 @@ LL | 'A'..'Z' if true => 2,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:51:9
|
||||
--> tests/ui/almost_complete_range.rs:65:9
|
||||
|
|
||||
LL | '0'..'9' if true => 3,
|
||||
| ^^^--^^^
|
||||
|
|
@ -122,7 +122,7 @@ LL | '0'..'9' if true => 3,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:64:17
|
||||
--> tests/ui/almost_complete_range.rs:79:17
|
||||
|
|
||||
LL | let _ = 'a'..'z';
|
||||
| ^^^--^^^
|
||||
|
|
@ -132,7 +132,7 @@ LL | let _ = 'a'..'z';
|
|||
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:65:17
|
||||
--> tests/ui/almost_complete_range.rs:81:17
|
||||
|
|
||||
LL | let _ = 'A'..'Z';
|
||||
| ^^^--^^^
|
||||
|
|
@ -142,7 +142,7 @@ LL | let _ = 'A'..'Z';
|
|||
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:66:17
|
||||
--> tests/ui/almost_complete_range.rs:83:17
|
||||
|
|
||||
LL | let _ = '0'..'9';
|
||||
| ^^^--^^^
|
||||
|
|
@ -152,7 +152,7 @@ LL | let _ = '0'..'9';
|
|||
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:73:9
|
||||
--> tests/ui/almost_complete_range.rs:91:9
|
||||
|
|
||||
LL | 'a'..'z' => 1,
|
||||
| ^^^--^^^
|
||||
|
|
@ -160,7 +160,7 @@ LL | 'a'..'z' => 1,
|
|||
| help: use an inclusive range: `...`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:74:9
|
||||
--> tests/ui/almost_complete_range.rs:93:9
|
||||
|
|
||||
LL | 'A'..'Z' => 2,
|
||||
| ^^^--^^^
|
||||
|
|
@ -168,7 +168,7 @@ LL | 'A'..'Z' => 2,
|
|||
| help: use an inclusive range: `...`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:75:9
|
||||
--> tests/ui/almost_complete_range.rs:95:9
|
||||
|
|
||||
LL | '0'..'9' => 3,
|
||||
| ^^^--^^^
|
||||
|
|
@ -176,7 +176,7 @@ LL | '0'..'9' => 3,
|
|||
| help: use an inclusive range: `...`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:82:13
|
||||
--> tests/ui/almost_complete_range.rs:103:13
|
||||
|
|
||||
LL | let _ = 'a'..'z';
|
||||
| ^^^--^^^
|
||||
|
|
@ -184,7 +184,7 @@ LL | let _ = 'a'..'z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:83:13
|
||||
--> tests/ui/almost_complete_range.rs:105:13
|
||||
|
|
||||
LL | let _ = 'A'..'Z';
|
||||
| ^^^--^^^
|
||||
|
|
@ -192,7 +192,7 @@ LL | let _ = 'A'..'Z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:84:13
|
||||
--> tests/ui/almost_complete_range.rs:107:13
|
||||
|
|
||||
LL | let _ = '0'..'9';
|
||||
| ^^^--^^^
|
||||
|
|
@ -200,7 +200,7 @@ LL | let _ = '0'..'9';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:86:9
|
||||
--> tests/ui/almost_complete_range.rs:110:9
|
||||
|
|
||||
LL | 'a'..'z' => 1,
|
||||
| ^^^--^^^
|
||||
|
|
@ -208,7 +208,7 @@ LL | 'a'..'z' => 1,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:87:9
|
||||
--> tests/ui/almost_complete_range.rs:112:9
|
||||
|
|
||||
LL | 'A'..'Z' => 1,
|
||||
| ^^^--^^^
|
||||
|
|
@ -216,7 +216,7 @@ LL | 'A'..'Z' => 1,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii range
|
||||
--> tests/ui/almost_complete_range.rs:88:9
|
||||
--> tests/ui/almost_complete_range.rs:114:9
|
||||
|
|
||||
LL | '0'..'9' => 3,
|
||||
| ^^^--^^^
|
||||
|
|
|
|||
|
|
@ -1,86 +1,109 @@
|
|||
#[warn(clippy::approx_constant)]
|
||||
fn main() {
|
||||
let my_e = 2.7182;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::E` found
|
||||
//~^ approx_constant
|
||||
|
||||
let almost_e = 2.718;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::E` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_e = 2.71;
|
||||
|
||||
let my_1_frac_pi = 0.3183;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::FRAC_1_PI` found
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
let almost_frac_1_sqrt_2 = 0.70711;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
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
|
||||
//~^ approx_constant
|
||||
|
||||
let no_frac_pi_8 = 0.392;
|
||||
|
||||
let my_ln_10 = 2.302585092994046;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::LN_10` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_ln_10 = 2.303;
|
||||
|
||||
let my_ln_2 = 0.6931471805599453;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::LN_2` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_ln_2 = 0.693;
|
||||
|
||||
let my_log10_e = 0.4342944819032518;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::LOG10_E` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_log10_e = 0.434;
|
||||
|
||||
let my_log2_e = 1.4426950408889634;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::LOG2_E` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_log2_e = 1.442;
|
||||
|
||||
let log2_10 = 3.321928094887362;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::LOG2_10` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_log2_10 = 3.321;
|
||||
|
||||
let log10_2 = 0.301029995663981;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::LOG10_2` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_log10_2 = 0.301;
|
||||
|
||||
let my_pi = 3.1415;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::PI` found
|
||||
//~^ approx_constant
|
||||
|
||||
let almost_pi = 3.14;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::PI` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_pi = 3.15;
|
||||
|
||||
let my_sq2 = 1.4142;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::SQRT_2` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_sq2 = 1.414;
|
||||
|
||||
let my_tau = 6.2832;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::TAU` found
|
||||
//~^ approx_constant
|
||||
|
||||
let almost_tau = 6.28;
|
||||
//~^ ERROR: approximate value of `f{32, 64}::consts::TAU` found
|
||||
//~^ approx_constant
|
||||
|
||||
let no_tau = 6.3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | let my_e = 2.7182;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::approx_constant)]`
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::E` found
|
||||
--> tests/ui/approx_const.rs:5:20
|
||||
--> tests/ui/approx_const.rs:6:20
|
||||
|
|
||||
LL | let almost_e = 2.718;
|
||||
| ^^^^^
|
||||
|
|
@ -17,7 +17,7 @@ LL | let almost_e = 2.718;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found
|
||||
--> tests/ui/approx_const.rs:9:24
|
||||
--> tests/ui/approx_const.rs:11:24
|
||||
|
|
||||
LL | let my_1_frac_pi = 0.3183;
|
||||
| ^^^^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL | let my_1_frac_pi = 0.3183;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found
|
||||
--> tests/ui/approx_const.rs:13:28
|
||||
--> tests/ui/approx_const.rs:16:28
|
||||
|
|
||||
LL | let my_frac_1_sqrt_2 = 0.70710678;
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -33,7 +33,7 @@ LL | let my_frac_1_sqrt_2 = 0.70710678;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found
|
||||
--> tests/ui/approx_const.rs:15:32
|
||||
--> tests/ui/approx_const.rs:19:32
|
||||
|
|
||||
LL | let almost_frac_1_sqrt_2 = 0.70711;
|
||||
| ^^^^^^^
|
||||
|
|
@ -41,7 +41,7 @@ LL | let almost_frac_1_sqrt_2 = 0.70711;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found
|
||||
--> tests/ui/approx_const.rs:19:24
|
||||
--> tests/ui/approx_const.rs:24:24
|
||||
|
|
||||
LL | let my_frac_2_pi = 0.63661977;
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -49,7 +49,7 @@ LL | let my_frac_2_pi = 0.63661977;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found
|
||||
--> tests/ui/approx_const.rs:23:27
|
||||
--> tests/ui/approx_const.rs:29:27
|
||||
|
|
||||
LL | let my_frac_2_sq_pi = 1.128379;
|
||||
| ^^^^^^^^
|
||||
|
|
@ -57,7 +57,7 @@ LL | let my_frac_2_sq_pi = 1.128379;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found
|
||||
--> tests/ui/approx_const.rs:27:24
|
||||
--> tests/ui/approx_const.rs:34:24
|
||||
|
|
||||
LL | let my_frac_pi_2 = 1.57079632679;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -65,7 +65,7 @@ LL | let my_frac_pi_2 = 1.57079632679;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found
|
||||
--> tests/ui/approx_const.rs:31:24
|
||||
--> tests/ui/approx_const.rs:39:24
|
||||
|
|
||||
LL | let my_frac_pi_3 = 1.04719755119;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -73,7 +73,7 @@ LL | let my_frac_pi_3 = 1.04719755119;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found
|
||||
--> tests/ui/approx_const.rs:35:24
|
||||
--> tests/ui/approx_const.rs:44:24
|
||||
|
|
||||
LL | let my_frac_pi_4 = 0.785398163397;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
@ -81,7 +81,7 @@ LL | let my_frac_pi_4 = 0.785398163397;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found
|
||||
--> tests/ui/approx_const.rs:39:24
|
||||
--> tests/ui/approx_const.rs:49:24
|
||||
|
|
||||
LL | let my_frac_pi_6 = 0.523598775598;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
@ -89,7 +89,7 @@ LL | let my_frac_pi_6 = 0.523598775598;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found
|
||||
--> tests/ui/approx_const.rs:43:24
|
||||
--> tests/ui/approx_const.rs:54:24
|
||||
|
|
||||
LL | let my_frac_pi_8 = 0.3926990816987;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
@ -97,7 +97,7 @@ LL | let my_frac_pi_8 = 0.3926990816987;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LN_10` found
|
||||
--> tests/ui/approx_const.rs:47:20
|
||||
--> tests/ui/approx_const.rs:59:20
|
||||
|
|
||||
LL | let my_ln_10 = 2.302585092994046;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -105,7 +105,7 @@ LL | let my_ln_10 = 2.302585092994046;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LN_2` found
|
||||
--> tests/ui/approx_const.rs:51:19
|
||||
--> tests/ui/approx_const.rs:64:19
|
||||
|
|
||||
LL | let my_ln_2 = 0.6931471805599453;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -113,7 +113,7 @@ LL | let my_ln_2 = 0.6931471805599453;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG10_E` found
|
||||
--> tests/ui/approx_const.rs:55:22
|
||||
--> tests/ui/approx_const.rs:69:22
|
||||
|
|
||||
LL | let my_log10_e = 0.4342944819032518;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -121,7 +121,7 @@ LL | let my_log10_e = 0.4342944819032518;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_E` found
|
||||
--> tests/ui/approx_const.rs:59:21
|
||||
--> tests/ui/approx_const.rs:74:21
|
||||
|
|
||||
LL | let my_log2_e = 1.4426950408889634;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -129,7 +129,7 @@ LL | let my_log2_e = 1.4426950408889634;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_10` found
|
||||
--> tests/ui/approx_const.rs:63:19
|
||||
--> tests/ui/approx_const.rs:79:19
|
||||
|
|
||||
LL | let log2_10 = 3.321928094887362;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -137,7 +137,7 @@ LL | let log2_10 = 3.321928094887362;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG10_2` found
|
||||
--> tests/ui/approx_const.rs:67:19
|
||||
--> tests/ui/approx_const.rs:84:19
|
||||
|
|
||||
LL | let log10_2 = 0.301029995663981;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -145,7 +145,7 @@ LL | let log10_2 = 0.301029995663981;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::PI` found
|
||||
--> tests/ui/approx_const.rs:71:17
|
||||
--> tests/ui/approx_const.rs:89:17
|
||||
|
|
||||
LL | let my_pi = 3.1415;
|
||||
| ^^^^^^
|
||||
|
|
@ -153,7 +153,7 @@ LL | let my_pi = 3.1415;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::PI` found
|
||||
--> tests/ui/approx_const.rs:73:21
|
||||
--> tests/ui/approx_const.rs:92:21
|
||||
|
|
||||
LL | let almost_pi = 3.14;
|
||||
| ^^^^
|
||||
|
|
@ -161,7 +161,7 @@ LL | let almost_pi = 3.14;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::SQRT_2` found
|
||||
--> tests/ui/approx_const.rs:77:18
|
||||
--> tests/ui/approx_const.rs:97:18
|
||||
|
|
||||
LL | let my_sq2 = 1.4142;
|
||||
| ^^^^^^
|
||||
|
|
@ -169,7 +169,7 @@ LL | let my_sq2 = 1.4142;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::TAU` found
|
||||
--> tests/ui/approx_const.rs:81:18
|
||||
--> tests/ui/approx_const.rs:102:18
|
||||
|
|
||||
LL | let my_tau = 6.2832;
|
||||
| ^^^^^^
|
||||
|
|
@ -177,7 +177,7 @@ LL | let my_tau = 6.2832;
|
|||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::TAU` found
|
||||
--> tests/ui/approx_const.rs:83:22
|
||||
--> tests/ui/approx_const.rs:105:22
|
||||
|
|
||||
LL | let almost_tau = 6.28;
|
||||
| ^^^^
|
||||
|
|
|
|||
|
|
@ -33,9 +33,12 @@ fn main() {
|
|||
let _ = Arc::new(42);
|
||||
|
||||
let _ = Arc::new(RefCell::new(42));
|
||||
//~^ arc_with_non_send_sync
|
||||
|
||||
let mutex = Mutex::new(1);
|
||||
let _ = Arc::new(mutex.lock().unwrap());
|
||||
//~^ arc_with_non_send_sync
|
||||
|
||||
let _ = Arc::new(&42 as *const i32);
|
||||
//~^ arc_with_non_send_sync
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ LL | let _ = Arc::new(RefCell::new(42));
|
|||
= help: to override `-D warnings` add `#[allow(clippy::arc_with_non_send_sync)]`
|
||||
|
||||
error: usage of an `Arc` that is not `Send` and `Sync`
|
||||
--> tests/ui/arc_with_non_send_sync.rs:38:13
|
||||
--> tests/ui/arc_with_non_send_sync.rs:39:13
|
||||
|
|
||||
LL | let _ = Arc::new(mutex.lock().unwrap());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -21,7 +21,7 @@ LL | let _ = Arc::new(mutex.lock().unwrap());
|
|||
= help: otherwise make `MutexGuard<'_, i32>` `Send` and `Sync` or consider a wrapper type such as `Mutex`
|
||||
|
||||
error: usage of an `Arc` that is not `Send` and `Sync`
|
||||
--> tests/ui/arc_with_non_send_sync.rs:40:13
|
||||
--> tests/ui/arc_with_non_send_sync.rs:42:13
|
||||
|
|
||||
LL | let _ = Arc::new(&42 as *const i32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -164,13 +164,16 @@ pub fn association_with_structures_should_not_trigger_the_lint() {
|
|||
|
||||
pub fn hard_coded_allowed() {
|
||||
let _ = 1f16 + 1f16;
|
||||
//~^ arithmetic_side_effects
|
||||
let _ = 1f32 + 1f32;
|
||||
let _ = 1f64 + 1f64;
|
||||
let _ = 1f128 + 1f128;
|
||||
//~^ arithmetic_side_effects
|
||||
|
||||
let _ = Saturating(0u32) + Saturating(0u32);
|
||||
let _ = String::new() + "";
|
||||
let _ = String::new() + &String::new();
|
||||
//~^ arithmetic_side_effects
|
||||
let _ = Wrapping(0u32) + Wrapping(0u32);
|
||||
|
||||
let saturating: Saturating<u32> = Saturating(0u32);
|
||||
|
|
@ -306,117 +309,221 @@ pub fn unknown_ops_or_runtime_ops_that_can_overflow() {
|
|||
|
||||
// Assign
|
||||
_n += 1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n += &1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n -= 1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n -= &1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n /= 0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n /= &0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n %= 0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n %= &0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n *= 2;
|
||||
//~^ arithmetic_side_effects
|
||||
_n *= &2;
|
||||
//~^ arithmetic_side_effects
|
||||
_n += -1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n += &-1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n -= -1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n -= &-1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n /= -0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n /= &-0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n %= -0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n %= &-0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n *= -2;
|
||||
//~^ arithmetic_side_effects
|
||||
_n *= &-2;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom += Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom += &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom -= Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom -= &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom /= Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom /= &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom %= Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom %= &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom *= Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom *= &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom >>= Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom >>= &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom <<= Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom <<= &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom += -Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom += &-Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom -= -Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom -= &-Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom /= -Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom /= &-Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom %= -Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom %= &-Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom *= -Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom *= &-Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom >>= -Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom >>= &-Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom <<= -Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom <<= &-Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
|
||||
// Binary
|
||||
_n = _n + 1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n + &1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = 1 + _n;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = &1 + _n;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n - 1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n - &1;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = 1 - _n;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = &1 - _n;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n / 0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n / &0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n % 0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n % &0;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n * 2;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = _n * &2;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = 2 * _n;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = &2 * _n;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = 23 + &85;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = &23 + 85;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = &23 + &85;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom + _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom + &_custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = Custom + _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = &Custom + _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom - Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom - &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = Custom - _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = &Custom - _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom / Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom / &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom % Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom % &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom * Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom * &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = Custom * _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = &Custom * _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = Custom + &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = &Custom + Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = &Custom + &Custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom >> _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = _custom >> &_custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = Custom << _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = &Custom << _custom;
|
||||
//~^ arithmetic_side_effects
|
||||
|
||||
// Method
|
||||
_n.saturating_div(0);
|
||||
//~^ arithmetic_side_effects
|
||||
_n.wrapping_div(0);
|
||||
//~^ arithmetic_side_effects
|
||||
_n.wrapping_rem(0);
|
||||
//~^ arithmetic_side_effects
|
||||
_n.wrapping_rem_euclid(0);
|
||||
//~^ arithmetic_side_effects
|
||||
|
||||
_n.saturating_div(_n);
|
||||
//~^ arithmetic_side_effects
|
||||
_n.wrapping_div(_n);
|
||||
//~^ arithmetic_side_effects
|
||||
_n.wrapping_rem(_n);
|
||||
//~^ arithmetic_side_effects
|
||||
_n.wrapping_rem_euclid(_n);
|
||||
//~^ arithmetic_side_effects
|
||||
|
||||
_n.saturating_div(*Box::new(_n));
|
||||
//~^ arithmetic_side_effects
|
||||
|
||||
// Unary
|
||||
_n = -_n;
|
||||
//~^ arithmetic_side_effects
|
||||
_n = -&_n;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = -_custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_custom = -&_custom;
|
||||
//~^ arithmetic_side_effects
|
||||
_ = -*Box::new(_n);
|
||||
//~^ arithmetic_side_effects
|
||||
}
|
||||
|
||||
// Copied and pasted from the `integer_arithmetic` lint for comparison.
|
||||
|
|
@ -426,10 +533,15 @@ pub fn integer_arithmetic() {
|
|||
let mut var2 = -1i32;
|
||||
|
||||
1 + i;
|
||||
//~^ arithmetic_side_effects
|
||||
i * 2;
|
||||
//~^ arithmetic_side_effects
|
||||
1 % i / 2;
|
||||
//~^ arithmetic_side_effects
|
||||
i - 2 + 2 - i;
|
||||
//~^ arithmetic_side_effects
|
||||
-i;
|
||||
//~^ arithmetic_side_effects
|
||||
i >> 1;
|
||||
i << 1;
|
||||
|
||||
|
|
@ -441,18 +553,27 @@ pub fn integer_arithmetic() {
|
|||
i ^ 1;
|
||||
|
||||
i += 1;
|
||||
//~^ arithmetic_side_effects
|
||||
i -= 1;
|
||||
//~^ arithmetic_side_effects
|
||||
i *= 2;
|
||||
//~^ arithmetic_side_effects
|
||||
i /= 2;
|
||||
i /= 0;
|
||||
//~^ arithmetic_side_effects
|
||||
i /= -1;
|
||||
i /= var1;
|
||||
//~^ arithmetic_side_effects
|
||||
i /= var2;
|
||||
//~^ arithmetic_side_effects
|
||||
i %= 2;
|
||||
i %= 0;
|
||||
//~^ arithmetic_side_effects
|
||||
i %= -1;
|
||||
i %= var1;
|
||||
//~^ arithmetic_side_effects
|
||||
i %= var2;
|
||||
//~^ arithmetic_side_effects
|
||||
i <<= 3;
|
||||
i >>= 2;
|
||||
|
||||
|
|
@ -463,6 +584,7 @@ pub fn integer_arithmetic() {
|
|||
|
||||
pub fn issue_10583(a: u16) -> u16 {
|
||||
10 / a
|
||||
//~^ arithmetic_side_effects
|
||||
}
|
||||
|
||||
pub fn issue_10767() {
|
||||
|
|
@ -517,10 +639,12 @@ pub fn issue_11392() {
|
|||
pub fn issue_11393() {
|
||||
fn example_div(x: Wrapping<i32>, maybe_zero: Wrapping<i32>) -> Wrapping<i32> {
|
||||
x / maybe_zero
|
||||
//~^ arithmetic_side_effects
|
||||
}
|
||||
|
||||
fn example_rem(x: Wrapping<i32>, maybe_zero: Wrapping<i32>) -> Wrapping<i32> {
|
||||
x % maybe_zero
|
||||
//~^ arithmetic_side_effects
|
||||
}
|
||||
|
||||
let [x, maybe_zero] = [1, 0].map(Wrapping);
|
||||
|
|
@ -532,17 +656,21 @@ pub fn issue_12318() {
|
|||
use core::ops::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign};
|
||||
let mut one: i32 = 1;
|
||||
one.add_assign(1);
|
||||
//~^ arithmetic_side_effects
|
||||
one.div_assign(1);
|
||||
one.mul_assign(1);
|
||||
one.rem_assign(1);
|
||||
one.sub_assign(1);
|
||||
//~^ arithmetic_side_effects
|
||||
}
|
||||
|
||||
pub fn explicit_methods() {
|
||||
use core::ops::Add;
|
||||
let one: i32 = 1;
|
||||
one.add(&one);
|
||||
//~^ arithmetic_side_effects
|
||||
Box::new(one).add(one);
|
||||
//~^ arithmetic_side_effects
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,763 +8,763 @@ LL | let _ = 1f16 + 1f16;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::arithmetic_side_effects)]`
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:169:13
|
||||
--> tests/ui/arithmetic_side_effects.rs:170:13
|
||||
|
|
||||
LL | let _ = 1f128 + 1f128;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:173:13
|
||||
--> tests/ui/arithmetic_side_effects.rs:175:13
|
||||
|
|
||||
LL | let _ = String::new() + &String::new();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:308:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:311:5
|
||||
|
|
||||
LL | _n += 1;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:309:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:313:5
|
||||
|
|
||||
LL | _n += &1;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:310:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:315:5
|
||||
|
|
||||
LL | _n -= 1;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:311:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:317:5
|
||||
|
|
||||
LL | _n -= &1;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:312:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:319:5
|
||||
|
|
||||
LL | _n /= 0;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:313:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:321:5
|
||||
|
|
||||
LL | _n /= &0;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:314:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:323:5
|
||||
|
|
||||
LL | _n %= 0;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:315:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:325:5
|
||||
|
|
||||
LL | _n %= &0;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:316:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:327:5
|
||||
|
|
||||
LL | _n *= 2;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:317:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:329:5
|
||||
|
|
||||
LL | _n *= &2;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:318:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:331:5
|
||||
|
|
||||
LL | _n += -1;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:319:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:333:5
|
||||
|
|
||||
LL | _n += &-1;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:320:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:335:5
|
||||
|
|
||||
LL | _n -= -1;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:321:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:337:5
|
||||
|
|
||||
LL | _n -= &-1;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:322:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:339:5
|
||||
|
|
||||
LL | _n /= -0;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:323:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:341:5
|
||||
|
|
||||
LL | _n /= &-0;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:324:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:343:5
|
||||
|
|
||||
LL | _n %= -0;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:325:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:345:5
|
||||
|
|
||||
LL | _n %= &-0;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:326:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:347:5
|
||||
|
|
||||
LL | _n *= -2;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:327:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:349:5
|
||||
|
|
||||
LL | _n *= &-2;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:328:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:351:5
|
||||
|
|
||||
LL | _custom += Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:329:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:353:5
|
||||
|
|
||||
LL | _custom += &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:330:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:355:5
|
||||
|
|
||||
LL | _custom -= Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:331:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:357:5
|
||||
|
|
||||
LL | _custom -= &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:332:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:359:5
|
||||
|
|
||||
LL | _custom /= Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:333:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:361:5
|
||||
|
|
||||
LL | _custom /= &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:334:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:363:5
|
||||
|
|
||||
LL | _custom %= Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:335:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:365:5
|
||||
|
|
||||
LL | _custom %= &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:336:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:367:5
|
||||
|
|
||||
LL | _custom *= Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:337:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:369:5
|
||||
|
|
||||
LL | _custom *= &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:338:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:371:5
|
||||
|
|
||||
LL | _custom >>= Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:339:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:373:5
|
||||
|
|
||||
LL | _custom >>= &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:340:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:375:5
|
||||
|
|
||||
LL | _custom <<= Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:341:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:377:5
|
||||
|
|
||||
LL | _custom <<= &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:342:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:379:5
|
||||
|
|
||||
LL | _custom += -Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:343:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:381:5
|
||||
|
|
||||
LL | _custom += &-Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:344:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:383:5
|
||||
|
|
||||
LL | _custom -= -Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:345:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:385:5
|
||||
|
|
||||
LL | _custom -= &-Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:346:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:387:5
|
||||
|
|
||||
LL | _custom /= -Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:347:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:389:5
|
||||
|
|
||||
LL | _custom /= &-Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:348:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:391:5
|
||||
|
|
||||
LL | _custom %= -Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:349:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:393:5
|
||||
|
|
||||
LL | _custom %= &-Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:350:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:395:5
|
||||
|
|
||||
LL | _custom *= -Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:351:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:397:5
|
||||
|
|
||||
LL | _custom *= &-Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:352:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:399:5
|
||||
|
|
||||
LL | _custom >>= -Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:353:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:401:5
|
||||
|
|
||||
LL | _custom >>= &-Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:354:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:403:5
|
||||
|
|
||||
LL | _custom <<= -Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:355:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:405:5
|
||||
|
|
||||
LL | _custom <<= &-Custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:358:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:409:10
|
||||
|
|
||||
LL | _n = _n + 1;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:359:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:411:10
|
||||
|
|
||||
LL | _n = _n + &1;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:360:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:413:10
|
||||
|
|
||||
LL | _n = 1 + _n;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:361:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:415:10
|
||||
|
|
||||
LL | _n = &1 + _n;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:362:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:417:10
|
||||
|
|
||||
LL | _n = _n - 1;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:363:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:419:10
|
||||
|
|
||||
LL | _n = _n - &1;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:364:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:421:10
|
||||
|
|
||||
LL | _n = 1 - _n;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:365:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:423:10
|
||||
|
|
||||
LL | _n = &1 - _n;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:366:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:425:10
|
||||
|
|
||||
LL | _n = _n / 0;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:367:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:427:10
|
||||
|
|
||||
LL | _n = _n / &0;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:368:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:429:10
|
||||
|
|
||||
LL | _n = _n % 0;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:369:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:431:10
|
||||
|
|
||||
LL | _n = _n % &0;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:370:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:433:10
|
||||
|
|
||||
LL | _n = _n * 2;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:371:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:435:10
|
||||
|
|
||||
LL | _n = _n * &2;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:372:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:437:10
|
||||
|
|
||||
LL | _n = 2 * _n;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:373:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:439:10
|
||||
|
|
||||
LL | _n = &2 * _n;
|
||||
| ^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:374:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:441:10
|
||||
|
|
||||
LL | _n = 23 + &85;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:375:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:443:10
|
||||
|
|
||||
LL | _n = &23 + 85;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:376:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:445:10
|
||||
|
|
||||
LL | _n = &23 + &85;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:377:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:447:15
|
||||
|
|
||||
LL | _custom = _custom + _custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:378:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:449:15
|
||||
|
|
||||
LL | _custom = _custom + &_custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:379:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:451:15
|
||||
|
|
||||
LL | _custom = Custom + _custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:380:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:453:15
|
||||
|
|
||||
LL | _custom = &Custom + _custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:381:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:455:15
|
||||
|
|
||||
LL | _custom = _custom - Custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:382:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:457:15
|
||||
|
|
||||
LL | _custom = _custom - &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:383:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:459:15
|
||||
|
|
||||
LL | _custom = Custom - _custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:384:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:461:15
|
||||
|
|
||||
LL | _custom = &Custom - _custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:385:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:463:15
|
||||
|
|
||||
LL | _custom = _custom / Custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:386:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:465:15
|
||||
|
|
||||
LL | _custom = _custom / &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:387:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:467:15
|
||||
|
|
||||
LL | _custom = _custom % Custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:388:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:469:15
|
||||
|
|
||||
LL | _custom = _custom % &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:389:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:471:15
|
||||
|
|
||||
LL | _custom = _custom * Custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:390:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:473:15
|
||||
|
|
||||
LL | _custom = _custom * &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:391:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:475:15
|
||||
|
|
||||
LL | _custom = Custom * _custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:392:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:477:15
|
||||
|
|
||||
LL | _custom = &Custom * _custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:393:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:479:15
|
||||
|
|
||||
LL | _custom = Custom + &Custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:394:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:481:15
|
||||
|
|
||||
LL | _custom = &Custom + Custom;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:395:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:483:15
|
||||
|
|
||||
LL | _custom = &Custom + &Custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:396:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:485:15
|
||||
|
|
||||
LL | _custom = _custom >> _custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:397:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:487:15
|
||||
|
|
||||
LL | _custom = _custom >> &_custom;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:398:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:489:15
|
||||
|
|
||||
LL | _custom = Custom << _custom;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:399:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:491:15
|
||||
|
|
||||
LL | _custom = &Custom << _custom;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:402:23
|
||||
--> tests/ui/arithmetic_side_effects.rs:495:23
|
||||
|
|
||||
LL | _n.saturating_div(0);
|
||||
| ^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:403:21
|
||||
--> tests/ui/arithmetic_side_effects.rs:497:21
|
||||
|
|
||||
LL | _n.wrapping_div(0);
|
||||
| ^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:404:21
|
||||
--> tests/ui/arithmetic_side_effects.rs:499:21
|
||||
|
|
||||
LL | _n.wrapping_rem(0);
|
||||
| ^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:405:28
|
||||
--> tests/ui/arithmetic_side_effects.rs:501:28
|
||||
|
|
||||
LL | _n.wrapping_rem_euclid(0);
|
||||
| ^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:407:23
|
||||
--> tests/ui/arithmetic_side_effects.rs:504:23
|
||||
|
|
||||
LL | _n.saturating_div(_n);
|
||||
| ^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:408:21
|
||||
--> tests/ui/arithmetic_side_effects.rs:506:21
|
||||
|
|
||||
LL | _n.wrapping_div(_n);
|
||||
| ^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:409:21
|
||||
--> tests/ui/arithmetic_side_effects.rs:508:21
|
||||
|
|
||||
LL | _n.wrapping_rem(_n);
|
||||
| ^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:410:28
|
||||
--> tests/ui/arithmetic_side_effects.rs:510:28
|
||||
|
|
||||
LL | _n.wrapping_rem_euclid(_n);
|
||||
| ^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:412:23
|
||||
--> tests/ui/arithmetic_side_effects.rs:513:23
|
||||
|
|
||||
LL | _n.saturating_div(*Box::new(_n));
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:415:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:517:10
|
||||
|
|
||||
LL | _n = -_n;
|
||||
| ^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:416:10
|
||||
--> tests/ui/arithmetic_side_effects.rs:519:10
|
||||
|
|
||||
LL | _n = -&_n;
|
||||
| ^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:417:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:521:15
|
||||
|
|
||||
LL | _custom = -_custom;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:418:15
|
||||
--> tests/ui/arithmetic_side_effects.rs:523:15
|
||||
|
|
||||
LL | _custom = -&_custom;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:419:9
|
||||
--> tests/ui/arithmetic_side_effects.rs:525:9
|
||||
|
|
||||
LL | _ = -*Box::new(_n);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:428:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:535:5
|
||||
|
|
||||
LL | 1 + i;
|
||||
| ^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:429:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:537:5
|
||||
|
|
||||
LL | i * 2;
|
||||
| ^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:430:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:539:5
|
||||
|
|
||||
LL | 1 % i / 2;
|
||||
| ^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:431:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:541:5
|
||||
|
|
||||
LL | i - 2 + 2 - i;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:432:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:543:5
|
||||
|
|
||||
LL | -i;
|
||||
| ^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:443:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:555:5
|
||||
|
|
||||
LL | i += 1;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:444:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:557:5
|
||||
|
|
||||
LL | i -= 1;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:445:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:559:5
|
||||
|
|
||||
LL | i *= 2;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:447:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:562:5
|
||||
|
|
||||
LL | i /= 0;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:449:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:565:5
|
||||
|
|
||||
LL | i /= var1;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:450:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:567:5
|
||||
|
|
||||
LL | i /= var2;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:452:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:570:5
|
||||
|
|
||||
LL | i %= 0;
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:454:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:573:5
|
||||
|
|
||||
LL | i %= var1;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:455:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:575:5
|
||||
|
|
||||
LL | i %= var2;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:465:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:586:5
|
||||
|
|
||||
LL | 10 / a
|
||||
| ^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:519:9
|
||||
--> tests/ui/arithmetic_side_effects.rs:641:9
|
||||
|
|
||||
LL | x / maybe_zero
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:523:9
|
||||
--> tests/ui/arithmetic_side_effects.rs:646:9
|
||||
|
|
||||
LL | x % maybe_zero
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:534:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:658:5
|
||||
|
|
||||
LL | one.add_assign(1);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:538:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:663:5
|
||||
|
|
||||
LL | one.sub_assign(1);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:544:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:670:5
|
||||
|
|
||||
LL | one.add(&one);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: arithmetic operation that can potentially result in unexpected side-effects
|
||||
--> tests/ui/arithmetic_side_effects.rs:545:5
|
||||
--> tests/ui/arithmetic_side_effects.rs:672:5
|
||||
|
|
||||
LL | Box::new(one).add(one);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ extern crate proc_macros;
|
|||
use proc_macros::{external, with_span};
|
||||
|
||||
fn main() {
|
||||
let i = 0u32 as u64;
|
||||
let i = 0u32 as u64; //~ as_conversions
|
||||
|
||||
let j = &i as *const u64 as *mut u64;
|
||||
//~^ as_conversions
|
||||
//~| as_conversions
|
||||
|
||||
external!(0u32 as u64);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ struct S;
|
|||
|
||||
fn f(s: &S) -> usize {
|
||||
&s as *const &S as usize
|
||||
//~^ ERROR: using inferred pointer cast
|
||||
//~^ as_pointer_underscore
|
||||
}
|
||||
|
||||
fn g(s: &mut S) -> usize {
|
||||
s as *mut S as usize
|
||||
//~^ ERROR: using inferred pointer cast
|
||||
//~^ as_pointer_underscore
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ struct S;
|
|||
|
||||
fn f(s: &S) -> usize {
|
||||
&s as *const _ as usize
|
||||
//~^ ERROR: using inferred pointer cast
|
||||
//~^ as_pointer_underscore
|
||||
}
|
||||
|
||||
fn g(s: &mut S) -> usize {
|
||||
s as *mut _ as usize
|
||||
//~^ ERROR: using inferred pointer cast
|
||||
//~^ as_pointer_underscore
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,11 @@ impl<T> Covariant<T> {
|
|||
fn main() {
|
||||
let mut string = String::new();
|
||||
let _ = string.as_ptr() as *mut u8;
|
||||
//~^ ERROR: casting the result of `as_ptr` to *mut u8
|
||||
//~| NOTE: `-D clippy::as-ptr-cast-mut` implied by `-D warnings`
|
||||
//~^ as_ptr_cast_mut
|
||||
|
||||
let _: *mut i8 = string.as_ptr() as *mut _;
|
||||
//~^ ERROR: casting the result of `as_ptr` to *mut i8
|
||||
//~^ as_ptr_cast_mut
|
||||
|
||||
let _ = string.as_ptr() as *const i8;
|
||||
let _ = string.as_mut_ptr();
|
||||
let _ = string.as_mut_ptr() as *mut u8;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ fn foo(_n: usize) {}
|
|||
fn main() {
|
||||
let n: u16 = 256;
|
||||
foo(n as usize);
|
||||
//~^ as_underscore
|
||||
|
||||
let n = 0_u128;
|
||||
let _n: u8 = n as u8;
|
||||
//~^ as_underscore
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ fn foo(_n: usize) {}
|
|||
fn main() {
|
||||
let n: u16 = 256;
|
||||
foo(n as _);
|
||||
//~^ as_underscore
|
||||
|
||||
let n = 0_u128;
|
||||
let _n: u8 = n as _;
|
||||
//~^ as_underscore
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ LL | foo(n as _);
|
|||
= help: to override `-D warnings` add `#[allow(clippy::as_underscore)]`
|
||||
|
||||
error: using `as _` conversion
|
||||
--> tests/ui/as_underscore.rs:10:18
|
||||
--> tests/ui/as_underscore.rs:11:18
|
||||
|
|
||||
LL | let _n: u8 = n as _;
|
||||
| ^^^^^-
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//@ignore-target: i686 x86
|
||||
//@needs-asm-support
|
||||
//@check-pass
|
||||
|
||||
#[warn(clippy::inline_asm_x86_intel_syntax)]
|
||||
#[warn(clippy::inline_asm_x86_att_syntax)]
|
||||
|
|
|
|||
|
|
@ -6,19 +6,24 @@ mod warn_intel {
|
|||
|
||||
pub(super) unsafe fn use_asm() {
|
||||
asm!("");
|
||||
//~^ ERROR: Intel x86 assembly syntax used
|
||||
//~^ inline_asm_x86_intel_syntax
|
||||
|
||||
asm!("", options());
|
||||
//~^ ERROR: Intel x86 assembly syntax used
|
||||
//~^ inline_asm_x86_intel_syntax
|
||||
|
||||
asm!("", options(nostack));
|
||||
//~^ ERROR: Intel x86 assembly syntax used
|
||||
//~^ inline_asm_x86_intel_syntax
|
||||
|
||||
asm!("", options(att_syntax));
|
||||
asm!("", options(nostack, att_syntax));
|
||||
}
|
||||
|
||||
global_asm!("");
|
||||
//~^ ERROR: Intel x86 assembly syntax used
|
||||
//~^ inline_asm_x86_intel_syntax
|
||||
|
||||
global_asm!("", options());
|
||||
//~^ ERROR: Intel x86 assembly syntax used
|
||||
//~^ inline_asm_x86_intel_syntax
|
||||
|
||||
global_asm!("", options(att_syntax));
|
||||
}
|
||||
|
||||
|
|
@ -31,15 +36,16 @@ mod warn_att {
|
|||
asm!("", options());
|
||||
asm!("", options(nostack));
|
||||
asm!("", options(att_syntax));
|
||||
//~^ ERROR: AT&T x86 assembly syntax used
|
||||
//~^ inline_asm_x86_att_syntax
|
||||
|
||||
asm!("", options(nostack, att_syntax));
|
||||
//~^ ERROR: AT&T x86 assembly syntax used
|
||||
//~^ inline_asm_x86_att_syntax
|
||||
}
|
||||
|
||||
global_asm!("");
|
||||
global_asm!("", options());
|
||||
global_asm!("", options(att_syntax));
|
||||
//~^ ERROR: AT&T x86 assembly syntax used
|
||||
//~^ inline_asm_x86_att_syntax
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | asm!("");
|
|||
= help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]`
|
||||
|
||||
error: Intel x86 assembly syntax used
|
||||
--> tests/ui/asm_syntax_x86.rs:10:9
|
||||
--> tests/ui/asm_syntax_x86.rs:11:9
|
||||
|
|
||||
LL | asm!("", options());
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -17,7 +17,7 @@ LL | asm!("", options());
|
|||
= help: use AT&T x86 assembly syntax
|
||||
|
||||
error: Intel x86 assembly syntax used
|
||||
--> tests/ui/asm_syntax_x86.rs:12:9
|
||||
--> tests/ui/asm_syntax_x86.rs:14:9
|
||||
|
|
||||
LL | asm!("", options(nostack));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL | asm!("", options(nostack));
|
|||
= help: use AT&T x86 assembly syntax
|
||||
|
||||
error: Intel x86 assembly syntax used
|
||||
--> tests/ui/asm_syntax_x86.rs:18:5
|
||||
--> tests/ui/asm_syntax_x86.rs:21:5
|
||||
|
|
||||
LL | global_asm!("");
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
@ -33,7 +33,7 @@ LL | global_asm!("");
|
|||
= help: use AT&T x86 assembly syntax
|
||||
|
||||
error: Intel x86 assembly syntax used
|
||||
--> tests/ui/asm_syntax_x86.rs:20:5
|
||||
--> tests/ui/asm_syntax_x86.rs:24:5
|
||||
|
|
||||
LL | global_asm!("", options());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -41,7 +41,7 @@ LL | global_asm!("", options());
|
|||
= help: use AT&T x86 assembly syntax
|
||||
|
||||
error: AT&T x86 assembly syntax used
|
||||
--> tests/ui/asm_syntax_x86.rs:33:9
|
||||
--> tests/ui/asm_syntax_x86.rs:38:9
|
||||
|
|
||||
LL | asm!("", options(att_syntax));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -51,7 +51,7 @@ LL | asm!("", options(att_syntax));
|
|||
= help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]`
|
||||
|
||||
error: AT&T x86 assembly syntax used
|
||||
--> tests/ui/asm_syntax_x86.rs:35:9
|
||||
--> tests/ui/asm_syntax_x86.rs:41:9
|
||||
|
|
||||
LL | asm!("", options(nostack, att_syntax));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -59,7 +59,7 @@ LL | asm!("", options(nostack, att_syntax));
|
|||
= help: use Intel x86 assembly syntax
|
||||
|
||||
error: AT&T x86 assembly syntax used
|
||||
--> tests/ui/asm_syntax_x86.rs:41:5
|
||||
--> tests/ui/asm_syntax_x86.rs:47:5
|
||||
|
|
||||
LL | global_asm!("", options(att_syntax));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -8,30 +8,35 @@ macro_rules! assert_const {
|
|||
}
|
||||
fn main() {
|
||||
assert!(true);
|
||||
//~^ ERROR: `assert!(true)` will be optimized out by the compiler
|
||||
//~^ assertions_on_constants
|
||||
|
||||
assert!(false);
|
||||
//~^ ERROR: `assert!(false)` should probably be replaced
|
||||
//~^ assertions_on_constants
|
||||
|
||||
assert!(true, "true message");
|
||||
//~^ ERROR: `assert!(true)` will be optimized out by the compiler
|
||||
//~^ assertions_on_constants
|
||||
|
||||
assert!(false, "false message");
|
||||
//~^ ERROR: `assert!(false, ..)` should probably be replaced
|
||||
//~^ assertions_on_constants
|
||||
|
||||
let msg = "panic message";
|
||||
assert!(false, "{}", msg.to_uppercase());
|
||||
//~^ ERROR: `assert!(false, ..)` should probably be replaced
|
||||
//~^ assertions_on_constants
|
||||
|
||||
const B: bool = true;
|
||||
assert!(B);
|
||||
//~^ ERROR: `assert!(true)` will be optimized out by the compiler
|
||||
//~^ assertions_on_constants
|
||||
|
||||
const C: bool = false;
|
||||
assert!(C);
|
||||
//~^ ERROR: `assert!(false)` should probably be replaced
|
||||
//~^ assertions_on_constants
|
||||
|
||||
assert!(C, "C message");
|
||||
//~^ ERROR: `assert!(false, ..)` should probably be replaced
|
||||
//~^ assertions_on_constants
|
||||
|
||||
debug_assert!(true);
|
||||
//~^ ERROR: `debug_assert!(true)` will be optimized out by the compiler
|
||||
//~^ assertions_on_constants
|
||||
|
||||
// Don't lint this, since there is no better way for expressing "Only panic in debug mode".
|
||||
debug_assert!(false); // #3948
|
||||
assert_const!(3);
|
||||
|
|
@ -47,10 +52,10 @@ fn main() {
|
|||
assert!(!CFG_FLAG);
|
||||
|
||||
const _: () = assert!(true);
|
||||
//~^ ERROR: `assert!(true)` will be optimized out by the compiler
|
||||
//~^ assertions_on_constants
|
||||
|
||||
assert!(8 == (7 + 1));
|
||||
//~^ ERROR: `assert!(true)` will be optimized out by the compiler
|
||||
//~^ assertions_on_constants
|
||||
|
||||
// Don't lint if the value is dependent on a defined constant:
|
||||
const N: usize = 1024;
|
||||
|
|
@ -59,6 +64,7 @@ fn main() {
|
|||
|
||||
const _: () = {
|
||||
assert!(true);
|
||||
//~^ ERROR: `assert!(true)` will be optimized out by the compiler
|
||||
//~^ assertions_on_constants
|
||||
|
||||
assert!(8 == (7 + 1));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | assert!(true);
|
|||
= help: to override `-D warnings` add `#[allow(clippy::assertions_on_constants)]`
|
||||
|
||||
error: `assert!(false)` should probably be replaced
|
||||
--> tests/ui/assertions_on_constants.rs:12:5
|
||||
--> tests/ui/assertions_on_constants.rs:13:5
|
||||
|
|
||||
LL | assert!(false);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
@ -17,7 +17,7 @@ LL | assert!(false);
|
|||
= help: use `panic!()` or `unreachable!()`
|
||||
|
||||
error: `assert!(true)` will be optimized out by the compiler
|
||||
--> tests/ui/assertions_on_constants.rs:14:5
|
||||
--> tests/ui/assertions_on_constants.rs:16:5
|
||||
|
|
||||
LL | assert!(true, "true message");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL | assert!(true, "true message");
|
|||
= help: remove it
|
||||
|
||||
error: `assert!(false, ..)` should probably be replaced
|
||||
--> tests/ui/assertions_on_constants.rs:16:5
|
||||
--> tests/ui/assertions_on_constants.rs:19:5
|
||||
|
|
||||
LL | assert!(false, "false message");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -33,7 +33,7 @@ LL | assert!(false, "false message");
|
|||
= help: use `panic!(..)` or `unreachable!(..)`
|
||||
|
||||
error: `assert!(false, ..)` should probably be replaced
|
||||
--> tests/ui/assertions_on_constants.rs:20:5
|
||||
--> tests/ui/assertions_on_constants.rs:23:5
|
||||
|
|
||||
LL | assert!(false, "{}", msg.to_uppercase());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -41,7 +41,7 @@ LL | assert!(false, "{}", msg.to_uppercase());
|
|||
= help: use `panic!(..)` or `unreachable!(..)`
|
||||
|
||||
error: `assert!(true)` will be optimized out by the compiler
|
||||
--> tests/ui/assertions_on_constants.rs:24:5
|
||||
--> tests/ui/assertions_on_constants.rs:27:5
|
||||
|
|
||||
LL | assert!(B);
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -49,7 +49,7 @@ LL | assert!(B);
|
|||
= help: remove it
|
||||
|
||||
error: `assert!(false)` should probably be replaced
|
||||
--> tests/ui/assertions_on_constants.rs:28:5
|
||||
--> tests/ui/assertions_on_constants.rs:31:5
|
||||
|
|
||||
LL | assert!(C);
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -57,7 +57,7 @@ LL | assert!(C);
|
|||
= help: use `panic!()` or `unreachable!()`
|
||||
|
||||
error: `assert!(false, ..)` should probably be replaced
|
||||
--> tests/ui/assertions_on_constants.rs:30:5
|
||||
--> tests/ui/assertions_on_constants.rs:34:5
|
||||
|
|
||||
LL | assert!(C, "C message");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -65,7 +65,7 @@ LL | assert!(C, "C message");
|
|||
= help: use `panic!(..)` or `unreachable!(..)`
|
||||
|
||||
error: `debug_assert!(true)` will be optimized out by the compiler
|
||||
--> tests/ui/assertions_on_constants.rs:33:5
|
||||
--> tests/ui/assertions_on_constants.rs:37:5
|
||||
|
|
||||
LL | debug_assert!(true);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -73,7 +73,7 @@ LL | debug_assert!(true);
|
|||
= help: remove it
|
||||
|
||||
error: `assert!(true)` will be optimized out by the compiler
|
||||
--> tests/ui/assertions_on_constants.rs:49:19
|
||||
--> tests/ui/assertions_on_constants.rs:54:19
|
||||
|
|
||||
LL | const _: () = assert!(true);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -81,7 +81,7 @@ LL | const _: () = assert!(true);
|
|||
= help: remove it
|
||||
|
||||
error: `assert!(true)` will be optimized out by the compiler
|
||||
--> tests/ui/assertions_on_constants.rs:52:5
|
||||
--> tests/ui/assertions_on_constants.rs:57:5
|
||||
|
|
||||
LL | assert!(8 == (7 + 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -89,7 +89,7 @@ LL | assert!(8 == (7 + 1));
|
|||
= help: remove it
|
||||
|
||||
error: `assert!(true)` will be optimized out by the compiler
|
||||
--> tests/ui/assertions_on_constants.rs:61:5
|
||||
--> tests/ui/assertions_on_constants.rs:66:5
|
||||
|
|
||||
LL | assert!(true);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ fn main() {
|
|||
let r: Result<Foo, DebugFoo> = Ok(Foo);
|
||||
debug_assert!(r.is_ok());
|
||||
r.unwrap();
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test ok with non-debug error type
|
||||
let r: Result<Foo, Foo> = Ok(Foo);
|
||||
|
|
@ -40,9 +41,11 @@ fn main() {
|
|||
Ok(Foo)
|
||||
}
|
||||
get_ok().unwrap();
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test macro ok
|
||||
get_ok_macro!().unwrap();
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test ok that shouldn't be moved
|
||||
let r: Result<CopyFoo, DebugFoo> = Ok(CopyFoo);
|
||||
|
|
@ -56,12 +59,14 @@ fn main() {
|
|||
// test ok that is copied
|
||||
let r: Result<CopyFoo, CopyFoo> = Ok(CopyFoo);
|
||||
r.unwrap();
|
||||
//~^ assertions_on_result_states
|
||||
r.unwrap();
|
||||
|
||||
// test reference to ok
|
||||
let r: Result<CopyFoo, CopyFoo> = Ok(CopyFoo);
|
||||
fn test_ref_copy_ok(r: &Result<CopyFoo, CopyFoo>) {
|
||||
r.unwrap();
|
||||
//~^ assertions_on_result_states
|
||||
}
|
||||
test_ref_copy_ok(&r);
|
||||
r.unwrap();
|
||||
|
|
@ -70,6 +75,7 @@ fn main() {
|
|||
let r: Result<DebugFoo, Foo> = Err(Foo);
|
||||
debug_assert!(r.is_err());
|
||||
r.unwrap_err();
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test err with non-debug value type
|
||||
let r: Result<Foo, Foo> = Err(Foo);
|
||||
|
|
@ -80,4 +86,5 @@ fn main() {
|
|||
fn issue9450() {
|
||||
let res: Result<i32, i32> = Ok(1);
|
||||
res.unwrap_err();
|
||||
//~^ assertions_on_result_states
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ fn main() {
|
|||
let r: Result<Foo, DebugFoo> = Ok(Foo);
|
||||
debug_assert!(r.is_ok());
|
||||
assert!(r.is_ok());
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test ok with non-debug error type
|
||||
let r: Result<Foo, Foo> = Ok(Foo);
|
||||
|
|
@ -40,9 +41,11 @@ fn main() {
|
|||
Ok(Foo)
|
||||
}
|
||||
assert!(get_ok().is_ok());
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test macro ok
|
||||
assert!(get_ok_macro!().is_ok());
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test ok that shouldn't be moved
|
||||
let r: Result<CopyFoo, DebugFoo> = Ok(CopyFoo);
|
||||
|
|
@ -56,12 +59,14 @@ fn main() {
|
|||
// test ok that is copied
|
||||
let r: Result<CopyFoo, CopyFoo> = Ok(CopyFoo);
|
||||
assert!(r.is_ok());
|
||||
//~^ assertions_on_result_states
|
||||
r.unwrap();
|
||||
|
||||
// test reference to ok
|
||||
let r: Result<CopyFoo, CopyFoo> = Ok(CopyFoo);
|
||||
fn test_ref_copy_ok(r: &Result<CopyFoo, CopyFoo>) {
|
||||
assert!(r.is_ok());
|
||||
//~^ assertions_on_result_states
|
||||
}
|
||||
test_ref_copy_ok(&r);
|
||||
r.unwrap();
|
||||
|
|
@ -70,6 +75,7 @@ fn main() {
|
|||
let r: Result<DebugFoo, Foo> = Err(Foo);
|
||||
debug_assert!(r.is_err());
|
||||
assert!(r.is_err());
|
||||
//~^ assertions_on_result_states
|
||||
|
||||
// test err with non-debug value type
|
||||
let r: Result<Foo, Foo> = Err(Foo);
|
||||
|
|
@ -80,4 +86,5 @@ fn main() {
|
|||
fn issue9450() {
|
||||
let res: Result<i32, i32> = Ok(1);
|
||||
assert!(res.is_err())
|
||||
//~^ assertions_on_result_states
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,37 +8,37 @@ LL | assert!(r.is_ok());
|
|||
= help: to override `-D warnings` add `#[allow(clippy::assertions_on_result_states)]`
|
||||
|
||||
error: called `assert!` with `Result::is_ok`
|
||||
--> tests/ui/assertions_on_result_states.rs:42:5
|
||||
--> tests/ui/assertions_on_result_states.rs:43:5
|
||||
|
|
||||
LL | assert!(get_ok().is_ok());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()`
|
||||
|
||||
error: called `assert!` with `Result::is_ok`
|
||||
--> tests/ui/assertions_on_result_states.rs:45:5
|
||||
--> tests/ui/assertions_on_result_states.rs:47:5
|
||||
|
|
||||
LL | assert!(get_ok_macro!().is_ok());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()`
|
||||
|
||||
error: called `assert!` with `Result::is_ok`
|
||||
--> tests/ui/assertions_on_result_states.rs:58:5
|
||||
--> tests/ui/assertions_on_result_states.rs:61:5
|
||||
|
|
||||
LL | assert!(r.is_ok());
|
||||
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
|
||||
|
||||
error: called `assert!` with `Result::is_ok`
|
||||
--> tests/ui/assertions_on_result_states.rs:64:9
|
||||
--> tests/ui/assertions_on_result_states.rs:68:9
|
||||
|
|
||||
LL | assert!(r.is_ok());
|
||||
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
|
||||
|
||||
error: called `assert!` with `Result::is_err`
|
||||
--> tests/ui/assertions_on_result_states.rs:72:5
|
||||
--> tests/ui/assertions_on_result_states.rs:77:5
|
||||
|
|
||||
LL | assert!(r.is_err());
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`
|
||||
|
||||
error: called `assert!` with `Result::is_err`
|
||||
--> tests/ui/assertions_on_result_states.rs:82:5
|
||||
--> tests/ui/assertions_on_result_states.rs:88:5
|
||||
|
|
||||
LL | assert!(res.is_err())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`
|
||||
|
|
|
|||
|
|
@ -5,25 +5,36 @@ use core::num::Wrapping;
|
|||
fn main() {
|
||||
let mut a = 5;
|
||||
a += 1;
|
||||
//~^ assign_op_pattern
|
||||
a += 1;
|
||||
//~^ assign_op_pattern
|
||||
a -= 1;
|
||||
//~^ assign_op_pattern
|
||||
a *= 99;
|
||||
//~^ assign_op_pattern
|
||||
a *= 42;
|
||||
//~^ assign_op_pattern
|
||||
a /= 2;
|
||||
//~^ assign_op_pattern
|
||||
a %= 5;
|
||||
//~^ assign_op_pattern
|
||||
a &= 1;
|
||||
//~^ assign_op_pattern
|
||||
a = 1 - a;
|
||||
a = 5 / a;
|
||||
a = 42 % a;
|
||||
a = 6 << a;
|
||||
let mut s = String::new();
|
||||
s += "bla";
|
||||
//~^ assign_op_pattern
|
||||
|
||||
// Issue #9180
|
||||
let mut a = Wrapping(0u32);
|
||||
a += Wrapping(1u32);
|
||||
//~^ assign_op_pattern
|
||||
let mut v = vec![0u32, 1u32];
|
||||
v[0] += v[1];
|
||||
//~^ assign_op_pattern
|
||||
let mut v = vec![Wrapping(0u32), Wrapping(1u32)];
|
||||
v[0] = v[0] + v[1];
|
||||
let _ = || v[0] = v[0] + v[1];
|
||||
|
|
|
|||
|
|
@ -5,25 +5,36 @@ use core::num::Wrapping;
|
|||
fn main() {
|
||||
let mut a = 5;
|
||||
a = a + 1;
|
||||
//~^ assign_op_pattern
|
||||
a = 1 + a;
|
||||
//~^ assign_op_pattern
|
||||
a = a - 1;
|
||||
//~^ assign_op_pattern
|
||||
a = a * 99;
|
||||
//~^ assign_op_pattern
|
||||
a = 42 * a;
|
||||
//~^ assign_op_pattern
|
||||
a = a / 2;
|
||||
//~^ assign_op_pattern
|
||||
a = a % 5;
|
||||
//~^ assign_op_pattern
|
||||
a = a & 1;
|
||||
//~^ assign_op_pattern
|
||||
a = 1 - a;
|
||||
a = 5 / a;
|
||||
a = 42 % a;
|
||||
a = 6 << a;
|
||||
let mut s = String::new();
|
||||
s = s + "bla";
|
||||
//~^ assign_op_pattern
|
||||
|
||||
// Issue #9180
|
||||
let mut a = Wrapping(0u32);
|
||||
a = a + Wrapping(1u32);
|
||||
//~^ assign_op_pattern
|
||||
let mut v = vec![0u32, 1u32];
|
||||
v[0] = v[0] + v[1];
|
||||
//~^ assign_op_pattern
|
||||
let mut v = vec![Wrapping(0u32), Wrapping(1u32)];
|
||||
v[0] = v[0] + v[1];
|
||||
let _ = || v[0] = v[0] + v[1];
|
||||
|
|
|
|||
|
|
@ -8,61 +8,61 @@ LL | a = a + 1;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::assign_op_pattern)]`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:8:5
|
||||
--> tests/ui/assign_ops.rs:9:5
|
||||
|
|
||||
LL | a = 1 + a;
|
||||
| ^^^^^^^^^ help: replace it with: `a += 1`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:9:5
|
||||
--> tests/ui/assign_ops.rs:11:5
|
||||
|
|
||||
LL | a = a - 1;
|
||||
| ^^^^^^^^^ help: replace it with: `a -= 1`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:10:5
|
||||
--> tests/ui/assign_ops.rs:13:5
|
||||
|
|
||||
LL | a = a * 99;
|
||||
| ^^^^^^^^^^ help: replace it with: `a *= 99`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:11:5
|
||||
--> tests/ui/assign_ops.rs:15:5
|
||||
|
|
||||
LL | a = 42 * a;
|
||||
| ^^^^^^^^^^ help: replace it with: `a *= 42`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:12:5
|
||||
--> tests/ui/assign_ops.rs:17:5
|
||||
|
|
||||
LL | a = a / 2;
|
||||
| ^^^^^^^^^ help: replace it with: `a /= 2`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:13:5
|
||||
--> tests/ui/assign_ops.rs:19:5
|
||||
|
|
||||
LL | a = a % 5;
|
||||
| ^^^^^^^^^ help: replace it with: `a %= 5`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:14:5
|
||||
--> tests/ui/assign_ops.rs:21:5
|
||||
|
|
||||
LL | a = a & 1;
|
||||
| ^^^^^^^^^ help: replace it with: `a &= 1`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:20:5
|
||||
--> tests/ui/assign_ops.rs:28:5
|
||||
|
|
||||
LL | s = s + "bla";
|
||||
| ^^^^^^^^^^^^^ help: replace it with: `s += "bla"`
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops.rs:24:5
|
||||
--> tests/ui/assign_ops.rs:33: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:26:5
|
||||
--> tests/ui/assign_ops.rs:36:5
|
||||
|
|
||||
LL | v[0] = v[0] + v[1];
|
||||
| ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]`
|
||||
|
|
|
|||
|
|
@ -6,24 +6,32 @@
|
|||
fn main() {
|
||||
let mut a = 5;
|
||||
a += a + 1;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~| NOTE: `-D clippy::misrefactored-assign-op` implied by `-D warnings`
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a += 1 + a;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a -= a - 1;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= a * 99;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= 42 * a;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a /= a / 2;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a %= a % 5;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a &= a & 1;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a *= a * a;
|
||||
//~^ ERROR: variable appears on both sides of an assignment operation
|
||||
//~^ misrefactored_assign_op
|
||||
|
||||
a = a * a * a;
|
||||
a = a * 42 * a;
|
||||
a = a * 2 + a;
|
||||
|
|
@ -61,8 +69,7 @@ fn cow_add_assign() {
|
|||
|
||||
// this can be linted
|
||||
buf = buf + cows.clone();
|
||||
//~^ ERROR: manual implementation of an assign operation
|
||||
//~| NOTE: `-D clippy::assign-op-pattern` implied by `-D warnings`
|
||||
//~^ assign_op_pattern
|
||||
|
||||
// this should not as cow<str> Add is not commutative
|
||||
buf = cows + buf;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ LL + a = a + 1 + a;
|
|||
|
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> tests/ui/assign_ops2.rs:13:5
|
||||
--> tests/ui/assign_ops2.rs:14: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:15:5
|
||||
--> tests/ui/assign_ops2.rs:17: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:17:5
|
||||
--> tests/ui/assign_ops2.rs:20: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:19:5
|
||||
--> tests/ui/assign_ops2.rs:23: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:21:5
|
||||
--> tests/ui/assign_ops2.rs:26: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:23:5
|
||||
--> tests/ui/assign_ops2.rs:29: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:25:5
|
||||
--> tests/ui/assign_ops2.rs:32:5
|
||||
|
|
||||
LL | a *= a * a;
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -154,7 +154,7 @@ LL + a = a * a * a;
|
|||
|
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> tests/ui/assign_ops2.rs:63:5
|
||||
--> tests/ui/assign_ops2.rs:71:5
|
||||
|
|
||||
LL | buf = buf + cows.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()`
|
||||
|
|
|
|||
|
|
@ -23,60 +23,73 @@ impl Clone for HasCloneFrom {
|
|||
|
||||
fn clone_method_rhs_val(mut_thing: &mut HasCloneFrom, value_thing: HasCloneFrom) {
|
||||
mut_thing.clone_from(&value_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_rhs_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing.clone_from(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing.clone_from(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(&mut mut_thing, ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_through_trait(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_through_type(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_fully_qualified(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_lhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be kept as necessary for a receiver
|
||||
(mut_thing + &mut HasCloneFrom).clone_from(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_rhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be removed since they are not needed in a function argument
|
||||
mut_thing.clone_from(ref_thing + ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_macro() {
|
||||
let mut s = String::from("");
|
||||
s.clone_from(&format!("{} {}", "hello", "world"));
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_macro() {
|
||||
let mut s = String::from("");
|
||||
Clone::clone_from(&mut s, &format!("{} {}", "hello", "world"));
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn assign_to_init_mut_var(b: HasCloneFrom) -> HasCloneFrom {
|
||||
let mut a = HasCloneFrom;
|
||||
for _ in 1..10 {
|
||||
a.clone_from(&b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
a
|
||||
}
|
||||
|
|
@ -148,6 +161,7 @@ fn ignore_generic_clone<T: Clone>(a: &mut T, b: &T) {
|
|||
#[clippy::msrv = "1.62"]
|
||||
fn msrv_1_62(mut a: String, b: String, c: &str) {
|
||||
a.clone_from(&b);
|
||||
//~^ assigning_clones
|
||||
// Should not be linted, as clone_into wasn't stabilized until 1.63
|
||||
a = c.to_owned();
|
||||
}
|
||||
|
|
@ -155,7 +169,9 @@ fn msrv_1_62(mut a: String, b: String, c: &str) {
|
|||
#[clippy::msrv = "1.63"]
|
||||
fn msrv_1_63(mut a: String, b: String, c: &str) {
|
||||
a.clone_from(&b);
|
||||
//~^ assigning_clones
|
||||
c.clone_into(&mut a);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
macro_rules! clone_inside {
|
||||
|
|
@ -186,35 +202,43 @@ impl Clone for AvoidRecursiveCloneFrom {
|
|||
// Deref handling
|
||||
fn clone_into_deref_method(mut a: DerefWrapper<HasCloneFrom>, b: HasCloneFrom) {
|
||||
(*a).clone_from(&b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_deref_with_clone_method(mut a: DerefWrapperWithClone<HasCloneFrom>, b: HasCloneFrom) {
|
||||
(*a).clone_from(&b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_box_method(mut a: Box<HasCloneFrom>, b: HasCloneFrom) {
|
||||
(*a).clone_from(&b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_self_deref_method(a: &mut DerefWrapperWithClone<HasCloneFrom>, b: DerefWrapperWithClone<HasCloneFrom>) {
|
||||
a.clone_from(&b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_deref_function(mut a: DerefWrapper<HasCloneFrom>, b: HasCloneFrom) {
|
||||
Clone::clone_from(&mut *a, &b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_box_function(mut a: Box<HasCloneFrom>, b: HasCloneFrom) {
|
||||
Clone::clone_from(&mut *a, &b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
// ToOwned
|
||||
fn owned_method_mut_ref(mut_string: &mut String, ref_str: &str) {
|
||||
ref_str.clone_into(mut_string);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_method_val(mut mut_string: String, ref_str: &str) {
|
||||
ref_str.clone_into(&mut mut_string);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
struct HasDeref {
|
||||
|
|
@ -236,28 +260,34 @@ impl DerefMut for HasDeref {
|
|||
|
||||
fn owned_method_box(mut_box_string: &mut Box<String>, ref_str: &str) {
|
||||
ref_str.clone_into(&mut (*mut_box_string));
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_method_deref(mut_box_string: &mut HasDeref, ref_str: &str) {
|
||||
ref_str.clone_into(&mut (*mut_box_string));
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_function_mut_ref(mut_thing: &mut String, ref_str: &str) {
|
||||
ToOwned::clone_into(ref_str, mut_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_function_val(mut mut_thing: String, ref_str: &str) {
|
||||
ToOwned::clone_into(ref_str, &mut mut_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_method_macro() {
|
||||
let mut s = String::from("");
|
||||
format!("{} {}", "hello", "world").clone_into(&mut s);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_function_macro() {
|
||||
let mut s = String::from("");
|
||||
ToOwned::clone_into(&format!("{} {}", "hello", "world"), &mut s);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
struct FakeToOwned;
|
||||
|
|
|
|||
|
|
@ -23,60 +23,73 @@ impl Clone for HasCloneFrom {
|
|||
|
||||
fn clone_method_rhs_val(mut_thing: &mut HasCloneFrom, value_thing: HasCloneFrom) {
|
||||
*mut_thing = value_thing.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_rhs_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = ref_thing.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing = ref_thing.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = Clone::clone(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing = Clone::clone(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_through_trait(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = Clone::clone(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_through_type(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = HasCloneFrom::clone(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_fully_qualified(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = <HasCloneFrom as Clone>::clone(ref_thing);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_lhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be kept as necessary for a receiver
|
||||
*(mut_thing + &mut HasCloneFrom) = ref_thing.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_rhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be removed since they are not needed in a function argument
|
||||
*mut_thing = (ref_thing + ref_thing).clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_method_macro() {
|
||||
let mut s = String::from("");
|
||||
s = format!("{} {}", "hello", "world").clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_function_macro() {
|
||||
let mut s = String::from("");
|
||||
s = Clone::clone(&format!("{} {}", "hello", "world"));
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn assign_to_init_mut_var(b: HasCloneFrom) -> HasCloneFrom {
|
||||
let mut a = HasCloneFrom;
|
||||
for _ in 1..10 {
|
||||
a = b.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
a
|
||||
}
|
||||
|
|
@ -148,6 +161,7 @@ fn ignore_generic_clone<T: Clone>(a: &mut T, b: &T) {
|
|||
#[clippy::msrv = "1.62"]
|
||||
fn msrv_1_62(mut a: String, b: String, c: &str) {
|
||||
a = b.clone();
|
||||
//~^ assigning_clones
|
||||
// Should not be linted, as clone_into wasn't stabilized until 1.63
|
||||
a = c.to_owned();
|
||||
}
|
||||
|
|
@ -155,7 +169,9 @@ fn msrv_1_62(mut a: String, b: String, c: &str) {
|
|||
#[clippy::msrv = "1.63"]
|
||||
fn msrv_1_63(mut a: String, b: String, c: &str) {
|
||||
a = b.clone();
|
||||
//~^ assigning_clones
|
||||
a = c.to_owned();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
macro_rules! clone_inside {
|
||||
|
|
@ -186,35 +202,43 @@ impl Clone for AvoidRecursiveCloneFrom {
|
|||
// Deref handling
|
||||
fn clone_into_deref_method(mut a: DerefWrapper<HasCloneFrom>, b: HasCloneFrom) {
|
||||
*a = b.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_deref_with_clone_method(mut a: DerefWrapperWithClone<HasCloneFrom>, b: HasCloneFrom) {
|
||||
*a = b.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_box_method(mut a: Box<HasCloneFrom>, b: HasCloneFrom) {
|
||||
*a = b.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_self_deref_method(a: &mut DerefWrapperWithClone<HasCloneFrom>, b: DerefWrapperWithClone<HasCloneFrom>) {
|
||||
*a = b.clone();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_deref_function(mut a: DerefWrapper<HasCloneFrom>, b: HasCloneFrom) {
|
||||
*a = Clone::clone(&b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn clone_into_box_function(mut a: Box<HasCloneFrom>, b: HasCloneFrom) {
|
||||
*a = Clone::clone(&b);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
// ToOwned
|
||||
fn owned_method_mut_ref(mut_string: &mut String, ref_str: &str) {
|
||||
*mut_string = ref_str.to_owned();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_method_val(mut mut_string: String, ref_str: &str) {
|
||||
mut_string = ref_str.to_owned();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
struct HasDeref {
|
||||
|
|
@ -236,28 +260,34 @@ impl DerefMut for HasDeref {
|
|||
|
||||
fn owned_method_box(mut_box_string: &mut Box<String>, ref_str: &str) {
|
||||
**mut_box_string = ref_str.to_owned();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_method_deref(mut_box_string: &mut HasDeref, ref_str: &str) {
|
||||
**mut_box_string = ref_str.to_owned();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_function_mut_ref(mut_thing: &mut String, ref_str: &str) {
|
||||
*mut_thing = ToOwned::to_owned(ref_str);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_function_val(mut mut_thing: String, ref_str: &str) {
|
||||
mut_thing = ToOwned::to_owned(ref_str);
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_method_macro() {
|
||||
let mut s = String::from("");
|
||||
s = format!("{} {}", "hello", "world").to_owned();
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
fn owned_function_macro() {
|
||||
let mut s = String::from("");
|
||||
s = ToOwned::to_owned(&format!("{} {}", "hello", "world"));
|
||||
//~^ assigning_clones
|
||||
}
|
||||
|
||||
struct FakeToOwned;
|
||||
|
|
|
|||
|
|
@ -8,175 +8,175 @@ LL | *mut_thing = value_thing.clone();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::assigning_clones)]`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:29:5
|
||||
--> tests/ui/assigning_clones.rs:30:5
|
||||
|
|
||||
LL | *mut_thing = ref_thing.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `mut_thing.clone_from(ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:33:5
|
||||
--> tests/ui/assigning_clones.rs:35:5
|
||||
|
|
||||
LL | mut_thing = ref_thing.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `mut_thing.clone_from(ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:37:5
|
||||
--> tests/ui/assigning_clones.rs:40:5
|
||||
|
|
||||
LL | *mut_thing = Clone::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:41:5
|
||||
--> tests/ui/assigning_clones.rs:45:5
|
||||
|
|
||||
LL | mut_thing = Clone::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(&mut mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:45:5
|
||||
--> tests/ui/assigning_clones.rs:50:5
|
||||
|
|
||||
LL | *mut_thing = Clone::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:49:5
|
||||
--> tests/ui/assigning_clones.rs:55:5
|
||||
|
|
||||
LL | *mut_thing = HasCloneFrom::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:53:5
|
||||
--> tests/ui/assigning_clones.rs:60:5
|
||||
|
|
||||
LL | *mut_thing = <HasCloneFrom as Clone>::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:58:5
|
||||
--> tests/ui/assigning_clones.rs:66:5
|
||||
|
|
||||
LL | *(mut_thing + &mut HasCloneFrom) = ref_thing.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `(mut_thing + &mut HasCloneFrom).clone_from(ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:63:5
|
||||
--> tests/ui/assigning_clones.rs:72:5
|
||||
|
|
||||
LL | *mut_thing = (ref_thing + ref_thing).clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `mut_thing.clone_from(ref_thing + ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:68:5
|
||||
--> tests/ui/assigning_clones.rs:78:5
|
||||
|
|
||||
LL | s = format!("{} {}", "hello", "world").clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `s.clone_from(&format!("{} {}", "hello", "world"))`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:73:5
|
||||
--> tests/ui/assigning_clones.rs:84:5
|
||||
|
|
||||
LL | s = Clone::clone(&format!("{} {}", "hello", "world"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(&mut s, &format!("{} {}", "hello", "world"))`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:79:9
|
||||
--> tests/ui/assigning_clones.rs:91:9
|
||||
|
|
||||
LL | a = b.clone();
|
||||
| ^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:150:5
|
||||
--> tests/ui/assigning_clones.rs:163:5
|
||||
|
|
||||
LL | a = b.clone();
|
||||
| ^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:157:5
|
||||
--> tests/ui/assigning_clones.rs:171:5
|
||||
|
|
||||
LL | a = b.clone();
|
||||
| ^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:158:5
|
||||
--> tests/ui/assigning_clones.rs:173:5
|
||||
|
|
||||
LL | a = c.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^ help: use `clone_into()`: `c.clone_into(&mut a)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:188:5
|
||||
--> tests/ui/assigning_clones.rs:204:5
|
||||
|
|
||||
LL | *a = b.clone();
|
||||
| ^^^^^^^^^^^^^^ help: use `clone_from()`: `(*a).clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:192:5
|
||||
--> tests/ui/assigning_clones.rs:209:5
|
||||
|
|
||||
LL | *a = b.clone();
|
||||
| ^^^^^^^^^^^^^^ help: use `clone_from()`: `(*a).clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:196:5
|
||||
--> tests/ui/assigning_clones.rs:214:5
|
||||
|
|
||||
LL | *a = b.clone();
|
||||
| ^^^^^^^^^^^^^^ help: use `clone_from()`: `(*a).clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:200:5
|
||||
--> tests/ui/assigning_clones.rs:219:5
|
||||
|
|
||||
LL | *a = b.clone();
|
||||
| ^^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:204:5
|
||||
--> tests/ui/assigning_clones.rs:224:5
|
||||
|
|
||||
LL | *a = Clone::clone(&b);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(&mut *a, &b)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:208:5
|
||||
--> tests/ui/assigning_clones.rs:229:5
|
||||
|
|
||||
LL | *a = Clone::clone(&b);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(&mut *a, &b)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:213:5
|
||||
--> tests/ui/assigning_clones.rs:235:5
|
||||
|
|
||||
LL | *mut_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(mut_string)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:217:5
|
||||
--> tests/ui/assigning_clones.rs:240:5
|
||||
|
|
||||
LL | mut_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut mut_string)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:238:5
|
||||
--> tests/ui/assigning_clones.rs:262:5
|
||||
|
|
||||
LL | **mut_box_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut (*mut_box_string))`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:242:5
|
||||
--> tests/ui/assigning_clones.rs:267:5
|
||||
|
|
||||
LL | **mut_box_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut (*mut_box_string))`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:246:5
|
||||
--> tests/ui/assigning_clones.rs:272:5
|
||||
|
|
||||
LL | *mut_thing = ToOwned::to_owned(ref_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ToOwned::clone_into(ref_str, mut_thing)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:250:5
|
||||
--> tests/ui/assigning_clones.rs:277:5
|
||||
|
|
||||
LL | mut_thing = ToOwned::to_owned(ref_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ToOwned::clone_into(ref_str, &mut mut_thing)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:255:5
|
||||
--> tests/ui/assigning_clones.rs:283:5
|
||||
|
|
||||
LL | s = format!("{} {}", "hello", "world").to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `format!("{} {}", "hello", "world").clone_into(&mut s)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:260:5
|
||||
--> tests/ui/assigning_clones.rs:289:5
|
||||
|
|
||||
LL | s = ToOwned::to_owned(&format!("{} {}", "hello", "world"));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ToOwned::clone_into(&format!("{} {}", "hello", "world"), &mut s)`
|
||||
|
|
|
|||
|
|
@ -38,9 +38,11 @@ fn main() {
|
|||
3
|
||||
}.await
|
||||
};
|
||||
//~^^^^ async_yields_async
|
||||
let _i = async {
|
||||
CustomFutureType.await
|
||||
};
|
||||
//~^^ async_yields_async
|
||||
let _i = async || {
|
||||
3
|
||||
};
|
||||
|
|
@ -49,10 +51,13 @@ fn main() {
|
|||
3
|
||||
}.await
|
||||
};
|
||||
//~^^^^ async_yields_async
|
||||
let _k = async || {
|
||||
CustomFutureType.await
|
||||
};
|
||||
//~^^ async_yields_async
|
||||
let _l = async || CustomFutureType.await;
|
||||
//~^ async_yields_async
|
||||
let _m = async || {
|
||||
println!("I'm bored");
|
||||
// Some more stuff
|
||||
|
|
@ -60,6 +65,7 @@ fn main() {
|
|||
// Finally something to await
|
||||
CustomFutureType.await
|
||||
};
|
||||
//~^^ async_yields_async
|
||||
let _n = async || custom_future_type_ctor();
|
||||
let _o = async || f();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,9 +38,11 @@ fn main() {
|
|||
3
|
||||
}
|
||||
};
|
||||
//~^^^^ async_yields_async
|
||||
let _i = async {
|
||||
CustomFutureType
|
||||
};
|
||||
//~^^ async_yields_async
|
||||
let _i = async || {
|
||||
3
|
||||
};
|
||||
|
|
@ -49,10 +51,13 @@ fn main() {
|
|||
3
|
||||
}
|
||||
};
|
||||
//~^^^^ async_yields_async
|
||||
let _k = async || {
|
||||
CustomFutureType
|
||||
};
|
||||
//~^^ async_yields_async
|
||||
let _l = async || CustomFutureType;
|
||||
//~^ async_yields_async
|
||||
let _m = async || {
|
||||
println!("I'm bored");
|
||||
// Some more stuff
|
||||
|
|
@ -60,6 +65,7 @@ fn main() {
|
|||
// Finally something to await
|
||||
CustomFutureType
|
||||
};
|
||||
//~^^ async_yields_async
|
||||
let _n = async || custom_future_type_ctor();
|
||||
let _o = async || f();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ LL ~ }.await
|
|||
|
|
||||
|
||||
error: an async construct yields a type which is itself awaitable
|
||||
--> tests/ui/async_yields_async.rs:42:9
|
||||
--> tests/ui/async_yields_async.rs:43:9
|
||||
|
|
||||
LL | let _i = async {
|
||||
| ____________________-
|
||||
|
|
@ -33,7 +33,7 @@ LL | | };
|
|||
| |_____- outer async construct
|
||||
|
||||
error: an async construct yields a type which is itself awaitable
|
||||
--> tests/ui/async_yields_async.rs:48:9
|
||||
--> tests/ui/async_yields_async.rs:50:9
|
||||
|
|
||||
LL | let _j = async || {
|
||||
| ________________________-
|
||||
|
|
@ -52,7 +52,7 @@ LL ~ }.await
|
|||
|
|
||||
|
||||
error: an async construct yields a type which is itself awaitable
|
||||
--> tests/ui/async_yields_async.rs:53:9
|
||||
--> tests/ui/async_yields_async.rs:56:9
|
||||
|
|
||||
LL | let _k = async || {
|
||||
| _______________________-
|
||||
|
|
@ -65,7 +65,7 @@ LL | | };
|
|||
| |_____- outer async construct
|
||||
|
||||
error: an async construct yields a type which is itself awaitable
|
||||
--> tests/ui/async_yields_async.rs:55:23
|
||||
--> tests/ui/async_yields_async.rs:59:23
|
||||
|
|
||||
LL | let _l = async || CustomFutureType;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
@ -75,7 +75,7 @@ LL | let _l = async || CustomFutureType;
|
|||
| help: consider awaiting this value: `CustomFutureType.await`
|
||||
|
||||
error: an async construct yields a type which is itself awaitable
|
||||
--> tests/ui/async_yields_async.rs:61:9
|
||||
--> tests/ui/async_yields_async.rs:66:9
|
||||
|
|
||||
LL | let _m = async || {
|
||||
| _______________________-
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
#![allow(clippy::missing_docs_in_private_items, clippy::panic, clippy::unreachable)]
|
||||
|
||||
#[inline(always)]
|
||||
//~^ ERROR: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a b
|
||||
//~| NOTE: `-D clippy::inline-always` implied by `-D warnings`
|
||||
//~^ inline_always
|
||||
fn test_attr_lint() {
|
||||
assert!(true)
|
||||
}
|
||||
|
|
@ -25,12 +24,11 @@ fn empty_and_false_positive_stmt() {
|
|||
}
|
||||
|
||||
#[deprecated(since = "forever")]
|
||||
//~^ ERROR: the since field must contain a semver-compliant version
|
||||
//~| NOTE: `-D clippy::deprecated-semver` implied by `-D warnings`
|
||||
//~^ deprecated_semver
|
||||
pub const SOME_CONST: u8 = 42;
|
||||
|
||||
#[deprecated(since = "1")]
|
||||
//~^ ERROR: the since field must contain a semver-compliant version
|
||||
//~^ deprecated_semver
|
||||
pub const ANOTHER_CONST: u8 = 23;
|
||||
|
||||
#[deprecated(since = "0.1.1")]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: the since field must contain a semver-compliant version
|
||||
--> tests/ui/attrs.rs:27:14
|
||||
--> tests/ui/attrs.rs:26:14
|
||||
|
|
||||
LL | #[deprecated(since = "forever")]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -8,7 +8,7 @@ LL | #[deprecated(since = "forever")]
|
|||
= help: to override `-D warnings` add `#[allow(clippy::deprecated_semver)]`
|
||||
|
||||
error: the since field must contain a semver-compliant version
|
||||
--> tests/ui/attrs.rs:32:14
|
||||
--> tests/ui/attrs.rs:30:14
|
||||
|
|
||||
LL | #[deprecated(since = "1")]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
fn main() {
|
||||
#[clippy::author]
|
||||
let x: char = 0x45 as char;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//@ check-pass
|
||||
//@edition:2018
|
||||
|
||||
#![allow(redundant_semicolons, clippy::no_effect)]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
fn main() {
|
||||
#[clippy::author]
|
||||
let _ = ::std::cmp::min(3, 4);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#[allow(clippy::all)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::zero_ptr)]
|
||||
#![allow(clippy::transmute_ptr_to_ref)]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![allow(
|
||||
clippy::never_loop,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
fn main() {
|
||||
#[clippy::author]
|
||||
let print_text = |x| println!("{}", x);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#![allow(clippy::let_and_return)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#[allow(clippy::no_effect)]
|
||||
fn main() {
|
||||
#[clippy::author]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@ check-pass
|
||||
|
||||
#![allow(
|
||||
clippy::unnecessary_operation,
|
||||
clippy::single_match,
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@ use std::cell::RefCell;
|
|||
|
||||
async fn bad(x: &RefCell<u32>) -> u32 {
|
||||
let b = x.borrow();
|
||||
//~^ ERROR: this `RefCell` reference is held across an await point
|
||||
//~^ await_holding_refcell_ref
|
||||
|
||||
baz().await
|
||||
}
|
||||
|
||||
async fn bad_mut(x: &RefCell<u32>) -> u32 {
|
||||
let b = x.borrow_mut();
|
||||
//~^ ERROR: this `RefCell` reference is held across an await point
|
||||
//~^ await_holding_refcell_ref
|
||||
|
||||
baz().await
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ async fn also_bad(x: &RefCell<u32>) -> u32 {
|
|||
let first = baz().await;
|
||||
|
||||
let b = x.borrow_mut();
|
||||
//~^ ERROR: this `RefCell` reference is held across an await point
|
||||
//~^ await_holding_refcell_ref
|
||||
|
||||
let second = baz().await;
|
||||
|
||||
|
|
@ -45,7 +47,7 @@ async fn less_bad(x: &RefCell<u32>) -> u32 {
|
|||
let first = baz().await;
|
||||
|
||||
let b = x.borrow_mut();
|
||||
//~^ ERROR: this `RefCell` reference is held across an await point
|
||||
//~^ await_holding_refcell_ref
|
||||
|
||||
let second = baz().await;
|
||||
|
||||
|
|
@ -61,7 +63,8 @@ async fn not_good(x: &RefCell<u32>) -> u32 {
|
|||
|
||||
let second = {
|
||||
let b = x.borrow_mut();
|
||||
//~^ ERROR: this `RefCell` reference is held across an await point
|
||||
//~^ await_holding_refcell_ref
|
||||
|
||||
baz().await
|
||||
};
|
||||
|
||||
|
|
@ -74,7 +77,8 @@ async fn not_good(x: &RefCell<u32>) -> u32 {
|
|||
fn block_bad(x: &RefCell<u32>) -> impl std::future::Future<Output = u32> + '_ {
|
||||
async move {
|
||||
let b = x.borrow_mut();
|
||||
//~^ ERROR: this `RefCell` reference is held across an await point
|
||||
//~^ await_holding_refcell_ref
|
||||
|
||||
baz().await
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ LL | let b = x.borrow();
|
|||
|
|
||||
= help: ensure the reference is dropped before calling `await`
|
||||
note: these are all the await points this reference is held through
|
||||
--> tests/ui/await_holding_refcell_ref.rs:8:11
|
||||
--> tests/ui/await_holding_refcell_ref.rs:9:11
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
|
@ -14,27 +14,27 @@ LL | baz().await
|
|||
= help: to override `-D warnings` add `#[allow(clippy::await_holding_refcell_ref)]`
|
||||
|
||||
error: this `RefCell` reference is held across an await point
|
||||
--> tests/ui/await_holding_refcell_ref.rs:12:9
|
||||
--> tests/ui/await_holding_refcell_ref.rs:13:9
|
||||
|
|
||||
LL | let b = x.borrow_mut();
|
||||
| ^
|
||||
|
|
||||
= help: ensure the reference is dropped before calling `await`
|
||||
note: these are all the await points this reference is held through
|
||||
--> tests/ui/await_holding_refcell_ref.rs:14:11
|
||||
--> tests/ui/await_holding_refcell_ref.rs:16:11
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `RefCell` reference is held across an await point
|
||||
--> tests/ui/await_holding_refcell_ref.rs:34:9
|
||||
--> tests/ui/await_holding_refcell_ref.rs:36:9
|
||||
|
|
||||
LL | let b = x.borrow_mut();
|
||||
| ^
|
||||
|
|
||||
= help: ensure the reference is dropped before calling `await`
|
||||
note: these are all the await points this reference is held through
|
||||
--> tests/ui/await_holding_refcell_ref.rs:37:24
|
||||
--> tests/ui/await_holding_refcell_ref.rs:39:24
|
||||
|
|
||||
LL | let second = baz().await;
|
||||
| ^^^^^
|
||||
|
|
@ -43,40 +43,40 @@ LL | let third = baz().await;
|
|||
| ^^^^^
|
||||
|
||||
error: this `RefCell` reference is held across an await point
|
||||
--> tests/ui/await_holding_refcell_ref.rs:47:9
|
||||
--> tests/ui/await_holding_refcell_ref.rs:49:9
|
||||
|
|
||||
LL | let b = x.borrow_mut();
|
||||
| ^
|
||||
|
|
||||
= help: ensure the reference is dropped before calling `await`
|
||||
note: these are all the await points this reference is held through
|
||||
--> tests/ui/await_holding_refcell_ref.rs:50:24
|
||||
--> tests/ui/await_holding_refcell_ref.rs:52:24
|
||||
|
|
||||
LL | let second = baz().await;
|
||||
| ^^^^^
|
||||
|
||||
error: this `RefCell` reference is held across an await point
|
||||
--> tests/ui/await_holding_refcell_ref.rs:63:13
|
||||
--> tests/ui/await_holding_refcell_ref.rs:65:13
|
||||
|
|
||||
LL | let b = x.borrow_mut();
|
||||
| ^
|
||||
|
|
||||
= help: ensure the reference is dropped before calling `await`
|
||||
note: these are all the await points this reference is held through
|
||||
--> tests/ui/await_holding_refcell_ref.rs:65:15
|
||||
--> tests/ui/await_holding_refcell_ref.rs:68:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
||||
error: this `RefCell` reference is held across an await point
|
||||
--> tests/ui/await_holding_refcell_ref.rs:76:13
|
||||
--> tests/ui/await_holding_refcell_ref.rs:79:13
|
||||
|
|
||||
LL | let b = x.borrow_mut();
|
||||
| ^
|
||||
|
|
||||
= help: ensure the reference is dropped before calling `await`
|
||||
note: these are all the await points this reference is held through
|
||||
--> tests/ui/await_holding_refcell_ref.rs:78:15
|
||||
--> tests/ui/await_holding_refcell_ref.rs:82:15
|
||||
|
|
||||
LL | baz().await
|
||||
| ^^^^^
|
||||
|
|
|
|||
|
|
@ -6,13 +6,16 @@ pub fn main() {
|
|||
let x = Some(5);
|
||||
// the easiest cases
|
||||
let _ = x;
|
||||
//~^ bind_instead_of_map
|
||||
let _ = x.map(|o| o + 1);
|
||||
//~^ bind_instead_of_map
|
||||
// and an easy counter-example
|
||||
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
|
||||
|
||||
// Different type
|
||||
let x: Result<u32, &str> = Ok(1);
|
||||
let _ = x;
|
||||
//~^ bind_instead_of_map
|
||||
}
|
||||
|
||||
pub fn foo() -> Option<String> {
|
||||
|
|
|
|||
|
|
@ -6,13 +6,16 @@ pub fn main() {
|
|||
let x = Some(5);
|
||||
// the easiest cases
|
||||
let _ = x.and_then(Some);
|
||||
//~^ bind_instead_of_map
|
||||
let _ = x.and_then(|o| Some(o + 1));
|
||||
//~^ bind_instead_of_map
|
||||
// and an easy counter-example
|
||||
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
|
||||
|
||||
// Different type
|
||||
let x: Result<u32, &str> = Ok(1);
|
||||
let _ = x.and_then(Ok);
|
||||
//~^ bind_instead_of_map
|
||||
}
|
||||
|
||||
pub fn foo() -> Option<String> {
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ LL | #![deny(clippy::bind_instead_of_map)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
|
||||
--> tests/ui/bind_instead_of_map.rs:9:13
|
||||
--> tests/ui/bind_instead_of_map.rs:10:13
|
||||
|
|
||||
LL | let _ = x.and_then(|o| Some(o + 1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)`
|
||||
|
||||
error: using `Result.and_then(Ok)`, which is a no-op
|
||||
--> tests/ui/bind_instead_of_map.rs:15:13
|
||||
--> tests/ui/bind_instead_of_map.rs:17:13
|
||||
|
|
||||
LL | let _ = x.and_then(Ok);
|
||||
| ^^^^^^^^^^^^^^ help: use the expression directly: `x`
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
pub fn main() {
|
||||
let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
|
||||
//~^ bind_instead_of_map
|
||||
let _ = Some("42").and_then(|s| if s.len() < 42 { None } else { Some(s.len()) });
|
||||
|
||||
let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
|
||||
//~^ bind_instead_of_map
|
||||
let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Err(()) } else { Ok(s.len()) });
|
||||
|
||||
let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 } else { s.len() });
|
||||
//~^ bind_instead_of_map
|
||||
let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Ok(()) } else { Err(s.len()) });
|
||||
|
||||
hard_example();
|
||||
|
|
@ -17,6 +20,7 @@ pub fn main() {
|
|||
|
||||
fn hard_example() {
|
||||
Some("42").map(|s| {
|
||||
//~^ bind_instead_of_map
|
||||
if {
|
||||
if s == "43" {
|
||||
return 43;
|
||||
|
|
@ -58,4 +62,5 @@ macro_rules! m {
|
|||
fn macro_example() {
|
||||
let _ = Some("").and_then(|s| if s.len() == 20 { m!() } else { Some(20) });
|
||||
let _ = Some("").map(|s| if s.len() == 20 { m!() } else { Some(20) });
|
||||
//~^ bind_instead_of_map
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
pub fn main() {
|
||||
let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
|
||||
//~^ bind_instead_of_map
|
||||
let _ = Some("42").and_then(|s| if s.len() < 42 { None } else { Some(s.len()) });
|
||||
|
||||
let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) });
|
||||
//~^ bind_instead_of_map
|
||||
let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Err(()) } else { Ok(s.len()) });
|
||||
|
||||
let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) });
|
||||
//~^ bind_instead_of_map
|
||||
let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Ok(()) } else { Err(s.len()) });
|
||||
|
||||
hard_example();
|
||||
|
|
@ -17,6 +20,7 @@ pub fn main() {
|
|||
|
||||
fn hard_example() {
|
||||
Some("42").and_then(|s| {
|
||||
//~^ bind_instead_of_map
|
||||
if {
|
||||
if s == "43" {
|
||||
return Some(43);
|
||||
|
|
@ -58,4 +62,5 @@ macro_rules! m {
|
|||
fn macro_example() {
|
||||
let _ = Some("").and_then(|s| if s.len() == 20 { m!() } else { Some(20) });
|
||||
let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
|
||||
//~^ bind_instead_of_map
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ LL + let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
|
|||
|
|
||||
|
||||
error: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as `map(|x| y)`
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:8:13
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:9:13
|
||||
|
|
||||
LL | let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -28,7 +28,7 @@ LL + let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len()
|
|||
|
|
||||
|
||||
error: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as `map_err(|x| y)`
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:11:13
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:13:13
|
||||
|
|
||||
LL | let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -40,12 +40,12 @@ LL + let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 }
|
|||
|
|
||||
|
||||
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:19:5
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:22:5
|
||||
|
|
||||
LL | / Some("42").and_then(|s| {
|
||||
LL | |
|
||||
LL | | if {
|
||||
LL | | if s == "43" {
|
||||
LL | | return Some(43);
|
||||
... |
|
||||
LL | | });
|
||||
| |______^
|
||||
|
|
@ -53,6 +53,7 @@ LL | | });
|
|||
help: use `map` instead
|
||||
|
|
||||
LL ~ Some("42").map(|s| {
|
||||
LL |
|
||||
LL | if {
|
||||
LL | if s == "43" {
|
||||
LL ~ return 43;
|
||||
|
|
@ -79,7 +80,7 @@ LL ~ _ => 1,
|
|||
|
|
||||
|
||||
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:60:13
|
||||
--> tests/ui/bind_instead_of_map_multipart.rs:64:13
|
||||
|
|
||||
LL | let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -12,27 +12,29 @@ fn main() {
|
|||
let x = 5;
|
||||
|
||||
x & 0 == 0;
|
||||
//~^ ERROR: &-masking with zero
|
||||
//~| NOTE: `-D clippy::bad-bit-mask` implied by `-D warnings`
|
||||
//~| ERROR: this operation will always return zero. This is likely not the intended ou
|
||||
//~| NOTE: `#[deny(clippy::erasing_op)]` on by default
|
||||
//~^ bad_bit_mask
|
||||
//~| erasing_op
|
||||
|
||||
x & 1 == 1; //ok, distinguishes bit 0
|
||||
x & 1 == 0; //ok, compared with zero
|
||||
x & 2 == 1;
|
||||
//~^ ERROR: incompatible bit mask: `_ & 2` can never be equal to `1`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
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: `_ | 3` can never be equal to `2`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
x & 1 > 1;
|
||||
//~^ ERROR: incompatible bit mask: `_ & 1` will never be higher than `1`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
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: `_ | 2` will always be higher than `1`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
x | 2 <= 2; // ok (if a bit silly), equals x <= 2
|
||||
|
||||
x & 192 == 128; // ok, tests for bit 7 and not bit 6
|
||||
|
|
@ -40,22 +42,26 @@ fn main() {
|
|||
|
||||
// this also now works with constants
|
||||
x & THREE_BITS == 8;
|
||||
//~^ ERROR: incompatible bit mask: `_ & 7` can never be equal to `8`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
x | EVEN_MORE_REDIRECTION < 7;
|
||||
//~^ ERROR: incompatible bit mask: `_ | 7` will never be lower than `7`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
0 & x == 0;
|
||||
//~^ ERROR: &-masking with zero
|
||||
//~| ERROR: this operation will always return zero. This is likely not the intended ou
|
||||
//~^ bad_bit_mask
|
||||
//~| erasing_op
|
||||
|
||||
1 | x > 1;
|
||||
|
||||
// and should now also match uncommon usage
|
||||
1 < 2 | x;
|
||||
//~^ ERROR: incompatible bit mask: `_ | 2` will always be higher than `1`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
2 == 3 | x;
|
||||
//~^ ERROR: incompatible bit mask: `_ | 3` can never be equal to `2`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
1 == x & 2;
|
||||
//~^ ERROR: incompatible bit mask: `_ & 2` can never be equal to `1`
|
||||
//~^ bad_bit_mask
|
||||
|
||||
x | 1 > 2; // no error, because we allowed ineffective bit masks
|
||||
ineffective();
|
||||
|
|
@ -67,14 +73,16 @@ fn ineffective() {
|
|||
let x = 5;
|
||||
|
||||
x | 1 > 3;
|
||||
//~^ ERROR: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared d
|
||||
//~| NOTE: `-D clippy::ineffective-bit-mask` implied by `-D warnings`
|
||||
//~^ ineffective_bit_mask
|
||||
|
||||
x | 1 < 4;
|
||||
//~^ ERROR: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared d
|
||||
//~^ ineffective_bit_mask
|
||||
|
||||
x | 1 <= 3;
|
||||
//~^ ERROR: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared d
|
||||
//~^ ineffective_bit_mask
|
||||
|
||||
x | 1 >= 8;
|
||||
//~^ ERROR: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared d
|
||||
//~^ ineffective_bit_mask
|
||||
|
||||
x | 1 > 2; // not an error (yet), better written as x >= 2
|
||||
x | 1 >= 7; // not an error (yet), better written as x >= 6
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ LL | x & 0 == 0;
|
|||
= note: `#[deny(clippy::erasing_op)]` on by default
|
||||
|
||||
error: incompatible bit mask: `_ & 2` can never be equal to `1`
|
||||
--> tests/ui/bit_masks.rs:21:5
|
||||
--> tests/ui/bit_masks.rs:20:5
|
||||
|
|
||||
LL | x & 2 == 1;
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -34,55 +34,55 @@ LL | x & 1 > 1;
|
|||
| ^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 2` will always be higher than `1`
|
||||
--> tests/ui/bit_masks.rs:34:5
|
||||
--> tests/ui/bit_masks.rs:35:5
|
||||
|
|
||||
LL | x | 2 > 1;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ & 7` can never be equal to `8`
|
||||
--> tests/ui/bit_masks.rs:42:5
|
||||
--> tests/ui/bit_masks.rs:44:5
|
||||
|
|
||||
LL | x & THREE_BITS == 8;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 7` will never be lower than `7`
|
||||
--> tests/ui/bit_masks.rs:44:5
|
||||
--> tests/ui/bit_masks.rs:47:5
|
||||
|
|
||||
LL | x | EVEN_MORE_REDIRECTION < 7;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: &-masking with zero
|
||||
--> tests/ui/bit_masks.rs:47:5
|
||||
--> tests/ui/bit_masks.rs:50:5
|
||||
|
|
||||
LL | 0 & x == 0;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: this operation will always return zero. This is likely not the intended outcome
|
||||
--> tests/ui/bit_masks.rs:47:5
|
||||
--> tests/ui/bit_masks.rs:50:5
|
||||
|
|
||||
LL | 0 & x == 0;
|
||||
| ^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 2` will always be higher than `1`
|
||||
--> tests/ui/bit_masks.rs:53:5
|
||||
--> tests/ui/bit_masks.rs:57:5
|
||||
|
|
||||
LL | 1 < 2 | x;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 3` can never be equal to `2`
|
||||
--> tests/ui/bit_masks.rs:55:5
|
||||
--> tests/ui/bit_masks.rs:60:5
|
||||
|
|
||||
LL | 2 == 3 | x;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ & 2` can never be equal to `1`
|
||||
--> tests/ui/bit_masks.rs:57:5
|
||||
--> tests/ui/bit_masks.rs:63:5
|
||||
|
|
||||
LL | 1 == x & 2;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
|
||||
--> tests/ui/bit_masks.rs:69:5
|
||||
--> tests/ui/bit_masks.rs:75:5
|
||||
|
|
||||
LL | x | 1 > 3;
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -91,19 +91,19 @@ LL | x | 1 > 3;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::ineffective_bit_mask)]`
|
||||
|
||||
error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly
|
||||
--> tests/ui/bit_masks.rs:72:5
|
||||
--> tests/ui/bit_masks.rs:78:5
|
||||
|
|
||||
LL | x | 1 < 4;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
|
||||
--> tests/ui/bit_masks.rs:74:5
|
||||
--> tests/ui/bit_masks.rs:81:5
|
||||
|
|
||||
LL | x | 1 <= 3;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly
|
||||
--> tests/ui/bit_masks.rs:76:5
|
||||
--> tests/ui/bit_masks.rs:84:5
|
||||
|
|
||||
LL | x | 1 >= 8;
|
||||
| ^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
//@compile-flags: -W clippy::restriction
|
||||
//@error-in-other-file: restriction
|
||||
|
||||
#![warn(clippy::blanket_clippy_restriction_lints)]
|
||||
|
||||
//! Test that the whole restriction group is not enabled
|
||||
#![warn(clippy::restriction)]
|
||||
//~^ ERROR: `clippy::restriction` is not meant to be enabled as a group
|
||||
//~^ blanket_clippy_restriction_lints
|
||||
#![deny(clippy::restriction)]
|
||||
//~^ ERROR: `clippy::restriction` is not meant to be enabled as a group
|
||||
//~^ blanket_clippy_restriction_lints
|
||||
#![forbid(clippy::restriction)]
|
||||
//~^ ERROR: `clippy::restriction` is not meant to be enabled as a group
|
||||
//~^ blanket_clippy_restriction_lints
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ error: `clippy::restriction` is not meant to be enabled as a group
|
|||
= help: to override `-D warnings` add `#[allow(clippy::blanket_clippy_restriction_lints)]`
|
||||
|
||||
error: `clippy::restriction` is not meant to be enabled as a group
|
||||
--> tests/ui/blanket_clippy_restriction_lints.rs:6:9
|
||||
--> tests/ui/blanket_clippy_restriction_lints.rs:7:9
|
||||
|
|
||||
LL | #![warn(clippy::restriction)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -14,7 +14,7 @@ LL | #![warn(clippy::restriction)]
|
|||
= help: enable the restriction lints you need individually
|
||||
|
||||
error: `clippy::restriction` is not meant to be enabled as a group
|
||||
--> tests/ui/blanket_clippy_restriction_lints.rs:8:9
|
||||
--> tests/ui/blanket_clippy_restriction_lints.rs:9:9
|
||||
|
|
||||
LL | #![deny(clippy::restriction)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -22,7 +22,7 @@ LL | #![deny(clippy::restriction)]
|
|||
= help: enable the restriction lints you need individually
|
||||
|
||||
error: `clippy::restriction` is not meant to be enabled as a group
|
||||
--> tests/ui/blanket_clippy_restriction_lints.rs:10:11
|
||||
--> tests/ui/blanket_clippy_restriction_lints.rs:11:11
|
||||
|
|
||||
LL | #![forbid(clippy::restriction)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ fn condition_has_block_with_single_expression() -> i32 {
|
|||
fn condition_is_normal() -> i32 {
|
||||
let x = 3;
|
||||
if x == 3 { 6 } else { 10 }
|
||||
//~^ nonminimal_bool
|
||||
}
|
||||
|
||||
fn condition_is_unsafe_block() {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ fn condition_has_block_with_single_expression() -> i32 {
|
|||
fn condition_is_normal() -> i32 {
|
||||
let x = 3;
|
||||
if true && x == 3 { 6 } else { 10 }
|
||||
//~^ nonminimal_bool
|
||||
}
|
||||
|
||||
fn condition_is_unsafe_block() {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ LL | if true && x == 3 { 6 } else { 10 }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
|
||||
|
||||
error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
|
||||
--> tests/ui/blocks_in_conditions.rs:75:5
|
||||
--> tests/ui/blocks_in_conditions.rs:76:5
|
||||
|
|
||||
LL | / match {
|
||||
LL | |
|
||||
|
|
|
|||
|
|
@ -85,65 +85,90 @@ fn main() {
|
|||
|
||||
assert_eq!("a".len(), 1);
|
||||
assert!(!"a".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!(a!(), b!());
|
||||
assert_eq!(a!(), "".is_empty());
|
||||
assert_eq!("".is_empty(), b!());
|
||||
assert_eq!(a, true);
|
||||
assert!(b);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
assert_ne!("a".len(), 1);
|
||||
assert!("a".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert!(!"".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert!(!"".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert_ne!(a!(), b!());
|
||||
assert_ne!(a!(), "".is_empty());
|
||||
assert_ne!("".is_empty(), b!());
|
||||
assert_ne!(a, true);
|
||||
assert!(!b);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
debug_assert_eq!("a".len(), 1);
|
||||
debug_assert!(!"a".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!(a!(), b!());
|
||||
debug_assert_eq!(a!(), "".is_empty());
|
||||
debug_assert_eq!("".is_empty(), b!());
|
||||
debug_assert_eq!(a, true);
|
||||
debug_assert!(b);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
debug_assert_ne!("a".len(), 1);
|
||||
debug_assert!("a".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!(!"".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!(!"".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_ne!(a!(), b!());
|
||||
debug_assert_ne!(a!(), "".is_empty());
|
||||
debug_assert_ne!("".is_empty(), b!());
|
||||
debug_assert_ne!(a, true);
|
||||
debug_assert!(!b);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
// assert with error messages
|
||||
assert_eq!("a".len(), 1, "tadam {}", 1);
|
||||
assert_eq!("a".len(), 1, "tadam {}", true);
|
||||
assert!(!"a".is_empty(), "tadam {}", 1);
|
||||
//~^ bool_assert_comparison
|
||||
assert!(!"a".is_empty(), "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
assert!(!"a".is_empty(), "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!(a, true, "tadam {}", false);
|
||||
|
||||
debug_assert_eq!("a".len(), 1, "tadam {}", 1);
|
||||
debug_assert_eq!("a".len(), 1, "tadam {}", true);
|
||||
debug_assert!(!"a".is_empty(), "tadam {}", 1);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!(!"a".is_empty(), "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!(!"a".is_empty(), "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!(a, true, "tadam {}", false);
|
||||
|
||||
assert!(a!());
|
||||
//~^ bool_assert_comparison
|
||||
assert!(b!());
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
use debug_assert_eq as renamed;
|
||||
renamed!(a, true);
|
||||
debug_assert!(b);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
let non_copy = NonCopy;
|
||||
assert_eq!(non_copy, true);
|
||||
|
|
@ -158,12 +183,20 @@ fn main() {
|
|||
in_macro!(a);
|
||||
|
||||
assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert!(!"requires negation".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert!(!"requires negation".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
debug_assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!("".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!(!"requires negation".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert!(!"requires negation".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,65 +85,90 @@ fn main() {
|
|||
|
||||
assert_eq!("a".len(), 1);
|
||||
assert_eq!("a".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!("".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!(true, "".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!(a!(), b!());
|
||||
assert_eq!(a!(), "".is_empty());
|
||||
assert_eq!("".is_empty(), b!());
|
||||
assert_eq!(a, true);
|
||||
assert_eq!(b, true);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
assert_ne!("a".len(), 1);
|
||||
assert_ne!("a".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
assert_ne!("".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_ne!(true, "".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
assert_ne!(a!(), b!());
|
||||
assert_ne!(a!(), "".is_empty());
|
||||
assert_ne!("".is_empty(), b!());
|
||||
assert_ne!(a, true);
|
||||
assert_ne!(b, true);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
debug_assert_eq!("a".len(), 1);
|
||||
debug_assert_eq!("a".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!("".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!(true, "".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!(a!(), b!());
|
||||
debug_assert_eq!(a!(), "".is_empty());
|
||||
debug_assert_eq!("".is_empty(), b!());
|
||||
debug_assert_eq!(a, true);
|
||||
debug_assert_eq!(b, true);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
debug_assert_ne!("a".len(), 1);
|
||||
debug_assert_ne!("a".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_ne!("".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_ne!(true, "".is_empty());
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_ne!(a!(), b!());
|
||||
debug_assert_ne!(a!(), "".is_empty());
|
||||
debug_assert_ne!("".is_empty(), b!());
|
||||
debug_assert_ne!(a, true);
|
||||
debug_assert_ne!(b, true);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
// assert with error messages
|
||||
assert_eq!("a".len(), 1, "tadam {}", 1);
|
||||
assert_eq!("a".len(), 1, "tadam {}", true);
|
||||
assert_eq!("a".is_empty(), false, "tadam {}", 1);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!("a".is_empty(), false, "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!(false, "a".is_empty(), "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!(a, true, "tadam {}", false);
|
||||
|
||||
debug_assert_eq!("a".len(), 1, "tadam {}", 1);
|
||||
debug_assert_eq!("a".len(), 1, "tadam {}", true);
|
||||
debug_assert_eq!("a".is_empty(), false, "tadam {}", 1);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!("a".is_empty(), false, "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!(false, "a".is_empty(), "tadam {}", true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!(a, true, "tadam {}", false);
|
||||
|
||||
assert_eq!(a!(), true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!(true, b!());
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
use debug_assert_eq as renamed;
|
||||
renamed!(a, true);
|
||||
renamed!(b, true);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
let non_copy = NonCopy;
|
||||
assert_eq!(non_copy, true);
|
||||
|
|
@ -158,12 +183,20 @@ fn main() {
|
|||
in_macro!(a);
|
||||
|
||||
assert_eq!("".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_ne!("".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
assert_ne!("requires negation".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
assert_eq!("requires negation".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
|
||||
debug_assert_eq!("".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_ne!("".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_ne!("requires negation".is_empty(), true);
|
||||
//~^ bool_assert_comparison
|
||||
debug_assert_eq!("requires negation".is_empty(), false);
|
||||
//~^ bool_assert_comparison
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ LL + assert!(!"a".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:88:5
|
||||
--> tests/ui/bool_assert_comparison.rs:89:5
|
||||
|
|
||||
LL | assert_eq!("".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL + assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:89:5
|
||||
--> tests/ui/bool_assert_comparison.rs:91:5
|
||||
|
|
||||
LL | assert_eq!(true, "".is_empty());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -37,7 +37,7 @@ LL + assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:94:5
|
||||
--> tests/ui/bool_assert_comparison.rs:97:5
|
||||
|
|
||||
LL | assert_eq!(b, true);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -49,7 +49,7 @@ LL + assert!(b);
|
|||
|
|
||||
|
||||
error: used `assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:97:5
|
||||
--> tests/ui/bool_assert_comparison.rs:101:5
|
||||
|
|
||||
LL | assert_ne!("a".is_empty(), false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -61,7 +61,7 @@ LL + assert!("a".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:98:5
|
||||
--> tests/ui/bool_assert_comparison.rs:103:5
|
||||
|
|
||||
LL | assert_ne!("".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -73,7 +73,7 @@ LL + assert!(!"".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:99:5
|
||||
--> tests/ui/bool_assert_comparison.rs:105:5
|
||||
|
|
||||
LL | assert_ne!(true, "".is_empty());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -85,7 +85,7 @@ LL + assert!(!"".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:104:5
|
||||
--> tests/ui/bool_assert_comparison.rs:111:5
|
||||
|
|
||||
LL | assert_ne!(b, true);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -97,7 +97,7 @@ LL + assert!(!b);
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:107:5
|
||||
--> tests/ui/bool_assert_comparison.rs:115:5
|
||||
|
|
||||
LL | debug_assert_eq!("a".is_empty(), false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -109,7 +109,7 @@ LL + debug_assert!(!"a".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:108:5
|
||||
--> tests/ui/bool_assert_comparison.rs:117:5
|
||||
|
|
||||
LL | debug_assert_eq!("".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -121,7 +121,7 @@ LL + debug_assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:109:5
|
||||
--> tests/ui/bool_assert_comparison.rs:119:5
|
||||
|
|
||||
LL | debug_assert_eq!(true, "".is_empty());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -133,7 +133,7 @@ LL + debug_assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:114:5
|
||||
--> tests/ui/bool_assert_comparison.rs:125:5
|
||||
|
|
||||
LL | debug_assert_eq!(b, true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -145,7 +145,7 @@ LL + debug_assert!(b);
|
|||
|
|
||||
|
||||
error: used `debug_assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:117:5
|
||||
--> tests/ui/bool_assert_comparison.rs:129:5
|
||||
|
|
||||
LL | debug_assert_ne!("a".is_empty(), false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -157,7 +157,7 @@ LL + debug_assert!("a".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:118:5
|
||||
--> tests/ui/bool_assert_comparison.rs:131:5
|
||||
|
|
||||
LL | debug_assert_ne!("".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -169,7 +169,7 @@ LL + debug_assert!(!"".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:119:5
|
||||
--> tests/ui/bool_assert_comparison.rs:133:5
|
||||
|
|
||||
LL | debug_assert_ne!(true, "".is_empty());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -181,7 +181,7 @@ LL + debug_assert!(!"".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:124:5
|
||||
--> tests/ui/bool_assert_comparison.rs:139:5
|
||||
|
|
||||
LL | debug_assert_ne!(b, true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -193,7 +193,7 @@ LL + debug_assert!(!b);
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:129:5
|
||||
--> tests/ui/bool_assert_comparison.rs:145:5
|
||||
|
|
||||
LL | assert_eq!("a".is_empty(), false, "tadam {}", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -205,7 +205,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", 1);
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:130:5
|
||||
--> tests/ui/bool_assert_comparison.rs:147:5
|
||||
|
|
||||
LL | assert_eq!("a".is_empty(), false, "tadam {}", true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -217,7 +217,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", true);
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:131:5
|
||||
--> tests/ui/bool_assert_comparison.rs:149:5
|
||||
|
|
||||
LL | assert_eq!(false, "a".is_empty(), "tadam {}", true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -229,7 +229,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", true);
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:136:5
|
||||
--> tests/ui/bool_assert_comparison.rs:155:5
|
||||
|
|
||||
LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -241,7 +241,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", 1);
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:137:5
|
||||
--> tests/ui/bool_assert_comparison.rs:157:5
|
||||
|
|
||||
LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -253,7 +253,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", true);
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:138:5
|
||||
--> tests/ui/bool_assert_comparison.rs:159:5
|
||||
|
|
||||
LL | debug_assert_eq!(false, "a".is_empty(), "tadam {}", true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -265,7 +265,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", true);
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:141:5
|
||||
--> tests/ui/bool_assert_comparison.rs:163:5
|
||||
|
|
||||
LL | assert_eq!(a!(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -277,7 +277,7 @@ LL + assert!(a!());
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:142:5
|
||||
--> tests/ui/bool_assert_comparison.rs:165:5
|
||||
|
|
||||
LL | assert_eq!(true, b!());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -289,7 +289,7 @@ LL + assert!(b!());
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:146:5
|
||||
--> tests/ui/bool_assert_comparison.rs:170:5
|
||||
|
|
||||
LL | renamed!(b, true);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -301,7 +301,7 @@ LL + debug_assert!(b);
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:160:5
|
||||
--> tests/ui/bool_assert_comparison.rs:185:5
|
||||
|
|
||||
LL | assert_eq!("".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -313,7 +313,7 @@ LL + assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:161:5
|
||||
--> tests/ui/bool_assert_comparison.rs:187:5
|
||||
|
|
||||
LL | assert_ne!("".is_empty(), false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -325,7 +325,7 @@ LL + assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:162:5
|
||||
--> tests/ui/bool_assert_comparison.rs:189:5
|
||||
|
|
||||
LL | assert_ne!("requires negation".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -337,7 +337,7 @@ LL + assert!(!"requires negation".is_empty());
|
|||
|
|
||||
|
||||
error: used `assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:163:5
|
||||
--> tests/ui/bool_assert_comparison.rs:191:5
|
||||
|
|
||||
LL | assert_eq!("requires negation".is_empty(), false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -349,7 +349,7 @@ LL + assert!(!"requires negation".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:165:5
|
||||
--> tests/ui/bool_assert_comparison.rs:194:5
|
||||
|
|
||||
LL | debug_assert_eq!("".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -361,7 +361,7 @@ LL + debug_assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:166:5
|
||||
--> tests/ui/bool_assert_comparison.rs:196:5
|
||||
|
|
||||
LL | debug_assert_ne!("".is_empty(), false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -373,7 +373,7 @@ LL + debug_assert!("".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_ne!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:167:5
|
||||
--> tests/ui/bool_assert_comparison.rs:198:5
|
||||
|
|
||||
LL | debug_assert_ne!("requires negation".is_empty(), true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -385,7 +385,7 @@ LL + debug_assert!(!"requires negation".is_empty());
|
|||
|
|
||||
|
||||
error: used `debug_assert_eq!` with a literal bool
|
||||
--> tests/ui/bool_assert_comparison.rs:168:5
|
||||
--> tests/ui/bool_assert_comparison.rs:200:5
|
||||
|
|
||||
LL | debug_assert_eq!("requires negation".is_empty(), false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -5,72 +5,86 @@
|
|||
fn main() {
|
||||
let x = true;
|
||||
if x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if !x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if !x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if !x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if !x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if !x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if !x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
let y = true;
|
||||
if !x & y {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x & !y {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
|
|
@ -119,12 +133,16 @@ fn issue4983() {
|
|||
let b = false;
|
||||
|
||||
if a != b {};
|
||||
//~^ bool_comparison
|
||||
if a != b {};
|
||||
//~^ bool_comparison
|
||||
if a == b {};
|
||||
if !a == !b {};
|
||||
|
||||
if b != a {};
|
||||
//~^ bool_comparison
|
||||
if b != a {};
|
||||
//~^ bool_comparison
|
||||
if b == a {};
|
||||
if !b == !a {};
|
||||
}
|
||||
|
|
@ -149,9 +167,13 @@ fn issue3973() {
|
|||
|
||||
// lint, could be simplified
|
||||
if !m!(func) {}
|
||||
//~^ bool_comparison
|
||||
if !m!(func) {}
|
||||
//~^ bool_comparison
|
||||
if m!(func) {}
|
||||
//~^ bool_comparison
|
||||
if m!(func) {}
|
||||
//~^ bool_comparison
|
||||
|
||||
// no lint with a variable
|
||||
let is_debug = false;
|
||||
|
|
@ -169,8 +191,11 @@ fn issue3973() {
|
|||
#[allow(clippy::unnecessary_cast)]
|
||||
fn issue9907() {
|
||||
let _ = (1 >= 2) as usize;
|
||||
//~^ bool_comparison
|
||||
let _ = (!m!(func)) as usize;
|
||||
//~^ bool_comparison
|
||||
// This is not part of the issue, but an unexpected found when fixing the issue,
|
||||
// the provided span was inside of macro rather than the macro callsite.
|
||||
let _ = ((1 < 2) != m!(func)) as usize;
|
||||
//~^ bool_comparison
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,72 +5,86 @@
|
|||
fn main() {
|
||||
let x = true;
|
||||
if x == true {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x == false {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if true == x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if false == x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x != true {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x != false {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if true != x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if false != x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x < true {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if false < x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x > false {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if true > x {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
let y = true;
|
||||
if x < y {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
};
|
||||
if x > y {
|
||||
//~^ bool_comparison
|
||||
"yes"
|
||||
} else {
|
||||
"no"
|
||||
|
|
@ -119,12 +133,16 @@ fn issue4983() {
|
|||
let b = false;
|
||||
|
||||
if a == !b {};
|
||||
//~^ bool_comparison
|
||||
if !a == b {};
|
||||
//~^ bool_comparison
|
||||
if a == b {};
|
||||
if !a == !b {};
|
||||
|
||||
if b == !a {};
|
||||
//~^ bool_comparison
|
||||
if !b == a {};
|
||||
//~^ bool_comparison
|
||||
if b == a {};
|
||||
if !b == !a {};
|
||||
}
|
||||
|
|
@ -149,9 +167,13 @@ fn issue3973() {
|
|||
|
||||
// lint, could be simplified
|
||||
if false == m!(func) {}
|
||||
//~^ bool_comparison
|
||||
if m!(func) == false {}
|
||||
//~^ bool_comparison
|
||||
if true == m!(func) {}
|
||||
//~^ bool_comparison
|
||||
if m!(func) == true {}
|
||||
//~^ bool_comparison
|
||||
|
||||
// no lint with a variable
|
||||
let is_debug = false;
|
||||
|
|
@ -169,8 +191,11 @@ fn issue3973() {
|
|||
#[allow(clippy::unnecessary_cast)]
|
||||
fn issue9907() {
|
||||
let _ = ((1 < 2) == false) as usize;
|
||||
//~^ bool_comparison
|
||||
let _ = (false == m!(func)) as usize;
|
||||
//~^ bool_comparison
|
||||
// This is not part of the issue, but an unexpected found when fixing the issue,
|
||||
// the provided span was inside of macro rather than the macro callsite.
|
||||
let _ = ((1 < 2) == !m!(func)) as usize;
|
||||
//~^ bool_comparison
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,145 +8,145 @@ LL | if x == true {
|
|||
= help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:12:8
|
||||
--> tests/ui/bool_comparison.rs:13:8
|
||||
|
|
||||
LL | if x == false {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> tests/ui/bool_comparison.rs:17:8
|
||||
--> tests/ui/bool_comparison.rs:19:8
|
||||
|
|
||||
LL | if true == x {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:22:8
|
||||
--> tests/ui/bool_comparison.rs:25:8
|
||||
|
|
||||
LL | if false == x {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: inequality checks against true can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:27:8
|
||||
--> tests/ui/bool_comparison.rs:31:8
|
||||
|
|
||||
LL | if x != true {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: inequality checks against false are unnecessary
|
||||
--> tests/ui/bool_comparison.rs:32:8
|
||||
--> tests/ui/bool_comparison.rs:37:8
|
||||
|
|
||||
LL | if x != false {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: inequality checks against true can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:37:8
|
||||
--> tests/ui/bool_comparison.rs:43:8
|
||||
|
|
||||
LL | if true != x {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: inequality checks against false are unnecessary
|
||||
--> tests/ui/bool_comparison.rs:42:8
|
||||
--> tests/ui/bool_comparison.rs:49:8
|
||||
|
|
||||
LL | if false != x {
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: less than comparison against true can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:47:8
|
||||
--> tests/ui/bool_comparison.rs:55:8
|
||||
|
|
||||
LL | if x < true {
|
||||
| ^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: greater than checks against false are unnecessary
|
||||
--> tests/ui/bool_comparison.rs:52:8
|
||||
--> tests/ui/bool_comparison.rs:61:8
|
||||
|
|
||||
LL | if false < x {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: greater than checks against false are unnecessary
|
||||
--> tests/ui/bool_comparison.rs:57:8
|
||||
--> tests/ui/bool_comparison.rs:67:8
|
||||
|
|
||||
LL | if x > false {
|
||||
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
||||
|
||||
error: less than comparison against true can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:62:8
|
||||
--> tests/ui/bool_comparison.rs:73:8
|
||||
|
|
||||
LL | if true > x {
|
||||
| ^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: order comparisons between booleans can be simplified
|
||||
--> tests/ui/bool_comparison.rs:68:8
|
||||
--> tests/ui/bool_comparison.rs:80:8
|
||||
|
|
||||
LL | if x < y {
|
||||
| ^^^^^ help: try simplifying it as shown: `!x & y`
|
||||
|
||||
error: order comparisons between booleans can be simplified
|
||||
--> tests/ui/bool_comparison.rs:73:8
|
||||
--> tests/ui/bool_comparison.rs:86:8
|
||||
|
|
||||
LL | if x > y {
|
||||
| ^^^^^ help: try simplifying it as shown: `x & !y`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> tests/ui/bool_comparison.rs:121:8
|
||||
--> tests/ui/bool_comparison.rs:135:8
|
||||
|
|
||||
LL | if a == !b {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `a != b`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> tests/ui/bool_comparison.rs:122:8
|
||||
--> tests/ui/bool_comparison.rs:137:8
|
||||
|
|
||||
LL | if !a == b {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `a != b`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> tests/ui/bool_comparison.rs:126:8
|
||||
--> tests/ui/bool_comparison.rs:142:8
|
||||
|
|
||||
LL | if b == !a {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `b != a`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> tests/ui/bool_comparison.rs:127:8
|
||||
--> tests/ui/bool_comparison.rs:144:8
|
||||
|
|
||||
LL | if !b == a {};
|
||||
| ^^^^^^^ help: try simplifying it as shown: `b != a`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:151:8
|
||||
--> tests/ui/bool_comparison.rs:169:8
|
||||
|
|
||||
LL | if false == m!(func) {}
|
||||
| ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:152:8
|
||||
--> tests/ui/bool_comparison.rs:171:8
|
||||
|
|
||||
LL | if m!(func) == false {}
|
||||
| ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> tests/ui/bool_comparison.rs:153:8
|
||||
--> tests/ui/bool_comparison.rs:173:8
|
||||
|
|
||||
LL | if true == m!(func) {}
|
||||
| ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> tests/ui/bool_comparison.rs:154:8
|
||||
--> tests/ui/bool_comparison.rs:175:8
|
||||
|
|
||||
LL | if m!(func) == true {}
|
||||
| ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:171:14
|
||||
--> tests/ui/bool_comparison.rs:193:14
|
||||
|
|
||||
LL | let _ = ((1 < 2) == false) as usize;
|
||||
| ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `1 >= 2`
|
||||
|
||||
error: equality checks against false can be replaced by a negation
|
||||
--> tests/ui/bool_comparison.rs:172:14
|
||||
--> tests/ui/bool_comparison.rs:195:14
|
||||
|
|
||||
LL | let _ = (false == m!(func)) as usize;
|
||||
| ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> tests/ui/bool_comparison.rs:175:14
|
||||
--> tests/ui/bool_comparison.rs:199:14
|
||||
|
|
||||
LL | let _ = ((1 < 2) == !m!(func)) as usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `(1 < 2) != m!(func)`
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ fn main() {
|
|||
// Lint returns and type inference
|
||||
fn some_fn(a: bool) -> u8 {
|
||||
u8::from(a)
|
||||
//~^ bool_to_int_with_if
|
||||
}
|
||||
|
||||
fn side_effect() {}
|
||||
|
|
|
|||
|
|
@ -12,31 +12,37 @@ fn main() {
|
|||
// Should lint
|
||||
// precedence
|
||||
if a {
|
||||
//~^ bool_to_int_with_if
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
if a {
|
||||
//~^ bool_to_int_with_if
|
||||
0
|
||||
} else {
|
||||
1
|
||||
};
|
||||
if !a {
|
||||
//~^ bool_to_int_with_if
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
if a || b {
|
||||
//~^ bool_to_int_with_if
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
if cond(a, b) {
|
||||
//~^ bool_to_int_with_if
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
if x + y < 4 {
|
||||
//~^ bool_to_int_with_if
|
||||
1
|
||||
} else {
|
||||
0
|
||||
|
|
@ -46,6 +52,7 @@ fn main() {
|
|||
if a {
|
||||
123
|
||||
} else if b {
|
||||
//~^ bool_to_int_with_if
|
||||
1
|
||||
} else {
|
||||
0
|
||||
|
|
@ -55,6 +62,7 @@ fn main() {
|
|||
if a {
|
||||
123
|
||||
} else if b {
|
||||
//~^ bool_to_int_with_if
|
||||
0
|
||||
} else {
|
||||
1
|
||||
|
|
@ -120,6 +128,7 @@ fn main() {
|
|||
// Lint returns and type inference
|
||||
fn some_fn(a: bool) -> u8 {
|
||||
if a { 1 } else { 0 }
|
||||
//~^ bool_to_int_with_if
|
||||
}
|
||||
|
||||
fn side_effect() {}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ error: boolean to int conversion using if
|
|||
--> tests/ui/bool_to_int_with_if.rs:14:5
|
||||
|
|
||||
LL | / if a {
|
||||
LL | |
|
||||
LL | | 1
|
||||
LL | | } else {
|
||||
LL | | 0
|
||||
|
|
@ -13,9 +14,10 @@ LL | | };
|
|||
= help: to override `-D warnings` add `#[allow(clippy::bool_to_int_with_if)]`
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:19:5
|
||||
--> tests/ui/bool_to_int_with_if.rs:20:5
|
||||
|
|
||||
LL | / if a {
|
||||
LL | |
|
||||
LL | | 0
|
||||
LL | | } else {
|
||||
LL | | 1
|
||||
|
|
@ -25,9 +27,10 @@ LL | | };
|
|||
= note: `!a as i32` or `(!a).into()` can also be valid options
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:24:5
|
||||
--> tests/ui/bool_to_int_with_if.rs:26:5
|
||||
|
|
||||
LL | / if !a {
|
||||
LL | |
|
||||
LL | | 1
|
||||
LL | | } else {
|
||||
LL | | 0
|
||||
|
|
@ -37,9 +40,10 @@ LL | | };
|
|||
= note: `!a as i32` or `(!a).into()` can also be valid options
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:29:5
|
||||
--> tests/ui/bool_to_int_with_if.rs:32:5
|
||||
|
|
||||
LL | / if a || b {
|
||||
LL | |
|
||||
LL | | 1
|
||||
LL | | } else {
|
||||
LL | | 0
|
||||
|
|
@ -49,9 +53,10 @@ LL | | };
|
|||
= note: `(a || b) as i32` or `(a || b).into()` can also be valid options
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:34:5
|
||||
--> tests/ui/bool_to_int_with_if.rs:38:5
|
||||
|
|
||||
LL | / if cond(a, b) {
|
||||
LL | |
|
||||
LL | | 1
|
||||
LL | | } else {
|
||||
LL | | 0
|
||||
|
|
@ -61,9 +66,10 @@ LL | | };
|
|||
= note: `cond(a, b) as i32` or `cond(a, b).into()` can also be valid options
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:39:5
|
||||
--> tests/ui/bool_to_int_with_if.rs:44:5
|
||||
|
|
||||
LL | / if x + y < 4 {
|
||||
LL | |
|
||||
LL | | 1
|
||||
LL | | } else {
|
||||
LL | | 0
|
||||
|
|
@ -73,10 +79,11 @@ LL | | };
|
|||
= note: `(x + y < 4) as i32` or `(x + y < 4).into()` can also be valid options
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:48:12
|
||||
--> tests/ui/bool_to_int_with_if.rs:54:12
|
||||
|
|
||||
LL | } else if b {
|
||||
| ____________^
|
||||
LL | |
|
||||
LL | | 1
|
||||
LL | | } else {
|
||||
LL | | 0
|
||||
|
|
@ -86,10 +93,11 @@ LL | | };
|
|||
= note: `b as i32` or `b.into()` can also be valid options
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:57:12
|
||||
--> tests/ui/bool_to_int_with_if.rs:64:12
|
||||
|
|
||||
LL | } else if b {
|
||||
| ____________^
|
||||
LL | |
|
||||
LL | | 0
|
||||
LL | | } else {
|
||||
LL | | 1
|
||||
|
|
@ -99,7 +107,7 @@ LL | | };
|
|||
= note: `!b as i32` or `(!b).into()` can also be valid options
|
||||
|
||||
error: boolean to int conversion using if
|
||||
--> tests/ui/bool_to_int_with_if.rs:122:5
|
||||
--> tests/ui/bool_to_int_with_if.rs:130:5
|
||||
|
|
||||
LL | if a { 1 } else { 0 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(a)`
|
||||
|
|
|
|||
|
|
@ -7,5 +7,7 @@ fn f<T>(_: T) {}
|
|||
fn main() {
|
||||
let mut val = 0;
|
||||
f(&raw const val);
|
||||
//~^ borrow_as_ptr
|
||||
f(&raw mut val);
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,7 @@ fn f<T>(_: T) {}
|
|||
fn main() {
|
||||
let mut val = 0;
|
||||
f(&val as *const _);
|
||||
//~^ borrow_as_ptr
|
||||
f(&mut val as *mut i32);
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ LL | f(&val as *const _);
|
|||
= help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]`
|
||||
|
||||
error: borrow as raw pointer
|
||||
--> tests/ui/borrow_and_ref_as_ptr.rs:10:7
|
||||
--> tests/ui/borrow_and_ref_as_ptr.rs:11:7
|
||||
|
|
||||
LL | f(&mut val as *mut i32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `&raw mut val`
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ fn a() -> i32 {
|
|||
fn main() {
|
||||
let val = 1;
|
||||
let _p = std::ptr::addr_of!(val);
|
||||
//~^ borrow_as_ptr
|
||||
let _p = &0 as *const i32;
|
||||
let _p = &a() as *const i32;
|
||||
let vec = vec![1];
|
||||
|
|
@ -16,12 +17,15 @@ fn main() {
|
|||
|
||||
let mut val_mut = 1;
|
||||
let _p_mut = std::ptr::addr_of_mut!(val_mut);
|
||||
//~^ borrow_as_ptr
|
||||
|
||||
let mut x: [i32; 2] = [42, 43];
|
||||
let _raw = std::ptr::addr_of_mut!(x[1]).wrapping_offset(-1);
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
||||
fn issue_13882() {
|
||||
let mut x: [i32; 2] = [42, 43];
|
||||
let _raw = (&raw mut x[1]).wrapping_offset(-1);
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ fn a() -> i32 {
|
|||
fn main() {
|
||||
let val = 1;
|
||||
let _p = &val as *const i32;
|
||||
//~^ borrow_as_ptr
|
||||
let _p = &0 as *const i32;
|
||||
let _p = &a() as *const i32;
|
||||
let vec = vec![1];
|
||||
|
|
@ -16,12 +17,15 @@ fn main() {
|
|||
|
||||
let mut val_mut = 1;
|
||||
let _p_mut = &mut val_mut as *mut i32;
|
||||
//~^ borrow_as_ptr
|
||||
|
||||
let mut x: [i32; 2] = [42, 43];
|
||||
let _raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
||||
fn issue_13882() {
|
||||
let mut x: [i32; 2] = [42, 43];
|
||||
let _raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@ LL | let _p = &val as *const i32;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]`
|
||||
|
||||
error: borrow as raw pointer
|
||||
--> tests/ui/borrow_as_ptr.rs:18:18
|
||||
--> tests/ui/borrow_as_ptr.rs:19:18
|
||||
|
|
||||
LL | let _p_mut = &mut val_mut as *mut i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(val_mut)`
|
||||
|
||||
error: borrow as raw pointer
|
||||
--> tests/ui/borrow_as_ptr.rs:21:16
|
||||
--> tests/ui/borrow_as_ptr.rs:23:16
|
||||
|
|
||||
LL | let _raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(x[1])`
|
||||
|
||||
error: borrow as raw pointer
|
||||
--> tests/ui/borrow_as_ptr.rs:26:17
|
||||
--> tests/ui/borrow_as_ptr.rs:29:17
|
||||
|
|
||||
LL | let _raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `&raw mut x[1]`
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@
|
|||
pub fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
let val = 1;
|
||||
let _p = core::ptr::addr_of!(val);
|
||||
//~^ borrow_as_ptr
|
||||
|
||||
let mut val_mut = 1;
|
||||
let _p_mut = core::ptr::addr_of_mut!(val_mut);
|
||||
//~^ borrow_as_ptr
|
||||
0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@
|
|||
pub fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
let val = 1;
|
||||
let _p = &val as *const i32;
|
||||
//~^ borrow_as_ptr
|
||||
|
||||
let mut val_mut = 1;
|
||||
let _p_mut = &mut val_mut as *mut i32;
|
||||
//~^ borrow_as_ptr
|
||||
0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ LL | let _p = &val as *const i32;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]`
|
||||
|
||||
error: borrow as raw pointer
|
||||
--> tests/ui/borrow_as_ptr_no_std.rs:11:18
|
||||
--> tests/ui/borrow_as_ptr_no_std.rs:12:18
|
||||
|
|
||||
LL | let _p_mut = &mut val_mut as *mut i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of_mut!(val_mut)`
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ fn a() -> i32 {
|
|||
fn main() {
|
||||
let val = 1;
|
||||
let _p = &raw const val;
|
||||
//~^ borrow_as_ptr
|
||||
let _p = &0 as *const i32;
|
||||
let _p = &a() as *const i32;
|
||||
let vec = vec![1];
|
||||
|
|
@ -16,4 +17,5 @@ fn main() {
|
|||
|
||||
let mut val_mut = 1;
|
||||
let _p_mut = &raw mut val_mut;
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ fn a() -> i32 {
|
|||
fn main() {
|
||||
let val = 1;
|
||||
let _p = &val as *const i32;
|
||||
//~^ borrow_as_ptr
|
||||
let _p = &0 as *const i32;
|
||||
let _p = &a() as *const i32;
|
||||
let vec = vec![1];
|
||||
|
|
@ -16,4 +17,5 @@ fn main() {
|
|||
|
||||
let mut val_mut = 1;
|
||||
let _p_mut = &mut val_mut as *mut i32;
|
||||
//~^ borrow_as_ptr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ LL | let _p = &val as *const i32;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::borrow_as_ptr)]`
|
||||
|
||||
error: borrow as raw pointer
|
||||
--> tests/ui/borrow_as_ptr_raw_ref.rs:18:18
|
||||
--> tests/ui/borrow_as_ptr_raw_ref.rs:19:18
|
||||
|
|
||||
LL | let _p_mut = &mut val_mut as *mut i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&raw mut val_mut`
|
||||
|
|
|
|||
|
|
@ -23,17 +23,17 @@ pub fn test1(foo: &mut Box<bool>) {
|
|||
|
||||
pub fn test2() {
|
||||
let foo: &bool;
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
}
|
||||
|
||||
struct Test3<'a> {
|
||||
foo: &'a bool,
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
}
|
||||
|
||||
trait Test4 {
|
||||
fn test4(a: &bool);
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
}
|
||||
|
||||
use std::any::Any;
|
||||
|
|
@ -94,24 +94,28 @@ pub fn test13(boxed_slice: &mut Box<[i32]>) {
|
|||
|
||||
// The suggestion should include proper parentheses to avoid a syntax error.
|
||||
pub fn test14(_display: &dyn Display) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test15(_display: &(dyn Display + Send)) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test16<'a>(_display: &'a (dyn Display + 'a)) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test17(_display: &impl Display) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test18(_display: &(impl Display + Send)) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test19<'a>(_display: &'a (impl Display + 'a)) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
// This exists only to check what happens when parentheses are already present.
|
||||
// Even though the current implementation doesn't put extra parentheses,
|
||||
// it's fine that unnecessary parentheses appear in the future for some reason.
|
||||
pub fn test20(_display: &(dyn Display + Send)) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
#[allow(clippy::borrowed_box)]
|
||||
trait Trait {
|
||||
|
|
|
|||
|
|
@ -23,17 +23,17 @@ pub fn test1(foo: &mut Box<bool>) {
|
|||
|
||||
pub fn test2() {
|
||||
let foo: &Box<bool>;
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
}
|
||||
|
||||
struct Test3<'a> {
|
||||
foo: &'a Box<bool>,
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
}
|
||||
|
||||
trait Test4 {
|
||||
fn test4(a: &Box<bool>);
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
}
|
||||
|
||||
use std::any::Any;
|
||||
|
|
@ -94,24 +94,28 @@ pub fn test13(boxed_slice: &mut Box<[i32]>) {
|
|||
|
||||
// The suggestion should include proper parentheses to avoid a syntax error.
|
||||
pub fn test14(_display: &Box<dyn Display>) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test15(_display: &Box<dyn Display + Send>) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test17(_display: &Box<impl Display>) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test18(_display: &Box<impl Display + Send>) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
// This exists only to check what happens when parentheses are already present.
|
||||
// Even though the current implementation doesn't put extra parentheses,
|
||||
// it's fine that unnecessary parentheses appear in the future for some reason.
|
||||
pub fn test20(_display: &Box<(dyn Display + Send)>) {}
|
||||
//~^ ERROR: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
//~^ borrowed_box
|
||||
|
||||
#[allow(clippy::borrowed_box)]
|
||||
trait Trait {
|
||||
|
|
|
|||
|
|
@ -29,37 +29,37 @@ LL | pub fn test14(_display: &Box<dyn Display>) {}
|
|||
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> tests/ui/borrow_box.rs:98:25
|
||||
--> tests/ui/borrow_box.rs:99:25
|
||||
|
|
||||
LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> tests/ui/borrow_box.rs:100:29
|
||||
--> tests/ui/borrow_box.rs:102:29
|
||||
|
|
||||
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> tests/ui/borrow_box.rs:103:25
|
||||
--> tests/ui/borrow_box.rs:105:25
|
||||
|
|
||||
LL | pub fn test17(_display: &Box<impl Display>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> tests/ui/borrow_box.rs:105:25
|
||||
--> tests/ui/borrow_box.rs:108:25
|
||||
|
|
||||
LL | pub fn test18(_display: &Box<impl Display + Send>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> tests/ui/borrow_box.rs:107:29
|
||||
--> tests/ui/borrow_box.rs:111:29
|
||||
|
|
||||
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`
|
||||
|
||||
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
||||
--> tests/ui/borrow_box.rs:113:25
|
||||
--> tests/ui/borrow_box.rs:117:25
|
||||
|
|
||||
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ mod should_lint {
|
|||
fn one_help() {
|
||||
let a = &12;
|
||||
let b = a;
|
||||
//~^ borrow_deref_ref
|
||||
|
||||
let b = &mut bar(&12);
|
||||
//~^ borrow_deref_ref
|
||||
}
|
||||
|
||||
fn bar(x: &u32) -> &u32 {
|
||||
|
|
@ -67,6 +69,8 @@ mod false_negative {
|
|||
let x = &12;
|
||||
let addr_x = &x as *const _ as usize;
|
||||
let addr_y = &x as *const _ as usize; // assert ok
|
||||
//
|
||||
//~^^ borrow_deref_ref
|
||||
// let addr_y = &x as *const _ as usize; // assert fail
|
||||
assert_ne!(addr_x, addr_y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ mod should_lint {
|
|||
fn one_help() {
|
||||
let a = &12;
|
||||
let b = &*a;
|
||||
//~^ borrow_deref_ref
|
||||
|
||||
let b = &mut &*bar(&12);
|
||||
//~^ borrow_deref_ref
|
||||
}
|
||||
|
||||
fn bar(x: &u32) -> &u32 {
|
||||
|
|
@ -67,6 +69,8 @@ mod false_negative {
|
|||
let x = &12;
|
||||
let addr_x = &x as *const _ as usize;
|
||||
let addr_y = &&*x as *const _ as usize; // assert ok
|
||||
//
|
||||
//~^^ borrow_deref_ref
|
||||
// let addr_y = &x as *const _ as usize; // assert fail
|
||||
assert_ne!(addr_x, addr_y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ LL | let b = &*a;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::borrow_deref_ref)]`
|
||||
|
||||
error: deref on an immutable reference
|
||||
--> tests/ui/borrow_deref_ref.rs:15:22
|
||||
--> tests/ui/borrow_deref_ref.rs:16:22
|
||||
|
|
||||
LL | let b = &mut &*bar(&12);
|
||||
| ^^^^^^^^^^ help: if you would like to reborrow, try removing `&*`: `bar(&12)`
|
||||
|
||||
error: deref on an immutable reference
|
||||
--> tests/ui/borrow_deref_ref.rs:69:23
|
||||
--> tests/ui/borrow_deref_ref.rs:71:23
|
||||
|
|
||||
LL | let addr_y = &&*x as *const _ as usize; // assert ok
|
||||
| ^^^ help: if you would like to reborrow, try removing `&*`: `x`
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ mod should_lint {
|
|||
fn two_helps() {
|
||||
let s = &String::new();
|
||||
let x: &str = &*s;
|
||||
//~^ ERROR: deref on an immutable reference
|
||||
//~| NOTE: `-D clippy::borrow-deref-ref` implied by `-D warnings`
|
||||
//~^ borrow_deref_ref
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,14 +62,20 @@ mod issue12979 {
|
|||
const CELL_REF: StaticRef<(UnsafeCell<u32>,)> = unsafe { StaticRef::new(std::ptr::null()) };
|
||||
|
||||
fn main() {
|
||||
ATOMIC.store(1, Ordering::SeqCst); //~ ERROR: interior mutability
|
||||
assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR: interior mutability
|
||||
ATOMIC.store(1, Ordering::SeqCst);
|
||||
//~^ borrow_interior_mutable_const
|
||||
assert_eq!(ATOMIC.load(Ordering::SeqCst), 5);
|
||||
//~^ borrow_interior_mutable_const
|
||||
|
||||
let _once = ONCE_INIT;
|
||||
let _once_ref = &ONCE_INIT; //~ ERROR: interior mutability
|
||||
let _once_ref_2 = &&ONCE_INIT; //~ ERROR: interior mutability
|
||||
let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR: interior mutability
|
||||
let _once_mut = &mut ONCE_INIT; //~ ERROR: interior mutability
|
||||
let _once_ref = &ONCE_INIT;
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _once_ref_2 = &&ONCE_INIT;
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _once_ref_4 = &&&&ONCE_INIT;
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _once_mut = &mut ONCE_INIT;
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _atomic_into_inner = ATOMIC.into_inner();
|
||||
// these should be all fine.
|
||||
let _twice = (ONCE_INIT, ONCE_INIT);
|
||||
|
|
@ -80,22 +86,30 @@ fn main() {
|
|||
let _ref_array_once = &[ONCE_INIT, ONCE_INIT][0];
|
||||
|
||||
// referencing projection is still bad.
|
||||
let _ = &ATOMIC_TUPLE; //~ ERROR: interior mutability
|
||||
let _ = &ATOMIC_TUPLE.0; //~ ERROR: interior mutability
|
||||
let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR: interior mutability
|
||||
let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR: interior mutability
|
||||
let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR: interior mutability
|
||||
let _ = &ATOMIC_TUPLE;
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _ = &ATOMIC_TUPLE.0;
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _ = &(&&&&ATOMIC_TUPLE).0;
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _ = &ATOMIC_TUPLE.0[0];
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst);
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _ = &ATOMIC_TUPLE.2;
|
||||
let _ = (&&&&ATOMIC_TUPLE).0;
|
||||
let _ = (&&&&ATOMIC_TUPLE).2;
|
||||
let _ = ATOMIC_TUPLE.0;
|
||||
let _ = ATOMIC_TUPLE.0[0]; //~ ERROR: interior mutability
|
||||
let _ = ATOMIC_TUPLE.0[0];
|
||||
//~^ borrow_interior_mutable_const
|
||||
let _ = ATOMIC_TUPLE.1.into_iter();
|
||||
let _ = ATOMIC_TUPLE.2;
|
||||
let _ = &{ ATOMIC_TUPLE };
|
||||
|
||||
CELL.set(2); //~ ERROR: interior mutability
|
||||
assert_eq!(CELL.get(), 6); //~ ERROR: interior mutability
|
||||
CELL.set(2);
|
||||
//~^ borrow_interior_mutable_const
|
||||
assert_eq!(CELL.get(), 6);
|
||||
//~^ borrow_interior_mutable_const
|
||||
|
||||
assert_eq!(INTEGER, 8);
|
||||
assert!(STRING.is_empty());
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ LL | #![deny(clippy::borrow_interior_mutable_const)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:66:16
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:67:16
|
||||
|
|
||||
LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5);
|
||||
| ^^^^^^
|
||||
|
|
@ -20,7 +20,7 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5);
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:69:22
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:71:22
|
||||
|
|
||||
LL | let _once_ref = &ONCE_INIT;
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -28,7 +28,7 @@ LL | let _once_ref = &ONCE_INIT;
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:70:25
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:73:25
|
||||
|
|
||||
LL | let _once_ref_2 = &&ONCE_INIT;
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -36,7 +36,7 @@ LL | let _once_ref_2 = &&ONCE_INIT;
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:71:27
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:75:27
|
||||
|
|
||||
LL | let _once_ref_4 = &&&&ONCE_INIT;
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -44,7 +44,7 @@ LL | let _once_ref_4 = &&&&ONCE_INIT;
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:72:26
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:77:26
|
||||
|
|
||||
LL | let _once_mut = &mut ONCE_INIT;
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -52,7 +52,7 @@ LL | let _once_mut = &mut ONCE_INIT;
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:83:14
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:89:14
|
||||
|
|
||||
LL | let _ = &ATOMIC_TUPLE;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -60,7 +60,7 @@ LL | let _ = &ATOMIC_TUPLE;
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:84:14
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:91:14
|
||||
|
|
||||
LL | let _ = &ATOMIC_TUPLE.0;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -68,7 +68,7 @@ LL | let _ = &ATOMIC_TUPLE.0;
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:85:19
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:93:19
|
||||
|
|
||||
LL | let _ = &(&&&&ATOMIC_TUPLE).0;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -76,7 +76,7 @@ LL | let _ = &(&&&&ATOMIC_TUPLE).0;
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:86:14
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:95:14
|
||||
|
|
||||
LL | let _ = &ATOMIC_TUPLE.0[0];
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -84,7 +84,7 @@ LL | let _ = &ATOMIC_TUPLE.0[0];
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:87:13
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:97:13
|
||||
|
|
||||
LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -92,7 +92,7 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst);
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:92:13
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:103:13
|
||||
|
|
||||
LL | let _ = ATOMIC_TUPLE.0[0];
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -100,7 +100,7 @@ LL | let _ = ATOMIC_TUPLE.0[0];
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:97:5
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:109:5
|
||||
|
|
||||
LL | CELL.set(2);
|
||||
| ^^^^
|
||||
|
|
@ -108,7 +108,7 @@ LL | CELL.set(2);
|
|||
= help: assign this const to a local or static variable, and use the variable here
|
||||
|
||||
error: a `const` item with interior mutability should not be borrowed
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:98:16
|
||||
--> tests/ui/borrow_interior_mutable_const/others.rs:111:16
|
||||
|
|
||||
LL | assert_eq!(CELL.get(), 6);
|
||||
| ^^^^
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue