Commit graph

40 commits

Author SHA1 Message Date
Guillaume Gomez
a05d3a4137 Automatic generation of error annotations for ui tests 2023-08-22 17:18:11 +02:00
Guillaume Gomez
3a31c05578 Remove/move comments to prevent weird rustfmt wrapping 2023-08-22 17:17:48 +02:00
Oli Scherer
3d88fae050 Update ui test crate 2023-08-11 14:02:28 +00:00
asquared31415
6681914b54 make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size 2023-03-28 23:55:47 -04:00
J-ZhengLi
52c4dc65d9 fix [cast_possible_truncation] offering wrong suggestion when casting from float
suggest `try_into` when casting to wildcard type;
fix [`cast_possible_truncation`] suggesting useless parenthesis;

remove suggesting for float to float conversion in [`cast_possible_truncation`]

style nit
2023-03-25 09:26:43 +08:00
xFrednet
5cb6246c3e
Address PR reivew 2023-01-12 12:37:56 +01:00
Alex Macleod
4a21082da2 Fix subtraction overflow in cast_possible_truncation 2022-04-11 18:54:44 +01:00
Paolo Borelli
b0edbca0e6 new lint cast_abs_to_unsigned
Add a lint to detect cast to unsigned for abs() and suggest
unsigned_abs() to avoid panic when called on MIN.
2022-04-07 11:28:14 +02:00
Jason Newcomb
90bb7a3476 New lint cast_enum_truncation 2022-02-18 09:16:17 -05:00
Jason Newcomb
8a466454ab Lint enum-to-int casts with cast_possible_truncation 2022-02-18 09:11:15 -05:00
Andre Bogus
00ea73e162 avoid linting possible_truncation on bit-reducing operations 2021-10-29 21:59:24 +02:00
ThibsG
566244a8bc Do not lint when cast is coming from signum method call 2021-10-21 19:15:26 +02:00
Lzu Tao
c9bd35cac3 Migrate to numeric associated consts 2020-06-10 01:35:47 +00:00
Krishna Veera Reddy
c0fb74baf5 Add widening tests for cast_sign_loss lint 2019-12-05 17:18:27 -08:00
Krishna Veera Reddy
7002a9ee83 Fix false positive with cast_sign_loss lint
`cast_sign_loss` lint incorrectly suggests that the result of
`checked_abs`, `rem_euclid` and `checked_rem_euclid` cannot
be casted to an unsigned integer without loss.
2019-12-05 15:47:15 -08:00
HMPerson1
0e1dd65c14
Allow casts from the result of abs to unsigned 2019-10-02 17:23:54 -04:00
Philipp Hansch
2d84d0361d
Split up cast.rs tests, run-rustfix for unnecessary_cast
This splits up the cast.rs tests and enables rustfix tests for the part
of the `unnecessary_cast` lint that emits `MachineApplicable`
suggestions.

cc #3630
2019-08-04 08:24:23 +02:00
cemil
8eae2d3707 Ignore unnecessary cast if inside macro 2019-04-25 12:06:20 +02:00
Philipp Hansch
8163a1a5f8
Move two cast_lossless tests to their correct files
First part of checking off the `tests/ui/cast.rs` checkbox in #3630.
2019-04-18 06:54:32 +02:00
rink1969
d9dd008e44 casting integer literal to float is unnecessary 2019-03-14 15:53:08 +08:00
Michael Wright
3cf8c0b3b5 Fix cast_sign_loss false positive
This checks if the value is a non-negative constant before linting about
losing the sign.

Because the `constant` function doesn't handle const functions, we check if
the value is from a call to a `max_value` function directly. A utility method
called `get_def_path` was added to make checking for the function paths
easier.

Fixes #2728
2019-01-31 06:32:29 +02:00
Philipp Hansch
38d4ac7cea
Remove all copyright license headers
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
2019-01-08 21:46:39 +01:00
Matthias Krüger
f1d5194e3d tests: revert some changs and add further rustfmt::skip attributes. 2018-12-11 00:59:59 +01:00
Matthias Krüger
435299be30 rustfmt tests 2018-12-09 23:26:16 +01:00
Oliver Scherer
b8654eaa6c Stabilize tool lints 2018-10-11 12:16:22 +02:00
Manish Goregaokar
e9c025ea70 Add license header to Rust files 2018-10-06 09:43:08 -07:00
flip1995
1b6f6051a8 Adapt ui-tests to the tool_lints 2018-08-29 11:08:29 -07:00
Philipp Hansch
fded77d85e
Split up casting UI tests
Part of #2038
2018-01-06 11:22:20 +01:00
Oliver Schneider
50ffaca4c9
Reduce the hackiness of cargo-clippy 2017-10-03 12:07:24 +02:00
Dan Gohman
396cfa7055 Only strip parens for binary expressions. 2017-09-05 10:55:08 -07:00
Dan Gohman
ffa0bd24ed Add a testcase demonstrating how precedence interacts with the lossless-cast lint. 2017-09-05 10:55:08 -07:00
Dan Gohman
35cf2715dc When suggesting from(x) for lossless casts, strip parens from x. 2017-09-05 10:55:04 -07:00
Dan Gohman
7714203c72 Add a lint for lossless casts. 2017-08-28 08:42:33 -07:00
Oliver Schneider
74c776585c Move all our tests back to ui tests 2017-08-01 17:54:21 +02:00
Oliver Schneider
4465bc3e3f Make most tests an example so we can run them one by one 2017-05-17 14:19:44 +02:00
Luis de Bethencourt
17284bacee clean tests/ui/cast.rs
Cleaning the empty lines for clarity.
2017-05-11 16:22:32 +01:00
Bood Qian
2f00ea3a07 Suppress lint for unsuffixed number casts 2017-02-16 22:55:41 +08:00
Bood Qian
afce85e96d Add lint for unnecessary casts (cast to same type) 2017-02-15 22:20:20 +08:00
Oliver Schneider
1f2c97a291 remove all //~ from tests 2017-02-08 14:58:07 +01:00
Oliver Schneider
fd1351f6e3 rustup and compile-fail -> ui test move 2017-02-07 21:05:30 +01:00
Renamed from tests/compile-fail/cast.rs (Browse further)