Files
rust/tests/ui
bors 1e656d8d6d Auto merge of #10970 - y21:read_line_without_trim, r=giraffate
new lint: `read_line_without_trim`

This adds a new lint that checks for calls to `Stdin::read_line` with a reference to a string that is then attempted to parse into an integer type without first trimming it, which is always going to fail at runtime.
This is something that I've seen happen a lot to beginners, because it's easy to run into when following the example of chapter 2 in the book where it shows how to program a guessing game.
It would be nice if we could point beginners to clippy and tell them "let's see what clippy has to say" and have clippy explain to them why it fails 👀

I think this lint can later be "generalized" to work not just for `Stdin` but also any `BufRead` (which seems to be where the guarantee about the trailing newline comes from) and also, matching/comparing it to a string slice that doesn't end in a newline character (e.g. `input == "foo"` is always going to fail)

changelog: new lint: [`read_line_without_trim`]
2023-07-05 00:13:59 +00:00
..
2023-06-26 14:13:07 +00:00
2023-06-12 16:21:06 +01:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-20 21:19:58 -05:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-05-24 11:06:56 -05:00
2023-05-24 11:06:56 -05:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-06 14:58:54 -04:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-15 07:04:47 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-09 15:32:42 -05:00
2023-06-09 15:32:42 -05:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-05-31 17:30:23 -05:00
2023-05-31 17:30:23 -05:00
2022-06-16 18:00:32 +04:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-30 11:43:02 -05:00
2023-06-30 11:43:02 -05:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-03-08 14:40:38 +00:00
2023-03-08 14:40:38 +00:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:04:34 +02:00
2023-06-12 16:04:34 +02:00
2023-06-12 16:04:34 +02:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-09 21:39:58 -04:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-06 22:56:57 +02:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2023-06-27 05:12:00 -05:00
2022-10-01 10:03:06 +00:00
2023-04-27 17:18:12 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-09 21:39:58 -04:00
2023-06-09 21:39:58 -04:00
2023-06-06 22:56:57 +02:00
2022-10-01 10:03:06 +00:00
2023-06-15 20:23:11 +02:00
2023-06-15 20:23:11 +02:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-28 03:20:21 -05:00
2023-06-28 03:20:21 -05:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-27 06:31:04 -05:00
2023-06-27 06:31:04 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-07-01 12:36:02 -05:00
2023-07-01 12:37:16 -05:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2022-10-01 10:03:06 +00:00
2023-06-27 06:31:04 -05:00
2023-06-10 06:51:03 -05:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-25 04:28:40 -05:00
2023-06-26 14:13:07 +00:00
2023-06-06 22:56:57 +02:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-10 06:51:03 -05:00
2023-07-02 07:11:05 -05:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-12 16:21:06 +01:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-10 06:51:03 -05:00
2023-06-26 14:13:07 +00:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-06 22:56:57 +02:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-27 06:31:04 -05:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-27 05:16:40 -05:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-29 09:27:49 -03:00
2023-06-29 09:27:49 -03:00
2023-06-29 09:27:49 -03:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-06-26 14:13:07 +00:00
2023-06-14 08:41:20 -05:00
2022-10-01 10:03:06 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-06 22:56:57 +02:00
2023-06-06 22:56:57 +02:00
2023-06-06 22:56:57 +02:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-29 06:46:28 -05:00
2023-06-19 00:36:16 +02:00
2023-06-19 00:36:16 +02:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2022-06-16 18:00:32 +04:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2023-06-12 16:21:06 +01:00
2022-10-01 10:03:06 +00:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-12 16:21:06 +01:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2023-06-10 06:51:03 -05:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2023-06-26 14:13:07 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00
2022-10-01 10:03:06 +00:00