Skip to content

Commit 9c3bc80

Browse files
committed
Auto merge of #127049 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
2 parents 2495953 + 3ce7f9e commit 9c3bc80

File tree

103 files changed

+3631
-1008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3631
-1008
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Lintcheck
2+
3+
on: pull_request
4+
5+
env:
6+
RUST_BACKTRACE: 1
7+
CARGO_INCREMENTAL: 0
8+
9+
concurrency:
10+
# For a given workflow, if we push to the same PR, cancel all previous builds on that PR.
11+
group: "${{ github.workflow }}-${{ github.event.pull_request.number}}"
12+
cancel-in-progress: true
13+
14+
jobs:
15+
# Runs lintcheck on the PR's target branch and stores the results as an artifact
16+
base:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
# HEAD is the generated merge commit `refs/pull/N/merge` between the PR and `master`, `HEAD^`
26+
# being the commit from `master` that is the base of the merge
27+
- name: Checkout base
28+
run: git checkout HEAD^
29+
30+
# Use the lintcheck from the PR to generate the JSON in case the PR modifies lintcheck in some
31+
# way
32+
- name: Checkout current lintcheck
33+
run: |
34+
rm -rf lintcheck
35+
git checkout ${{ github.sha }} -- lintcheck
36+
37+
- name: Cache lintcheck bin
38+
id: cache-lintcheck-bin
39+
uses: actions/cache@v4
40+
with:
41+
path: target/debug/lintcheck
42+
key: lintcheck-bin-${{ hashfiles('lintcheck/**') }}
43+
44+
- name: Build lintcheck
45+
if: steps.cache-lintcheck-bin.outputs.cache-hit != 'true'
46+
run: cargo build --manifest-path=lintcheck/Cargo.toml
47+
48+
- name: Create cache key
49+
id: key
50+
run: echo "key=lintcheck-base-${{ hashfiles('lintcheck/**') }}-$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
51+
52+
- name: Cache results JSON
53+
id: cache-json
54+
uses: actions/cache@v4
55+
with:
56+
path: lintcheck-logs/lintcheck_crates_logs.json
57+
key: ${{ steps.key.outputs.key }}
58+
59+
- name: Run lintcheck
60+
if: steps.cache-json.outputs.cache-hit != 'true'
61+
run: ./target/debug/lintcheck --format json
62+
63+
- name: Upload base JSON
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: base
67+
path: lintcheck-logs/lintcheck_crates_logs.json
68+
69+
# Runs lintcheck on the PR and stores the results as an artifact
70+
head:
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v4
76+
77+
- name: Cache lintcheck bin
78+
id: cache-lintcheck-bin
79+
uses: actions/cache@v4
80+
with:
81+
path: target/debug/lintcheck
82+
key: lintcheck-bin-${{ hashfiles('lintcheck/**') }}
83+
84+
- name: Build lintcheck
85+
if: steps.cache-lintcheck-bin.outputs.cache-hit != 'true'
86+
run: cargo build --manifest-path=lintcheck/Cargo.toml
87+
88+
- name: Run lintcheck
89+
run: ./target/debug/lintcheck --format json
90+
91+
- name: Upload head JSON
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: head
95+
path: lintcheck-logs/lintcheck_crates_logs.json
96+
97+
# Retrieves the head and base JSON results and prints the diff to the GH actions step summary
98+
diff:
99+
runs-on: ubuntu-latest
100+
101+
needs: [base, head]
102+
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v4
106+
107+
- name: Restore lintcheck bin
108+
uses: actions/cache/restore@v4
109+
with:
110+
path: target/debug/lintcheck
111+
key: lintcheck-bin-${{ hashfiles('lintcheck/**') }}
112+
fail-on-cache-miss: true
113+
114+
- name: Download JSON
115+
uses: actions/download-artifact@v4
116+
117+
- name: Diff results
118+
run: ./target/debug/lintcheck diff {base,head}/lintcheck_crates_logs.json >> $GITHUB_STEP_SUMMARY

src/tools/clippy/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -5362,6 +5362,7 @@ Released 2018-09-13
53625362
[`extra_unused_type_parameters`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
53635363
[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
53645364
[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
5365+
[`field_scoped_visibility_modifiers`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_scoped_visibility_modifiers
53655366
[`filetype_is_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#filetype_is_file
53665367
[`filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map
53675368
[`filter_map_bool_then`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_bool_then
@@ -5520,6 +5521,7 @@ Released 2018-09-13
55205521
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
55215522
[`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
55225523
[`manual_hash_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one
5524+
[`manual_inspect`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
55235525
[`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed
55245526
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
55255527
[`manual_is_finite`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_finite
@@ -5915,6 +5917,7 @@ Released 2018-09-13
59155917
[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
59165918
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
59175919
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
5920+
[`unnecessary_min_or_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max
59185921
[`unnecessary_mut_passed`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed
59195922
[`unnecessary_operation`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
59205923
[`unnecessary_owned_empty_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_owned_empty_strings

src/tools/clippy/book/src/lint_configuration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ default configuration of Clippy. By default, any configuration will replace the
454454
* `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
455455
* `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.
456456

457-
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "WebGL", "WebGL2", "WebGPU", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
457+
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "DevOps", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "WebGL", "WebGL2", "WebGPU", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
458458

459459
---
460460
**Affected lints:**
@@ -695,6 +695,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
695695
* [`manual_is_ascii_check`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check)
696696
* [`manual_let_else`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else)
697697
* [`manual_non_exhaustive`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive)
698+
* [`manual_pattern_char_comparison`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_pattern_char_comparison)
698699
* [`manual_range_contains`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains)
699700
* [`manual_rem_euclid`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid)
700701
* [`manual_retain`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain)

src/tools/clippy/book/src/usage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You can configure lint levels on the command line by adding
3636
cargo clippy -- -Aclippy::style -Wclippy::double_neg -Dclippy::perf
3737
```
3838

39-
For [CI] all warnings can be elevated to errors which will inturn fail
39+
For [CI] all warnings can be elevated to errors which will in turn fail
4040
the build and cause Clippy to exit with a code other than `0`.
4141

4242
```

src/tools/clippy/clippy_config/src/conf.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::{cmp, env, fmt, fs, io};
1818
#[rustfmt::skip]
1919
const DEFAULT_DOC_VALID_IDENTS: &[&str] = &[
2020
"KiB", "MiB", "GiB", "TiB", "PiB", "EiB",
21+
"DevOps",
2122
"DirectX",
2223
"ECMAScript",
2324
"GPLv2", "GPLv3",
@@ -265,7 +266,7 @@ define_Conf! {
265266
///
266267
/// Suppress lints whenever the suggested change would cause breakage for other crates.
267268
(avoid_breaking_exported_api: bool = true),
268-
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP, MANUAL_C_STR_LITERALS, ASSIGNING_CLONES, LEGACY_NUMERIC_CONSTANTS, ALLOW_ATTRIBUTES, ALLOW_ATTRIBUTES_WITHOUT_REASON.
269+
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP, MANUAL_C_STR_LITERALS, ASSIGNING_CLONES, LEGACY_NUMERIC_CONSTANTS, MANUAL_PATTERN_CHAR_COMPARISON, ALLOW_ATTRIBUTES, ALLOW_ATTRIBUTES_WITHOUT_REASON.
269270
///
270271
/// The minimum rust version that the project supports. Defaults to the `rust-version` field in `Cargo.toml`
271272
#[default_text = ""]

src/tools/clippy/clippy_config/src/msrvs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ macro_rules! msrv_aliases {
1919
msrv_aliases! {
2020
1,81,0 { LINT_REASONS_STABILIZATION }
2121
1,77,0 { C_STR_LITERALS }
22-
1,76,0 { PTR_FROM_REF }
22+
1,76,0 { PTR_FROM_REF, OPTION_RESULT_INSPECT }
2323
1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE }
2424
1,70,0 { OPTION_RESULT_IS_VARIANT_AND, BINARY_HEAP_RETAIN }
2525
1,68,0 { PATH_MAIN_SEPARATOR_STR }

src/tools/clippy/clippy_lints/src/arc_with_non_send_sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare_clippy_lint! {
1717
/// `Arc<T>` is a thread-safe `Rc<T>` and guarantees that updates to the reference counter
1818
/// use atomic operations. To send an `Arc<T>` across thread boundaries and
1919
/// share ownership between multiple threads, `T` must be [both `Send` and `Sync`](https://doc.rust-lang.org/std/sync/struct.Arc.html#thread-safety),
20-
/// so either `T` should be made `Send + Sync` or an `Rc` should be used instead of an `Arc`
20+
/// so either `T` should be made `Send + Sync` or an `Rc` should be used instead of an `Arc`.
2121
///
2222
/// ### Example
2323
/// ```no_run

src/tools/clippy/clippy_lints/src/assigning_clones.rs

+77-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
use clippy_config::msrvs::{self, Msrv};
22
use clippy_utils::diagnostics::span_lint_and_then;
33
use clippy_utils::macros::HirNode;
4+
use clippy_utils::mir::{enclosing_mir, PossibleBorrowerMap};
45
use clippy_utils::sugg::Sugg;
56
use clippy_utils::{is_trait_method, local_is_initialized, path_to_local};
67
use rustc_errors::Applicability;
78
use rustc_hir::{self as hir, Expr, ExprKind};
89
use rustc_lint::{LateContext, LateLintPass};
10+
use rustc_middle::mir;
911
use rustc_middle::ty::{self, Instance, Mutability};
1012
use rustc_session::impl_lint_pass;
1113
use rustc_span::def_id::DefId;
1214
use rustc_span::symbol::sym;
13-
use rustc_span::{ExpnKind, SyntaxContext};
15+
use rustc_span::{ExpnKind, Span, SyntaxContext};
1416

1517
declare_clippy_lint! {
1618
/// ### What it does
@@ -144,6 +146,7 @@ fn extract_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<
144146
};
145147

146148
Some(CallCandidate {
149+
span: expr.span,
147150
target,
148151
kind,
149152
method_def_id: resolved_method.def_id(),
@@ -215,13 +218,85 @@ fn is_ok_to_suggest<'tcx>(cx: &LateContext<'tcx>, lhs: &Expr<'tcx>, call: &CallC
215218
return false;
216219
};
217220

221+
if clone_source_borrows_from_dest(cx, lhs, call.span) {
222+
return false;
223+
}
224+
218225
// Now take a look if the impl block defines an implementation for the method that we're interested
219226
// in. If not, then we're using a default implementation, which is not interesting, so we will
220227
// not suggest the lint.
221228
let implemented_fns = cx.tcx.impl_item_implementor_ids(impl_block);
222229
implemented_fns.contains_key(&provided_fn.def_id)
223230
}
224231

232+
/// Checks if the data being cloned borrows from the place that is being assigned to:
233+
///
234+
/// ```
235+
/// let mut s = String::new();
236+
/// let s2 = &s;
237+
/// s = s2.to_owned();
238+
/// ```
239+
///
240+
/// This cannot be written `s2.clone_into(&mut s)` because it has conflicting borrows.
241+
fn clone_source_borrows_from_dest(cx: &LateContext<'_>, lhs: &Expr<'_>, call_span: Span) -> bool {
242+
/// If this basic block only exists to drop a local as part of an assignment, returns its
243+
/// successor. Otherwise returns the basic block that was passed in.
244+
fn skip_drop_block(mir: &mir::Body<'_>, bb: mir::BasicBlock) -> mir::BasicBlock {
245+
if let mir::TerminatorKind::Drop { target, .. } = mir.basic_blocks[bb].terminator().kind {
246+
target
247+
} else {
248+
bb
249+
}
250+
}
251+
252+
let Some(mir) = enclosing_mir(cx.tcx, lhs.hir_id) else {
253+
return false;
254+
};
255+
let PossibleBorrowerMap { map: borrow_map, .. } = PossibleBorrowerMap::new(cx, mir);
256+
257+
// The operation `dest = src.to_owned()` in MIR is split up across 3 blocks *if* the type has `Drop`
258+
// code. For types that don't, the second basic block is simply skipped.
259+
// For the doc example above that would be roughly:
260+
//
261+
// bb0:
262+
// s2 = &s
263+
// s_temp = ToOwned::to_owned(move s2) -> bb1
264+
//
265+
// bb1:
266+
// drop(s) -> bb2 // drop the old string
267+
//
268+
// bb2:
269+
// s = s_temp
270+
for bb in mir.basic_blocks.iter() {
271+
let terminator = bb.terminator();
272+
273+
// Look for the to_owned/clone call.
274+
if terminator.source_info.span != call_span {
275+
continue;
276+
}
277+
278+
if let mir::TerminatorKind::Call { ref args, target: Some(assign_bb), .. } = terminator.kind
279+
&& let [source] = &**args
280+
&& let mir::Operand::Move(source) = &source.node
281+
&& let assign_bb = skip_drop_block(mir, assign_bb)
282+
// Skip any storage statements as they are just noise
283+
&& let Some(assignment) = mir.basic_blocks[assign_bb].statements
284+
.iter()
285+
.find(|stmt| {
286+
!matches!(stmt.kind, mir::StatementKind::StorageDead(_) | mir::StatementKind::StorageLive(_))
287+
})
288+
&& let mir::StatementKind::Assign(box (borrowed, _)) = &assignment.kind
289+
&& let Some(borrowers) = borrow_map.get(&borrowed.local)
290+
&& borrowers.contains(source.local)
291+
{
292+
return true;
293+
}
294+
295+
return false;
296+
}
297+
false
298+
}
299+
225300
fn suggest<'tcx>(
226301
cx: &LateContext<'tcx>,
227302
ctxt: SyntaxContext,
@@ -255,6 +330,7 @@ enum TargetTrait {
255330

256331
#[derive(Debug)]
257332
struct CallCandidate<'tcx> {
333+
span: Span,
258334
target: TargetTrait,
259335
kind: CallKind<'tcx>,
260336
// DefId of the called method from an impl block that implements the target trait

src/tools/clippy/clippy_lints/src/attrs/allow_attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
use super::ALLOW_ATTRIBUTES;
12
use clippy_utils::diagnostics::span_lint_and_sugg;
23
use clippy_utils::is_from_proc_macro;
34
use rustc_ast::{AttrStyle, Attribute};
45
use rustc_errors::Applicability;
56
use rustc_lint::{LateContext, LintContext};
67
use rustc_middle::lint::in_external_macro;
7-
use super::ALLOW_ATTRIBUTES;
88

99
// Separate each crate's features.
1010
pub fn check<'cx>(cx: &LateContext<'cx>, attr: &'cx Attribute) {
1111
if !in_external_macro(cx.sess(), attr.span)
1212
&& let AttrStyle::Outer = attr.style
1313
&& let Some(ident) = attr.ident()
14-
&& !is_from_proc_macro(cx, &attr)
14+
&& !is_from_proc_macro(cx, attr)
1515
{
1616
span_lint_and_sugg(
1717
cx,

src/tools/clippy/clippy_lints/src/attrs/allow_attributes_without_reason.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(super) fn check<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMet
1717
}
1818

1919
// Check if the attribute is in an external macro and therefore out of the developer's control
20-
if in_external_macro(cx.sess(), attr.span) || is_from_proc_macro(cx, &attr) {
20+
if in_external_macro(cx.sess(), attr.span) || is_from_proc_macro(cx, attr) {
2121
return;
2222
}
2323

src/tools/clippy/clippy_lints/src/attrs/mod.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! checks for attributes
22
3-
mod allow_attributes_without_reason;
43
mod allow_attributes;
4+
mod allow_attributes_without_reason;
55
mod blanket_clippy_restriction_lints;
66
mod deprecated_cfg_attr;
77
mod deprecated_semver;
@@ -505,6 +505,7 @@ pub struct Attributes {
505505
}
506506

507507
impl_lint_pass!(Attributes => [
508+
ALLOW_ATTRIBUTES,
508509
ALLOW_ATTRIBUTES_WITHOUT_REASON,
509510
INLINE_ALWAYS,
510511
DEPRECATED_SEMVER,
@@ -534,15 +535,12 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
534535
if is_lint_level(ident.name, attr.id) {
535536
blanket_clippy_restriction_lints::check(cx, ident.name, items);
536537
}
537-
if matches!(ident.name, sym::allow) {
538-
if self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION) {
539-
allow_attributes::check(cx, attr);
540-
}
538+
if matches!(ident.name, sym::allow) && self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION) {
539+
allow_attributes::check(cx, attr);
541540
}
542-
if matches!(ident.name, sym::allow | sym::expect) {
543-
if self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION) {
544-
allow_attributes_without_reason::check(cx, ident.name, items, attr);
545-
}
541+
if matches!(ident.name, sym::allow | sym::expect) && self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION)
542+
{
543+
allow_attributes_without_reason::check(cx, ident.name, items, attr);
546544
}
547545
if items.is_empty() || !attr.has_name(sym::deprecated) {
548546
return;

0 commit comments

Comments
 (0)