c209fc9349
Prior to this change, string_lit_as_bytes would trigger for constructs like `include_str!("filename").as_bytes()` and would recommend fixing it by rewriting as `binclude_str!("filename")`. This change updates the lint to act as an EarlyLintPass lint. It then differentiates between string literals and macros that have bytes yielding alternatives. Closes #3205
65 lines
1.9 KiB
Plaintext
65 lines
1.9 KiB
Plaintext
error: manual implementation of an assign operation
|
|
--> $DIR/strings.rs:20:9
|
|
|
|
|
20 | x = x + ".";
|
|
| ^^^^^^^^^^^ help: replace it with: `x += "."`
|
|
|
|
|
= note: `-D clippy::assign-op-pattern` implied by `-D warnings`
|
|
|
|
error: you added something to a string. Consider using `String::push_str()` instead
|
|
--> $DIR/strings.rs:20:13
|
|
|
|
|
20 | x = x + ".";
|
|
| ^^^^^^^
|
|
|
|
|
= note: `-D clippy::string-add` implied by `-D warnings`
|
|
|
|
error: you added something to a string. Consider using `String::push_str()` instead
|
|
--> $DIR/strings.rs:24:13
|
|
|
|
|
24 | let z = y + "...";
|
|
| ^^^^^^^^^
|
|
|
|
error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead
|
|
--> $DIR/strings.rs:34:9
|
|
|
|
|
34 | x = x + ".";
|
|
| ^^^^^^^^^^^
|
|
|
|
|
= note: `-D clippy::string-add-assign` implied by `-D warnings`
|
|
|
|
error: manual implementation of an assign operation
|
|
--> $DIR/strings.rs:34:9
|
|
|
|
|
34 | x = x + ".";
|
|
| ^^^^^^^^^^^ help: replace it with: `x += "."`
|
|
|
|
error: you assigned the result of adding something to this string. Consider using `String::push_str()` instead
|
|
--> $DIR/strings.rs:48:9
|
|
|
|
|
48 | x = x + ".";
|
|
| ^^^^^^^^^^^
|
|
|
|
error: manual implementation of an assign operation
|
|
--> $DIR/strings.rs:48:9
|
|
|
|
|
48 | x = x + ".";
|
|
| ^^^^^^^^^^^ help: replace it with: `x += "."`
|
|
|
|
error: you added something to a string. Consider using `String::push_str()` instead
|
|
--> $DIR/strings.rs:52:13
|
|
|
|
|
52 | let z = y + "...";
|
|
| ^^^^^^^^^
|
|
|
|
error: calling `as_bytes()` on a string literal
|
|
--> $DIR/strings.rs:60:14
|
|
|
|
|
60 | let bs = "hello there".as_bytes();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using a byte string literal instead: `b"hello there"`
|
|
|
|
|
= note: `-D clippy::string-lit-as-bytes` implied by `-D warnings`
|
|
|
|
error: aborting due to 11 previous errors
|
|
|