Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
f39ed7a
fix: `match_single_binding` suggests wrongly inside tuple
profetia Aug 22, 2025
e1ed9ec
clean-up
ada4a Sep 25, 2025
c3257f4
merge `DeprecationStatus::{Replaced,Deprecated}`
ada4a Sep 28, 2025
0c01341
overhaul `LimitStack`
ada4a Sep 25, 2025
e55b435
give functions more descriptive names, add docs
ada4a Sep 25, 2025
1aa5b99
clean-up a bit
ada4a Oct 1, 2025
12426b6
fix: return `true` everywhere we emit the lint
ada4a Oct 1, 2025
6aecd1f
refactor: also handle `Vec` in `match_buffer_type`
ada4a Oct 1, 2025
3714236
fix: make the suggestion apply only to the inner type
ada4a Oct 1, 2025
f2e6667
refactor: reduce code duplication further
ada4a Oct 1, 2025
a4924e2
clean-up
ada4a Oct 11, 2025
9816437
feat(ok_expect): add autofix
ada4a Oct 11, 2025
dd943fd
fix: `match_single_binding` misses curlies for const
profetia Oct 10, 2025
2fe16a5
Fix spacing typo in new inefficient_to_string info
MeGaGiGaGon Oct 15, 2025
b42f87c
fix: `missing_inline_in_public_items` fail to fulfill `expect` in `--…
profetia Jul 21, 2025
ff9a175
refactor ub_checks and contract_checks to share logic
pitaj May 4, 2025
892cb18
clean-up
ada4a Oct 21, 2025
59890a9
introduce `as_some_pattern`
ada4a Oct 21, 2025
605cc87
introduce `as_some_expr`, `is_none_expr`
ada4a Oct 21, 2025
b7f9216
Consider type conversion that won't overflow
c410-f3r Oct 27, 2025
bd22913
`unused_enumerate_index`: move to loops lint pass
Jarcho Oct 28, 2025
ce6f8bc
Refactor `unused_enumerate_index`.
Jarcho Oct 28, 2025
07b6b32
Trait aliases are rare large ast nodes, box them
oli-obk Jul 21, 2025
6d7072b
extend `needless_collect`
lengyijun Mar 6, 2025
42f074d
Implement pattern matching for `&pin mut|const T`
frank-king Apr 13, 2025
8992878
Rename `#[pin_project]` to `#[pin_v2]` to avoid naming conflicts
frank-king Oct 24, 2025
0fd7406
fix: Only special case single line item attribute suggestions
Muscraft Oct 22, 2025
3f5ea6b
Constify trait aliases
oli-obk Jul 21, 2025
33232af
Rollup merge of #144291 - oli-obk:const_trait_alias, r=fee1-dead
matthiaskrgr Oct 31, 2025
938dd5f
misc: test cases with escaping are mostly autofixable now
ada4a Oct 10, 2025
6c93427
move `write.rs` to `write/mod.rs`
ada4a Oct 10, 2025
0fcb000
extract each lint into its own module
ada4a Oct 10, 2025
c71f7b6
Merge commit 'c936595d17413c1f08e162e117e504fb4ed126e4' into clippy-s…
flip1995 Oct 31, 2025
c23eed6
refactor(write): split each lint into its own module (#15857)
Alexendoo Oct 31, 2025
e629869
extend `needless_collect` (#14361)
Jarcho Oct 31, 2025
34abe4e
use `ExtractIf`
ada4a Jul 25, 2025
adf38c0
match on `kind` directly
ada4a Jul 25, 2025
31b7ddc
use `if let`
ada4a Jul 25, 2025
44e3b16
rm some `Box`es
ada4a Jul 28, 2025
e7b4ae8
clean-up
ada4a Oct 12, 2025
54a84c1
move `ptr.rs` to `ptr/mod.rs`
ada4a Oct 31, 2025
ccd5130
extract each lint into its own module
ada4a Oct 31, 2025
f51c555
clean-up `unnested_or_patterns` (#15344)
Jarcho Nov 1, 2025
a2c13c1
refactor(ptr): split each lint into a separate module (#16001)
Jarcho Nov 1, 2025
78adb20
Rollup merge of #139751 - frank-king:feature/pin-project, r=Nadrieril…
matthiaskrgr Nov 1, 2025
7ec6593
Rollup merge of #148340 - flip1995:clippy-subtree-update, r=Manishearth
matthiaskrgr Nov 1, 2025
7562179
Overhaul and document `clippy_utils::attrs` (#15763)
Jarcho Nov 1, 2025
6bc8d21
fix(let_and_return): disallow _any_ text between let and return
ada4a Nov 1, 2025
eefeff5
mgca: Add ConstArg representation for const items
camelid Oct 14, 2025
31d8210
`unused_enumerate_index`: move to loops lint pass (#15279)
y21 Nov 1, 2025
8e8fe61
Introduce helper functions for `Some(x)`/`None` patterns and expressi…
llogiq Nov 1, 2025
6729799
Fix spacing typo in new inefficient_to_string info (#15888)
llogiq Nov 1, 2025
098ded3
fix: `replace_box` FP when the box is moved
profetia Nov 1, 2025
e121ab8
Fix `replace_box` FP when the box is moved (#15984)
samueltardieu Nov 2, 2025
a456519
fix(let_and_return): disallow _any_ text between let and return (#16006)
samueltardieu Nov 2, 2025
ce0c449
Generalize branch references to HEAD
Kobzol Nov 2, 2025
8f9ef1c
Fix `missing_transmute_annotations` example
GuillaumeGomez Nov 3, 2025
0afbb65
Remove `no_run` tags on `missing_transmute_annotations` code examples
GuillaumeGomez Nov 3, 2025
ad7fc4f
Fix `missing_transmute_annotations` example (#16024)
Centri3 Nov 3, 2025
99124be
Rollup merge of #148004 - Muscraft:only-single-line-item-attributes, …
matthiaskrgr Nov 3, 2025
0d6fdc0
Use macOS 14 instead of GitHub-deprecated macOS 13
samueltardieu Nov 4, 2025
deff3fd
CI: use macOS 14 instead of GitHub-deprecated macOS 13 in merge queue…
flip1995 Nov 5, 2025
4eac58a
Consider type conversion that won't overflow (#15950)
samueltardieu Nov 5, 2025
3dab273
Do not run merge queue tests on tier 2 x86_64-apple-darwin
samueltardieu Nov 5, 2025
8769aff
CI: do not run merge queue tests on tier 2 x86_64-apple-darwin (#16035)
flip1995 Nov 5, 2025
5db7300
feat: Use annotate-snippets by default on nightly
Muscraft Oct 15, 2025
c100a08
fix: `nonminimal_bool` wrongly unmangled terms
profetia Nov 2, 2025
c95d95b
Fix `match_single_binding` suggests wrongly inside tuple (#15539)
llogiq Nov 6, 2025
0ab135f
fix: `missing_asserts_for_indexing` changes `assert_eq` to `assert`
profetia Nov 5, 2025
a86dd63
Make `missing_inline_in_public_items` warn on executables
profetia Aug 21, 2025
8539de9
Don't flag cfg(test) as multiple inherent impl
nickdrozd Nov 5, 2025
52a3999
Fix `missing_inline_in_public_items` fail to fulfill `expect` in `--t…
Alexendoo Nov 6, 2025
36324e8
Don't flag cfg(test) as multiple inherent impl (#16041)
llogiq Nov 6, 2025
c004be4
Fix `nonminimal_bool` wrongly unmangled terms (#16017)
Jarcho Nov 6, 2025
8ed05ab
Fix `missing_asserts_for_indexing` changes `assert_eq` to `assert` (#…
llogiq Nov 6, 2025
e6a3dde
Make bug report issue template more similar to that of `rust-lang/rust`
ada4a Nov 7, 2025
da7bde7
Fix mod_module_files FP for tests in workspaces
TomFryersMidsummer Nov 7, 2025
dddaf07
Make bug report issue template more similar to that of `rust-lang/rus…
flip1995 Nov 7, 2025
9147a36
perf(manual_is_power_of_two): perform the `is_integer_literal` check …
ada4a Nov 7, 2025
21ddc50
chore(unnecessary_map_on_constructor): clean-up
ada4a Nov 7, 2025
6e33489
chore(unnecessary_map_on_constructor): clean-up (#16051)
Alexendoo Nov 8, 2025
b59b2fd
chore(unnecessary_mut_passed): show the intention not to lint `&raw` …
ada4a Nov 8, 2025
ee4390f
perf(manual_is_power_of_two): perform the `is_integer_literal` check …
y21 Nov 8, 2025
d154da9
chore(unnecessary_mut_passed): show the intention not to lint `&raw` …
Jarcho Nov 8, 2025
a4a88ea
refactor(needless_arbitrary_self_type): give suggestions with finer d…
ada4a Nov 1, 2025
8cb6e1b
Fix clippy
camelid Nov 1, 2025
7a745ff
Use "rhs" terminology instead of "body"
camelid Nov 1, 2025
5b5709b
Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
bors Nov 8, 2025
f5ccdae
Rollup merge of #128666 - pitaj:intrinsic-overflow_checks, r=BoxyUwU
Zalathar Nov 9, 2025
2760531
Implement `&pin` patterns and `ref pin` bindings
frank-king Nov 2, 2025
d16f26b
Allow `function_casts_as_integer` in non-related clippy ui tests
GuillaumeGomez May 24, 2025
3c3452a
Fix mod_module_files false positive for tests in workspaces (#16048)
dswij Nov 10, 2025
4e35148
Fix website history interactions
Alexendoo Oct 31, 2025
c8885d5
fix: `single_range_in_vec_init` FP for explicit `Range`
profetia Nov 7, 2025
6834ab6
fix: `single_range_in_vec_init` wrongly unmangles macros
profetia Nov 7, 2025
8a1dde1
fix: `useless_let_if_seq` FN when `if` is in the last expr of block
profetia Nov 10, 2025
e1ac7da
fix: `useless_let_if_seq` wrongly unmangled macros
profetia Nov 10, 2025
0b30af0
Fix `useless_let_if_seq` FN when `if` is in the last expr of block (#…
llogiq Nov 10, 2025
39107ff
Rollup merge of #141470 - GuillaumeGomez:function_casts_as_integer, r…
Zalathar Nov 11, 2025
d599529
Fix `single_range_in_vec_init` FP for explicit `Range` (#16043)
samueltardieu Nov 11, 2025
a72893f
Simplify jemalloc setup
madsmtm Nov 11, 2025
70cfebb
Fix building rustdoc and clippy with jemalloc feature
madsmtm Oct 25, 2025
18de216
Make clippy happy.
m-ou-se Nov 10, 2025
7ae882e
Bless clippy tests.
m-ou-se Nov 11, 2025
3352bea
Bless clippy tests.
m-ou-se Nov 12, 2025
a537e86
`incompatible_msrv`: Don't check the contents of any `std` macro.
Jarcho Nov 12, 2025
da2a220
`incompatible_msrv`: Don't check the contents of any `std` macro. (#1…
flip1995 Nov 12, 2025
0ac6646
refactor(needless_arbitrary_self_type): give suggestions with finer d…
y21 Nov 12, 2025
801e5b3
Fix website history interactions (#16060)
samueltardieu Nov 13, 2025
44700b9
add documentation comments for `clippy_utils::numeric_literal`
fernandovtorres Nov 12, 2025
4016c0f
Add documentation for `clippy_utils::numeric_literal` (#16078)
samueltardieu Nov 13, 2025
663ef9b
fix(rc_buffer): don't touch the path to `Rc`/`Arc` in the suggestion …
llogiq Nov 14, 2025
3bef3ff
refactor(rc_buffer): remove `RcKind`
ada4a Nov 14, 2025
540e2f4
feat(ok_expect): add autofix (#15867)
llogiq Nov 14, 2025
bffde26
Register early passes with `extend` instead of `register_early_pass`.
Jarcho Oct 31, 2025
cd41914
Register late passes with `extend` instead of `register_late_pass`.
Jarcho Oct 31, 2025
2027c0e
Update `dev new_lint` to add passes to each array.
Jarcho Oct 31, 2025
f1c7461
refactor(rc_buffer): remove `RcKind` (#16089)
llogiq Nov 14, 2025
c48592e
Use `extend` when creating the lint pass constructors (#15994)
blyxyas Nov 14, 2025
03cd6b6
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 14, 2025
ca4557c
Bump nightly version -> 2025-11-15
flip1995 Nov 14, 2025
72fc40c
Fix fn_to_numeric_cast 32 bit stderr
flip1995 Nov 14, 2025
62589a2
Rustup (#16094)
flip1995 Nov 15, 2025
e4170e1
Merge commit '62589a21d351f63d77dcd173c31107e9f1d06328' into clippy-s…
flip1995 Nov 15, 2025
84af28b
Update Cargo.lock
flip1995 Nov 15, 2025
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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ dependencies = [
"serde_json",
"tempfile",
"termize",
"tikv-jemalloc-sys",
"toml 0.9.7",
"ui_test",
"walkdir",
Expand Down Expand Up @@ -5537,9 +5538,9 @@ version = "0.1.0"

[[package]]
name = "tikv-jemalloc-sys"
version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d"
checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b"
dependencies = [
"cc",
"libc",
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/.github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ body:
label: Reproducer
description: Please provide the code and steps to reproduce the bug
value: |
I tried this code:
Code:

```rust
<code>
```

I expected to see this happen:
Current output:

Instead, this happened:
Desired output:
- type: textarea
id: version
attributes:
Expand Down
2 changes: 0 additions & 2 deletions src/tools/clippy/.github/workflows/clippy_mq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
host: i686-unknown-linux-gnu
- os: windows-latest
host: x86_64-pc-windows-msvc
- os: macos-13
host: x86_64-apple-darwin
- os: macos-latest
host: aarch64-apple-darwin

Expand Down
3 changes: 2 additions & 1 deletion src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tempfile = { version = "3.20", optional = true }
termize = "0.2"
color-print = "0.3.4"
anstream = "0.6.18"
tikv-jemalloc-sys = { version = "0.6.1", optional = true, features = ['override_allocator_on_supported_platforms'] }

[dev-dependencies]
cargo_metadata = "0.18.1"
Expand All @@ -56,7 +57,7 @@ rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" }
[features]
integration = ["dep:tempfile"]
internal = ["dep:clippy_lints_internal", "dep:tempfile"]
jemalloc = []
jemalloc = ["dep:tikv-jemalloc-sys"]

[package.metadata.rust-analyzer]
# This package uses #[feature(rustc_private)]
Expand Down
15 changes: 8 additions & 7 deletions src/tools/clippy/clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,19 @@ fn add_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
let path = "clippy_lints/src/lib.rs";
let mut lib_rs = fs::read_to_string(path).context("reading")?;

let comment_start = lib_rs.find("// add lints here,").expect("Couldn't find comment");
let ctor_arg = if lint.pass == Pass::Late { "_" } else { "" };
let lint_pass = lint.pass;
let (comment, ctor_arg) = if lint.pass == Pass::Late {
("// add late passes here", "_")
} else {
("// add early passes here", "")
};
let comment_start = lib_rs.find(comment).expect("Couldn't find comment");
let module_name = lint.name;
let camel_name = to_camel_case(lint.name);

let new_lint = if enable_msrv {
format!(
"store.register_{lint_pass}_pass(move |{ctor_arg}| Box::new({module_name}::{camel_name}::new(conf)));\n ",
)
format!("Box::new(move |{ctor_arg}| Box::new({module_name}::{camel_name}::new(conf))),\n ",)
} else {
format!("store.register_{lint_pass}_pass(|{ctor_arg}| Box::new({module_name}::{camel_name}));\n ",)
format!("Box::new(|{ctor_arg}| Box::new({module_name}::{camel_name})),\n ",)
};

lib_rs.insert_str(comment_start, &new_lint);
Expand Down
13 changes: 7 additions & 6 deletions src/tools/clippy/clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
use clippy_utils::higher::has_let_expr;
use clippy_utils::msrvs::{self, Msrv};
use clippy_utils::res::MaybeDef;
use clippy_utils::source::SpanRangeExt;
use clippy_utils::source::{SpanRangeExt, snippet_with_context};
use clippy_utils::sugg::Sugg;
use clippy_utils::ty::implements_trait;
use clippy_utils::{eq_expr_value, sym};
Expand Down Expand Up @@ -415,19 +415,20 @@ fn simplify_not(cx: &LateContext<'_>, curr_msrv: Msrv, expr: &Expr<'_>) -> Optio
BinOpKind::Ge => Some(" < "),
_ => None,
}
.and_then(|op| {
let lhs_snippet = lhs.span.get_source_text(cx)?;
let rhs_snippet = rhs.span.get_source_text(cx)?;
.map(|op| {
let mut app = Applicability::MachineApplicable;
let (lhs_snippet, _) = snippet_with_context(cx, lhs.span, SyntaxContext::root(), "", &mut app);
let (rhs_snippet, _) = snippet_with_context(cx, rhs.span, SyntaxContext::root(), "", &mut app);

if !(lhs_snippet.starts_with('(') && lhs_snippet.ends_with(')'))
&& let (ExprKind::Cast(..), BinOpKind::Ge) = (&lhs.kind, binop.node)
{
// e.g. `(a as u64) < b`. Without the parens the `<` is
// interpreted as a start of generic arguments for `u64`
return Some(format!("({lhs_snippet}){op}{rhs_snippet}"));
return format!("({lhs_snippet}){op}{rhs_snippet}");
}

Some(format!("{lhs_snippet}{op}{rhs_snippet}"))
format!("{lhs_snippet}{op}{rhs_snippet}")
})
},
ExprKind::MethodCall(path, receiver, args, _) => {
Expand Down
10 changes: 4 additions & 6 deletions src/tools/clippy/clippy_lints/src/if_then_some_else_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::eager_or_lazy::switch_to_eager_eval;
use clippy_utils::msrvs::{self, Msrv};
use clippy_utils::res::{MaybeDef, MaybeQPath};
use clippy_utils::source::{snippet_with_applicability, snippet_with_context, walk_span_to_context};
use clippy_utils::sugg::Sugg;
use clippy_utils::{
contains_return, expr_adjustment_requires_coercion, higher, is_else_clause, is_in_const_context, peel_blocks, sym,
as_some_expr, contains_return, expr_adjustment_requires_coercion, higher, is_else_clause, is_in_const_context,
is_none_expr, peel_blocks, sym,
};
use rustc_errors::Applicability;
use rustc_hir::LangItem::{OptionNone, OptionSome};
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::impl_lint_pass;
Expand Down Expand Up @@ -70,11 +69,10 @@ impl<'tcx> LateLintPass<'tcx> for IfThenSomeElseNone {
}) = higher::If::hir(expr)
&& let ExprKind::Block(then_block, _) = then.kind
&& let Some(then_expr) = then_block.expr
&& let ExprKind::Call(then_call, [then_arg]) = then_expr.kind
&& let Some(then_arg) = as_some_expr(cx, then_expr)
&& !expr.span.from_expansion()
&& !then_expr.span.from_expansion()
&& then_call.res(cx).ctor_parent(cx).is_lang_item(cx, OptionSome)
&& peel_blocks(els).res(cx).ctor_parent(cx).is_lang_item(cx, OptionNone)
&& is_none_expr(cx, peel_blocks(els))
&& !is_else_clause(cx.tcx, expr)
&& !is_in_const_context(cx)
&& self.msrv.meets(cx, msrvs::BOOL_THEN)
Expand Down
66 changes: 45 additions & 21 deletions src/tools/clippy/clippy_lints/src/incompatible_msrv.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::msrvs::Msrv;
use clippy_utils::{is_in_const_context, is_in_test};
use clippy_utils::{is_in_const_context, is_in_test, sym};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, HirId, RustcVersion, StabilityLevel, StableSince};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::impl_lint_pass;
use rustc_span::def_id::{CrateNum, DefId};
use rustc_span::{ExpnKind, Span, sym};
use rustc_span::{ExpnKind, Span};

declare_clippy_lint! {
/// ### What it does
Expand Down Expand Up @@ -77,11 +77,36 @@ enum Availability {
Since(RustcVersion),
}

/// All known std crates containing a stability attribute.
struct StdCrates([Option<CrateNum>; 6]);
impl StdCrates {
fn new(tcx: TyCtxt<'_>) -> Self {
let mut res = Self([None; _]);
for &krate in tcx.crates(()) {
// FIXME(@Jarcho): We should have an internal lint to detect when this list is out of date.
match tcx.crate_name(krate) {
sym::alloc => res.0[0] = Some(krate),
sym::core => res.0[1] = Some(krate),
sym::core_arch => res.0[2] = Some(krate),
sym::proc_macro => res.0[3] = Some(krate),
sym::std => res.0[4] = Some(krate),
sym::std_detect => res.0[5] = Some(krate),
_ => {},
}
}
res
}

fn contains(&self, krate: CrateNum) -> bool {
self.0.contains(&Some(krate))
}
}

pub struct IncompatibleMsrv {
msrv: Msrv,
availability_cache: FxHashMap<(DefId, bool), Availability>,
check_in_tests: bool,
core_crate: Option<CrateNum>,
std_crates: StdCrates,

// The most recently called path. Used to skip checking the path after it's
// been checked when visiting the call expression.
Expand All @@ -96,11 +121,7 @@ impl IncompatibleMsrv {
msrv: conf.msrv,
availability_cache: FxHashMap::default(),
check_in_tests: conf.check_incompatible_msrv_in_tests,
core_crate: tcx
.crates(())
.iter()
.find(|krate| tcx.crate_name(**krate) == sym::core)
.copied(),
std_crates: StdCrates::new(tcx),
called_path: None,
}
}
Expand Down Expand Up @@ -152,21 +173,24 @@ impl IncompatibleMsrv {
node: HirId,
span: Span,
) {
if def_id.is_local() {
// We don't check local items since their MSRV is supposed to always be valid.
if !self.std_crates.contains(def_id.krate) {
// No stability attributes to lookup for these items.
return;
}
let expn_data = span.ctxt().outer_expn_data();
if let ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) = expn_data.kind {
// Desugared expressions get to cheat and stability is ignored.
// Intentionally not using `.from_expansion()`, since we do still care about macro expansions
return;
}
// Functions coming from `core` while expanding a macro such as `assert*!()` get to cheat too: the
// macros may have existed prior to the checked MSRV, but their expansion with a recent compiler
// might use recent functions or methods. Compiling with an older compiler would not use those.
if Some(def_id.krate) == self.core_crate && expn_data.macro_def_id.map(|did| did.krate) == self.core_crate {
return;
// Use `from_expansion` to fast-path the common case.
if span.from_expansion() {
let expn = span.ctxt().outer_expn_data();
match expn.kind {
// FIXME(@Jarcho): Check that the actual desugaring or std macro is supported by the
// current MSRV. Note that nested expansions need to be handled as well.
ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => return,
ExpnKind::Macro(..) if expn.macro_def_id.is_some_and(|did| self.std_crates.contains(did.krate)) => {
return;
},
// All other expansions share the target's MSRV.
// FIXME(@Jarcho): What should we do about version dependant macros from external crates?
_ => {},
}
}

if (self.check_in_tests || !is_in_test(cx.tcx, node))
Expand Down
5 changes: 3 additions & 2 deletions src/tools/clippy/clippy_lints/src/inherent_impl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clippy_config::Conf;
use clippy_config::types::InherentImplLintScope;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::fulfill_or_allowed;
use clippy_utils::{fulfill_or_allowed, is_cfg_test, is_in_cfg_test};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
use rustc_hir::{Item, ItemKind, Node};
Expand Down Expand Up @@ -100,7 +100,8 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
},
InherentImplLintScope::Crate => Criterion::Crate,
};
match type_map.entry((impl_ty, criterion)) {
let is_test = is_cfg_test(cx.tcx, hir_id) || is_in_cfg_test(cx.tcx, hir_id);
match type_map.entry((impl_ty, criterion, is_test)) {
Entry::Vacant(e) => {
// Store the id for the first impl block of this type. The span is retrieved lazily.
e.insert(IdOrSpan::Id(impl_id));
Expand Down
Loading
Loading