5

Add `items_after_test_module` lint by blyxyas · Pull Request #10578 · rust-lang/...

 1 year ago
source link: https://github.com/rust-lang/rust-clippy/pull/10578
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Contributor

Resolves task 3 of #10506, alongside 1 resolved at #10543 in an effort to help standarize a little bit more testing modules.


changelog:[items_after_test_module]: Added the lint.

Collaborator

r? @dswij

(rustbot has picked a reviewer for you, use r? to override)

rustbot

added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label

Mar 31, 2023

Contributor

umbrella The latest upstream changes (presumably #10534) made this pull request unmergeable. Please resolve the merge conflicts.

Contributor

umbrella The latest upstream changes (presumably #10543) made this pull request unmergeable. Please resolve the merge conflicts.

Contributor

umbrella The latest upstream changes (presumably #10601) made this pull request unmergeable. Please resolve the merge conflicts.

Contributor

Author

Im thinking about removing suggestions.
The current commit fixes that specific test case, but I tried with putting an attribute over should_not_lint, but it completely breaks the program.

I could fix that case, but then if I put another item with an attribute over that one, it will break again.

dswij reacted with thumbs up emoji

Contributor

umbrella The latest upstream changes (presumably #10497) made this pull request unmergeable. Please resolve the merge conflicts.

blyxyas

force-pushed the items_after_test_module

branch 2 times, most recently from 614e03e to 4e91b2e Compare

April 7, 2023 18:08

declare_lint_pass!(ItemsAfterTestModule => [ITEMS_AFTER_TEST_MODULE]);

impl LateLintPass<'_> for ItemsAfterTestModule {

fn check_mod(&mut self, cx: &LateContext<'_>, _: &Mod<'_>, _: HirId) {

Some style nit/suggestion dump, feel free to ignore sweat_smile

Maybe we can take out the if_chain check, then do a skip_while iterator on items iter.

Member

Im thinking about removing suggestions. The current commit fixes that specific test case, but I tried with putting an attribute over should_not_lint, but it completely breaks the program.

Yeah, that sounds a bit convoluted. I'd recommend leaving the suggestion for now, and maybe come back to it in the future

Member

@dswij dswij

left a comment

@blyxyas Sorry for the rather slow review.

Just a question, and should be good to merge afterwards :)

if_chain! {

if was_test_mod_visited;

if i == (items.len() - 3 /* Weird magic number (HIR-translation behaviour) */);

Will this ever cause a panic? i.e. will items.len() < 3?

Contributor

Author

Just tested it with this code (The minimum amount of items that meats the requirements for the lint):

#[cfg(test)]
mod test {}

const U: usize = 0;

In an independent crate using this command: cargo dev lint ../<test dir>/ -- -- -W clippy::items_after_test_module --test
Even though the lint, well, lints. It doesn't overflow.

dswij reacted with thumbs up emoji

Member

Thank you! @bors r+

Contributor

pushpin Commit 0c6da4c has been approved by dswij

It is now in the queue for this repository.

Contributor

hourglass Testing commit 0c6da4c with merge 138f692...

Contributor

broken_heart Test failed - checks-action_test

Member

@blyxyas Whoops, CI failed there. Can you help to take a look?

Contributor

Author

I don't know how to fix this, it work on my machine and the normal Github CI test 'base'. Maybe retrying?

Contributor

Author

@dswij Could you retry the bors tests?

Member

@bors retry

Contributor

hourglass Testing commit 0c6da4c with merge 0884d16...

Contributor

broken_heart Test failed - checks-action_test

Contributor

Author

??? It works on my machine, with a modern 64-bit Ubuntu-based OS, like the CI. I guess I'm going to ask on Zulip, because I can't replicate this CI

Contributor

Author

It's fixed now, the bug was caused because the test didn't change to the //@ syntax for headers.

Member

@bors r+

Contributor

pushpin Commit 1ac8dc5 has been approved by dswij

It is now in the queue for this repository.

Contributor

hourglass Testing commit 1ac8dc5 with merge a3ed905...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

dswij

dswij approved these changes
Assignees

dswij

Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

None yet

4 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK