Repository navigation
Don't suggest fixes that cut through a macro call - #18035
Itz-Agasta wants to merge 6 commits into
Conversation
|
Thanks for the pull request, and welcome! You should hear from one of our reviewers after this PR gets at least 2 reviews from the community. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
community review: hi, as a rustc dev I made sure that we never used issue{N} as a name for a test file ever again. clippy has its own standards about naming things, but let's just say that this kind of name is a good way to create work for someone else to research and clean up later. rust-lang/compiler-team#658
d0a03d6 to
8149b3d
Compare
Make sense .. I myself am not a big fan of this style either. I have already disclosed that tests were made by agent... so when I was doing the local review I noticed so many earlier tests too were written this way that's why ignored it.... But yeah, have a look now |
Please take into account that this is your code, and you have full responsibility of it. |
Yes I'm aware of that ... I'm kinda getting used to the repo standards.. as this style is already there in earlier so many tests written by others so I thought this might be the way that's why ignored that ... That said yes pardon me, i will keep a good eye on these from next time 🫡 |
|
Btw @blyxyas I was looking at the issue and the things @workingjubilee mentioned.... rustc has this rule written down in the contributor guide also a tidy check..... Won't it be good if Clippy has it too like in |
|
probably better to put that stuff in a separate PR, people like to haggle over it when it gets written down as a rule whereas if the clippy code is fine this PR is fine. (I only looked at the added tests, and they're mostly the same as the stuff in the issues.) |
got it... i believe this rule/suggesion should naturally go in |
|
hey @CommanderStorm if y got some time can y do the 2nd community review pls 👉👈 thanks |
ok so my single counter works because rustc already rejects mismatched brackets & that's not obvious/ readable from my code i believe. (i did some back and forth on this earlier, before pusing one counter so yes it works) your three counters still let let mut open = Vec::new();
for token in tokenize(snippet, FrontmatterAllowed::No) {
let expected = match token.kind {
TokenKind::OpenParen | TokenKind::OpenBracket | TokenKind::OpenBrace => {
open.push(token.kind);
continue;
},
TokenKind::CloseParen => TokenKind::OpenParen,
TokenKind::CloseBracket => TokenKind::OpenBracket,
TokenKind::CloseBrace => TokenKind::OpenBrace,
_ => continue,
};
if open.pop() != Some(expected) {
return false;
}
}
open.is_empty()same results & little easier to follow (lol i just remember i was revising this dsa pattern few weeks ago 😹 ). i mean its kinda opinionated on coding style..fine with whichever you prefer |
8149b3d to
98b140d
Compare
|
rustbot has assigned @samueltardieu for the project review. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
On zulip (#t-clippy > Remaining (yet-unreported) fuzzing issues) these two were reported too. Important These are LLM/fuzzer/? findings, so really no need to take action at all! ^^ They seem like the same fix that you already applied here, so I am mostly commenting in case you want to fix them here too, I can also do an followup for this..
|
Follow-up to the [discussion](rust-lang#18035 (review)) in rust-lang#18035. Adds a short "Naming Test Cases" section to the testing chapter of the book CC: rust-lang/compiler-team#658 changelog: none
Follow-up to the [discussion](rust-lang/rust-clippy#18035 (review)) in rust-lang/rust-clippy#18035. Adds a short "Naming Test Cases" section to the testing chapter of the book CC: rust-lang/compiler-team#658 changelog: none
|
The problem with all the suggestions is the span adjustments are just outright incorrect. I have various instances of this fixed (e.g. For reference the fix for |
|
Reminder, once the PR becomes ready for a review, use |
28a661c to
07e4991
Compare
…ough a macro call
…ugh a macro call
07e4991 to
8277c59
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. |
mmmm looked...span adjustments is the right call too ig,,,,so yaa should i close this pr? or keep it as a temp stop-gap :( |
View all comments
Part of #18018
lints that build their replacement span from a macro argument (eg.
vinid!(v)) can cut through the macro call... so addedclippy_utils::span_has_balanced_delims(lexes the span's source and checks that every(/[/{is closed inside it). The lints below now skip when the span isn't balanced.fixes #18006
fixes #18007
fixes #18008
fixes #18009
fixes #18010
changelog: [
iter_cloned_collect], [bool_comparison], [manual_is_variant_and], [collapsible_match], [blocks_in_conditions]: don't lint when the suggestion would cut through a macro call