Commit Graph

129 Commits

Author SHA1 Message Date
Jana Dönszelmann 87b3f55b16 fix src/tools 2026-02-20 10:35:52 +01:00
Philipp Krones 44731205b8 Merge commit '62589a21d351f63d77dcd173c31107e9f1d06328' into clippy-subtree-update 2025-11-16 15:19:59 +01:00
Cameron Steffen 6a0aa123a0 Fix clippy for impl_trait_header changes 2025-10-17 08:36:34 -05: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
Philipp Krones 9b0611ff7a Merge commit 'e9b70454e4c9584be3b22ddabd26b741aeb06c10' into clippy-subtree-update 2025-09-04 18:27:27 -04:00
Jana Dönszelmann 79f3ae4b72 add a flag to codegen fn attrs for foreign items 2025-08-26 13:05:51 +02:00
Jana Dönszelmann 68c1574f5f make no_mangle explicit on foreign items 2025-08-12 12:07:14 +02:00
Philipp Krones eb15cf0a30 Merge commit '334fb906aef13d20050987b13448f37391bb97a2' into clippy-subtree-update 2025-08-07 17:05:15 +02:00
Jana Dönszelmann 05e3a7a499 remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
Philipp Krones 5c7418b38a Merge commit '1db89a1b1ca87f24bf22d0bad21d14b2d81b3e99' into clippy-subtree-update 2025-07-25 15:54:22 +02:00
Deadbeef 19f8c5004e parse const trait Trait 2025-07-17 18:06:26 +08:00
Camille GILLOT 8510965e6b Retire hir::*ItemRef. 2025-07-13 13:50:01 +00:00
Philipp Krones 074ccaf3c0 Merge commit 'c5dbd1de07e0407b9687619a868384d6de06253f' into clippy-subtree-update 2025-06-27 12:20:57 +02:00
Jana Dönszelmann bc2ed2ca9f fix clippy 2025-06-17 23:22:51 +02:00
Jana Dönszelmann 697b4f8306 convert entire codebase to parsed inline attrs 2025-06-17 23:19:31 +02:00
Philipp Krones ff428d91c2 Merge commit '0621446356e20fd2ead13a6763bb936c95eb0cfa' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
Philipp Krones c86216ebe7 Merge commit '1e5237f4a56ae958af7e5824343eacf737b67083' into clippy-subtree-update 2025-03-20 22:34:29 +01:00
Nicholas Nethercote 6222a735b0 Move hir::Item::ident into hir::ItemKind.
`hir::Item` has an `ident` field.

- It's always non-empty for these item kinds: `ExternCrate`, `Static`,
  `Const`, `Fn`, `Macro`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`,
  Trait`, TraitAalis`.

- It's always empty for these item kinds: `ForeignMod`, `GlobalAsm`,
  `Impl`.

- For `Use`, it is non-empty for `UseKind::Single` and empty for
  `UseKind::{Glob,ListStem}`.

All of this is quite non-obvious; the only documentation is a single
comment saying "The name might be a dummy name in case of anonymous
items". Some sites that handle items check for an empty ident, some
don't. This is a very C-like way of doing things, but this is Rust, we
have sum types, we can do this properly and never forget to check for
the exceptional case and never YOLO possibly empty identifiers (or
possibly dummy spans) around and hope that things will work out.

The commit is large but it's mostly obvious plumbing work. Some notable
things.

- A similar transformation makes sense for `ast::Item`, but this is
  already a big change. That can be done later.

- Lots of assertions are added to item lowering to ensure that
  identifiers are empty/non-empty as expected. These will be removable
  when `ast::Item` is done later.

- `ItemKind::Use` doesn't get an `Ident`, but `UseKind::Single` does.

- `lower_use_tree` is significantly simpler. No more confusing `&mut
  Ident` to deal with.

- `ItemKind::ident` is a new method, it returns an `Option<Ident>`. It's
  used with `unwrap` in a few places; sometimes it's hard to tell
  exactly which item kinds might occur. None of these unwraps fail on
  the test suite. It's conceivable that some might fail on alternative
  input. We can deal with those if/when they happen.

- In `trait_path` the `find_map`/`if let` is replaced with a loop, and
  things end up much clearer that way.

- `named_span` no longer checks for an empty name; instead the call site
  now checks for a missing identifier if necessary.

- `maybe_inline_local` doesn't need the `glob` argument, it can be
  computed in-function from the `renamed` argument.

- `arbitrary_source_item_ordering::check_mod` had a big `if` statement
  that was just getting the ident from the item kinds that had one. It
  could be mostly replaced by a single call to the new `ItemKind::ident`
  method.

- `ItemKind` grows from 56 to 64 bytes, but `Item` stays the same size,
  and that's what matters, because `ItemKind` only occurs within `Item`.
2025-03-18 06:29:50 +11:00
Nicholas Nethercote 650b7d957b Move methods from Map to TyCtxt, part 4.
Continuing the work from #137350.

Removes the unused methods: `expect_variant`, `expect_field`,
`expect_foreign_item`.

Every method gains a `hir_` prefix.
2025-03-12 08:55:37 +11:00
Michael Goulet e5dbcc2c16 Make asm a named field 2025-02-22 00:05:09 +00:00
Nicholas Nethercote 8cf9eea5b3 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
Nicholas Nethercote d30f045fce Convert two rustc_middle::lint functions to Span methods.
`rustc_middle` is a huge crate and it's always good to move stuff out of
it. There are lots of similar methods already on `Span`, so these two
functions, `in_external_macro` and `is_from_async_await`, fit right in.
The diff is big because `in_external_macro` is used a lot by clippy
lints.
2025-02-02 13:57:34 +11:00
Philipp Krones 9da9ddb7db Merge commit '51d49c1ae2785b24ef18a46ef233fc1d91844666' into clippy-subtree-update 2025-01-28 19:33:54 +01:00
Philipp Krones d0a74af979 Merge commit '19e305bb57a7595f2a8d81f521c0dd8bf854e739' into clippy-subtree-update 2025-01-09 18:57:00 +01:00
Ralf Jung f416f266b0 turn hir::ItemKind::Fn into a named-field variant 2025-01-04 11:35:31 +01:00
Jonathan Dönszelmann 6dfa37f02a Add hir::Attribute 2024-12-15 19:18:46 +01:00
Michael Goulet b14362f665 ty::KContainer -> ty::AssocItemContainer::K 2024-11-04 04:45:52 +00:00
Camille GILLOT 8ad3e13765 Adapt clippy. 2024-10-04 23:50:02 +00:00
Philipp Krones b61fcbee76 Merge commit '7901289135257ca0fbed3a5522526f95b0f5edba' into clippy-subtree-update 2024-09-24 11:58:04 +02:00
Philipp Krones f67f72695a Merge commit 'c9139bd546d9cd69df817faeab62c5f9b1a51337' into clippy-subtree-update 2024-05-30 10:49:05 +02:00
Philipp Krones 0ae4a048c6 Merge commit '9725c4a162502a02c1c67fdca6b797fe09b2b73c' into clippy-subtree-update 2024-04-04 19:52:55 +02:00
surechen 0109fa6b49 remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
Philipp Krones c9a43b18f1 Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-sync 2023-12-01 18:21:58 +01:00
bors 2d9af160af Auto merge of #117507 - nnethercote:rustc_span, r=Nilstrieb
`rustc_span` cleanups

Just some things I found while looking over this crate.

r? `@oli-obk`
2023-11-03 14:57:40 +00:00
Philipp Krones 77c1e3aaa1 Merge commit '09ac14c901abc43bd0d617ae4a44e8a4fed98d9c' into clippyup 2023-11-02 17:35:56 +01:00
Nicholas Nethercote e1ec2d5cc9 Minimize pub usage in source_map.rs.
Most notably, this commit changes the `pub use crate::*;` in that file
to `use crate::*;`. This requires a lot of `use` items in other crates
to be adjusted, because everything defined within `rustc_span::*` was
also available via `rustc_span::source_map::*`, which is bizarre.

The commit also removes `SourceMap::span_to_relative_line_string`, which
is unused.
2023-11-02 19:35:00 +11:00
Vadim Petrochenkov 36a50008d0 rustc: Move crate_types from Session to GlobalCtxt
Removes a piece of mutable state.
Follow up to #114578.
2023-08-09 14:17:54 +08:00
Deadbeef c11573d78c Rename impl_defaultness to defaultness 2023-06-01 06:14:06 +00:00
Kyle Matsuda b92d90211e change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata 2023-01-14 00:29:56 -07:00
Kyle Matsuda a160ce3a48 change usages of impl_trait_ref to bound_impl_trait_ref 2023-01-14 00:23:32 -07:00
Nicholas Nethercote efca32e23a Rename some OwnerId fields.
spastorino noticed some silly expressions like `item_id.def_id.def_id`.

This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.

`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.
2022-10-29 20:28:38 +11:00
Vadim Petrochenkov 45c000bbc7 privacy: Rename "accessibility levels" to "effective visibilities"
And a couple of other naming tweaks

Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26 16:34:53 +04:00
Yuki Okushi 5ccf727344 Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8Ki
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type`

The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2022-10-10 00:09:42 +09:00
Michael Goulet 8e76d6687e ImplItemKind::TyAlias => ImplItemKind::Type 2022-10-09 07:09:57 +00:00
Philipp Krones d75b25faab Merge commit 'ac0e10aa68325235069a842f47499852b2dee79e' into clippyup 2022-10-06 09:44:38 +02:00
Takayuki Maeda ea75178219 separate definitions and HIR owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
Michael Goulet 854f751b26 Appease clippy again 2022-09-09 01:31:46 +00:00
Michael Goulet ac1c68a5e6 Make clippy happy 2022-09-09 01:31:45 +00:00
Camille GILLOT 119247ad32 Remove DefId from AssocItemContainer. 2022-08-01 21:38:45 +02:00