-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #7453 - F3real:assume_function_calls_have_side_effect, …
…r=flip1995 Don't report function calls as unnecessary operation if used in array index Attempts to fix: #7412 changelog: Don't report function calls used in indexing as unnecessary operation. [`unnecessary_operation`]
- Loading branch information
Showing
3 changed files
with
94 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,128 @@ | ||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:51:5 | ||
| | ||
LL | Tuple(get_number()); | ||
| ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
| | ||
= note: `-D clippy::unnecessary-operation` implied by `-D warnings` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:52:5 | ||
| | ||
LL | Struct { field: get_number() }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:53:5 | ||
| | ||
LL | Struct { ..get_struct() }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_struct();` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_struct();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:54:5 | ||
| | ||
LL | Enum::Tuple(get_number()); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:55:5 | ||
| | ||
LL | Enum::Struct { field: get_number() }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:56:5 | ||
| | ||
LL | 5 + get_number(); | ||
| ^^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` | ||
| ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:57:5 | ||
| | ||
LL | *&get_number(); | ||
| ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:58:5 | ||
| | ||
LL | &get_number(); | ||
| ^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:59:5 | ||
| | ||
LL | (5, 6, get_number()); | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `5;6;get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;6;get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:60:5 | ||
| | ||
LL | box get_number(); | ||
| ^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:61:5 | ||
| | ||
LL | get_number()..; | ||
| ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:62:5 | ||
| | ||
LL | ..get_number(); | ||
| ^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:63:5 | ||
| | ||
LL | 5..get_number(); | ||
| ^^^^^^^^^^^^^^^^ help: replace it with: `5;get_number();` | ||
| ^^^^^^^^^^^^^^^^ help: statement can be reduced to: `5;get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:64:5 | ||
| | ||
LL | [42, get_number()]; | ||
| ^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:65:5 | ||
| | ||
LL | [42, 55][get_usize()]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42, 55];get_usize();` | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42, 55].len() > get_usize());` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:66:5 | ||
| | ||
LL | (42, get_number()).1; | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `42;get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `42;get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:67:5 | ||
| | ||
LL | [get_number(); 55]; | ||
| ^^^^^^^^^^^^^^^^^^^ help: replace it with: `get_number();` | ||
| ^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:68:5 | ||
| | ||
LL | [42; 55][get_usize()]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `[42; 55];get_usize();` | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: statement can be written as: `assert!([42; 55].len() > get_usize());` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:69:5 | ||
| | ||
LL | / { | ||
LL | | get_number() | ||
LL | | }; | ||
| |______^ help: replace it with: `get_number();` | ||
| |______^ help: statement can be reduced to: `get_number();` | ||
|
||
error: statement can be reduced | ||
error: unnecessary operation | ||
--> $DIR/unnecessary_operation.rs:72:5 | ||
| | ||
LL | / FooString { | ||
LL | | s: String::from("blah"), | ||
LL | | }; | ||
| |______^ help: replace it with: `String::from("blah");` | ||
| |______^ help: statement can be reduced to: `String::from("blah");` | ||
|
||
error: aborting due to 20 previous errors | ||
|