Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add impl_trait_in_params lint #10197

Merged
merged 9 commits into from
Feb 21, 2023
Merged

Add impl_trait_in_params lint #10197

merged 9 commits into from
Feb 21, 2023

Conversation

blyxyas
Copy link
Member

@blyxyas blyxyas commented Jan 13, 2023

As this is a lint about style, and using impl Trait is purely cosmetical (even with downsides), a lot of unrelated files needed to allow this lint.


Resolves #10030

changelog: New lint: [impl_trait_in_params]
10197

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2023

r? @Jarcho

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 13, 2023
@blyxyas blyxyas changed the title Add impl_trait_in_params Add impl_trait_in_params lint Jan 13, 2023
@Jarcho
Copy link
Contributor

Jarcho commented Jan 13, 2023

This should be a restriction lint,

Copy link
Contributor

@Jarcho Jarcho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking a while. Basically just small things.

clippy_lints/src/functions/impl_trait_in_params.rs Outdated Show resolved Hide resolved
}
}

fn next_valid_letter(generics: &Generics<'_>) -> char {
Copy link
Contributor

@Jarcho Jarcho Jan 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really do want to suggest a name, it should be a 'good' name that matches the trait if possible. e.g.

  • Iterator/IntoIter/DoubleEndedIterator/ExactSizeIterator/TrustedLen/FusedIterator -> I/J/K
  • Fn(...) -> bool -> P
  • Fn(...) -> _ -> F
  • Hasher -> H
  • Read/BufRead/RangeBounds -> R
  • io::Write/fmt::Write -> W
  • Eveything else -> T/U/V

If the name isn't available it would be better to leave a placeholder for the name rather than use any random name.

Just using a placeholder is also a reasonable option. Or even not implementing the list and just using T/U/V also works. If all three are already taken it's already beyond a reasonable number of meaningless names.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @blyxyas. Are you still working on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am still working on it. I thought the lint didn't need it because "Just using a placeholder is also a reasonable option" so I didn't change anything. Sorry for not seeing the ping before. I'll implement this right now.

clippy_lints/src/functions/impl_trait_in_params.rs Outdated Show resolved Hide resolved
clippy_lints/src/functions/impl_trait_in_params.rs Outdated Show resolved Hide resolved
clippy_lints/src/functions/impl_trait_in_params.rs Outdated Show resolved Hide resolved
clippy_utils/src/check_proc_macro.rs Outdated Show resolved Hide resolved
@blyxyas
Copy link
Member Author

blyxyas commented Jan 19, 2023

What is wrong here?
CI talks about cargo dev update_lints --check, but using cargo dev update_lints does nothing. Even after rebasing, it still fails.

@Jarcho
Copy link
Contributor

Jarcho commented Jan 19, 2023

You're a few days behind master. Rebasing onto that and running update_lints again should fix it.

@blyxyas
Copy link
Member Author

blyxyas commented Jan 19, 2023

I did that, using git rebase upstream/master doesn't do anything (Current branch impl_trait_param is up to date.), and cargo dev update_lints doesn't output anything and doesn't change any files. cargo dev update_lints --check doesn't output any errors.

@Jarcho
Copy link
Contributor

Jarcho commented Jan 20, 2023

You're currently 27 commits behind. You need to pull the latest changes first. git pull upstream master

@bors
Copy link
Collaborator

bors commented Feb 10, 2023

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

@blyxyas
Copy link
Member Author

blyxyas commented Feb 18, 2023

Sorry for coming so late with 89fde4a, I didn't see the ping and had a very big confussion thinking that the PR was finished and needed no further changes to it. This new commit adds placeholders instead of name suggestions.

@blyxyas
Copy link
Member Author

blyxyas commented Feb 18, 2023

remark failed because of a curl error when installing mdbook:

curl: (22) The requested URL returned error: 503

Is this my fault?

@Jarcho
Copy link
Contributor

Jarcho commented Feb 21, 2023

I think that's just a spurious error. Hopefully this works. @bors r+

Thank you.

@bors
Copy link
Collaborator

bors commented Feb 21, 2023

📌 Commit 89fde4a has been approved by Jarcho

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Feb 21, 2023

⌛ Testing commit 89fde4a with merge 5ef3cc8...

@bors
Copy link
Collaborator

bors commented Feb 21, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Jarcho
Pushing 5ef3cc8 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint to ban impl Trait in parameters
4 participants