Commit Graph

539 Commits

Author SHA1 Message Date
Jason Newcomb 53675ce061 Remove path_to_local 2025-10-10 23:09:26 -04:00
Jason Newcomb 3f686a074d Remove is_res_lang_ctor 2025-10-10 23:00:17 -04:00
Jason Newcomb 3ed7aa0d5f Remove path_def_id 2025-10-10 23:00:17 -04:00
Jason Newcomb 5b659ba0b4 Remove path_res 2025-10-10 22:51:33 -04:00
Jason Newcomb 53783de8f0 Remove MaybePath 2025-10-10 22:51:33 -04:00
Jason Newcomb cb32444ee6 Remove is_path_diagnostic_item 2025-10-10 22:30:57 -04:00
Jason Newcomb d32ef64ed5 Remove is_path_lang_item 2025-10-10 22:30:57 -04:00
Jason Newcomb 748a593a7f Add new utils for defninition identification. 2025-10-10 22:30:25 -04:00
Nick Drozd 5318883d75 Use expect for lint warnings 2025-10-06 20:17:12 -04:00
Samuel Tardieu d289009eea Const eval changes (#15773)
First commit treats all constants containing a macro call as non-local
and renames `eval_simple` to be a little clearer.

Second commit removes `CoreConstant` and treats most of them as though
they were local. A couple of the constants like `usize::MAX` are treated
as non-local as different targets may have different values.
`const_is_empty` will now ignore non-local constants since there's no
guarantee that they are the same across all targets/features/versions.

The third commit just changes some `eval` calls to `eval_local`. Most of
these were style lints which shouldn't be assuming the value of a
constant won't ever change.

changelog: none
2025-10-04 18:16:35 +00:00
Jason Newcomb 3d351c839d Const eval changes:
* Remove `CoreConstant`.
* Treat most constants from core as though they were inlined.
* Don't evaluate `is_empty` for named constants.
2025-10-04 10:41:35 -04:00
Alejandra González 0c7e0344cf Do not suggest using a if let chain if it is not supported (#15746)
This might be due to a low edition (< 2024) or too low a MSRV. In this
case, we will suggest only `match`.

Fixes rust-lang/rust-clippy#15744

changelog: [`unnecessary_unwrap`]: do not suggest using `if let` chains
if this is not supported with the current edition or MSRV
changelog:[`collapsible_if`]: Do not suggest using `if let` if this is
not supported with the current edition or MSRV
2025-10-01 16:08:15 +00:00
Samuel Tardieu f1079915b4 Do not suggest using a if let chain if it is not supported
This might be due to a low edition (< 2024) or too low a MSRV.
2025-10-01 07:41:49 +02:00
Ada Alakbarova 6b4febeeb7 simplify and inline is_async_fn 2025-09-28 17:31:03 +02:00
Ada Alakbarova bd39ea463f inline clippy_utils::ptr into needless_pass_by_value
..and make it less generic, thanks to all the callers being known
2025-09-25 20:34:10 +02:00
Philipp Krones 2d3efb0f0b Merge remote-tracking branch 'upstream/master' into rustup 2025-09-18 16:59:09 +02:00
Samuel Tardieu c1f782919b match_as_ref: do not lint if other arm is not None => None 2025-09-17 19:35:05 +02:00
bors 968569fc42 Auto merge of #145186 - camsteffen:assoc-impl-kind, r=petrochenkov
Make `AssocItem` aware of its impl kind

The general goal is to have fewer query dependencies by making `AssocItem` aware of its parent impl kind (inherent vs. trait) without having to query the parent def_kind.

See individual commits.
2025-09-13 13:59:48 +00:00
Cameron Steffen 324c214122 Split AssocContainer::{InherentImpl,TraitImpl} 2025-09-12 15:14:15 -05:00
Cameron Steffen d419d51f93 Rename AssocItemContainer -> AssocContainer 2025-09-12 15:10:30 -05:00
Ada Alakbarova 31c7e621c2 reorganize peel_*_ty_refs functions
- give `ty::walk_ptrs_hir_ty` a more standard name
  `peel_hir_ty_refs_and_ptrs`
- move it out of `ty`, since that's for `middle::ty::Ty`

- remove `ty::walk_ptrs_ty_depth` for equivalent `peel_middle_ty_refs`
- rename the latter into `ty::peel_and_count_ty_refs`
- incorporate mutability tracking (from
  `ty::peel_mid_ty_refs_is_mutable`) into that
2025-09-12 18:13:20 +02:00
Jana Dönszelmann 32722771ec fixup no_{core,std} handling code 2025-09-10 11:45:24 -07:00
Philipp Krones 9b0611ff7a Merge commit 'e9b70454e4c9584be3b22ddabd26b741aeb06c10' into clippy-subtree-update 2025-09-04 18:27:27 -04:00
Philipp Krones 4b73b961e6 Merge remote-tracking branch 'upstream/master' into rustup 2025-09-04 18:18:20 -04:00
Vishruth-Thimmaiah 991021785e fix: collapsible_match suggests ref/derefs when needed 2025-08-28 01:53:08 +05:30
Samuel Tardieu 27d005a171 Document is_unit_expr() 2025-08-27 00:35:13 +02:00
Samuel Tardieu f0514d993c Fix async_yields_async wrongly unmangled macros (#15553)
Closes rust-lang/rust-clippy#15552

changelog: [`async_yields_async`] fix wrong unmangle of macros
2025-08-25 17:33:01 +00:00
yanglsh 137feef308 fix: async_yields_async wrongly unmangled macros 2025-08-26 00:55:54 +08:00
Valdemar Erk 01fefaad02 add span to struct pattern rest (..) 2025-08-25 09:55:50 +02:00
Samuel Tardieu f35c2034f5 use get_diagnostic_item in even more places (#15528)
continuation of https://github.com/rust-lang/rust-clippy/pull/15519, see
there for the commit structure

AFAICT this finally resolves
https://github.com/rust-lang/rust-clippy/issues/7784

changelog: none
2025-08-23 23:16:29 +00:00
Ada Alakbarova ebbea34572 is_expr_identity_of_pat: simplify using (unordered_)over 2025-08-22 15:11:37 +02:00
Ada Alakbarova 81b4de649f is_default_equivalent_ctor: store name in a var 2025-08-22 15:03:15 +02:00
Ada Alakbarova f51b5afd50 is_default_equivalent_ctor: check for String once 2025-08-22 15:03:14 +02:00
Philipp Krones 71b79ab466 Merge commit '877967959ae8da9814df4f2614971f4d784bf53f' into clippy-subtree-update 2025-08-22 14:57:22 +02:00
Philipp Krones 284b596ac4 Merge remote-tracking branch 'upstream/master' into rustup 2025-08-22 14:25:23 +02:00
Cameron Steffen 9f98857714 Propagate TraitImplHeader to hir 2025-08-11 17:05:42 -05:00
Ada Alakbarova 04606e27dc introduce path_to_local_with_projections
combine two similar arms

use in `eager_transmute`

use in `double_ended_iterator_last`

use different numbers in the new test case to avoid possible confusion

move the other "unfixable" case as well; it shouldn't lint anyway, so
having it in the main test file is fine
2025-08-09 20:27:30 +02:00
Philipp Krones eb15cf0a30 Merge commit '334fb906aef13d20050987b13448f37391bb97a2' into clippy-subtree-update 2025-08-07 17:05:15 +02:00
Philipp Krones f2b7e9ff52 Merge remote-tracking branch 'upstream/master' into rustup 2025-08-07 16:47:42 +02:00
Ada Alakbarova eea4d6dc3c {flat_,}map_identity: recognize (tuple) struct de- and restructuring
base check

same fields different struct

reordered fields

different paths to the same struct

same for tuple structs

style: use `zip`-the-function all over the place

makes the code a bit more concise by removing the need for explicit
`.iter()`

style: move precondition checking to the match guard

the match arms above put the "sanity" checks in the guard, and call only
`check_pat` in the body. With this commit, the (tuple) struct cases
follow that convention as well. Well, almost -- I think the ident check
belongs to the second category of checks, so I put it in the body as
well

misc: use `None` in the pattern directly

this'll probably be marginally faster thanks to the equality check being
now structural

move the tests to the right file
2025-08-01 11:24:44 +02:00
Jana Dönszelmann 05e3a7a499 remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
Cameron Steffen 86ff11e729 Rename impl_of_method -> impl_of_assoc 2025-07-28 09:54:53 -05:00
Cameron Steffen b0740198ae Rename trait_of_item -> trait_of_assoc 2025-07-28 09:53:50 -05:00
dswij f4f579f4ac Fix match_single_binding wrongly handles scope (#15060)
Closes rust-lang/rust-clippy#15018
Closes rust-lang/rust-clippy#15269

Continuation of rust-lang/rust-clippy#15017

changelog: [`match_single_binding`] fix wrong handling of scope
2025-07-28 12:10:42 +00:00
Philipp Krones 5c7418b38a Merge commit '1db89a1b1ca87f24bf22d0bad21d14b2d81b3e99' into clippy-subtree-update 2025-07-25 15:54:22 +02:00
Philipp Krones c98e60a56e Merge remote-tracking branch 'upstream/master' into rustup 2025-07-25 15:04:01 +02:00
yanglsh 1b883197d7 fix: if_then_some_else_none FP when require type coercion 2025-07-20 13:52:18 +08:00
yanglsh 48df86f37d fix: match_single_binding suggests wrongly inside binary expr 2025-07-17 20:54:42 +08:00
Nicholas Nethercote b7caf7593e Improve path segment joining.
There are many places that join path segments with `::` to produce a
string. A lot of these use `join("::")`. Many in rustdoc use
`join_with_double_colon`, and a few use `.joined("..")`. One in Clippy
uses `itertools::join`. A couple of them look for `kw::PathRoot` in the
first segment, which can be important.

This commit introduces `rustc_ast::join_path_{syms,ident}` to do the
joining for everyone. `rustc_ast` is as good a location for these as
any, being the earliest-running of the several crates with a `Path`
type. Two functions are needed because `Ident` printing is more complex
than simple `Symbol` printing.

The commit also removes `join_with_double_colon`, and
`estimate_item_path_byte_length` with it.

There are still a handful of places that join strings with "::" that are
unchanged. They are not that important: some of them are in tests, and
some of them first split a path around "::" and then rejoin with "::".

This fixes one test case where `{{root}}` shows up in an error message.
2025-07-17 08:37:19 +10:00
bors f4b827abeb Auto merge of #143745 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`

Cargo.lock update due to `ui_test` bump and restructure.
2025-07-14 19:53:18 +00:00