rust/compiler/rustc_resolve/src
Nicholas Nethercote df247968f2 Move ast::Item::ident into ast::ItemKind.
`ast::Item` has an `ident` field.

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

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

There is a similar story for `AssocItemKind` and `ForeignItemKind`.

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.

- `ast::Item` got 8 bytes bigger. This could be avoided by boxing the
  fields within some of the `ast::ItemKind` variants (specifically:
  `Struct`, `Union`, `Enum`). I might do that in a follow-up; this
  commit is big enough already.

- For the visitors: `FnKind` no longer needs an `ident` field because
  the `Fn` within how has one.

- In the parser, the `ItemInfo` typedef is no longer needed. It was used
  in various places to return an `Ident` alongside an `ItemKind`, but
  now the `Ident` (if present) is within the `ItemKind`.

- In a few places I renamed identifier variables called `name` (or
  `foo_name`) as `ident` (or `foo_ident`), to better match the type, and
  because `name` is normally used for `Symbol`s. It's confusing to see
  something like `foo_name.name`.
2025-04-01 14:08:57 +11:00
..
late Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
build_reduced_graph.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
check_unused.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
def_collector.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
diagnostics.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
effective_visibilities.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
errors.rs Allow builtin macros to be used more than once. 2025-03-19 14:12:47 +01:00
ident.rs resolve: Avoid some unstable iteration 2 2025-03-24 23:03:11 +03:00
imports.rs resolve: Avoid some unstable iteration 2 2025-03-24 23:03:11 +03:00
late.rs Move ast::Item::ident into ast::ItemKind. 2025-04-01 14:08:57 +11:00
lib.rs Rollup merge of #138929 - oli-obk:assoc-ctxt-of-trait, r=compiler-errors 2025-03-25 18:09:07 +01:00
macros.rs Rollup merge of #138929 - oli-obk:assoc-ctxt-of-trait, r=compiler-errors 2025-03-25 18:09:07 +01:00
rustdoc.rs rustc_resolve: prevent iteration of refids for completeness 2025-03-27 12:39:48 -04:00