Commit Graph

26 Commits

Author SHA1 Message Date
Catherine
6a1084c26f Check if if conditions always evaluate to true in never_loop 2023-06-22 04:31:05 -05:00
Samuel Tardieu
657ee48bec Ignore instructions following a break from block in never_loop lint
It is not sufficient to ignore break from a block inside the loop.
Instructions after the break must be ignored, as they are unreachable.
This is also true for all instructions in outer blocks and loops
until the right block is reached.
2023-02-14 09:55:44 +01:00
Samuel Tardieu
e9dffa3910 Fix a bug in never_loop when anonymous blocks are nested in named blocks
The following code

```
loop {
    'a: {
        { }
        break 'a;
    }
}
```

was detected as a never-looping loop.
2023-02-14 09:23:04 +01:00
Kartavya Vashishtha
9f3b6e9acd
don't emit AlwaysBreaks if it targets a block
Introduced an ignored_ids parameter.
Takes O(n^2) time in the worst case.

Can be changed to collect block ids in first phase,
and then filter with binary search in second.
2022-11-16 11:01:07 +05:30
Kartavya Vashishtha
989986144c
fix never_loop false positive
on unconditional break to internal labeled block

ref #9831
2022-11-12 20:36:30 +05:30
Philipp Krones
bbcde66685
Merge remote-tracking branch 'upstream/master' into rustup 2022-09-28 14:27:32 +02:00
Yotam Ofek
d63aeceaa1 [never_loop]: Fix FP with let..else statements. 2022-09-19 10:57:29 +00:00
flip1995
f8f9d01c2a Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' into clippyup 2022-06-16 17:39:06 +02:00
andylizi
a8370d4460
Fix false positive for never_loop struct expression fields 2022-06-15 18:02:59 +08:00
flip1995
d164ab65f7 Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup 2020-07-26 21:07:07 +02:00
Matthias Krüger
3618b97f59 fix typos (found by codespell) 2020-07-17 01:58:41 +02:00
Michael Wright
7c98915da9 Fix never_loop false positive
Closes #4058
2019-07-01 07:22:04 +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
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
Karim Snj
5c1be4a4ba lint: immutable only vars in while condition 2018-02-25 18:25:31 +01:00
laurent
bcdf57e220 Refactor the never-loop detection, fixes #1991. 2017-11-05 14:43:28 +00:00
Cameron Steffen
a013568f70 add never_loop tests 2017-10-08 17:03:34 -05:00
Cameron Steffen
d6b35f9839 add never_loop test 2017-10-05 23:46:08 -05:00
Oliver Schneider
50ffaca4c9
Reduce the hackiness of cargo-clippy 2017-10-03 12:07:24 +02:00
Seiichi Uchida
0215a1acb0 Update a test 2017-09-14 22:27:29 +09: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
Andre Bogus
505eb53d29 New never loop lint
This lint detects loops that unconditionally break or return.

Closes #257
2017-02-17 04:53:14 +01:00