Skip to content

Update Clippy #87954

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

Merged
merged 72 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
fb9b13a
Fix FP for nonstandard_macro_braces lint
DevinR528 Jul 20, 2021
5bc5bfc
Add tests for FP in nonstandard_macro_braces
DevinR528 Jul 21, 2021
f5c3ed4
Only trigger for one level of macros
DevinR528 Jul 22, 2021
44d37a4
Lint inside macro when owned by current crate
DevinR528 Jul 24, 2021
2b20f49
Merge commit '0cce3f643bfcbb92d5a1bb71858c9cbaff749d6b' into clippyup
flip1995 Jul 29, 2021
dbb10b8
add xor-swap lint
May 2, 2021
fdf29c0
Updated changelog for 1.55
xFrednet Jul 27, 2021
b3b2024
Auto merge of #7498 - xFrednet:changelog-1-55, r=flip1995
bors Jul 29, 2021
e9004b0
Remove `or_patterns` feature gate in example
LeSeulArtichaut Jul 29, 2021
2fe716c
Auto merge of #7507 - LeSeulArtichaut:patch-1, r=flip1995
bors Jul 29, 2021
35a74a1
Updated config value name in changelog for 1.54
xFrednet Jul 29, 2021
f6a5889
Auto merge of #7509 - xFrednet:patch-1, r=flip1995
bors Jul 29, 2021
967a721
Remove unnecessary trailing semicolons from clippy tests
Aaron1011 Jul 29, 2021
6c2199e
rfc3052: Remove authors field from Cargo manifests
lf- Jul 27, 2021
9a6ae78
Use multispan suggestions more often
estebank Jun 28, 2021
0af50b4
Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov
JohnTitor Jul 30, 2021
c9e45e4
Auto merge of #86754 - estebank:use-multispans-more, r=varkor
bors Jul 30, 2021
fc387b8
Workaround rust-lang/rustfmt#4477 - relative paths in `path` attribute
Jarcho Jul 31, 2021
fe75faa
Fix `while_let_on_iterator`
Jarcho Jul 31, 2021
205aa88
Fix `while_let_on_iterator`
Jarcho Jul 31, 2021
05fa78f
Auto merge of #7520 - Jarcho:while_let_7510, r=Manishearth
bors Jul 31, 2021
a1f790c
Fix clippy
petrochenkov Jul 28, 2021
69d4390
Handle `Result` on `map_flatten` lint
dswij Aug 1, 2021
2f315b8
bump bootstrap compiler to 1.55
pietroalbini Jul 30, 2021
b6c2329
Auto merge of #7519 - Jarcho:rustfmt_fix, r=giraffate
bors Aug 2, 2021
10bb28c
Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
bors Aug 2, 2021
4e760b6
Auto merge of #7522 - dswij:map-flatten-result, r=llogiq
bors Aug 2, 2021
b7d80e7
Updated `define_Conf!` to support multi-line doc comments
xFrednet Aug 2, 2021
51f94ad
Added the `metadata-collector-lint` feature to the CI
xFrednet Aug 2, 2021
77af56d
Auto merge of #7525 - xFrednet:7172-update-define-conf-macro, r=flip1995
bors Aug 2, 2021
bc7fac9
fixup! Lint inside macro when owned by current crate
DevinR528 Aug 3, 2021
54c41c0
needless_borrow: try to make lint example a bit more illustrating
matthiaskrgr Aug 3, 2021
f4ea50b
Use node v12.x in CI
giraffate Aug 4, 2021
afe6b12
Auto merge of #87568 - petrochenkov:localevel, r=cjgillot
bors Aug 4, 2021
827f661
Address warnings for remark check
giraffate Aug 4, 2021
8556910
Auto merge of #7529 - giraffate:update_node_version, r=flip1995,llogiq
bors Aug 4, 2021
2dbf0c1
Auto merge of #7528 - matthiaskrgr:nedlbrw, r=Manishearth
bors Aug 4, 2021
4743ec1
Don't emit `too_many_lines` for closures
LeSeulArtichaut Aug 5, 2021
8a4ffb8
fixed bug that had to deal with mut and non mut suggestion
Valentine-Mario Aug 5, 2021
ccb5d73
Properly handle `Self` type for `trivially_copy_pass_by_ref`
LeSeulArtichaut Aug 5, 2021
15b8708
Add missing backtick in docs for `redundant_allocation`
LeSeulArtichaut Aug 5, 2021
64ff2b0
Replace `span_to_snippet` calls with `snippet_opt` from `clippy_utils`
LeSeulArtichaut Aug 6, 2021
ae700b4
Use `EarlyContext::sess` instead of `LintContext::sess()`
LeSeulArtichaut Aug 6, 2021
43ee3fe
Clean up examples in new lint suggestion template
wooster0 Aug 7, 2021
a0e71e5
Auto merge of #7533 - Valentine-Mario:vec_extend_to_append, r=xFrednet
bors Aug 7, 2021
6cb30ad
Auto merge of #7534 - LeSeulArtichaut:7517-closure-too-many-lines, r=…
bors Aug 7, 2021
176df7c
Auto merge of #7536 - LeSeulArtichaut:redundant-allocation-doc, r=gir…
bors Aug 7, 2021
bc9459f
similar_names: allow "iter" and "item"
mgeier Aug 7, 2021
6d36d1a
merge XOR_SWAP with MANUAL_SWAP
HKalbasi Jul 29, 2021
0084195
Auto merge of #7506 - HKalbasi:add-xor-swap, r=camsteffen
bors Aug 9, 2021
14d2aa1
Auto merge of #7542 - LeSeulArtichaut:cleanups, r=flip1995
bors Aug 9, 2021
87ce09d
Auto merge of #7544 - r00ster91:patch-1, r=flip1995
bors Aug 9, 2021
f998e89
Auto merge of #7478 - DevinR528:preemtive, r=llogiq
bors Aug 10, 2021
76c4a33
Auto merge of #7535 - LeSeulArtichaut:7518-self-ty-arg, r=xFrednet
bors Aug 10, 2021
11ef047
Add unwrap_or_else_default lint
lf- Jul 30, 2021
c78cc7a
Add is_trait_item, refactor or_fun_call and unwrap_or_else_default
lf- Aug 6, 2021
23d398b
tree-wide: Fix all the rustdoc warnings
lf- Aug 6, 2021
652b6a7
update clippy
estebank Aug 11, 2021
fc0af8e
`never_loop`: suggest using an `if let` instead of a `for` loop
LeSeulArtichaut Aug 6, 2021
b1b3860
Auto merge of #7541 - LeSeulArtichaut:for-never-loop, r=camsteffen
bors Aug 11, 2021
573b897
Add test for similar names "iter" and "item"
mgeier Aug 11, 2021
ee63ebe
rustfmt
mgeier Aug 11, 2021
f7784ef
fix line numbers
mgeier Aug 11, 2021
979ce29
Correctly report inclusive range in no_effect lint
F3real Aug 11, 2021
295df88
Reword is_trait_item description
lf- Aug 12, 2021
dd9fe5c
Auto merge of #7556 - F3real:no_effect_inclusive_range, r=flip1995
bors Aug 12, 2021
e62a6ca
Auto merge of #7516 - lf-:unwrap-or-default, r=xFrednet
bors Aug 12, 2021
62f4187
Auto merge of #7546 - mgeier:patch-1, r=giraffate
bors Aug 12, 2021
d02016d
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Aug 12, 2021
c3995b5
Bump nightly version -> 2021-08-12
flip1995 Aug 12, 2021
7bfc26e
Auto merge of #7558 - flip1995:rustup, r=flip1995
bors Aug 12, 2021
f92a0c8
Merge commit '7bfc26ec8e7a454786668e7e52ffe527fc649735' into clippyup
flip1995 Aug 12, 2021
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
5 changes: 3 additions & 2 deletions src/tools/clippy/.github/ISSUE_TEMPLATE/new_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ labels: A-lint
*What is the advantage of the recommended code over the original code*

For example:
- Remove bounce checking inserted by ...
- Remove the need to duplicating/storing/typo ...
- Remove bounds check inserted by ...
- Remove the need to duplicate/store ...
- Remove typo ...

### Drawbacks

Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/.github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV

- name: Build
run: cargo build --features deny-warnings,internal-lints
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint

- name: Test
run: cargo test --features deny-warnings,internal-lints
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint

- name: Test clippy_lints
run: cargo test --features deny-warnings,internal-lints
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
working-directory: clippy_lints

- name: Test rustc_tools_util
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/.github/workflows/clippy_bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ jobs:
echo "$SYSROOT/bin" >> $GITHUB_PATH

- name: Build
run: cargo build --features deny-warnings,internal-lints
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint

- name: Test
run: cargo test --features deny-warnings,internal-lints
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint

- name: Test clippy_lints
run: cargo test --features deny-warnings,internal-lints
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
working-directory: clippy_lints

- name: Test rustc_tools_util
Expand Down
2 changes: 2 additions & 0 deletions src/tools/clippy/.github/workflows/remark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:

- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '12.x'

- name: Install remark
run: npm install remark-cli remark-lint remark-lint-maximum-line-length remark-preset-lint-recommended remark-gfm
Expand Down
141 changes: 136 additions & 5 deletions src/tools/clippy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,141 @@ document.

## Unreleased / In Rust Nightly

[3ae8faf...master](https://github.com/rust-lang/rust-clippy/compare/3ae8faf...master)
[74d1561...master](https://github.com/rust-lang/rust-clippy/compare/74d1561...master)

## Rust 1.55

Current beta, release 2021-09-09

[3ae8faf...74d1561](https://github.com/rust-lang/rust-clippy/compare/3ae8faf...74d1561)

### Important Changes

* Stabilized `cargo clippy --fix` :tada:
[#7405](https://github.com/rust-lang/rust-clippy/pull/7405)

### New Lints

* [`rc_mutex`]
[#7316](https://github.com/rust-lang/rust-clippy/pull/7316)
* [`nonstandard_macro_braces`]
[#7299](https://github.com/rust-lang/rust-clippy/pull/7299)
* [`strlen_on_c_strings`]
[#7243](https://github.com/rust-lang/rust-clippy/pull/7243)
* [`self_named_constructors`]
[#7403](https://github.com/rust-lang/rust-clippy/pull/7403)
* [`disallowed_script_idents`]
[#7400](https://github.com/rust-lang/rust-clippy/pull/7400)
* [`disallowed_type`]
[#7315](https://github.com/rust-lang/rust-clippy/pull/7315)
* [`missing_enforced_import_renames`]
[#7300](https://github.com/rust-lang/rust-clippy/pull/7300)
* [`extend_with_drain`]
[#7270](https://github.com/rust-lang/rust-clippy/pull/7270)

### Moves and Deprecations

* Moved [`from_iter_instead_of_collect`] to `pedantic`
[#7375](https://github.com/rust-lang/rust-clippy/pull/7375)
* Added `suspicious` as a new lint group for *code that is most likely wrong or useless*
[#7350](https://github.com/rust-lang/rust-clippy/pull/7350)
* Moved [`blanket_clippy_restriction_lints`] to `suspicious`
* Moved [`empty_loop`] to `suspicious`
* Moved [`eval_order_dependence`] to `suspicious`
* Moved [`float_equality_without_abs`] to `suspicious`
* Moved [`for_loops_over_fallibles`] to `suspicious`
* Moved [`misrefactored_assign_op`] to `suspicious`
* Moved [`mut_range_bound`] to `suspicious`
* Moved [`mutable_key_type`] to `suspicious`
* Moved [`suspicious_arithmetic_impl`] to `suspicious`
* Moved [`suspicious_assignment_formatting`] to `suspicious`
* Moved [`suspicious_else_formatting`] to `suspicious`
* Moved [`suspicious_map`] to `suspicious`
* Moved [`suspicious_op_assign_impl`] to `suspicious`
* Moved [`suspicious_unary_op_formatting`] to `suspicious`

### Enhancements

* [`while_let_on_iterator`]: Now suggests `&mut iter` inside closures
[#7262](https://github.com/rust-lang/rust-clippy/pull/7262)
* [`doc_markdown`]:
* Now detects unbalanced ticks
[#7357](https://github.com/rust-lang/rust-clippy/pull/7357)
* Add `FreeBSD` to the default configuration as an allowed identifier
[#7334](https://github.com/rust-lang/rust-clippy/pull/7334)
* [`wildcard_enum_match_arm`], [`match_wildcard_for_single_variants`]: Now allows wildcards for enums with unstable
or hidden variants
[#7407](https://github.com/rust-lang/rust-clippy/pull/7407)
* [`redundant_allocation`]: Now additionally supports the `Arc<>` type
[#7308](https://github.com/rust-lang/rust-clippy/pull/7308)
* [`blacklisted_name`]: Now allows blacklisted names in test code
[#7379](https://github.com/rust-lang/rust-clippy/pull/7379)
* [`redundant_closure`]: Suggests `&mut` for `FnMut`
[#7437](https://github.com/rust-lang/rust-clippy/pull/7437)
* [`disallowed_method`], [`disallowed_type`]: The configuration values `disallowed-method` and `disallowed-type`
no longer require fully qualified paths
[#7345](https://github.com/rust-lang/rust-clippy/pull/7345)
* [`zst_offset`]: Fixed lint invocation after it was accidentally suppressed
[#7396](https://github.com/rust-lang/rust-clippy/pull/7396)

### False Positive Fixes

* [`default_numeric_fallback`]: No longer lints on float literals as function arguments
[#7446](https://github.com/rust-lang/rust-clippy/pull/7446)
* [`use_self`]: No longer lints on type parameters
[#7288](https://github.com/rust-lang/rust-clippy/pull/7288)
* [`unimplemented`]: Now ignores the `assert` and `debug_assert` macros
[#7439](https://github.com/rust-lang/rust-clippy/pull/7439)
* [`branches_sharing_code`]: Now always checks for block expressions
[#7462](https://github.com/rust-lang/rust-clippy/pull/7462)
* [`field_reassign_with_default`]: No longer triggers in macros
[#7160](https://github.com/rust-lang/rust-clippy/pull/7160)
* [`redundant_clone`]: No longer lints on required clones for borrowed data
[#7346](https://github.com/rust-lang/rust-clippy/pull/7346)
* [`default_numeric_fallback`]: No longer triggers in external macros
[#7325](https://github.com/rust-lang/rust-clippy/pull/7325)
* [`needless_bool`]: No longer lints in macros
[#7442](https://github.com/rust-lang/rust-clippy/pull/7442)
* [`useless_format`]: No longer triggers when additional text is being appended
[#7442](https://github.com/rust-lang/rust-clippy/pull/7442)
* [`assertions_on_constants`]: `cfg!(...)` is no longer considered to be a constant
[#7319](https://github.com/rust-lang/rust-clippy/pull/7319)

### Suggestion Fixes/Improvements

* [`needless_collect`]: Now show correct lint messages for shadowed values
[#7289](https://github.com/rust-lang/rust-clippy/pull/7289)
* [`wrong_pub_self_convention`]: The deprecated message now suggest the correct configuration value
[#7382](https://github.com/rust-lang/rust-clippy/pull/7382)
* [`semicolon_if_nothing_returned`]: Allow missing semicolon in blocks with only one expression
[#7326](https://github.com/rust-lang/rust-clippy/pull/7326)

### ICE Fixes

* [`zero_sized_map_values`]
[#7470](https://github.com/rust-lang/rust-clippy/pull/7470)
* [`redundant_pattern_matching`]
[#7471](https://github.com/rust-lang/rust-clippy/pull/7471)
* [`modulo_one`]
[#7473](https://github.com/rust-lang/rust-clippy/pull/7473)
* [`use_self`]
[#7428](https://github.com/rust-lang/rust-clippy/pull/7428)

### Documentation Improvements

* Reworked Clippy's website:
[#7279](https://github.com/rust-lang/rust-clippy/pull/7279)
[#7172](https://github.com/rust-lang/rust-clippy/issues/7172)
* Added applicability information about lints
* Added a link to jump into the implementation
* Improved loading times
* Adapted some styling
* Clippy now uses a lint to generate its documentation
[#7298](https://github.com/rust-lang/rust-clippy/pull/7298)

## Rust 1.54

Current beta, release 2021-07-29
Current stable, released 2021-07-29

[7c7683c...3ae8faf](https://github.com/rust-lang/rust-clippy/compare/7c7683c...3ae8faf)

Expand All @@ -29,7 +159,7 @@ Current beta, release 2021-07-29
### Moves and Deprecations

- Deprecate `pub_enum_variant_names` and `wrong_pub_self_convention` in favor of
the new `avoid_breaking_exported_api` config option (see
the new `avoid-breaking-exported-api` config option (see
[Enhancements](#1-54-enhancements))
[#7187](https://github.com/rust-lang/rust-clippy/pull/7187)
- Move [`inconsistent_struct_constructor`] to `pedantic`
Expand All @@ -51,7 +181,7 @@ Current beta, release 2021-07-29
[#7163](https://github.com/rust-lang/rust-clippy/pull/7163)
- [`if_then_some_else_none`]: Now works with the MSRV config
[#7177](https://github.com/rust-lang/rust-clippy/pull/7177)
- Add `avoid_breaking_exported_api` config option for the lints
- Add `avoid-breaking-exported-api` config option for the lints
[`enum_variant_names`], [`large_types_passed_by_value`],
[`trivially_copy_pass_by_ref`], [`unnecessary_wraps`],
[`upper_case_acronyms`], and [`wrong_self_convention`]. We recommend to set
Expand Down Expand Up @@ -138,7 +268,7 @@ Current beta, release 2021-07-29

## Rust 1.53

Current stable, released 2021-06-17
Released 2021-06-17

[6ed6f1e...7c7683c](https://github.com/rust-lang/rust-clippy/compare/6ed6f1e...7c7683c)

Expand Down Expand Up @@ -2869,6 +2999,7 @@ Released 2018-09-13
[`unused_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
[`unusual_byte_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings
[`unwrap_in_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_in_result
[`unwrap_or_else_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_else_default
[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
[`upper_case_acronyms`]: https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/as_conversions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clippy_utils::diagnostics::span_lint_and_help;
use rustc_ast::ast::{Expr, ExprKind};
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};

Expand Down Expand Up @@ -47,7 +47,7 @@ declare_lint_pass!(AsConversions => [AS_CONVERSIONS]);

impl EarlyLintPass for AsConversions {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if in_external_macro(cx.sess(), expr.span) {
if in_external_macro(cx.sess, expr.span) {
return;
}

Expand Down
20 changes: 2 additions & 18 deletions src/tools/clippy/clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
panic_span: None,
};
fpu.visit_expr(&body.value);
lint_for_missing_headers(
cx,
item.def_id,
item.span,
sig,
headers,
Some(body_id),
fpu.panic_span,
);
lint_for_missing_headers(cx, item.def_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
}
},
hir::ItemKind::Impl(ref impl_) => {
Expand Down Expand Up @@ -278,15 +270,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
panic_span: None,
};
fpu.visit_expr(&body.value);
lint_for_missing_headers(
cx,
item.def_id,
item.span,
sig,
headers,
Some(body_id),
fpu.panic_span,
);
lint_for_missing_headers(cx, item.def_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/else_if_without_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use clippy_utils::diagnostics::span_lint_and_help;
use rustc_ast::ast::{Expr, ExprKind};
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};

Expand Down Expand Up @@ -49,7 +49,7 @@ declare_lint_pass!(ElseIfWithoutElse => [ELSE_IF_WITHOUT_ELSE]);

impl EarlyLintPass for ElseIfWithoutElse {
fn check_expr(&mut self, cx: &EarlyContext<'_>, mut item: &Expr) {
if in_external_macro(cx.sess(), item.span) {
if in_external_macro(cx.sess, item.span) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
hir_id: hir::HirId,
) {
too_many_arguments::check_fn(cx, kind, decl, span, hir_id, self.too_many_arguments_threshold);
too_many_lines::check_fn(cx, span, body, self.too_many_lines_threshold);
too_many_lines::check_fn(cx, kind, span, body, self.too_many_lines_threshold);
not_unsafe_ptr_arg_deref::check_fn(cx, kind, decl, body, hir_id);
}

Expand Down
13 changes: 11 additions & 2 deletions src/tools/clippy/clippy_lints/src/functions/too_many_lines.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rustc_hir as hir;
use rustc_hir::intravisit::FnKind;
use rustc_lint::{LateContext, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_span::Span;
Expand All @@ -8,8 +9,16 @@ use clippy_utils::source::snippet_opt;

use super::TOO_MANY_LINES;

pub(super) fn check_fn(cx: &LateContext<'_>, span: Span, body: &'tcx hir::Body<'_>, too_many_lines_threshold: u64) {
if in_external_macro(cx.sess(), span) {
pub(super) fn check_fn(
cx: &LateContext<'_>,
kind: FnKind<'tcx>,
span: Span,
body: &'tcx hir::Body<'_>,
too_many_lines_threshold: u64,
) {
// Closures must be contained in a parent body, which will be checked for `too_many_lines`.
// Don't check closures for `too_many_lines` to avoid duplicated lints.
if matches!(kind, FnKind::Closure) || in_external_macro(cx.sess(), span) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/if_not_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use clippy_utils::diagnostics::span_lint_and_help;
use rustc_ast::ast::{BinOpKind, Expr, ExprKind, UnOp};
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};

Expand Down Expand Up @@ -48,7 +48,7 @@ declare_lint_pass!(IfNotElse => [IF_NOT_ELSE]);

impl EarlyLintPass for IfNotElse {
fn check_expr(&mut self, cx: &EarlyContext<'_>, item: &Expr) {
if in_external_macro(cx.sess(), item.span) {
if in_external_macro(cx.sess, item.span) {
return;
}
if let ExprKind::If(ref cond, _, Some(ref els)) = item.kind {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_lints/src/items_after_statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use clippy_utils::diagnostics::span_lint;
use rustc_ast::ast::{Block, ItemKind, StmtKind};
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};

Expand Down Expand Up @@ -54,7 +54,7 @@ declare_lint_pass!(ItemsAfterStatements => [ITEMS_AFTER_STATEMENTS]);

impl EarlyLintPass for ItemsAfterStatements {
fn check_block(&mut self, cx: &EarlyContext<'_>, item: &Block) {
if in_external_macro(cx.sess(), item.span) {
if in_external_macro(cx.sess, item.span) {
return;
}

Expand All @@ -68,7 +68,7 @@ impl EarlyLintPass for ItemsAfterStatements {
// lint on all further items
for stmt in stmts {
if let StmtKind::Item(ref it) = *stmt {
if in_external_macro(cx.sess(), it.span) {
if in_external_macro(cx.sess, it.span) {
return;
}
if let ItemKind::MacroDef(..) = it.kind {
Expand Down
Loading