bors
885f97e2ce
Auto merge of #11656 - y21:unnecessary_string_from_utf8, r=Jarcho
...
[`unnecessary_to_owned`]: catch `to_owned` on byte slice to create temporary `&str`
Closes #11648
Detects the pattern `&String::from_utf8(bytes.to_vec()).unwrap()` and suggests `core::str::from_utf8(bytes).unwrap()`, which avoids the unnecessary intermediate allocation.
I decided to put this in the existing `unnecessary_to_owned` lint (rather than creating a new lint) for a few reasons:
- we get to use some of its logic (for example, recognizing any of the functions in the `to_owned` family, e.g. `to_vec`)
- the actual inefficient operation that can be avoided here is the call to `.to_vec()`, so this is in a way similar to the other cases caught by `unnecessary_to_owned`, just through a bunch of type conversions
- we can make this more "generic" later and catch other cases, so imo it's best not to tie this lint specifically to the `String` type
changelog: [`unnecessary_to_owned`]: catch `&String::from_utf8(bytes.to_vec()).unwrap()` and suggest `core::str::from_utf8(bytes).unwrap()`
2024-07-05 02:04:06 +00:00
..
2024-06-20 13:57:16 +00:00
2024-06-25 17:50:48 +02:00
2024-06-27 18:49:59 +02:00
2024-07-02 23:27:14 +02:00
2024-07-04 15:56:11 +08:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-20 04:25:17 +00:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-07-04 14:31:15 +02:00
2024-07-04 14:31:15 +02:00
2024-07-04 14:31:15 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-27 18:49:59 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-27 18:49:59 +02:00
2024-06-27 18:49:59 +02:00
2024-06-24 16:08:51 +03:00
2024-06-16 18:33:43 -04:00
2024-06-16 18:33:43 -04:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-07-03 21:25:43 +07:00
2024-07-03 21:25:43 +07:00
2024-07-03 21:25:43 +07:00
2024-06-16 15:54:48 -04:00
2024-06-16 15:54:48 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-27 18:49:59 +02:00
2024-06-27 18:49:59 +02:00
2024-06-27 18:49:59 +02:00
2024-07-01 19:00:10 -07:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-16 18:33:43 -04:00
2024-06-16 18:33:43 -04:00
2024-06-28 10:29:18 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-15 21:52:42 +02:00
2024-06-15 21:45:35 +02:00
2024-06-15 21:45:35 +02:00
2024-06-29 22:31:10 +02:00
2024-06-29 22:31:10 +02:00
2024-06-29 22:31:10 +02:00
2024-06-21 18:18:28 +02:00
2024-06-21 18:18:28 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-20 04:25:17 +00:00
2024-06-20 04:25:17 +00:00
2024-07-02 19:30:01 +02:00
2024-07-02 19:30:01 +02:00
2024-07-02 19:30:01 +02:00
2024-07-02 19:30:01 +02:00
2024-07-02 19:30:01 +02:00
2024-07-03 20:58:21 +02:00
2024-07-03 20:58:21 +02:00
2024-07-03 20:58:21 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-16 22:36:24 -04:00
2024-06-16 22:36:24 -04:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-07-03 19:42:34 +01:00
2024-07-03 19:42:34 +01:00
2024-06-24 16:08:51 +03:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-24 16:08:51 +03:00
2024-06-20 13:57:16 +00:00
2024-06-20 13:57:16 +00:00
2024-06-20 13:57:16 +00:00
2024-06-20 00:09:31 +02:00
2024-06-20 00:09:31 +02:00
2024-06-20 00:09:31 +02:00
2024-06-25 17:50:48 +02:00
2024-06-25 17:50:48 +02:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-19 13:30:21 -04:00
2024-06-25 17:50:48 +02:00