Auto merge of #9187 - sgued:iter-once, r=flip1995

Add lint recommending using `std::iter::once` and `std::iter::empty`

```
changelog: [`iter_once`]: add new lint
changelog: [`iter_empty`]: add new lint
```

fixes #9186

- \[ ] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

The lint doesn't really follow the naming conventions. I don't have any better idea so I'm open to suggestions.
This commit is contained in:
bors 2022-08-14 15:45:17 +00:00
commit 679fa9f2bf
16 changed files with 524 additions and 5 deletions

View file

@ -350,7 +350,7 @@ define_Conf! {
/// Lint: DISALLOWED_SCRIPT_IDENTS.
///
/// The list of unicode scripts allowed to be used in the scope.
(allowed_scripts: Vec<String> = ["Latin"].iter().map(ToString::to_string).collect()),
(allowed_scripts: Vec<String> = vec!["Latin".to_string()]),
/// Lint: NON_SEND_FIELDS_IN_SEND_TY.
///
/// Whether to apply the raw pointer heuristic to determine if a type is `Send`.

View file

@ -797,7 +797,7 @@ fn get_lint_group_and_level_or_lint(
let result = cx.lint_store.check_lint_name(
lint_name,
Some(sym::clippy),
&[Ident::with_dummy_span(sym::clippy)].into_iter().collect(),
&std::iter::once(Ident::with_dummy_span(sym::clippy)).collect(),
);
if let CheckLintNameResult::Tool(Ok(lint_lst)) = result {
if let Some(group) = get_lint_group(cx, lint_lst[0]) {