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

Clippy subtree update #117021

Merged
merged 70 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
6e0c456
triagebot no-merges: exclude "Rustup"s, add labels
pitaj Sep 16, 2023
77c121e
Warn missing_enforced_import_renames by default
taiki-e Sep 20, 2023
faacd55
Fix typo in attrs.rs
eltociear Oct 4, 2023
31fd282
[`get_first`]: lint on non-primitive types
y21 Oct 4, 2023
e6f29f1
dogfood
y21 Oct 4, 2023
010a9b1
Rename `Features::active_features`.
nnethercote Oct 5, 2023
9de3e6c
Add more diagnostic items for clippy
Jarcho Sep 27, 2023
ddd1564
Add regression test for #11610 about mutable usage of argument in asy…
GuillaumeGomez Oct 6, 2023
8ebed4c
Merge commit 'b105fb4c39bc1a010807a6c076193cef8d93c109' into clippyup
flip1995 Oct 6, 2023
68d2082
Fix ice
koka831 Oct 6, 2023
3662bd8
Auto merge of #11623 - koka831:fix/11619, r=llogiq
bors Oct 6, 2023
0ed398e
Rollup merge of #116423 - eltociear:patch-22, r=flip1995
matthiaskrgr Oct 6, 2023
bffba76
Fix two typos in lint description
samueltardieu Oct 7, 2023
1c6fa29
[`into_iter_without_iter`]: look for `iter` method in deref chains
y21 Oct 7, 2023
7624045
Auto merge of #11639 - y21:issue11635, r=llogiq
bors Oct 7, 2023
56400a0
Auto merge of #116437 - nnethercote:rustc_features, r=Nilstrieb
bors Oct 7, 2023
33f49f3
Auto merge of #11638 - samueltardieu:into-iter, r=Manishearth
bors Oct 7, 2023
850f2f5
Update ui_test to 0.21.2
Alexendoo Oct 8, 2023
5ed338d
`impl_trait_in_params` now supports impls and traits
blyxyas Sep 21, 2023
7755737
Fix tests, only lint for public tests
blyxyas Sep 23, 2023
bde0482
Auto merge of #11550 - blyxyas:fix-impl_trait_in_params-for_assocfn, …
bors Oct 8, 2023
929a288
Auto merge of #11645 - Alexendoo:ui_test, r=flip1995
bors Oct 9, 2023
70b8d15
Extend impl's def_span to include where clauses
compiler-errors Oct 6, 2023
0b60531
[`map_identity`]: allow closure with type annotations
y21 Sep 17, 2023
bba155e
move changed logic to into its own util function
y21 Oct 9, 2023
359fa98
Rejig some top-level `rustc_hir_pretty` functions.
nnethercote Oct 10, 2023
0b8495b
Rollup merge of #116625 - nnethercote:rustc_hir_pretty, r=fee1-dead
matthiaskrgr Oct 12, 2023
b5488f9
[`manual_is_ascii_check`]: Also check for `is_ascii_hexdigt`
aDotInTheVoid Oct 12, 2023
ff00e9c
Auto merge of #11659 - aDotInTheVoid:hexdigit, r=Jarcho
bors Oct 12, 2023
eb6fb18
Avoid `panic!`, omit instead
koka831 Oct 13, 2023
9fc717d
add test for macro-in-loop
koka831 Oct 13, 2023
c40359d
Auto merge of #11664 - koka831:fix/11134, r=blyxyas
bors Oct 13, 2023
d179605
Document conflicting lints
c410-f3r Oct 13, 2023
8c0870d
Address comment
c410-f3r Oct 13, 2023
1ffd09a
Stabilize AFIT and RPITIT
compiler-errors Sep 13, 2023
6ed04af
Make `multiple_unsafe_ops_per_block` ignore await desugaring
Noratrieb Oct 8, 2023
bb6516a
[`unnecessary_lazy_eval`]: don't emit autofix suggestion if closure h…
y21 Oct 15, 2023
ef95be5
Auto merge of #11609 - y21:get_first_non_primitives, r=giraffate
bors Oct 15, 2023
ae52ee5
Auto merge of #11514 - pitaj:triagebot_no-merges_exclude-titles, r=fl…
bors Oct 16, 2023
387d756
Auto merge of #11666 - c410-f3r:dsadasewqasdsa, r=flip1995
bors Oct 16, 2023
3960bc0
Now `declare_interior_mutable_const` and `borrow_interior_mutable_con…
slinkydeveloper Oct 16, 2023
9f27b15
Auto merge of #11673 - y21:issue11672, r=Manishearth
bors Oct 16, 2023
2cf708d
Auto merge of #11646 - Nilstrieb:compiler-does-not-comply-with-the-li…
bors Oct 17, 2023
9ee26d0
fix lint failures in clippy
a-lafrance Oct 16, 2023
09535a5
[RFC 3127 - Trim Paths]: Fix building tools (rustdoc, clippy, ...)
Urgau Aug 23, 2023
2640d5c
Auto merge of #11622 - GuillaumeGomez:needless_pass_by_ref_mut-regres…
bors Oct 17, 2023
bc97f7d
Don't emit `needless_pass_by_ref_mut` if the variable is used in an u…
GuillaumeGomez Oct 6, 2023
80a092c
Add test for `needless_pass_by_ref_mut` to ensure that the lint is no…
GuillaumeGomez Oct 6, 2023
d9dc5ee
AliasTy::new instead of tcx method
lcnr Oct 18, 2023
8b02dac
add lint for struct field names
jonboh Oct 17, 2023
5fb312e
Auto merge of #11624 - GuillaumeGomez:needless_pass_by_ref_mut-unsafe…
bors Oct 18, 2023
fe21991
Auto merge of #11496 - jonboh:prefix_postfix_struct, r=y21
bors Oct 18, 2023
ec2b8ab
Fix invalid warning for closure in non-async function for `needless_p…
GuillaumeGomez Oct 6, 2023
3b4b07c
Add test for closure in non-async function for `needless_pass_by_ref_…
GuillaumeGomez Oct 6, 2023
3e6db95
Add regression test for #11561
GuillaumeGomez Oct 6, 2023
1528c1d
Deserialize Msrv directly in Conf
Alexendoo Oct 18, 2023
a07c032
Tweak wording of type errors involving type params
estebank Oct 18, 2023
9574d28
Auto merge of #11683 - Alexendoo:msrv-config, r=Manishearth,flip1995
bors Oct 19, 2023
cd477d4
Auto merge of #11621 - GuillaumeGomez:needless_pass_by_ref_mut-closur…
bors Oct 19, 2023
214b4d9
Auto merge of #115214 - Urgau:rfc-3127-trim-paths, r=compiler-errors
bors Oct 19, 2023
e230f19
Auto merge of #11521 - y21:issue9122, r=llogiq
bors Oct 20, 2023
090df7a
Auto merge of #11678 - slinkydeveloper:master, r=Alexendoo
bors Oct 20, 2023
868e513
s/Generator/Coroutine/
oli-obk Oct 19, 2023
d9259fd
s/generator/coroutine/
oli-obk Oct 19, 2023
23af253
Auto merge of #11539 - taiki-e:enforced-import-renames, r=Centri3
bors Oct 21, 2023
5f03156
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Oct 21, 2023
a585cda
Bump nightly version -> 2023-10-21
flip1995 Oct 21, 2023
2b030eb
Auto merge of #11694 - flip1995:rustup, r=flip1995
bors Oct 21, 2023
24b3554
Merge commit '2b030eb03d9e5837440b1ee0b98c50b97c0c5889' into clippyup
flip1995 Oct 21, 2023
b8b55fe
Update Cargo.lock (ui_test update)
flip1995 Oct 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 3 additions & 29 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ dependencies = [
"tester",
"tokio",
"toml 0.7.5",
"ui_test 0.20.0",
"ui_test",
"walkdir",
]

Expand Down Expand Up @@ -614,6 +614,7 @@ dependencies = [
"if_chain",
"itertools",
"rustc-semver",
"serde",
]

[[package]]
Expand Down Expand Up @@ -2511,7 +2512,7 @@ dependencies = [
"rustc_version",
"serde",
"smallvec",
"ui_test 0.21.2",
"ui_test",
]

[[package]]
Expand Down Expand Up @@ -5740,33 +5741,6 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"

[[package]]
name = "ui_test"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971"
dependencies = [
"annotate-snippets",
"anyhow",
"bstr",
"cargo-platform",
"cargo_metadata 0.15.4",
"color-eyre",
"colored",
"comma",
"crossbeam-channel",
"indicatif",
"lazy_static",
"levenshtein",
"prettydiff",
"regex",
"rustc_version",
"rustfix",
"serde",
"serde_json",
"tempfile",
]

[[package]]
name = "ui_test"
version = "0.21.2"
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5463,6 +5463,7 @@ Released 2018-09-13
[`string_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_to_string
[`strlen_on_c_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#strlen_on_c_strings
[`struct_excessive_bools`]: https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools
[`struct_field_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#struct_field_names
[`stutter`]: https://rust-lang.github.io/rust-clippy/master/index.html#stutter
[`suboptimal_flops`]: https://rust-lang.github.io/rust-clippy/master/index.html#suboptimal_flops
[`suspicious_arithmetic_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_arithmetic_impl
Expand Down Expand Up @@ -5625,6 +5626,7 @@ Released 2018-09-13
[`single-char-binding-names-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#single-char-binding-names-threshold
[`too-large-for-stack`]: https://doc.rust-lang.org/clippy/lint_configuration.html#too-large-for-stack
[`enum-variant-name-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#enum-variant-name-threshold
[`struct-field-name-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#struct-field-name-threshold
[`enum-variant-size-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#enum-variant-size-threshold
[`verbose-bit-mask-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#verbose-bit-mask-threshold
[`literal-representation-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#literal-representation-threshold
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ color-print = "0.3.4" # Sync version with Cargo
anstream = "0.5.0"

[dev-dependencies]
ui_test = "0.20"
ui_test = "0.21.2"
tester = "0.9"
regex = "1.5"
toml = "0.7.3"
Expand Down
19 changes: 19 additions & 0 deletions src/tools/clippy/book/src/development/adding_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ because that's clearly a non-descriptive name.
- [Documentation](#documentation)
- [Running rustfmt](#running-rustfmt)
- [Debugging](#debugging)
- [Conflicting lints](#conflicting-lints)
- [PR Checklist](#pr-checklist)
- [Adding configuration to a lint](#adding-configuration-to-a-lint)
- [Cheat Sheet](#cheat-sheet)
Expand Down Expand Up @@ -612,6 +613,24 @@ output in the `stdout` part.

[`dbg!`]: https://doc.rust-lang.org/std/macro.dbg.html

## Conflicting lints

There are several lints that deal with the same pattern but suggest different approaches. In other words, some lints
may suggest modifications that go in the opposite direction to what some other lints already propose for the same
code, creating conflicting diagnostics.

When you are creating a lint that ends up in this scenario, the following tips should be encouraged to guide
classification:

* The only case where they should be in the same category is if that category is `restriction`. For example,
`semicolon_inside_block` and `semicolon_outside_block`.
* For all the other cases, they should be in different categories with different levels of allowance. For example,
`implicit_return` (restriction, allow) and `needless_return` (style, warn).

For lints that are in different categories, it is also recommended that at least one of them should be in the
`restriction` category. The reason for this is that the `restriction` group is the only group where we don't
recommend to enable the entire set, but cherry pick lints out of.

## PR Checklist

Before submitting your PR make sure you followed all the basic requirements:
Expand Down
12 changes: 11 additions & 1 deletion src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Suppress lints whenever the suggested change would cause breakage for other crat
## `msrv`
The minimum rust version that the project supports

**Default Value:** `None` (`Option<String>`)
**Default Value:** `Msrv { stack: [] }` (`crate::Msrv`)

---
**Affected lints:**
Expand Down Expand Up @@ -273,6 +273,16 @@ The minimum number of enum variants for the lints about variant names to trigger
* [`enum_variant_names`](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names)


## `struct-field-name-threshold`
The minimum number of struct fields for the lints about field names to trigger

**Default Value:** `3` (`u64`)

---
**Affected lints:**
* [`struct_variant_names`](https://rust-lang.github.io/rust-clippy/master/index.html#struct_variant_names)


## `enum-variant-size-threshold`
The maximum size of an enum's variant to avoid box suggestion

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
use clippy_utils::source::snippet;
use clippy_utils::ty::implements_trait;
use rustc_errors::Applicability;
use rustc_hir::{AsyncCoroutineKind, Body, BodyId, ExprKind, CoroutineKind, QPath};
use rustc_hir::{AsyncCoroutineKind, Body, BodyId, CoroutineKind, ExprKind, QPath};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};

Expand Down
5 changes: 4 additions & 1 deletion src/tools/clippy/clippy_lints/src/await_holding_invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,8 @@ fn is_mutex_guard(cx: &LateContext<'_>, def_id: DefId) -> bool {
}

fn is_refcell_ref(cx: &LateContext<'_>, def_id: DefId) -> bool {
matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::RefCellRef | sym::RefCellRefMut))
matches!(
cx.tcx.get_diagnostic_name(def_id),
Some(sym::RefCellRef | sym::RefCellRefMut)
)
}
3 changes: 2 additions & 1 deletion src/tools/clippy/clippy_lints/src/box_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use clippy_utils::macros::macro_backtrace;
use clippy_utils::ty::expr_sig;
use clippy_utils::{get_parent_node, is_default_equivalent, path_def_id};
use rustc_errors::Applicability;
use rustc_hir::def::Res;
use rustc_hir::intravisit::{walk_ty, Visitor};
use rustc_hir::{def::Res, Block, Expr, ExprKind, Local, Node, QPath, TyKind};
use rustc_hir::{Block, Expr, ExprKind, Local, Node, QPath, TyKind};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_middle::ty::print::with_forced_trimmed_paths;
Expand Down
7 changes: 4 additions & 3 deletions src/tools/clippy/clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::endian_bytes::LITTLE_ENDIAN_BYTES_INFO,
crate::entry::MAP_ENTRY_INFO,
crate::enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT_INFO,
crate::enum_variants::ENUM_VARIANT_NAMES_INFO,
crate::enum_variants::MODULE_INCEPTION_INFO,
crate::enum_variants::MODULE_NAME_REPETITIONS_INFO,
crate::equatable_if_let::EQUATABLE_IF_LET_INFO,
crate::error_impl_error::ERROR_IMPL_ERROR_INFO,
crate::escape::BOXED_LOCAL_INFO,
Expand Down Expand Up @@ -226,6 +223,10 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::instant_subtraction::UNCHECKED_DURATION_SUBTRACTION_INFO,
crate::int_plus_one::INT_PLUS_ONE_INFO,
crate::invalid_upcast_comparisons::INVALID_UPCAST_COMPARISONS_INFO,
crate::item_name_repetitions::ENUM_VARIANT_NAMES_INFO,
crate::item_name_repetitions::MODULE_INCEPTION_INFO,
crate::item_name_repetitions::MODULE_NAME_REPETITIONS_INFO,
crate::item_name_repetitions::STRUCT_FIELD_NAMES_INFO,
crate::items_after_statements::ITEMS_AFTER_STATEMENTS_INFO,
crate::items_after_test_module::ITEMS_AFTER_TEST_MODULE_INFO,
crate::iter_not_returning_iterator::ITER_NOT_RETURNING_ITERATOR_INFO,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::source::snippet_with_context;
use clippy_utils::last_path_segment;
use clippy_utils::source::snippet_with_context;
use rustc_errors::Applicability;
use rustc_hir::{def, Expr, ExprKind, GenericArg, QPath, TyKind};
use rustc_lint::{LateContext, LateLintPass};
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/exit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clippy_utils::diagnostics::span_lint;
use clippy_utils::{is_entrypoint_fn};
use clippy_utils::is_entrypoint_fn;
use if_chain::if_chain;
use rustc_hir::{Expr, ExprKind, Item, ItemKind, Node};
use rustc_lint::{LateContext, LateLintPass};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::ty::is_c_void;
use clippy_utils::path_def_id;
use clippy_utils::ty::is_c_void;
use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, ExprKind, QPath};
use rustc_lint::{LateContext, LateLintPass};
Expand Down
126 changes: 90 additions & 36 deletions src/tools/clippy/clippy_lints/src/functions/impl_trait_in_params.rs
Original file line number Diff line number Diff line change
@@ -1,50 +1,104 @@
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::is_in_test_function;

use rustc_hir as hir;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{Body, HirId};
use rustc_hir::{Body, GenericParam, Generics, HirId, ImplItem, ImplItemKind, TraitItem, TraitItemKind};
use rustc_lint::LateContext;
use rustc_span::Span;
use rustc_span::symbol::Ident;
use rustc_span::{BytePos, Span};

use super::IMPL_TRAIT_IN_PARAMS;

fn report(
cx: &LateContext<'_>,
param: &GenericParam<'_>,
ident: &Ident,
generics: &Generics<'_>,
first_param_span: Span,
) {
// No generics with nested generics, and no generics like FnMut(x)
span_lint_and_then(
cx,
IMPL_TRAIT_IN_PARAMS,
param.span,
"`impl Trait` used as a function parameter",
|diag| {
if let Some(gen_span) = generics.span_for_param_suggestion() {
// If there's already a generic param with the same bound, do not lint **this** suggestion.
diag.span_suggestion_with_style(
gen_span,
"add a type parameter",
format!(", {{ /* Generic name */ }}: {}", &param.name.ident().as_str()[5..]),
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways,
);
} else {
diag.span_suggestion_with_style(
Span::new(
first_param_span.lo() - rustc_span::BytePos(1),
ident.span.hi(),
ident.span.ctxt(),
ident.span.parent(),
),
"add a type parameter",
format!("<{{ /* Generic name */ }}: {}>", &param.name.ident().as_str()[5..]),
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways,
);
}
},
);
}

pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body: &'tcx Body<'_>, hir_id: HirId) {
if cx.tcx.visibility(cx.tcx.hir().body_owner_def_id(body.id())).is_public() && !is_in_test_function(cx.tcx, hir_id)
{
if let FnKind::ItemFn(ident, generics, _) = kind {
if_chain! {
if let FnKind::ItemFn(ident, generics, _) = kind;
if cx.tcx.visibility(cx.tcx.hir().body_owner_def_id(body.id())).is_public();
if !is_in_test_function(cx.tcx, hir_id);
then {
for param in generics.params {
if param.is_impl_trait() {
// No generics with nested generics, and no generics like FnMut(x)
span_lint_and_then(
cx,
IMPL_TRAIT_IN_PARAMS,
param.span,
"'`impl Trait` used as a function parameter'",
|diag| {
if let Some(gen_span) = generics.span_for_param_suggestion() {
diag.span_suggestion_with_style(
gen_span,
"add a type parameter",
format!(", {{ /* Generic name */ }}: {}", &param.name.ident().as_str()[5..]),
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways,
);
} else {
diag.span_suggestion_with_style(
Span::new(
body.params[0].span.lo() - rustc_span::BytePos(1),
ident.span.hi(),
ident.span.ctxt(),
ident.span.parent(),
),
"add a type parameter",
format!("<{{ /* Generic name */ }}: {}>", &param.name.ident().as_str()[5..]),
rustc_errors::Applicability::HasPlaceholders,
rustc_errors::SuggestionStyle::ShowAlways,
);
}
},
);
report(cx, param, ident, generics, body.params[0].span);
};
}
}
}
}

pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
if_chain! {
if let ImplItemKind::Fn(_, body_id) = impl_item.kind;
if let hir::Node::Item(item) = cx.tcx.hir().get_parent(impl_item.hir_id());
if let hir::ItemKind::Impl(impl_) = item.kind;
if let hir::Impl { of_trait, .. } = *impl_;
if of_trait.is_none();
let body = cx.tcx.hir().body(body_id);
if cx.tcx.visibility(cx.tcx.hir().body_owner_def_id(body.id())).is_public();
if !is_in_test_function(cx.tcx, impl_item.hir_id());
then {
for param in impl_item.generics.params {
if param.is_impl_trait() {
report(cx, param, &impl_item.ident, impl_item.generics, body.params[0].span);
}
}
}
}
}

pub(super) fn check_trait_item(cx: &LateContext<'_>, trait_item: &TraitItem<'_>, avoid_breaking_exported_api: bool) {
if_chain! {
if !avoid_breaking_exported_api;
if let TraitItemKind::Fn(_, _) = trait_item.kind;
if let hir::Node::Item(item) = cx.tcx.hir().get_parent(trait_item.hir_id());
// ^^ (Will always be a trait)
if !item.vis_span.is_empty(); // Is public
if !is_in_test_function(cx.tcx, trait_item.hir_id());
then {
for param in trait_item.generics.params {
if param.is_impl_trait() {
let sp = trait_item.ident.span.with_hi(trait_item.ident.span.hi() + BytePos(1));
report(cx, param, &trait_item.ident, trait_item.generics, sp.shrink_to_hi());
}
}
}
Expand Down
Loading
Loading