Skip to content

Clippy subtree update #142451

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 94 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
d49b8aa
Remove `ClippyCtfe` pass
Alexendoo Apr 30, 2025
a9225f8
Updated feature flag and output of `clippy/tests/ui/map_flatten*`
May 16, 2025
0524773
fix: `unit_arg` suggests wrongly for `Default::default`
profetia May 24, 2025
ebf39a5
fix: `unit_arg` wrongly handled macros
profetia May 24, 2025
d82e51b
Test that all interned symbols are referenced in Clippy sources
samueltardieu May 18, 2025
f6e5fa2
remove eq_unspanned from TokenStream
chenyukang May 26, 2025
8e581e3
add lint infallible_try_from
ComputerDruid May 15, 2025
e177dd0
Reduce `P<T>` to a typedef of `Box<T>`.
nnethercote May 26, 2025
1c070ca
fix: `branches_sharing_code` suggests wrongly when dealing with macros
profetia May 28, 2025
4f3d529
Remove incremental test, disable incremental for cargo tests
Alexendoo May 28, 2025
3c8bfd1
`zombie_processes`: do not complain about early early returns
samueltardieu May 28, 2025
459280c
Reorder fields in `hir::ItemKind` variants.
nnethercote May 28, 2025
e64dd8e
new restriction lint: pointer_format
llogiq May 13, 2025
9f86a57
Merge commit '57cbadd68ac473bc50453f6b1320a02b68115f12'
flip1995 May 31, 2025
3ed210c
Use interned symbols instead of strings in more places
samueltardieu May 20, 2025
43b7d87
`missing_const_for_fn`: consider constness of instance
samueltardieu May 8, 2025
61465ed
Rollup merge of #141072 - Rynibami:stabilize-const-result-flatten, r=…
jhpratt May 31, 2025
8029208
Lint more cases in `unit_arg`
profetia May 31, 2025
1652187
new restriction lint: pointer_format (#14792)
samueltardieu Jun 1, 2025
d4aed51
Do not count deprecated lints in lint total
samueltardieu Jun 1, 2025
3f48a2b
Use interned symbols instead of strings in more places (#14855)
y21 Jun 1, 2025
466e0fb
Do not count deprecated lints in lint total (#14948)
llogiq Jun 1, 2025
89dc07a
chore: fix smart quote in comment used by update_lints script
krikera Jun 1, 2025
a5a7eea
chore: replace smart quote with straight quote in update_lints commen…
Centri3 Jun 1, 2025
abf5d4c
Invert the sense of `is_not_macro_export`.
nnethercote May 29, 2025
12fc6c7
fix: `semicolon_outside_block` suggests wrongly when inside macros
profetia Jun 2, 2025
88bb8d1
Fix `semicolon_outside_block` suggests wrongly when inside macros (#1…
samueltardieu Jun 2, 2025
a4360d6
fix: `unnecessary_debug_formatting` FP inside `Debug` impl
profetia Jun 2, 2025
225abd6
Use `None::<u64>` instead of `0` to denote an absence of value
samueltardieu Jun 2, 2025
d7b27ec
add lint `infallible_try_from` (#14813)
llogiq Jun 2, 2025
6fa2866
Use `None::<u64>` instead of `0` to denote an absence of value (#14957)
llogiq Jun 2, 2025
8708e3f
Auto merge of #141814 - flip1995:clippy-subtree-update, r=Manishearth
bors Jun 2, 2025
9b8c42c
Test that all interned symbols are referenced in Clippy sources (#14842)
Alexendoo Jun 2, 2025
166f664
Use the informative error as the main const eval error message
oli-obk May 28, 2025
d1f9d02
Clarify why we are talking about a failed const eval at a random place
oli-obk May 30, 2025
b51e737
Introduce coerce_container_to_any
Ralith May 15, 2025
fcfbcc8
doc_suspicious_footnotes: lint text that looks like a footnote
notriddle Apr 29, 2025
1b2b7e6
Overhaul `UsePath`.
nnethercote May 29, 2025
4effc58
Rollup merge of #141741 - nnethercote:overhaul-UsePath, r=petrochenkov
matthiaskrgr Jun 3, 2025
8d8b3f1
Add new lint: `ip_consant`
relaxcn May 23, 2025
716eadf
`zombie_processes`: do not complain about early early returns (#14912)
Jarcho Jun 3, 2025
eafef84
`missing_const_for_fn`: consider constness of instance (#14759)
Jarcho Jun 3, 2025
3b64c5c
Lint reversed ordering in partial ord impl
donkomura Jun 1, 2025
a4debd2
Lint reversed ordering in partial ord impl (#14945)
samueltardieu Jun 3, 2025
ed226d2
Fix false positive for unused_unit
Jun 3, 2025
1e96456
Reference correct PR
Jun 3, 2025
2a5a2fa
Use interned strings when possible, for efficiency purposes
samueltardieu Jun 3, 2025
a0b0f91
Rollup merge of #141698 - oli-obk:ctfe-err-flip, r=RalfJung
matthiaskrgr Jun 3, 2025
84ef7fb
Use interned strings when possible, for efficiency purposes (#14963)
llogiq Jun 4, 2025
6ed003d
fix suggestion-causes-error of `print_literal` and `write_literal`
relaxcn Jun 3, 2025
1ae37ad
Do not recurse indefinitely while checking for inner mutability
samueltardieu Jun 4, 2025
ed143af
fix suggestion-causes-error of `print_literal` and `write_literal` (#…
samueltardieu Jun 4, 2025
9b8bf53
Rollup merge of #141570 - chenyukang:yukang-fix-eq_unspanned, r=worki…
matthiaskrgr Jun 4, 2025
8b59e34
Replace `elided_named_lifetimes` with `mismatched_lifetime_syntaxes`
shepmaster Mar 17, 2025
c9a97e1
Do not lint macro generated codes
donkomura Jun 4, 2025
a76c2b3
Fix `unnecessary_debug_formatting` FP inside `Debug` impl (#14955)
dswij Jun 4, 2025
29492da
Fix suggestion-causes-error of `manual_swap`
relaxcn Jun 4, 2025
c90c7c4
doc_suspicious_footnotes: lint text that looks like a footnote (#14708)
blyxyas Jun 5, 2025
9f9f993
Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None
oli-obk Jun 4, 2025
cf75dd4
Remove incremental test, disable incremental for cargo tests (#14910)
dswij Jun 5, 2025
f8a3929
Do not lint macro generated codes (#14976)
Alexendoo Jun 5, 2025
6ef2a2d
add new lint: `ip_constant` (#14878)
llogiq Jun 5, 2025
b379d54
Introduce coerce_container_to_any (#14812)
llogiq Jun 5, 2025
da93448
Do not recurse indefinitely while checking for inner mutability (#14965)
llogiq Jun 5, 2025
6bb0c97
Fix false positive for unused_unit (#14962)
llogiq Jun 5, 2025
2f80ead
Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax,…
bors Jun 5, 2025
2c95105
Rollup merge of #142012 - oli-obk:no-optional-spans, r=fee1-dead
matthiaskrgr Jun 5, 2025
5930e54
fix typo
ada4a Jun 6, 2025
f2922e7
fix typo (#14995)
samueltardieu Jun 6, 2025
507183d
Rollup merge of #141603 - nnethercote:reduce-P, r=fee1-dead
GuillaumeGomez Jun 6, 2025
33052be
Fix `branches_sharing_code` suggests wrongly when dealing with macros…
dswij Jun 7, 2025
aace547
Add missing word to `cloned_ref_to_slice_refs` docs
cenviity Jun 7, 2025
0138c79
Add missing word to `cloned_ref_to_slice_refs` docs (#15012)
Centri3 Jun 8, 2025
4d6254c
fix: `create_dir` ignores paths in suggestions
profetia Jun 7, 2025
f397a30
Invert suggestion if pointer is tested for non-nullness
samueltardieu Jun 8, 2025
a1a1393
Invert suggestion if pointer is tested for non-nullness (#15015)
llogiq Jun 8, 2025
d98070d
fix: `std_instead_of_core` FP when part of the `use` cannot be replaced
profetia Jun 8, 2025
737b8be
Fix `std_instead_of_core` FP when part of the `use` cannot be replace…
llogiq Jun 8, 2025
b5eac24
fix: `match_single_binding` misses curlies on type signatures
profetia Jun 8, 2025
3af333e
Fix `create_dir` ignores paths in suggestions (#15011)
Alexendoo Jun 8, 2025
9e7782b
Fix `match_single_binding` misses curlies on type signatures (#15017)
llogiq Jun 8, 2025
4389e17
optimize codes
relaxcn Jun 9, 2025
358b80c
Fix `manual_flatten` removes the useless if let
donkomura May 21, 2025
6d7c16a
Remove `ClippyCtfe` pass (#14712)
blyxyas Jun 11, 2025
ce8d263
Fixes `manual_flatten` removes the useless if let (#14861)
samueltardieu Jun 12, 2025
180adb3
Fix `unit_arg` suggests wrongly for `Default::default` (#14881)
samueltardieu Jun 12, 2025
59d8345
Fix suggestion-causes-error of `manual_swap` (#14978)
samueltardieu Jun 12, 2025
6cd55b9
Optimize by 99.75% strlen_on_c_strings, 8.5% globally
blyxyas Jun 12, 2025
6662aed
[PERF] Optimize 3rd heaviest func, (81b -> 10m) (#15043)
samueltardieu Jun 13, 2025
85655d4
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jun 13, 2025
19c2f03
Bump nightly version -> 2025-06-13
flip1995 Jun 13, 2025
4ef7529
Rustup (#15044)
flip1995 Jun 13, 2025
8fe9c2c
Merge commit '4ef75291b5dd6739212f1f61666d19d4e086690d' into clippy-s…
flip1995 Jun 13, 2025
9cb0a64
Move COERCE_CONTAINER_TO_ANY to nursery, as it has FPs
flip1995 Jun 13, 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
4 changes: 2 additions & 2 deletions clippy_lints/src/disallowed_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl_lint_pass!(DisallowedTypes => [DISALLOWED_TYPES]);
impl<'tcx> LateLintPass<'tcx> for DisallowedTypes {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
if let ItemKind::Use(path, UseKind::Single(_)) = &item.kind {
for res in &path.res {
self.check_res_emit(cx, res, item.span);
if let Some(res) = path.res.type_ns {
self.check_res_emit(cx, &res, item.span);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion clippy_lints/src/legacy_numeric_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ impl<'tcx> LateLintPass<'tcx> for LegacyNumericConstants {
// so lint on the `use` statement directly.
if let ItemKind::Use(path, kind @ (UseKind::Single(_) | UseKind::Glob)) = item.kind
&& !item.span.in_external_macro(cx.sess().source_map())
&& let Some(def_id) = path.res[0].opt_def_id()
// use `present_items` because it could be in either type_ns or value_ns
&& let Some(res) = path.res.present_items().next()
&& let Some(def_id) = res.opt_def_id()
&& self.msrv.meets(cx, msrvs::NUMERIC_ASSOCIATED_CONSTANTS)
{
let module = if is_integer_module(cx, def_id) {
Expand Down
5 changes: 1 addition & 4 deletions clippy_lints/src/macro_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ impl LateLintPass<'_> for MacroUseImports {
&& let hir_id = item.hir_id()
&& let attrs = cx.tcx.hir_attrs(hir_id)
&& let Some(mac_attr) = attrs.iter().find(|attr| attr.has_name(sym::macro_use))
&& let Some(id) = path.res.iter().find_map(|res| match res {
Res::Def(DefKind::Mod, id) => Some(id),
_ => None,
})
&& let Some(Res::Def(DefKind::Mod, id)) = path.res.type_ns
&& !id.is_local()
{
for kid in cx.tcx.module_children(id) {
Expand Down
5 changes: 3 additions & 2 deletions clippy_lints/src/min_ident_chars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ impl Visitor<'_> for IdentVisitor<'_, '_> {
// If however the identifier is different, this means it is an alias (`use foo::bar as baz`). In
// this case, we need to emit the warning for `baz`.
if let Some(imported_item_path) = usenode
&& let Some(Res::Def(_, imported_item_defid)) = imported_item_path.res.first()
&& cx.tcx.item_name(*imported_item_defid).as_str() == str
// use `present_items` because it could be in any of type_ns, value_ns, macro_ns
&& let Some(Res::Def(_, imported_item_defid)) = imported_item_path.res.value_ns
&& cx.tcx.item_name(imported_item_defid).as_str() == str
{
return;
}
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/missing_enforced_import_rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ impl_lint_pass!(ImportRename => [MISSING_ENFORCED_IMPORT_RENAMES]);
impl LateLintPass<'_> for ImportRename {
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if let ItemKind::Use(path, UseKind::Single(_)) = &item.kind {
for &res in &path.res {
// use `present_items` because it could be in any of type_ns, value_ns, macro_ns
for res in path.res.present_items() {
if let Res::Def(_, id) = res
&& let Some(name) = self.renames.get(&id)
// Remove semicolon since it is not present for nested imports
Expand Down
23 changes: 11 additions & 12 deletions clippy_lints/src/redundant_pub_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::source::HasSession;
use rustc_errors::Applicability;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{Item, ItemKind};
use rustc_hir::{Item, ItemKind, UseKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty;
use rustc_session::impl_lint_pass;
Expand Down Expand Up @@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
if cx.tcx.visibility(item.owner_id.def_id) == ty::Visibility::Restricted(CRATE_DEF_ID.to_def_id())
&& !cx.effective_visibilities.is_exported(item.owner_id.def_id)
&& self.is_exported.last() == Some(&false)
&& is_not_macro_export(item)
&& !is_ignorable_export(item)
&& !item.span.in_external_macro(cx.sess().source_map())
{
let span = item
Expand Down Expand Up @@ -86,18 +86,17 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
}
}

fn is_not_macro_export<'tcx>(item: &'tcx Item<'tcx>) -> bool {
if let ItemKind::Use(path, _) = item.kind {
if path
.res
.iter()
.all(|res| matches!(res, Res::Def(DefKind::Macro(MacroKind::Bang), _)))
{
return false;
// We ignore macro exports. And `ListStem` uses, which aren't interesting.
fn is_ignorable_export<'tcx>(item: &'tcx Item<'tcx>) -> bool {
if let ItemKind::Use(path, kind) = item.kind {
let ignore = matches!(path.res.macro_ns, Some(Res::Def(DefKind::Macro(MacroKind::Bang), _)))
|| kind == UseKind::ListStem;
if ignore {
return true;
}
} else if let ItemKind::Macro(..) = item.kind {
return false;
return true;
}

true
false
}
2 changes: 1 addition & 1 deletion clippy_lints/src/unused_trait_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedTraitNames {
// Ignore imports that already use Underscore
&& ident.name != kw::Underscore
// Only check traits
&& let Some(Res::Def(DefKind::Trait, _)) = path.res.first()
&& let Some(Res::Def(DefKind::Trait, _)) = path.res.type_ns
&& cx.tcx.maybe_unused_trait_imports(()).contains(&item.owner_id.def_id)
// Only check this import if it is visible to its module only (no pub, pub(crate), ...)
&& let module = cx.tcx.parent_module_from_def_id(item.owner_id.def_id)
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/wildcard_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ impl LateLintPass<'_> for WildcardImports {
format!("{import_source_snippet}::{imports_string}")
};

// Glob imports always have a single resolution.
let (lint, message) = if let Res::Def(DefKind::Enum, _) = use_path.res[0] {
// Glob imports always have a single resolution. Enums are in the value namespace.
let (lint, message) = if let Some(Res::Def(DefKind::Enum, _)) = use_path.res.value_ns {
(ENUM_GLOB_USE, "usage of wildcard import for enum variants")
} else {
(WILDCARD_IMPORTS, "usage of wildcard import")
Expand Down
11 changes: 7 additions & 4 deletions clippy_utils/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,13 @@ fn local_item_child_by_name(tcx: TyCtxt<'_>, local_id: LocalDefId, ns: PathNS, n
let item = tcx.hir_item(item_id);
if let ItemKind::Use(path, UseKind::Single(ident)) = item.kind {
if ident.name == name {
path.res
.iter()
.find(|res| ns.matches(res.ns()))
.and_then(Res::opt_def_id)
let opt_def_id = |ns: Option<Res>| ns.and_then(|res| res.opt_def_id());
match ns {
PathNS::Type => opt_def_id(path.res.type_ns),
PathNS::Value => opt_def_id(path.res.value_ns),
PathNS::Macro => opt_def_id(path.res.macro_ns),
PathNS::Arbitrary => unreachable!(),
}
} else {
None
}
Expand Down