Lint against iterator functions that panics when N is zero #153563
Lint against iterator functions that panics when N is zero #153563Urgau wants to merge 4 commits intorust-lang:mainfrom
N is zero #153563Conversation
|
Some changes occurred in compiler/rustc_hir/src/attrs cc @jdonszelmann, @JonathanBrouwer This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @vakaras Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer This PR changes rustc_public cc @oli-obk, @celinval, @ouz-a, @makai410 Some changes occurred to the CTFE machinery Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in compiler/rustc_attr_parsing |
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
ff233d2 to
44380ea
Compare
This seems to do much more than that. It adds a new language primitive, a new kind of built-in assertion. Could you motivate that? |
The code is unfortunately tangled, it doesn't add a new language primitive per se, but I could probably modify that function so it doesn't take an |
|
Given that |
44380ea to
36de202
Compare
|
Understandable, I've reworked the PR to avoid touching at |
There was a problem hiding this comment.
I love the idea but it should better for someone more familiar with this topic other than me to review. @RalfJung Could you take over? Otherwise I'd reroll.
|
I'm afraid not, I don't have capacity at the moment. @rustbot reroll |
This comment has been minimized.
This comment has been minimized.
36de202 to
0a8cacf
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I think the overall idea is good and I could see myself approving down the line, however I think we should see if we can have an attribute on the generic parameter itself instead of applying rustc_panics_when_n_is_zero to the enclosing function. If not, I'd still want something more verbose, such as #[rustc_panics_when_const_param_is_zero(N)]
I don't think this should be touching AssertLint. I feel like it might be simpler to just add a separate error for this rather than using existing mechanisms.
0a8cacf to
d033014
Compare
This comment has been minimized.
This comment has been minimized.
|
I had to add the encoding of const-params in I've also removed any interaction with @rustbot ready |
|
overall looks good, would like someone else to sign off with me on this together though @rustbot reroll |
This comment has been minimized.
This comment has been minimized.
d033014 to
c4355b4
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c4355b4 to
b4b14d8
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This PR adds new kind of variant to the deny-by-default
unconditional_paniclint, by linting on iterator functions that panics whenN(chunks/windows size) is zero.cc @rust-lang/libs-api